Replace Qwen3.5 FLA paths with Attention Gym - #4389
Draft
drisspg wants to merge 3 commits into
Draft
Conversation
## Human Note ## Agent note Use Attention Gym for Qwen3.5 GDN training, batch-invariant backward recomputation, recurrent execution, decode, and paged chunk prefill. The paged prefill path advances vLLM SSM cache slots in place, eliminating the previous gather/chunk/scatter copies and preserving the shared [slots, H, V, K] layout across prefill and decode. Remove the now-unused FLA backend selection and dependency, normalize Q/K explicitly at the Attention Gym boundary, and update debug configurations to the fused backend K=V=128 contract while retaining two key heads for TP=2 coverage. ## Performance On GB200, isolated paged-prefill measurements reduced GPU time by 18.2-31.7% across five T=1024-8192, N=1-64 cases. A matched end-to-end vLLM debug-model comparison at prompt=128, generation=64, and batch sizes 1-16 improved output throughput by 1.5-6.4%. ## Test Plan ```bash PYTHONPATH=/home/drisspg/meta/attention-gym-paged-gdn:/home/drisspg/meta/torchtitan pytest -q tests/unit_tests/gpu/test_qwen3_5_deltanet.py tests/unit_tests/test_qwen3_5_mrope_positions.py -x PYTHONPATH=/home/drisspg/meta/attention-gym-paged-gdn:/home/drisspg/meta/torchtitan pytest -q tests/unit_tests/cpu/test_state_dict_keys.py tests/unit_tests/cpu/test_integration_test_definitions.py tests/unit_tests/cpu/test_train_spec.py -x PYTHONPATH=/home/drisspg/meta/torchtitan:/home/drisspg/meta/attention-gym-paged-gdn torchrun --nproc-per-node=2 -m pytest torchtitan/experiments/rl/tests/test_bitwise_parity.py::TestBitwiseParityQwen35DebugVarlen -v -s ```
drisspg
force-pushed
the
gdn-attn-gym-paged
branch
from
September 1, 2026 05:39
25307b6 to
8857cdb
Compare
## Human Note ## Agent note Use Attention Gym's paged causal convolution API for vLLM multi-token prefill. The operation reads fresh or resumed cache slots directly and advances them in place, removing the remaining temporary history allocation, gather, host-syncing continuation check, and final-state scatter from Qwen3.5 serving. ## Performance On GB200 at the TP=2-local Qwen3.5 shape (C=4096, W=4, BF16), direct paging reduced convolution prefill GPU time by 43.8-79.4% for fresh prompts and 46.2-80.4% for resumed prefixes across N=1-64 and 128-512 tokens per sequence. ## Test Plan ```bash PYTHONPATH=/home/drisspg/meta/attention-gym:/home/drisspg/meta/torchtitan pytest -q tests/unit_tests/gpu/test_qwen3_5_deltanet.py tests/unit_tests/test_qwen3_5_mrope_positions.py -x PYTHONPATH=/home/drisspg/meta/attention-gym .venv/bin/pytest -q -n 6 test/test_short_conv_cute.py test/linear/test_gdn_chunk_fused.py test/test_namespaces.py PYTHONPATH=/home/drisspg/meta/torchtitan:/home/drisspg/meta/attention-gym torchrun --nproc-per-node=2 -m pytest -q torchtitan/experiments/rl/tests/test_bitwise_parity.py::TestBitwiseParityQwen35DebugVarlen ```
drisspg
force-pushed
the
gdn-attn-gym-paged
branch
from
September 1, 2026 07:03
e341e0e to
436eeb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human Note
Agent note
This incorporates Angel Li's Attention Gym migration from #4363 and extends it so the resulting
change can land as one self-contained PR against
main. It uses Attention Gym for Qwen3.5 GDNtraining, batch-invariant backward recomputation, recurrent execution, decode, and paged prefill.
The vLLM path advances both convolution and SSM cache slots in place. This removes the prior
prefill-time temporary state allocations, grouped-head expansion, gather/scatter copies, transposes,
and host-syncing continuation check while preserving the shared
[slots, H, V, K]SSM layout.The paged operations landed in Attention Gym as
meta-pytorch/attention-gym#431 and
meta-pytorch/attention-gym#432.
The now-unused FLA backend selection and direct dependency are removed. Q/K normalization is explicit
at the Attention Gym boundary, and debug configurations use the fused backend's
K = V = 128contract while retaining two key heads for TP=2 coverage.
Note
The required Attention Gym APIs are on its
mainbranch at6ee58c2a. PyPI currently stops atattn-gym==0.0.6, so this draft still needs the next Attention Gym release and corresponding pinupdate before it is ready to land. A clean wheel built from
6ee58c2awas installed into an isolatedtarget and successfully exported both paged APIs to this TorchTitan adapter.
Performance
End-to-end vLLM: before either PR vs combined candidate
GB200, Qwen3.5 debug model with production GDN dimensions
K=V=128, prompt length 128, generationlength 64, TP=1, FULL_AND_PIECEWISE CUDA graphs, five measured rounds per engine launch. Three engine
launches were paired at the parent of #4363 (
9aadc3616) and the combined candidate; the table reportsmedian throughput across launches and the median paired change.
Process-level throughput varied, but every paired before/after launch improved at every batch size.
GDN prefill ablation
GB200, fixed-pointer warm-cache,
HK=8,H=16,K=V=128, BF16 QKV, FP32 state, five interleavedrounds of 30 iterations:
The middle column isolates the backend migration while retaining state copies; direct paging removes
another 16.5-28.1% from that path.
Convolution prefill ablation
At the Qwen3.5 TP=2-local shape (
C=4096,W=4, BF16), direct paging reduced GPU time by43.8-79.4% for fresh prompts and 46.2-80.4% for resumed prefixes across N=1-64 and 128-512
tokens per sequence.
Test Plan
The real Qwen3.5-9B vLLM benchmark was also attempted, but the installed SM100 FA4 path rejects
head_dim=256withseqused_q/seqused_kbefore GDN executes. The matched debug-model benchmark andTP=2 parity suite exercise the Qwen3.5 GDN paths without that unrelated attention-backend limitation.