Repository navigation
[qwen3_8_fn] Drop the removed ModelConfigConverter from build_model_config - #6316
Merged
Merged
Conversation
liangel-02
requested review from
acisseJZhong,
fegin,
felipemello1,
shuhuayu,
tianyu-l and
wwwjn
as code owners
November 21, 2026 12:44
…onfig
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
#6164 deleted `ModelConfigConverter`, `validate_converter_compatibility` and
the `converters` argument of every `build_model_config`, while the Flash-Next
model (#6046-#6054) landed still using them. On main, importing
`torchtitan.models.qwen3_8_flash_next` fails with
`ImportError: cannot import name 'ModelConfigConverter'`, so every Flash-Next
test errors at collection.
This applies #6164's change to Flash-Next: remove the import, the `converters`
argument and its conversion block from `build_model_config`, as #6164 did for
the other models. Recipes apply converters as transforms with
`apply_transforms`. No in-repo caller passes `converters` to Flash-Next.
```bash
pytest -q tests/unit_tests/cpu/models/qwen3_8_flash_next
```
stack-info: PR: #6316, branch: liangel-02/stack/32
liangel-02
force-pushed
the
liangel-02/stack/32
branch
from
November 21, 2026 12:44
ed6da59 to
75324ee
Compare
This was referenced Nov 21, 2026
tianyu-l
approved these changes
Nov 21, 2026
wwwjn
pushed a commit
that referenced
this pull request
Nov 23, 2026
Stacked PRs: * #6305 * #6308 * #6203 * #6202 * __->__#6201 * #6316 --- --- --- ### Add vLLM paged QSA attention and graph metadata ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> ## Why The Flash-Next training model selects complete four-token blocks plus the current incomplete tail. Generation needs to read those selections from vLLM's physical KV pages across appends, request reordering, and graph padding. The existing vLLM replacement does not implement that QSA cache contract. For a request with 11 tokens selecting block 0, attention must read token positions `[0, 1, 2, 3, 8, 9, 10]`, even if its logical pages have moved. ## What changed - Add a parameter-free vLLM page owner calling Attention Gym `paged_sparse_decode`. - Add `QSAPagedMetadataBuilder`, which builds decode metadata as views of vLLM's persistent runner buffers. vLLM already pads them for `FULL_DECODE_ONLY` graphs (zero lengths, null pages, `-1` slots), so replay reads each step's request layout without extra copies. It only uses vLLM's generic backend and `CommonAttentionMetadata` contracts, like `TorchTitanLinearAttentionMetadataBuilder`. - Preserve request-local addressing, incomplete causal tails, and inactive rows. - Reject unsupported cache dtypes, speculative decoding, decode CP, and graph modes. - Every step calls Attention Gym's `paged_sparse_decode` once with vLLM's per-request block table, `query_start_loc` and `seq_lens`. Decode-only steps keep the host-bound call (`max_seqlen_q=1`). Steps with prompt rows pass `max_seqlen_q=None` and `causal_topk=True` (the paged lightning indexer's output satisfies that contract), so each row finds its request on the device and prompt rows are attended in query tiles that load each K/V chunk once. No step gathers a prompt's context or needs host token counts. This needs the Attention Gym change that adds `causal_topk` (meta-pytorch/attention-gym#979). QSA attention per layer, GB300, 24/2 heads, against gathering each prompt's context and running `gather_attn` (timed eagerly, since it needs host counts): | Step | `gather_attn` | `causal_topk` | | --- | --- | --- | | 16 decode + 2 x 137 | 143.5 us | 46.3 us | | 64 decode + 8 x 210 | 271.2 us | 119.3 us | | 64 decode + 8 x 1000 | 827.6 us | 438.3 us | | 2 x 4096 | 1360.0 us | 1034.2 us | | 1 x 8192 | 1970.6 us | 1924.5 us | - Add `torchtitan/rl/generator/local_compile.py` with two shared `local_compile` region names for generator-only functions, `INFERENCE_BATCH_INVARIANT_REGION` and `INFERENCE_BATCH_VARIANT_REGION`; `inference_local_compile(batch_invariant=...)`, which registers a function under the matching one; and `inference_regions()`, which returns the regions that have registered functions (leaving out the batch-variant one in batch-invariant mode), so a generator can enable them without knowing which layers registered functions. Core `torchtitan/distributed/local_compile.py` is unchanged. QSA's padding-row helper registers under the batch-invariant region; the generator enables the regions in #6202. - The common Attention Gym export additions are mechanical import plumbing. vLLM remains responsible for allocation and reclamation; Python-owned request caches would duplicate that ownership. ## User-facing changes | Before | After | | --- | --- | | No paged QSA attention adapter | Sparse block IDs read directly from vLLM KV pages | | No QSA graph metadata | `FULL_DECODE_ONLY` decode replays QSA attention | ## Testing `pytest -q tests/rl/unit_tests/gpu/test_vllm_qsa.py` The attention test checks reordered physical pages against an independent sparse causal reference, including incomplete tails and padding. The graph test refreshes persistent metadata buffers in place with vLLM's padding, as vLLM's runner does, and checks replay after changing page tables, lengths, and live request counts. Full Flash-Next generation additionally needs the indexer and PLE changes in the next two commits. ## Validation scope This commit alone is covered by `tests/rl/unit_tests/gpu/test_vllm_qsa.py`; the training-loss and generation checks below cover the whole stack. Validation used local B200 GPUs and an Attention Gym development build preserving the original cuDNN linear kernels, with the paged sparse APIs added. The pinned `attn-gym==0.0.20` alone does not supply these APIs. No GDN/KDA migration is included. The complete stack passed `pre-commit run --all-files`. A deterministic seed-42 BF16 debug-model forward/backward (32 tokens) was compared against `44ff1567196fe91ba8a8f96a1aeefbc6715dda8c`: loss `4.4367218017578125`, gradient norm `22.315799713134766`, logits, and all 192 parameter gradients were bitwise identical using `torch.equal`. This is one-GPU training evidence, not a representative-data convergence run or a 125B performance measurement. Additional cache-reuse validation: 38 focused tests pass, including native metadata, padded cache strides, and extra sequence-parallel model rows. Across three rounds of two requests, generated tokens and log probabilities are exactly equal to published stack 02f9eb9 in BF16 Dist-MoE TP2/EP2 + SP, both eager and FULL_DECODE_ONLY, on both ranks. Full pre-commit checks pass.
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.
Stacked PRs:
[qwen3_8_fn] Drop the removed ModelConfigConverter from build_model_config
Summary (human-written)
#6164 deleted
ModelConfigConverter,validate_converter_compatibilityandthe
convertersargument of everybuild_model_config, while the Flash-Nextmodel (#6046-#6054) landed still using them. On main, importing
torchtitan.models.qwen3_8_flash_nextfails withImportError: cannot import name 'ModelConfigConverter', so every Flash-Nexttest errors at collection.
This applies #6164's change to Flash-Next: remove the import, the
convertersargument and its conversion block from
build_model_config, as #6164 did forthe other models. Recipes apply converters as transforms with
apply_transforms. No in-repo caller passesconvertersto Flash-Next.