Repository navigation
fix error in #701 - #704
Merged
Merged
Conversation
Summary: I mistakenly landed a debug version of #701, fixing. Test Plan: CI Reviewers: Subscribers: Tasks: Tags:
tianyu-l
approved these changes
Nov 27, 2024
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 13, 2026
Summary: I mistakenly landed a debug version of pytorch#701, fixing. Test Plan: CI Reviewers: Subscribers: Tasks: Tags:
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 25, 2026
Summary: I mistakenly landed a debug version of pytorch#701, fixing. Test Plan: CI Reviewers: Subscribers: Tasks: Tags:
tianyu-l
added a commit
that referenced
this pull request
Nov 9, 2026
…nt scan (#5963) Bottom of the SGLang generator stack; based on main. ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> _The sections below were written by Claude (AI agent)._ ## Problem `TestBitwiseParityQwen35DebugVarlen` (RL Multi-GPU Unit Tests) fails on about half of main's runs: the trainer's Qwen3.5 GDN prefill and vLLM's differ in the last bits. ```text main run commit result 42532195905 4b10eee NOT bitwise identical (max_delta=1.91e-06), and after reload (1.72e-05) 42530745168 7d88c59 pass 42507290038 c561eee NOT bitwise identical (max_delta=5.36e-03) 42506959712 a24a35c pass 42478797821 057ded6 NOT bitwise identical (max_delta=3.38e-03) ``` In batch-invariant mode, both sides run attn-gym's recurrent GDN scan. In attn-gym 0.0.18, the scan picks its launch config (`BV`, `num_warps`, `PREFETCH`) from the batch shape, and each config rounds differently: `PREFETCH` uses another output formula, and `tl.sum`'s order and FMA fusion follow the thread layout. The trainer scores a sequence in a packed batch, vLLM in its own batch shape, so the bits depend on what else was batched. meta-pytorch/attention-gym#704 adds an opt-in, `kernel_options={"batch_invariant": True}`, that uses one formula, fixed-order sums and no FMA fusion for every launch config. ## What changed - `.ci/docker/requirements.txt` (and the root `requirements.txt`, a symlink to it): pin attn-gym at 26beb36, the merge of #704, with a TODO to pin a release once one includes it. `models/common/attn_gym.py`'s install hint and `test_optional_imports.py` follow the pin. - `models/common/attention/gdn.py`: the trainer's recurrent GDN custom op passes the opt-in. Mechanical: it is renamed `_recurrent_gdn_fwd` -> `_batch_invariant_recurrent_gdn_fwd` (op `torchtitan::batch_invariant_recurrent_gdn_fwd`), since it only runs in batch-invariant mode, and `test_qwen3_5_deltanet.py` follows the rename. - `rl/generator/vllm/attention/gdn.py`: vLLM's batch-invariant GDN path (prefill, and decode, which runs the same scan) passes the opt-in. Outside batch-invariant mode nothing changes: the chunked GDN kernels and `recurrent_gdn_decode` don't call the scan, and the scan's default arithmetic is 0.0.18's. | | Before | After | | --- | --- | --- | | Batch-invariant Qwen3.5 trainer vs vLLM | bitwise on some batch shapes only | bitwise | | attn-gym requirement | `attn-gym[linear,cudnn]==0.0.18` | `attn-gym[linear,cudnn] @ git+...@26beb36` | ## Numerics Batch-invariant GDN changes by last-bit rounding (the scan's arithmetic is now the same for every launch config). Training outside batch-invariant mode is unchanged: no loss or golden change. ## Testing On GB300, `torchrun --nproc-per-node=2 -m pytest tests/rl/unit_tests/gpu/test_bitwise_parity.py::TestBitwiseParityQwen35DebugVarlen`, as CI runs it: | | Runs | Result | | --- | --- | --- | | main (057ded6), attn-gym 0.0.18 | 3 | 2 fail (`max_delta=1.73e-03`; after reload `9.54e-07`) | | this PR, attn-gym 26beb36 | 3 | 3 x 5 passed | - `tests/unit_tests/gpu/models/qwen3_5/test_qwen3_5_deltanet.py`: 9 passed. - `tests/unit_tests/cpu/models/common/test_optional_imports.py`: passes. - No new test: `TestBitwiseParityQwen35DebugVarlen` already covers it, and fails without the fix. - CI needs the `ciflow/docker` label to build an image with the new pin.
shuhuayu
added a commit
that referenced
this pull request
Nov 11, 2026
## Why The Qwen3.8-Flash-Next QSA attention (#5782) will use `gather_attn`'s grouped-KV / separate-V Triton kernels. They first appear in attention-gym v0.0.19, after attention-gym #678, #701, #702, #713, #714, #715 and #703. torchtitan pins `26beb363`, which predates all of these. This PR only bumps the pin; the Flash-Next change stays in #5782. ## What changed (all mechanical) | | Before | After | | --- | --- | --- | | attn-gym pin | `26beb363` (#704 merge) | `0d0197fb` (v0.0.19 tag, #703 merge) | - `.ci/docker/requirements.txt` (root `requirements.txt` symlinks to it): new SHA. The TODO now says to switch to the PyPI release once v0.0.19 is published there (PyPI's newest is 0.0.18). #704, which the old TODO waited on, is already included in both pins. - `torchtitan/models/common/attn_gym.py` (install hint) and `tests/unit_tests/cpu/models/common/test_optional_imports.py` (2 asserts): same SHA. ## Why v0.0.19 rather than attention-gym `main` `26beb363..0d0197fb` changes only `attn_gym/sparse/gather_attn` (plus its tests and docs). I diffed the two installed `attn_gym` trees to confirm this. GDN, KDA, short_conv, the indexer, MLA and the CuTe backend are byte-identical, so qwen3_5, qwen3_8, kimi and the deepseek_v4 indexer can't change. `main` would also pull in the warpdrive rewrite and the indexer/delta-H ports (~28 `_delta_rule` files). ## Numerics The only `gather_attn` consumer is `torchtitan/models/deepseek_v4/attention.py`. Old vs new pin, 10 steps, seed 42, deterministic, loss and grad_norm read from TensorBoard via `scripts/loss_compare.py`, on GB300: | Config | GPUs | Result | | --- | --- | --- | | `deepseek_v4_debugmodel_fsdp4_ep4` (DistMuon) | 4 | bitwise identical* | | `deepseek_v4_debugmodel_fsdp2_tp2_ep2_pp2` with dp_shard=1 (host has 4 GPUs) | 4 | bitwise identical* | \* With `gather_attn`'s Triton tuners pinned to the same candidate in both runs. Without pinning, deepseek_v4 isn't run-to-run reproducible on **either** pin when the autotune cache is cold. `_FWD_TMA` and `_BWD_DLOCAL_KV_TMA` choose `num_warps` 4 vs 8 by timing, and the two give different bits. Ranks and cold-cache runs can pick different winners, and torch's deterministic flag doesn't control this. This already happens on main. I filed it upstream as meta-pytorch/attention-gym#777, with a single-GPU repro. Because of it, this PR adds no deepseek_v4 golden; see follow-ups. ## Testing - `pre-commit run --all-files` passes, including `pyrefly-check`. - `pytest tests/unit_tests/cpu/models/common` plus the deepseek_v4, qwen3_5, qwen3_8 and kimi_k3 CPU tests: 416 passed. The same 9 tests fail with both the old and new pin on this aarch64 host (`test_lora_forward` and 8 qwen3_5 tests). The one I inspected, `test_lora_forward`, fails with "torch.compile on current platform is not supported for CPU". ## Known issues / follow-ups - deepseek_v4 golden numerics: add once attention-gym#777 lets us fix the tile config. The golden then has to be exported on CI's A10G runners, not on GB300.
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.
Summary:
I mistakenly landed a debug version of #701, fixing.
Test Plan: CI
Reviewers:
Subscribers:
Tasks:
Tags: