Repository navigation
[Fix] Kimi-K3: Fix derived weight buffers across CUDA graph reloads - #43675
Conversation
nvpohanh
left a comment
There was a problem hiding this comment.
[by Claude Code] This review is done by agents. Please feel free to disagree if they do not make sense.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
[by Claude Code] @wolfcomos, could you merge the latest |
updated |
|
[by Claude Code] @wolfcomos, the remaining relevant CI failure (base-b-test-1-gpu-large (0), Could you enable "Allow edits by maintainers" on this PR (checkbox in the right sidebar)? Then I can merge the latest |
thanks, edits enabled |
|
[by Claude Code] I've started babysitting the NVIDIA CI of this PR. I'll check it every 30 minutes until all NV pipelines pass. If a relevant job fails, I may rerun it, merge the latest Anyone can stop me at any time: just post a comment asking me to stop (for example, |
|
[by Claude Code] @wolfcomos, the relevant CI failure appears to be caused by this PR: https://github.com/sgl-project/sglang/actions/runs/42020871324/job/127241401272. The new test |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
[BBuf Review Agent] Could you rebase this onto the latest main? It conflicts with main now. |
Resolve the kimi_k3.py import conflict with sgl-project#48781, which split utils.common: take main's imports and import bind_or_assign from sglang.srt.models.utils. attn_residual.py now imports bind_or_assign from there too, since sglang.srt.utils no longer re-exports it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
[by Claude Code] I've started babysitting the NVIDIA CI of this PR. I'll check it every 30 minutes until all NV pipelines pass. If a relevant job fails, I may rerun it, merge the latest Anyone can stop me at any time: just post a comment asking me to stop (for example, |
|
/rerun-failed-ci |
|
[by Claude Code] All NV pipelines have passed. |
|
[BBuf Review Agent] Could you rebase this onto the latest main? It conflicts with main now. |
Resolve the kimi_k3.py conflict by keeping bind_or_assign for w_kc/w_vc and refreshing main's DCP pre-projected V weights after the update. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
[by Claude Code] I've started babysitting the NVIDIA CI of this PR. I'll check it every 30 minutes until all NV pipelines pass. If a relevant job fails, I may rerun it, merge the latest Anyone can stop me at any time: just post a comment asking me to stop (for example, |
BBuf
left a comment
There was a problem hiding this comment.
[BBuf Review Agent] One thing to fix before this can go in.
| / 512 | ||
| ) | ||
|
|
||
| attn = SimpleNamespace( |
There was a problem hiding this comment.
[BBuf Review Agent] The registered reload suite now raises AttributeError before graph capture: this fixture lacks _dcp_v_weights, and the MoE fixture also lacks the _front_shard property read by the merged method. Could we update both fixtures for main’s changes?
There was a problem hiding this comment.
Thanks, fixed both fixtures in d365f2b. The MLA fixture now initializes _dcp_v_weights=None, and the MoE fixture exposes _front_shard as a property returning None so it remains available after _merge_front_weights() invalidates cached instance attributes. Test-only changes; syntax and cache-invalidation checks passed locally. Full CUDA graph regression validation is pending GPU CI.
There was a problem hiding this comment.
[BBuf Review Agent] Checked d365f2b: both missing attributes are covered, and the _front_shard property survives cache invalidation. That resolves this fixture issue; I haven’t run the GPU tests.
|
[by Claude Code] I've started babysitting the NVIDIA CI of this PR. I'll check it every 30 minutes until all NV pipelines pass. If a relevant job fails, I may rerun it, merge the latest Anyone can stop me at any time: just post a comment asking me to stop (for example, |
|
[by Claude Code] All NV pipelines have passed. |
Motivation
Reloading Kimi-K3 weights after CUDA graph capture can leave captured operations reading old derived-weight storage. AttnRes also retains its cached norm/projection product after the underlying weights change, affecting eager execution as well.
Changes
The reload contract assumes unchanged model configuration, shapes, dtypes, and devices. Native ROCm kernels and all quantized loader variants are not covered by this validation. This is not a claim that every K3 hot-update path has been validated.
AMD/ROCm follow-up
The Python buffer-lifecycle fix for the ROCm fused KDA input projection is included and regression-tested on H100 by invoking
_merge_kda_inproj_weights_hip()with an eligible fixture. Native AMD/ROCm graph replay, fused kernels, and token-threshold branches still need validation, tracked in #47508. H100 results do not establish ROCm end-to-end hot-update correctness.Validation
The original MLA regression failed before its fix and passed after it on one H100, with exact graph/eager projection equality after two successive updates.
The four additional regressions exercise front-weight views, dense/dequantized BFA buffer lifetime, CUDA KDA static buffers, and both AttnRes cache dtypes. Each performs two updates after CUDA graph capture, checks changed values, exact replay/eager buffer equality, and stable addresses. The dequantized BFA branch uses a mocked dequantization boundary returning fresh tensors; it does not validate an FP8 quantizer.
On one H100 80GB using PyTorch
2.14.1+cu130/ CUDA 13.0 andlmsysorg/sglang:devat digestsha256:78142f9f4b7fb3ee27f59065615dc7bb263f643ed256c9299c3861086ade4d47:f05814ad4eaa02f28afd6d86c3b1fc8fd049e098, using the same image and test source.cc5159e.Follow-up commit
810b49e2bc3ee7d80ebc3beb520638f77d2a29fbadds the HIP input-projection storage regression. On one H100 PCIe with PyTorch2.14.1+cu130/ CUDA 13.0 and image digestsha256:77ff63ee69fd7ebef20df3a6d036ee4b8a4ffe0734efb0028c3b7643386e3ccf:58a5db50225e8aad6b3a3ee9652b90e122a4e8ea(including stale replay values after the second update) and passes after the fix.Applicable pre-commit checks pass. Full-model accuracy, real rollout weight synchronization, and performance benchmarking are outside this validation.
CI States
Latest PR Test (Base): ✅ Run #42572728289
Latest PR Test (Extra): ❌ Run #42572728267
Latest PR Test (AMD ROCm 10): ⏳ Run #42572728341
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: