Repository navigation
[RL] Capture GDN prefill with stable replay metadata - #4738
Conversation
e46f1db to
a82a129
Compare
a82a129 to
81782e7
Compare
## Summary PR chain: **this PR** -> #4738 (Qwen/FULL-graph fix) -> #4737 (FA4 b31 pin, pending publication). Bump `attn-gym[linear]` from **0.0.8 to the published 0.0.9 release** in `pyproject.toml` and `.ci/docker/requirements.txt`. This is the dependency-only bottom layer for the GDN capture work in #4738. No TorchTitan model, vLLM integration, or graph behavior changes are included. ## Validation - PyPI release availability and published wheel SHA256 verified. - Published wheel is byte-identical to the release workflow artifact. Compared with the previously validated source pin, 202 Python files are unchanged; only three sparse-indexer files differ. GDN/gate code is unchanged. - Installed the published release into the existing validated Torch/vLLM environment. Import checks from outside the checkout passed. - Real Qwen3.5-0.8B TP1 engine validation passed on this dependency-only layer: five batches of 32 requests x 4096 input tokens, with 64 scheduler chunks per batch. Generated outputs also match the historical pre-bump baseline exactly. This was a compatibility check, not a new performance measurement. - Dependency pin consistency, scoped pre-commit, and whitespace checks passed. The following layer (#4738) adds FULL-graph support; #4737 updates the FA4 recommendation afterward, pending b31 publication. This PR can be reviewed independently as a two-line dependency bump.
3240bfe to
ab19520
Compare
6081476 to
f3f60ab
Compare
f3f60ab to
66f35fe
Compare
## Summary Published b31 is now available and validated on GB200. PR chain: #4736 (Gym release, merged); **this PR, based on main** -> #4738 (GDN FULL graphs, waiting for the next Gym release). Update the Blackwell FA4 recommendation to: ```bash uv pip install "flash-attn-4[cu13]>=4.0.0b31" ``` Qwen3.5 head-dimension-256 paged inference needs the sequence-length/paged-KV fixes from [FA4 #2810](Dao-AILab/flash-attention#2810) and the output-alignment fix from [FA4 #2880](Dao-AILab/flash-attention#2880). The inspected PyPI b30 wheel predates those changes. **Only +2/-1 in the RL README.** Original unpinned Torch/torchvision/vLLM/torchcomms instructions, CUDA index, and existing FFI warning remain unchanged. ## Published b31 validation Installed exact **`flash-attn-4[cu13]==4.0.0b31` from PyPI**, using normal binary-only dependency resolution. All 52 installed Python files match the published wheel. Torch, vLLM, Gym, CuTeDSL and TVM-FFI versions were unchanged; this is not a fresh-environment dependency-resolution claim. - Reproduced b30's `SM100 forward with head_dim=256 does not support seqused_q/seqused_k` failure. The identical GPU call passes on published b31. - **Four GPU cases passed** against an independent FP64 reference: decode/prefill, non-page-aligned KV lengths, oversized shuffled page tables, packed KV strides, and padded/transposed output alignment. - **Seven existing TorchTitan tests passed** on the graph layer's unchanged model/test sources, including real Qwen3.5-0.8B TP1/DP1 eager/FULL execution in regular and batch-invariant modes. Each mode independently matched exactly: 96 generated tokens, 480 logprob entries/ranks, cumulative logprobs, and 1,584 used conv/SSM state hashes; 43 actual FULL replays per mode. - Tests explicitly forced Flash and recorded actual FA4 calls, including capture. Activation alone can allow cuDNN selection in this Torch build. **Limits:** GB200/SM100, BF16 forward, TP1 only. Unused KV padding must be finite: a separate NaN-poison probe contaminates b31 outputs. The established environment's FFI/optional-package/platform-tag warnings are unchanged. No performance remeasurement or equality claim against the previous development FA4 build. Historical trace results still use source commit `383cbcba`. Only the README minimum changes in this PR; graph support and its Gym release dependency remain in #4738. Requirement syntax, scoped pre-commit and whitespace checks previously passed; the reorder preserves the combined source tree exactly.
5a72100 to
4025777
Compare
7e3c01d to
1018b0b
Compare
| @@ -130,6 +132,9 @@ def __init__(self, config: Config) -> None: | |||
| raise ValueError(f"Duplicate GDN layer name: {self.prefix}") | |||
| compilation_config.static_forward_context[self.prefix] = self | |||
|
|
|||
| def get_attn_backend(self) -> type[AttentionBackend]: | |||
There was a problem hiding this comment.
so seems this not required by MambaBase, rather it's a helper called by TorchTitanGPUModelRunner.load_model()?
There was a problem hiding this comment.
And its just to smuggle in:
class GDNExecutionPath(Enum):
SINGLE_TOKEN = auto()
PACKED = auto()
So when we know when its safe to do the fast fuse decode impl vs the pakced form
There was a problem hiding this comment.
thanks for explaining -- I was wondering if this function is a vllm override, and it seems so https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/mamba/abstract.py#L86
1018b0b to
b888796
Compare
| @@ -130,6 +132,9 @@ def __init__(self, config: Config) -> None: | |||
| raise ValueError(f"Duplicate GDN layer name: {self.prefix}") | |||
| compilation_config.static_forward_context[self.prefix] = self | |||
|
|
|||
| def get_attn_backend(self) -> type[AttentionBackend]: | |||
There was a problem hiding this comment.
thanks for explaining -- I was wondering if this function is a vllm override, and it seems so https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/mamba/abstract.py#L86
| # The caller-owned output has a stable address across graph replays. | ||
| # vLLM leaves attention eager under PIECEWISE and captures this same | ||
| # implementation under FULL. Metadata is prepared exclusively by the builder. | ||
| @eager_break_during_capture |
There was a problem hiding this comment.
Why we still keep this decorator? To make "our GDN kernel + vllm prepared metadata" still PIECEWISE cudagraph-able?
I wonder if people would use this our GDN kernel + vllm prepared metadata path. If titanRL only allows our GDN kernel + titanRL prepared metadata, we can just remove this decorator?
## Summary Rename `PyTorchVarlenInnerAttentionBackend` to `TorchTitanVarlenInnerAttentionBackend`, following the naming feedback on #4738. This is a class-name-only change; vLLM's `CUSTOM` registration and implementation remain unchanged. ## Validation - Verified `AttentionBackendEnum.CUSTOM.get_class()` resolves to the renamed class and its registry name remains `CUSTOM`. - Scoped pre-commit passed; the global mutating Pyrefly hook was skipped.

Summary
Agent notes
attn-gym[linear]==0.0.10.Performance
Actual pre-PR
a3a819c67(FULL_AND_PIECEWISE) →1018b0b9c(FULL): Qwen3.5-0.8B AlphabetSort RL, one trainer + one generator GB200, TP1/DP1, BF16 compute, compile off. Trainer FA2 / generator FA4 b31; policy lag 3 and vLLM async ON in both.One sequential pair, two warmup updates + ten measured update intervals; initialization/capture excluded. Measured between completed weight pulls, including native generation/control/handoff waits. Each returned 376 completions (9,788 / 9,779 tokens). Observed latency reduction: 91.6%, workload-specific—not an isolated kernel speedup or convergence claim.
Perfetto: generator before/after · trainer + rollout + handoffs. Separate profiled runs; do not infer speedup from trace duration. Links are internal with 28-day upload retention.
Earlier inference-only prefill: batch 32 × 4096 input tokens, output 1, one GB200, async off: median 1.869 → 0.809 s (2.31×) over ten runs. Before/after trace. Historical
c48650f06→1ac48cbbf, not a current-head rerun.Correctness / limits
4ac49088a, not a rerun against the pinned 0.0.10 wheel. Broader topologies remain unvalidated; no TP4 claim.