Repository navigation
Conversation
whx-sjtu
left a comment
There was a problem hiding this comment.
ATOM PR #3628 — Run Kimi ReplaySSM decode and verify through fused KDA
Routes eligible Kimi and inherited GLM decode/verify steps through the parent fused KDA API while retaining the existing path for unsupported configurations.
Review: ✅ LGTM for source and CPU scope at 35936e8786e4c516eeab62eefced5c6fa5cc66c8; ready for human review with hold landing.
Coverage: 3 files / 75 added lines -- within one review pass
Validation (advisory): Inspected maintained Linux CPU CI 44690383887 at this head: 15,108 passed, 1,526 skipped and 3 xfailed; all 25 consumer cases executed. Black, Ruff and catalog passed. This is one external CI run, unverified by the review validator. Tests replace GPU launches and do not qualify numerical parity. Actual plugin execution, GPU eager/compiled/full-graph routing and flush/rollback parity, required accuracy and C16/K7 complete layer/step timing remain NOT RUN. Actual base is 507c116b422; current parent 6a37814a102 changes comments only. Parent #3618, #3501, #3587 and final landing-tree validation remain holds.
_hash_traced_files opens each file Dynamo traced to key the compile cache, skipping only "<string>" and "<frozen os>". A traced function that reaches another frozen stdlib module adds e.g. "<frozen genericpath>" (os.path.exists) to the traced files, and the open() raises FileNotFoundError, which fails the first compile as BackendCompilerFailed. Skip every "<...>" name. Co-authored-by: ruili <ruili@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit cccc96a)
valar-cop
left a comment
There was a problem hiding this comment.
some changes needed..
kimi-k3 tp8 plugin accuracy gate result? and any gpu run of the glm-5.3 path, flag defaults on for it..
ci Model Accuracy P0 (Kimi-K3 TP8) failed — not sure yet (low): The stored log for this job is empty (0 lines), so the failure cannot be attributed. The same job failed on main on 2026-11-17 and passes on most other runs (2 success / 1 failure on other recent runs), which suggests flakiness rather than this PR — the plugin path never sets replayssm metadata, so the fused branch is not reachable there.
(.valar/ci/job_137263393356.log is empty — 0 lines)
next: Re-run the job and attach/share the log; confirm the native Kimi-K3 TP8 plugin accuracy gate independently before merge. https://github.com/ROCm/ATOM/actions/runs/45037126999/job/137263393356
| and conv_state.shape[-1] >= 2 + kda_metadata.replayssm_max_query_len | ||
| and cache.replay_buf_k.shape[2] >= 2 * kda_metadata.replayssm_max_query_len | ||
| and get_gfx_runtime() == "gfx950" | ||
| and 0 < num_seqs * nlh <= get_cu_num() |
There was a problem hiding this comment.
why one-wave bound? kernel is not persistent and no cross-program counter, so multi-wave grid is legal. what's the measured crossover? and log the fallback so tp1/tp2 knows the flag did nothing..
There was a problem hiding this comment.
No crossover appeared in six adjacent TP8/TP2/TP1 local-layer cases at c1137a4e2: fused won all 120 pairs, including three multi-wave grids. The unchanged one-wave limit is conservative admission, not a legality limit. 620ad060 adds TP-rank-0, deduplicated fallback geometry logging. CI passed all 28 consumer cases.
Boundary measurements and logging
The c113 source used one gfx950 GPU/256 CUs, synthetic weights and verify8. Each row passed unchanged numerical/state/flush and graph replay 1/10 checks, with five warmups and twenty alternating complete-layer pairs.
| TP-local | Local heads | Requests | Programs | Default | Split/fused GPU medians, ms |
|---|---|---|---|---|---|
| 8 | 12 | 21 | 252 | fused | 0.602243 / 0.437223 |
| 8 | 12 | 22 | 264 | split | 0.601883 / 0.438083 |
| 2 | 48 | 5 | 240 | fused | 0.536043 / 0.391502 |
| 2 | 48 | 6 | 288 | split | 0.520144 / 0.388762 |
| 1 | 96 | 2 | 192 | fused | 0.545703 / 0.403822 |
| 1 | 96 | 3 | 288 | split | 0.558704 / 0.413562 |
Default routing used the real CU count; only admission was overridden for above-bound fused comparisons. This is local-layer evidence without collectives or a later crossover measurement.
620ad060 logs TP size, padded requests, local heads, programs and CUs for this guard's split fallback. A 32-entry LRU deduplicates geometry; other ranks/guards and flag-off do not log. Admission and numerical paths remain unchanged.
Raw result SHA256: 9eb3e2d9fb137897d7feb183dcbce7ea48739c67c7d36a5141c54d5b17e98f83; driver SHA256: 910ba0aa48600222a607b096ce79d4b4978abeac561fc5944d1dc261822ed7a2.
|
ci triage for 5686e3e:
|
|
Part of the review reply: the Kimi-K3 TP8 plugin gate passed 1,269/1,319 (96.2092%) on full 5-shot GSM8K, above 0.95. The GLM-5.3 default-on GPU consumer also passed numerical/state/flush and graph replay checks. Both ran at Plugin result, original failure and GLM scopePlugin run, result artifact: both filters passed the unchanged Kimi-K3 TP8 catalog case, no limit, with eight ATOM plugin constructions. This tests plugin fallback, which does not enter native fused ReplaySSM. Only aggregates were saved; no independent response rescore is claimed. Runtime source: c113, image The original log and server artifact show a readiness timeout; accuracy never ran. The follow-up raised retries 120→220 but became ready in 23m39s, inside the old 60-minute window, so the larger wait is not established as the cause of success. Cleanup completed. The separate GLM run used c113/native AITER GLM raw-result SHA256: |
…3642) _hash_traced_files opens each file Dynamo traced to key the compile cache, skipping only "<string>" and "<frozen os>". A traced function that reaches another frozen stdlib module adds e.g. "<frozen genericpath>" (os.path.exists) to the traced files, and the open() raises FileNotFoundError, which fails the first compile as BackendCompilerFailed. Skip every "<...>" name. Co-authored-by: ruili <ruili@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit cccc96a) (cherry picked from commit c1137a4) Co-authored-by: Cursor <cursoragent@cursor.com> Ported-from: ROCm#3628
Pass initialization-time counters and wait selection through native and SGLang callers. Guard fallback launch wiring and record-store ownership in CPU tests. Move the unused fused KDA implementation and its tests to the existing consumer PR.
valar-cop
left a comment
There was a problem hiding this comment.
LGTM
ci Run non-GPU unit tests (Pre Checkin) failed — main is already broken the same way (high): The stored log is empty so the error text is unknown, but the same job fails five consecutive times on main in the same window and on every recent run, so main is red independently of this PR (which touches only Kimi-K3 KDA code and its tests).
same job on main: ['2026-11-27T03:29 failure', '2026-11-27T03:21 failure', '2026-11-27T02:56 failure', '2026-11-27T02:43 failure', '2026-11-27T02:24 failure']
.valar/ci/job_140311198589.log is empty (0 lines)
next: Re-run once main's Pre Checkin is green again; nothing to change in this PR. https://github.com/ROCm/ATOM/actions/runs/45939785137/job/140311198589
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (4)
Thanks for keeping the split path byte-identical and for the fork/rollback tests. We traced the fused kernel at this head and found no correctness bug:
- The conv window is read at
num_accepted-1and T+2 rows are written, matchingcausal_conv1d_update. - Records are read before the barrier and written after it, and each program owns one head.
- The kernel never touches
flush_arrivals, so a sequence can switch between the fused and split paths from step to step.
-
Post gfx950 fused-vs-split numbers at this head. The route is on by default with no flag on gfx950 + ReplaySSM (Kimi-K3 and the GLM models that inherit the layer). The only number is one synthetic C16/K7 layer from 35936e8. Please add:
- a layer or step table for T ∈ {1,2,4,8} × padded bs ∈ {1,4,8,16,21} at TP8, plus one TP4 row;
- which deployments actually reach this path, given that Kimi-K3 mono decode serves plain decode and uniform verify up to 64 rows by default.
The one-wave guard (
model.py:1468-1473) is an unmeasured cutoff. Show the crossover, or narrow the gate to where the data shows a win. -
Stop re-evaluating init-time constants on every layer of every step (
kimi_k3/model.py:1446-1467). About 17 terms (head dim, conv width, f_b dtype/shape/quant/bias, ssm_state strides, arch, …) run on every eager decode/verify step, about 2.9 µs per layer. On gfx942 the arch test comes 17th, so the step pays for the whole chain and never fuses.- Compute the static terms once in
process_weights_after_loading, or on first use for the pool tensors. - Keep only the per-step terms.
- Drop
(num_decodes>0) != (num_spec_decodes>0)(the builder never sets both,gdn_attn.py:1645-1647) and0 < num_seqs * nlh(already implied bynum_seqs > 0).
- Compute the static terms once in
-
Make
_kda_gatecall the new_kda_log_decayinstead of keeping a second copy of the formula (fla_ops/replayssm.py:1656-1661vs:1665-1674). Fused and split steps must write identicalbuf_grecords. Triton inlines the helper, so the split kernel's code does not change.
Nit (still needs a change):
- Use the three-line header in
tests/models/test_kimi_k3_kda_decode_fused.py:1(SPDX line only) andtests/model_ops/test_replayssm_kda_fused_gpu.py:1-2(missing the ATOM Project Contributors line).
Root cause vs patch: the root problem is three launches (conv, f_b GEMM, recurrence) plus intermediates per KDA decode step, and one fused kernel next to the ReplaySSM record format is the right fix. Keeping it in ATOM is justified:
- aiter's
fused_kda_decode_unifieduses a different conv-state convention (fixed tail, no rollback offset, one in-place slot) and always applies RMSNorm itself. - The record, commit and flush protocol this kernel writes lives in ATOM's
replayssm.py, and the kernel reuses its helpers.
The patch-like parts are items 1-3.
Pre-existing, not required for this PR: test_replayssm_kda_fused_gpu.py, like every test_replayssm_*_gpu.py, is skipped in all CI lanes.
Reviewed at 2d1d17c (Deep, first review, split rule waived; passes A+B). CI: non-GPU unit tests, Black and Ruff pass; heavy accuracy passed for Kimi-K3 and Kimi-K3 DSpark PP2, while Kimi-K3.1 and GLM-5.3 are still pending.
| ) | ||
| if fused: | ||
| num_cus = get_cu_num() | ||
| if num_seqs * nlh > num_cus: |
There was a problem hiding this comment.
this is default-on with no flag, but the one-wave cutoff (num_seqs*nlh > CUs) is unmeasured. post the fused-vs-split table at this head, or narrow the gate to the measured win region?
| num_seqs = 0 | ||
| if kda_metadata.num_prefills == 0 and getattr(kda_metadata, "replayssm", False): | ||
| num_seqs = kda_metadata.num_decodes or kda_metadata.num_spec_decodes | ||
| fused = ( |
There was a problem hiding this comment.
~18 init-time constants re-evaluated every step, get_gfx_runtime() 17th so gfx942 pays the whole chain before rejecting. hoist the static terms out, keep only per-step ones?
|
|
||
|
|
||
| @triton.jit | ||
| def _kda_log_decay(x, b_A, LOWER_BOUND, USE_LOWER_BOUND): |
There was a problem hiding this comment.
second copy of the log-decay formula here, both branches identical to _kda_log_decay. make _kda_gate call it, triton inlines so split kernel code is same
|
Ready for code re-review of requests 2–4 at Static checks are cached with binding invalidation; prefills stay separate. The decay helper is shared and headers are fixed. Windows CPU: 116 tests and 23 subtests passed, one GPU skip; style and independent source review passed. Timing/admission request 1 remains open; its gpu-pool experiment is queued. |
| ) | ||
| if fused: | ||
| num_cus = self._fused_kda_max_programs | ||
| if num_seqs * nlh > num_cus: |
There was a problem hiding this comment.
fused route is default-on but the one-wave cutoff is still unmeasured.. post the current-head fused-vs-split table and crossover, or narrow the gate to where data shows a win?
There was a problem hiding this comment.
Ready for re-review at 5686e3ef; the PR body now contains the complete requested TP8 grid, TP4 row and boundary table. T=1 crosses from 59.40→51.90 µs at B=21 to 60.22→64.02 µs at B=22; every B=22 pair favors split. We retain the conservative one-wave guard. T=1/B=1 is near-flat. Scope, mono reachability, native HIP graph timing and fixed-input correctness controls are documented; this is not new full-model qualification. Please re-review the admission evidence.
Closes https://github.com/wuhuikx/LLM-Booster/issues/694. Code fixes and the requested current-head timing evidence are supplied; ready for re-review.
Fuse causal convolution, f_b projection and ReplaySSM KDA recurrence for eligible native Kimi and inherited GLM decode/verify steps. Unsupported configurations retain the split path and pool-owned flush resources.
Dev record
Named result
At
5686e3ef, TP8 T=1/B=21: 59.40 → 51.90 µs; B=22: 60.22 → 64.02 µs, with all 20 forced-fused pairs slower. TP4 T=8/B=8: 96.28 → 86.34 µs. These are instrumented complete-layer graph intervals on one GPU, with synthetic BF16 weights and TP-local geometry.All 29 measured cells and 14 existing numerical/graph/flush contracts passed. TP8 T=1/B=1 is near-flat; the policy is conservative across T, rather than an optimal cutoff for each T.
Gates
Windows CPU validation remains 116 tests plus 23 subtests passed, one GPU-dependent skip; Black/Ruff/whitespace passed. Independent source review cleared code requests 2–4. The new layer experiment does not replace full-model, distributed or GLM qualification. Latest native CI stopped at the Pre Checkin status gate and skipped model accuracy.
Current-head gfx950 matrix, boundary and measurement scope
Native-HIP graph timing matrix
Twenty alternating pairs; unadjusted median complete-layer graph intervals. Fused/split is the ratio of arm medians. All rows live; zero history; no flush; one gfx950 GPU, TP-local geometry, synthetic BF16 weights.
Requested matrix
Kimi TP8 boundary diagnostics
B=21 is production-admitted; B≥22 forces fused only for diagnostics. Paired ranges are observed extrema, not confidence intervals.
Reproduction and numerical scope
Source
5686e3efeca69b8f23b6cdbe9312d06d7e9119ed, gfx950 with 256 CUs, Torch2.10.0+rocm7.2.4.git3d3aa833, HIP7.2.53211, AITER0.1.1.dev1+g898952053, Triton3.8.0. The AITER wheel's SHA256 matches the existing CI artifact exactly. Executed driver SHA256:237c092fb8d2b48d63283b669a0c37c718c0fdfc6e2a44ba3bccc9dd5a39c9fa.One constructed native Kimi KDA layer, original in_proj through original o_proj, one GPU with local heads 12/24 representing TP8/TP4. No collectives or model checkpoint. Actual T equals configured maximum query length. All padded-B rows are live; history is zero and timing performs no flush. T=1 explicitly enables ReplaySSM, which ordinary non-speculative decode defaults off.
Each cell uses 20 alternating split/fused pairs with resets outside the measurement. Fresh timing graphs restore all original GEMMs and use two native HIP event-record nodes whose dependencies surround all layer work; timestamps advance on every replay. Empty-bracket medians before/after are 6.76/9.66 µs, ranges 6.56–9.32/6.60–13.60 µs. Nothing is subtracted. Treat the 0.72 µs T=1/B=1 difference as near-flat. Retained eager/wall observations include host scheduling and do not determine this admission decision.
Correctness compares both transformed paths on one immutable real in_proj output per cell because independently executed in_proj calls were non-repeatable at M21/22, including with the supported AITER wheel. This preserves the existing FP32 recurrence and record/state tolerances. Three correctness graph reset/replays per route reproduce their eager raw recurrence/state; all 174 full-output graph differences against those corresponding eager witnesses are zero. The 14 unchanged operator contracts separately cover graph, fork/rollback and flush behavior. Timed GEMMs are unmodified; no new end-to-end accuracy result is claimed.
Admission and deployment
The T=1 boundary moves from 252 programs at B=21 to 264 at B=22, crossing the 256-CU limit. B=22's paired fused/split ratios are 1.038–1.128. T=8 remains near-flat just above one wave and regresses at larger B, so the existing shared bound is conservative. These results support retaining
padded_requests * local_heads <= CU_count; T=2/T=4 above-bound crossings and TP4's own boundary were not measured.Default Kimi mono handles eligible TP8 steps up to 64 token rows, but layer 0 remains on production KDA. Later eligible layers use mono K1; larger steps, TP4/PP and mono refusals can reach the ordinary production path. Native GLM-5.3 inherits this layer without a matching mono installer, but its different head geometry was not timed here. Current vLLM/SGLang adapters do not supply this native fused ReplaySSM contract.
Retained code fixes and earlier evidence
At the same head, device/model constants are cached at first eligible decode; final child weights/pools are qualified by weak-reference identity after loading. Prefills avoid decode initialization.
_kda_gateshares_kda_log_decay, and both test headers are complete. Independent source review and cross-refutation cover these fixes.The earlier C16/K7 result at
35936e87, c113 native 1285/1319 accuracy/graph result and plugin/GLM evidence retain their original revisions and recipes. They are not new current-head model results.