Skip to content

[qwen3_8_fn] Drop the removed ModelConfigConverter from build_model_config - #6316

Merged
tianyu-l merged 1 commit into
mainfrom
liangel-02/stack/32
Nov 21, 2026
Merged

tianyu-l merged 1 commit into
mainfrom
liangel-02/stack/32

Conversation

@liangel-02

@liangel-02 liangel-02 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PRs:


[qwen3_8_fn] Drop the removed ModelConfigConverter from build_model_config

Summary (human-written)

#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.

pytest -q tests/unit_tests/cpu/models/qwen3_8_flash_next

…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
@tianyu-l
tianyu-l merged commit 5b71d52 into main Nov 21, 2026
18 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants