Repository navigation
[GDN] Use native Attention Gym summaries for context parallelism - #6167
liangel-02 wants to merge 2 commits into
Conversation
|
@claude review |
|
Claude finished @liangel-02's task in 2m 17s —— View job Request changes -- review posted: the new native-CP test never runs in CI, and the attn-gym bump also changes the non-CP Blackwell kernel without numbers. |
There was a problem hiding this comment.
Verdict: Request changes -- The one-line CP fix is the right change. But the test that guards it never runs in CI, and the dependency bump also swaps the kernel on the non-CP Blackwell path, which the PR shows no numbers for.
What this PR does. ContextParallelInnerGDN.gdn_core now passes the existing chunk_kernel_options(...) to context_parallel_gdn, so packed bf16 CP on SM100/SM103 uses Attention Gym's warpdrive backend. That backend has native scalar-gate CP summaries. The PR also moves the attn-gym pin from 0.0.20 to a main commit, renames the cuDNN kernel classes to the warpdrive ones, adds a B200 GPU unit test, and adds a B200 CP=2 integration entry.
Example.
Qwen3.5, CP=2, packed bf16, B200, non-deterministic
main: context_parallel_gdn(..., kernel_options=None) -> fused CP; g_1TH expanded to [1,T,H,128] fp32
PR: context_parallel_gdn(..., kernel_options=KernelOptions("warpdrive")) -> native summaries, no expansion
Qwen3.5, CP=1, B200
main: chunk_gdn(..., backend="cudnn") (attn-gym 0.0.20, cudnn extra)
PR: chunk_gdn(..., backend="warpdrive") (attn-gym 4d0d791, no cudnn extra) <- not measured in the PR
Must fix
tests/unit_tests/gpu/models/qwen3_5/test_qwen3_5_deltanet.py:181-- The new native-CP test always skips in CI: GPU unit tests run on A10G, and it isn't in the B200 workflow's explicit pytest list. The integration entry can't catch a revert to fused. Add the test tointegration_test_b200.yaml.torchtitan/models/common/attention/linear_attention.py:58-72-- The pin bump changes which kernel runs on the non-CP Blackwell training and RL-generator paths (cuDNN -> warpdrive). The docstring's perf justification was also deleted. Add a B200 non-CP numerics and perf comparison to the description, or state with an upstream link that it is a pure rename.
Should consider
tests/integration_tests/b200.py:140-- The new entry exercises warpdrive CP but doesn't confirm that warpdrive actually ran, so it duplicates the H100 entry with the same config. That's fine as a smoke test on SM100. Mention in the PR that the backend selection is guarded by the unit test from item 1, not by this entry.
Details
- Gate: the problem is real on main. Before this PR,
cp_gdn.py:278calledcontext_parallel_gdnwithoutkernel_options, so CP fell back to fused even on Blackwell. The fix is at the right layer: it reuses the existing policy, and the summaries are implemented upstream in meta-pytorch/attention-gym#904. The git pin has a TODO with a link, andtorch_rematsets the precedent for git pins. - KDA CP (
cp_kda.py:255) still passes nokernel_options. The PR says this is intentional. Vector gates don't need expanding, so this isn't a one-sided design problem. - The deterministic C4 run (fused vs fused, bitwise identical) does show that the fused path is unchanged across the attn-gym bump.
- The CPU optional-import test updates and the
attn_gym.py/ RL README edits are mechanical and correct. The rootrequirements.txtis a symlink to.ci/docker/requirements.txt, so the new install hint resolves to the pinned dependency.
Not verified: whether warpdrive's non-CP kernels match the 0.0.20 cuDNN kernels numerically or in speed (needs a B200 run). A maintainer still needs to review.
Summary (human-written)
changes torchtitan to use gdn cp summaries in attention gym using warpdrive
Why
GDN context parallelism currently calls Attention Gym without selecting a backend. On Blackwell this still uses fused CP summaries, expanding each scalar decay gate across the key dimension to reuse KDA kernels. Attention Gym now has native scalar-GDN summaries that avoid that allocation and compute chunk factors on chip (upstream PR).
For packed BF16 Qwen3.5 with CP=2 on B200:
What changed
chunk_kernel_optionspolicy tocontext_parallel_gdn. Eligible SM100/SM103 inputs select warpdrive; deterministic mode, batch-invariant mode, and other devices retain fused execution.4d0d7912ebbab5d5a71739c786af8f03fd1bbce3: the current 0.0.20 release does not expose the new CP backend.Keeping the selection at the CP helper call reuses the existing routing and backend policy. Hard-coding warpdrive would bypass deterministic/device selection; implementing summaries inside TorchTitan would duplicate the upstream implementation.
Numerics
Compared against public TorchTitan main
aa90d4abd45e92866dc2da24b9590030d4adc7e5, using separate editable environments with their respective Attention Gym dependencies. Both use PyTorch2.16.0.dev20261117+cu134, CuTeDSL 4.8.1, BF16, seed 42, CP=2 with head-tail balancing, and two B200 GPUs.The native backend changes floating-point evaluation order, so its results are compared numerically rather than bitwise. These are short debug-model training checks, not 10M-context or production-scale convergence/performance measurements. No existing golden-loss file is changed.
C4 comparison recipe and commands
Save as
agent_space/cp_numerics.pyin each checkout:Compare all 20 full-precision
loss_metrics/global_avg_lossandgrad_normscalars usingscripts.loss_compare.extract_metrics_from_tensorboard.Testing
python -m tests.integration_tests.run_tests agent_space/native-cp-integration-ready --test_suite b200 --test_name qwen35_mm_native_gdn_cp --ngpu 2 --gpu_arch b200 --no-parallelpasses all 10 training steps with SPMD type checking enabled.pre-commit run --all-files: formatting, lint, and other hooks pass. Pyrefly reportsFSDPModule.set_unshard_in_current_streammissing intorchtitan/distributed/fsdp.py:622with this PyTorch nightly; the identical error reproduces on unchanged main.