fix(kda-onepass): 카운터를 블록 폭별로, 프로브 출력 게이트는 비트 동일 -- #316 코덱스 3건 후속 - #319
Conversation
…트는 비트 동일, cudaGraphLaunch 호스트 시간 별도 측정 (Codex 3건) - prepare_counters(device, nv): 폭마다 버퍼, resolve() 가 서빙 폭(NV=16)을 캡처 전에 준비, 캡처 중 없는 폭은 spec_onepass 가 stock 으로 내린다(counters_ready). 프로브의 BV=8/16/32 스윕이 한 버퍼를 섞고 있었다 - micro_fusion_check: KDA 8 케이스의 출력 불일치는 실패(rel 게이트로 새던 것); graph_time 이 replay() 의 호스트 시간을 submit_ms 로 반환, _fmt 가 host submit 을 찍는다 - 계약 테스트·README·원장 31차 (8) 항 반영. probe 13 (kda 섹션, 부팅 창): 전부 bit-exact, VERDICT PASS Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_64187bfb-4874-4e51-a519-b83e15f113ca) |
There was a problem hiding this comment.
🔵 Needs a closer look
It changes CUDA-graph capture preconditions and last-arriver synchronization behavior where subtle races are difficult to validate automatically beyond existing tests.
Pull request overview
This PR updates the GLM53 KDA one-pass path to avoid counter-buffer mixing across block widths (NV), tightens the probe’s output gate to bit equality, and improves timing reporting by separating host submit time from stream-bracketed “+launch” time.
Changes:
- Key last-arriver counter buffers by
(device, NV), and pre-prepare serving-width counters inresolve()while declining to stock if counters are missing during CUDA-graph capture. - Make the micro-fusion probe require bit-identical bf16 outputs for KDA cases (instead of a relative-error gate).
- Extend
graph_time()reporting to includesubmit_ms(host time spent inreplay()).
File summaries
| File | Description |
|---|---|
| tests/test_logic.py | Extends contract checks to enforce (device, NV) counter keying and capture-time fallback behavior. |
| probes/micro_fusion_check.py | Tightens KDA output gate to bit equality and adds submit_ms to timing output. |
| overlay/modules/glm53_kda_onepass/README.md | Documents per-NV counters and capture-time “decline to stock” behavior for missing widths. |
| overlay/modules/glm53_kda_onepass/glm53_kda_onepass.py | Implements per-NV counter buffers, serving-width preparation in resolve(), and capture-time fallback gating. |
| MEASUREMENTS.md | Updates runbook notes to reflect NV-scoped counters, bit-equality gate, and timing interpretation. |
| build/glm53/glm53_kda_onepass.py | Mirrors the overlay module changes in the built artifact. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| sweeps BV=8/16/32). Every launch of a width slices the same buffer, so | ||
| the address a captured graph records stays valid and no allocation ever | ||
| happens under capture -- a missing width under capture raises instead. | ||
| The counters are monotonic: nothing resets them.""" |
| sweeps BV=8/16/32). Every launch of a width slices the same buffer, so | ||
| the address a captured graph records stays valid and no allocation ever | ||
| happens under capture -- a missing width under capture raises instead. | ||
| The counters are monotonic: nothing resets them.""" |
kda-onepass: 카운터를 블록 폭별로, 프로브 출력 게이트는 비트 동일 (PR #316 코덱스 3건의 후속)
#316 은 이 커밋이 푸시되기 전에 머지됐다(a501efd 에서). 그 PR 의 코덱스 스레드 3개(3938261391 / 3938261393 / 3938261395)에 "Fixed in 3507575" 로 답한 내용이 이 PR 이다(같은 변경을 main 위에 cherry-pick, 76da645). 노브는 그대로 프로필 기본 0, 부팅 없음.
변경
count % NV라 한 버퍼는 한 NV 만 봐야 한다. 프로브의 BV=8/16/32 스윕이 한 버퍼를 섞고 있었고(코덱스), 그러면 이른 프로그램이 마지막으로 뽑혀 conv 상태 갱신이 읽기와 경주할 수 있다.prepare_counters(device, nv);resolve()가 서빙 폭(BV=8, NV=16)을 캡처 전에 준비하고, 캡처 중 없는 폭은spec_onepass가 stock 으로 내린다(counters_ready).n_mis > 0이면 실패; rel 2e-3 게이트로 새던 것).graph_time이replay()의 호스트 시간을submit_ms로 반환,_fmt가host submit을 찍는다.+launch(유휴 스트림 이벤트 브래킷)는 제출 간극을 포함한 장치 시간이고 CPU 측정이 아니라는 점을 문서에 적었다.검증
python3 tests/test_logic.py: all OK (44,781 checks, origin/main 3872176 위).bash probes/run_micro_fusion_check.sh --sections kda --iters 3(probe 13, K5TRY 부팅 창): 자가진단 PASS, 8 케이스 + 2스텝 사슬 conv/recurrent/출력 전부 bit-exact, 적용성 7건 OK, VERDICT PASS. host submit stock 0.2 / 원패스 0.3 us/층(그래프당 ≈ 7~10 us, 노드 수 238 vs 34 에 거의 무관) — 이 묶음의 이득은 호스트 제출이 아니라 장치 시간에서 온다.🤖 Generated with Claude Code
Note
Medium Risk
Changes synchronization for conv-state/norm last-arriver logic and CUDA-graph capture preconditions; incorrect NV buffering could cause subtle races, but missing-width paths fall back to stock and tests enforce the new contract.
Overview
Fixes a last-arriver counter race in KDA one-pass: because arrival uses
count % NV, a single counter buffer must only see one block width. Counters are now keyed by(device, NV), launches callprepare_counters(device, nv), andresolve()pre-allocates the serving geometry (BV=8 → NV=16) before CUDA-graph capture. Missing counters during capture decline to the stock chain (or raise if allocation is attempted under capture) instead of mixing BV sweeps on one buffer.The micro-fusion probe now requires bit-identical bf16 outputs vs stock for KDA cases (replacing a ~2e-3 relative gate).
graph_timealso reportssubmit_ms(host time insidereplay()), and timing docs note that one-pass gains come from device time, not graph launch CPU cost (~0.2 vs ~0.3 µs/layer host submit).Docs (MEASUREMENTS, module README) and
test_logiccontract checks were updated for the new counter wiring.Reviewed by Cursor Bugbot for commit 76da645. Bugbot is set up for automated code reviews on this repo. Configure here.