Skip to content

fix(kda-onepass): PR #304 리뷰 15건 반영 -- 자가진단·단조 카운터·스킵 분리·fp32 conv 상태·프로브 clone 편향 정정, 원장 31차 최종 수치 - #316

Merged
choiceoh merged 6 commits into
mainfrom
claude/micro-fusion-bundle-optimization-f1727c
Sep 4, 2026
Merged

Conversation

@choiceoh

@choiceoh choiceoh commented Sep 4, 2026

Copy link
Copy Markdown
Owner

미세 융합 묶음 2 (EXP-20) — PR #304 리뷰 15건 반영 + 원장 31차 최종 수치

#304 는 첫 커밋(9fa2900)만 실린 채 #310 경유로 머지됐다(원장 번호 29차→31차 이동은 그 머지가 했다). 이 PR 은 그 위의 리뷰 반영분이다. 부팅은 없다 — 브래킷 부팅은 운영자 결정. 노브 3개는 그대로 프로필 기본 0.

리뷰 반영 (코드)

  • 부팅 자가진단: 첫 eager forward 에서 stock 체인 vs 원패스 3 케이스 bit 비교, 불일치면 [kda-onepass] self-test FAIL ... DISARMED(레이아웃 함정의 회귀 감시). 프로브와 같은 코드(selftest/make_fixture/run_stock_chain).
  • 단조 카운터: 마지막 도착자 = 카운트가 NV 의 배수(2의 거듭제곱 검사), 리셋 없음, int32 랩 무해. 버퍼(256 요청 × 16 헤드) 초과는 raise 대신 stock 으로.
  • 스킵 조건 분리: conv 는 spec 슬롯 0 이 널 블록이 아닐 때만, recurrent 는 재개 슬롯 유효할 때만, 둘 다 아니면 반환(stock 세 커널 의미 그대로). n_acc <= 0 가드(Copilot).
  • fp32 conv 상태(MAMBA_CACHE_DTYPE=float32, MK-KDA 부팅) 지원 — 탭 dtype 은 stock 커널처럼 상태 dtype 을 따른다. 레이아웃은 dim-first 뷰 한 번으로 도출.
  • 가드는 num_actual_tokens 기준(CUDA 그래프 패딩 행, Codex). 배선은 모듈 API(resolve()/gate_gemms()/spec_onepass())만 부르고 _forward 가 o_norm 을 스스로 적용(플래그 없음).
  • 듀얼 GEMM BLOCK_N=32(프로브 N 타일 스윕: M=8 7.6 → 6.7 → 6.4 us/층), M≤32 만, 거절 로그는 M≤32 에서만.
  • 러너 compgen | grep ... || true(Copilot), 프로브: stock 체인 입력 clone 을 그래프 밖으로(clone 노드 편향), 짝지은 두 리플레이의 둘째 + 유휴 단발 시간 분리, 2스텝 사슬·fp32·적용성(admit/decline, strided) 케이스.

원장 31차 최종 수치 (프로브 11, 조용한 GPU; 수치 게이트는 프로브 12 도 전부 PASS)

층당 us 스텝 Δ
듀얼 GEMM (BLOCK_N=32) 10.0 → 6.4 (M=8) −0.12 ms
KDA 원패스 (BV=8) 68.8 → 67.6 (C=1), 228.4 → 221.5 (C=4) −0.04 / −0.23 ms
kpool 직접 positions 6.9 → 5.6 −0.014 ms

첫 판의 원패스 −0.14 는 stock 쪽 그래프에만 clone 노드가 얹힌 편향이었다 → 정직한 합계 ≈ −0.18 ms/스텝(0.3%), 런치 −249/1,548. 브래킷 해상도 아래이므로 R2 규칙(bit-exact + 트레이스 소멸 + 무회귀)으로 판정한다.

2차 리뷰 반영 (Copilot 5 + Codex 4) 와 원패스 보류의 재정정

  • 배선은 노브가 정확히 1 일 때만 모듈을 import — 프로필 기본 0 은 import·resolve 비용 없음(계약 테스트는 배선이 판정을 resolve() 에서만 받는지 검사).
  • 카운터를 블록 폭(NV)별로 — 마지막 도착 판정이 count % NV 라 한 버퍼는 한 NV 만 봐야 한다(프로브의 BV=8/16/32 스윕이 섞고 있었다, Codex). resolve() 가 서빙 폭(BV=8, NV=16)을 캡처 전에 준비하고, 캡처 중 없는 폭은 stock 으로 내린다.
  • 프로브 출력 게이트 = 비트 동일(8 케이스 전부; rel 게이트로 새던 것, Codex). +launch 는 유휴 스트림이 보는 제출 간극 포함 장치 시간이라 적고, cudaGraphLaunch 의 호스트 시간은 host submit 로 따로 잰다.
  • EXP-20 원패스 "이 러너엔 순수 spec-verify 스텝이 없다" 보류(09-05 07:04~07:11, main)는 되돌렸다. 그 보류는 32차 §11 의 정정 전 가설(spec_sequence_masks 항상 None)에 기댔는데, §11 의 04:50 정정과 KDAPROOF3(kda lane CAPTURED into the decode graph: T=32 n_spec=4)이 이미 철회한 가설이다. 이미지 코드로 확인: mamba_hybrid.prepare_attn 은 실제 스텝마다 행별 num_decode_draft_tokens_cpu 를 채우고, GDNAttentionMetadataBuilder.build_for_cudagraph_capturequery_start_loc 차분에서 그것을 만든다 → 유니폼 디코드 그래프의 캡처 형상이 곧 순수 spec-verify 배치. 브래킷은 세 노브로, 원패스 증명은 캡처 시점 one-pass KDA serving 줄이며 그 줄이 없으면 그 축만 보류(듀얼+kpool 로 판정) — 창을 잃지 않는다.

검증

  • python3 tests/test_logic.py: all OK (44,779 checks), origin/main 7499f8c 머지 뒤.
  • bash probes/run_micro_fusion_check.sh: VERDICT PASS(듀얼 M≤16 bit-exact, 원패스 8 케이스 + 2스텝 사슬 bit-exact, 자가진단 PASS, 적용성 admit/decline 7건, kpool bit-exact).

🤖 Generated with Claude Code

choiceoh and others added 5 commits September 5, 2026 01:32
… 모듈 API 호출로

- 모듈이 resolve()/gate_gemms()/spec_onepass() 를 노출하고 배선(glm5next_kda.py)은
  guarded import + 호출 둘로 줄었다; _forward 가 모든 경로의 gated norm 을 소유해
  True-플래그 반환이 사라졌다.
- resolve() 가 첫 eager forward 에서 stock 체인 대비 자가진단(bf16/fp32 conv 상태,
  acc 1/3/8, varlen)을 돌리고 불일치면 DISARM 한다.
- 도착 카운터는 단조(마지막 도착 = 카운트가 NV 의 배수; NV 2^k, int32 랩 무해),
  리셋 없음. 카운터 상한 초과는 raise 대신 가드에서 거절.
- conv/recurrent 스킵 조건을 stock 처럼 분리(null conv line 이면 raw 행을 recurrence 에).
- conv 상태 dtype bf16·fp32 둘 다(MK-KDA 의 MAMBA_CACHE_DTYPE=float32 와 공존),
  탭은 상태 dtype 으로 통일. num_accepted_tokens <= 0 은 null 요청으로 처리.
- 가드가 padded projection 행이 아니라 실제 토큰 수로 out/g1/g2 를 재고, 인덱스
  텐서의 단위 stride 를 요구한다. 듀얼 GEMM BLOCK_N 32 (프로브 스윕).
- 프로브: stock 타이밍의 clone 노드 제거(사전 clone), 두 번 연속 리플레이로 device
  시간과 launch 포함 시간을 분리, fp32 conv 케이스·두 스텝 체인·가드 admit/decline
  케이스 추가, kpool 판정 출력 수정, 러너 pipefail 수정.
- README 의 낡은 [8,128] 타일 설명 제거, 런북 EXP-20 의 "-> stock" 규칙 정정.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…undle-optimization-f1727c

# Conflicts:
#	RUNBOOK_KERNEL_CAMPAIGN2.md
…s no VLLM_* keys, RUNBOOK EXP-20 ordering entry after item 7

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…undle-optimization-f1727c

# Conflicts:
#	RUNBOOK_KERNEL_CAMPAIGN2.md
#	overlay/modules/glm53_kda_onepass/README.md
#	tests/test_logic.py
…2 ms, 원패스 −0.04 (C=1)/−0.23 (C=4) ms, kpool −0.014 ms; 방법 정정(clone 편향·짝지은 리플레이·자가진단·단조 카운터·fp32 conv 상태)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 4, 2026 22:16
@cursor

cursor Bot commented Sep 4, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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_2496a0e4-3d2e-4336-bf07-4170401694ac)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T22:34:18.908994Z a501efd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The KDA wiring currently imports/resolves glm53_kda_onepass even when profile-default knobs are set to "0", which breaks the default-off contract and adds avoidable boot/first-forward overhead.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR applies follow-up review fixes to the EXP-20 “micro-fusion bundle 2” work around glm53_kda_onepass, tightening correctness/guarding (boot self-test, monotonic last-arriver counters, skip semantics split, fp32 conv-state support) and updating probes/tests/docs to match the revised protocol and the “31차” final measurements.

Changes:

  • Moves knob/guard/self-test logic into glm53_kda_onepass and updates the GLM-5.3 KDA wiring to call resolve()/gate_gemms()/spec_onepass() only.
  • Extends probe + contract tests to cover knob parsing semantics, monotonic counters, separated conv/recurrent skip rules, fp32 conv-state, and updated timing methodology.
  • Updates RUNBOOK/MEASUREMENTS/README to reflect the corrected measurement protocol and new boot self-test behavior.
File summaries
File Description
tests/test_logic.py Updates EXP-20 contract test expectations for new module API/self-test/guards.
RUNBOOK_KERNEL_CAMPAIGN2.md Updates EXP-20 table + boot log anchors and adds EXP-20 to the runbook checklist.
profiles/glm53.env Documents self-test behavior and both-cache-dtype support for one-pass.
probes/run_micro_fusion_check.sh Makes VLLM_* env forwarding robust under pipefail.
probes/micro_fusion_check.py Updates numerics coverage and timing methodology/reporting.
overlay/modules/glm53_mk_kda_wiring/glm5next_kda.py Refactors wiring to delegate dual/onepass decisions to the module and always apply o_norm in _forward.
overlay/modules/glm53_kda_onepass/README.md Documents resolve() self-test, monotonic counters, skip semantics, and updated offline gate protocol.
overlay/modules/glm53_kda_onepass/glm53_kda_onepass.py Implements self-test/disarm, monotonic counters, fp32 conv-state handling, separated skip rules, and API surface (gate_gemms/spec_onepass).
MEASUREMENTS.md Updates “31차” final numbers and explains methodology corrections.
build/glm53/glm5next_kda.py Build copy of the wiring refactor.
build/glm53/glm53_kda_onepass.py Build copy of the module changes.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread build/glm53/glm5next_kda.py
Comment thread overlay/modules/glm53_mk_kda_wiring/glm5next_kda.py
Comment thread tests/test_logic.py Outdated
Comment thread RUNBOOK_KERNEL_CAMPAIGN2.md Outdated
Comment thread probes/micro_fusion_check.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b0aa8c7ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread overlay/modules/glm53_kda_onepass/glm53_kda_onepass.py
Comment thread probes/micro_fusion_check.py
Comment thread probes/micro_fusion_check.py
Comment thread overlay/modules/glm53_mk_kda_wiring/glm5next_kda.py Outdated
- 배선은 노브가 정확히 "1" 일 때만 glm53_kda_onepass 를 import 한다(프로필 기본 0 은 import 비용 없음);
  계약 테스트는 배선이 판정을 resolve() 에서만 받는지 검사
- 프로브 graph_time 문서: "+launch" 는 CPU 측정이 아니라 유휴 스트림이 보는 제출 간극 포함 장치 시간
- RUNBOOK "순서와 근거" 의 EXP-20 중복 항목 제거
- EXP-20 원패스 "이 러너엔 순수 spec-verify 스텝이 없다" 보류는 32차 §11 의 정정 전 가설에 기댄 것 --
  §11 04:50 정정, KDAPROOF3 캡처 줄(n_spec=4), 이미지 코드(prepare_attn / build_for_cudagraph_capture)로
  철회하고 세 노브 브래킷으로 되돌림; 원패스 증명은 캡처 시점 줄, 없으면 그 축만 보류

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 4, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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_fd8f6349-7f37-4296-9ed6-92e81d97ffd0)

@choiceoh
choiceoh merged commit d1b2b9c into main Sep 4, 2026
3 checks passed
choiceoh pushed a commit that referenced this pull request Sep 5, 2026
…ound3 -- smlp_forward keeps main's capture proof line and the smlp2 route
@choiceoh

choiceoh commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

The three Codex threads answered with "Fixed in 3507575" were pushed after this PR was merged; that commit is now #319 (cherry-picked onto main as 76da645).

🤖 Addressed by Claude Code

choiceoh added a commit that referenced this pull request Sep 5, 2026
fix(kda-onepass): 카운터를 블록 폭별로, 프로브 출력 게이트는 비트 동일 -- #316 코덱스 3건 후속
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants