Repository navigation
Skip CUDA-graph config validation where graphs cannot capture - #4790
Conversation
CUDA graph capture is unavailable on ROCm: wrap_with_cuda_graph() logs a warning and returns the eager callable. The validators that enforce CUDA-graph restrictions did not check the device, so they raised ValueError on ROCm for configurations that run fine there. Since disable_cuda_graphs defaults to False, ROCm users hit this by default. Export the capability predicate as cuda_graphs_supported() and have wrap_with_cuda_graph() and every validator share it, so the sites cannot drift apart: - config/validation.py: varlen attention without max_num_documents, and expert parallelism with a synchronizing token dispatcher - trainer.py: pipeline parallelism with a validator - training_engine.py: looped pipeline schedules, and SDC replay with num_replays > 1 No behaviour change on NVIDIA: cuda_graphs_supported() is True there, so every error path fires exactly as before. The existing tests for these raises now pin the predicate to True and keep asserting them; new tests cover the inert case. Fixes pytorch#4789
|
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
Verified on NVIDIA B200: no behaviour changeI ran the PR head ( Evidence (environment, four checks, logs)Environment Note: torchtitan main now requires the Check 1 — predicate: Check 2 — graphs still capture
Check 3 — the five raises, base vs PR: Check 4 — The 21 failing/erroring tests are the same set on base and PR (no PR-only failure), and the PR has exactly +7 passing tests. All 21 are environment-only and unrelated to CUDA graphs: missing
|
tianyu-l
left a comment
There was a problem hiding this comment.
sorry, I missed the argument, now I get it.
Summary
CUDA graph capture cannot run on ROCm —
wrap_with_cuda_graph()logs a warningand returns the eager callable. But the validators that enforce CUDA-graph
restrictions never checked the device, so they raised
ValueErroron ROCm forconfigurations that would run fine there.
training.disable_cuda_graphsdefaults to
False, so ROCm users hit this by default.This exports the capability check as
cuda_graphs_supported()and haswrap_with_cuda_graph()and every validator share it, so the sites cannotdrift apart.
Gated sites:
config/validation.pymax_num_documentsunsetconfig/validation.pytrainer.pytraining_engine.pytraining_engine.pynum_replays > 1No behaviour change on NVIDIA.
cuda_graphs_supported()isTrueon CUDA,so every existing error path fires exactly as before.
This does not touch the ROCm exclusion itself. hipGraph exists and the blanket
torch.version.hip is Nonemay be worth revisiting, but that is a separatequestion — see the issue.
Tests
The existing CUDA-graph rejection tests in
test_config_manager.pyassertedraises that are now device-dependent, and would silently stop asserting anything
on a CPU-only runner. They now pin the predicate to
Trueand keep assertingthe raises; new tests cover the inert case and the previously untested varlen
path.
Verified on 8x MI350X (gfx950, torch 2.15.0.dev+rocm7.2):
max_num_documents, EP=2 withLocalTokenDispatcher,and PP=2 with a looped schedule each raised
ValueErrorat config time.llama3_debugmodel_varlen_attnwithmax_num_documents=Nonetrains (3 steps, loss 8.18 -> 7.20) with the expected"using eager execution" warning.
tests/unit_tests/cpu/: same 4 pre-existing failures before and after(missing
torchvision/vllmlocally), +7 new passing tests.Fixes #4789