Skip to content

feat(glm53): #227 split-K head-gate 를 main 에 반영 (v2 브랜치로 머지된 것) - #228

Merged
choiceoh merged 2 commits into
mainfrom
feat/glm53-prep-fused-v2
Sep 2, 2026
Merged

feat(glm53): #227 split-K head-gate 를 main 에 반영 (v2 브랜치로 머지된 것)#228
choiceoh merged 2 commits into
mainfrom
feat/glm53-prep-fused-v2

Conversation

@choiceoh

@choiceoh choiceoh commented Sep 2, 2026

Copy link
Copy Markdown
Owner

#227 이 base 브랜치 feat/glm53-prep-fused-v2 로 머지된 시점에 #226 은 이미 main 에 들어가 있어서 split-K 커밋(83d9eae)이 main 에 없다. 이 PR 의 diff 는 #227 과 동일 (모듈 glm53_indexer_gate_splitk, opt-in, EXP-9, 41,165 checks OK).

🤖 Generated with Claude Code


Note

Medium Risk
Opt-in numerics change on sparse indexer head-gates (non bit-exact fp32 reduction) can affect top-k pool selection; mitigated by default-off, M≤16 routing, and required quality bracket.

Overview
Adds overlay module glm53_indexer_gate_splitk so the sparse indexer’s fp32 head-gate matmul ([M,4096]×[4096,16], 11 layers/step) can use a split-K Triton kernel instead of cuBLAS’s two-block gemmSN path on decode-sized batches (M≤16). Larger shapes and default-off behavior keep torch.mm.

Wiring: New glm53_indexer_gate.py exposes head_gate() gated by VLLM_GLM53_INDEXER_GATE_SPLITK=1 (profile default 0). glm5next_attention.py and glm53_prefill_fastpath.py route Indexer / fused-k-gate forwards through a shared helper (lazy import in fastpath when the module isn’t mounted). Manifest, profiles/glm53.env, and glm53_model_wiring prefill hunk stay in sync.

Validation & ops: Offline probe probes/indexer_gate_check.py, test_glm53_indexer_gate_splitk_contracts, and per-profile overlay symbol checks in test_overlay_symbol_contracts. Docs record ~50→10 µs microbench, ~0.65%/step ceiling, and RUNBOOK EXP-9 (ride on EXP-7/8 boots, not solo).

Reviewed by Cursor Bugbot for commit 2abc932. Bugbot is set up for automated code reviews on this repo. Configure here.

choiceoh and others added 2 commits September 2, 2026 20:16
…te_splitk, opt-in)

Indexer.forward 의 torch.mm(hidden.float(), _wp_fp32) ([M,4096]x[4096,16] fp32,
층당 1회 x 11) 을 cuBLAS 가 2블록 gemmSN 커널로 답한다: 유휴 GB10 47 us, 트레이스
(CUPTI) 86 us. (행, K-슬라이스 512) 마다 프로그램 하나 + fp32 atomic 의 split-K
Triton 커널이 같은 곱을 10 us 에 낸다. M<=16(디코드) 만 라우팅, 나머지는 stock.

- overlay/modules/glm53_indexer_gate_splitk: attention.py 오버레이(플릿 preimage
  a0870c31..., fi618 과 동일) + 커널 파일. 노브 VLLM_GLM53_INDEXER_GATE_SPLITK,
  정확히 "1" 만 켬, 기본 0 = stock 과 같은 torch.mm 호출.
- glm53_prefill_fastpath.py 의 융합 인덱서(FUSED_K_GATE=1)도 같은 헬퍼를 탄다.
- 수치: fp32 누적 순서만 다름 — 300회/2,480행 max|diff| 2.4e-6, top-1 뒤집힘 0,
  top-4 집합 변화 0 (probes/indexer_gate_check.py). bit-exact 아님 -> 품질 브래킷.
- 천장 11 x 40 us = 0.44 ms/스텝, C=1 의 ~0.65% (<1%): 단독 부팅 금지, EXP-7/8
  부팅에 얹어 잰다. RUNBOOK EXP-9, MEASUREMENTS 원장.
- tests: test_overlay_symbol_contracts 를 프로필 단위로 (dsv4 mla_indexer 와 glm53
  glm53_tail_slot_persistent 가 같은 경로를 각자 소유 — 전역 "마지막 매니페스트"
  맵이 glm53 attention.py 를 dsv4 indexer 에 대조하고 있었다). 새 계약 테스트.
  41,165 checks OK. build/glm53 스냅샷 재구성 (33 overlays / 22 modules).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
feat(glm53): 인덱서 fp32 head-gate split-K (glm53_indexer_gate_splitk, opt-in, EXP-9)
Copilot AI lite review requested due to automatic review settings September 2, 2026 11:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-02T11:25:43.387964Z 2abc932 PR opened
ℹ️ 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.

@choiceoh
choiceoh merged commit 4cb318b into main Sep 2, 2026
4 checks passed

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 new Triton split-K path lacks basic applicability guards (CUDA/device/shape) and contiguity handling, which can lead to runtime failures or incorrect results under valid tensor layouts.

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

Pull request overview

This PR ports PR #227’s opt-in GLM53 sparse indexer fp32 head-gate split-K path onto main, adding a new overlay module (glm53_indexer_gate_splitk) that can replace the small-M decode torch.mm(hidden.float(), _wp_fp32) with a Triton split-K kernel when explicitly armed.

Changes:

  • Add glm53_indexer_gate_splitk overlay (pinned attention.py overlay + new glm53_indexer_gate.py helper/kernel) and wire it into both the indexer and fused-K-gate fastpath via a shared helper.
  • Extend contract tests to validate per-profile overlay symbol ownership, and add explicit contracts for the new split-K module and profile knob defaulting to stock.
  • Update profile defaults and documentation/runbook/measurements to record arming, numerics caveat, and expected performance impact.
File summaries
File Description
tests/test_logic.py Makes overlay symbol-contract checking profile-aware; adds split-K module contract tests and updates fastpath contract symbol set.
STEP_KERNEL_MAP.md Notes the new split-K head-gate module as the intended optimization target.
RUNBOOK_KERNEL_CAMPAIGN2.md Adds EXP-9 runbook entry describing split-K head-gate, gating, numerics, and measurement procedure.
profiles/glm53.env Mounts glm53_indexer_gate_splitk and ships VLLM_GLM53_INDEXER_GATE_SPLITK=0 default knob.
probes/indexer_gate_check.py Adds an offline probe script to compare numerics and measure CUDA-graph replay timing.
overlay/modules/glm53_model_wiring/glm53_prefill_fastpath.py Adds lazy-resolved _glm53_head_gate helper and routes fused-indexer forward through it with ImportError fallback.
overlay/modules/glm53_indexer_gate_splitk/requires Declares dependency on glm53_model_wiring for the fastpath hunk.
overlay/modules/glm53_indexer_gate_splitk/README.md Documents motivation, numerics caveat, offline timings, and arming procedure.
overlay/modules/glm53_indexer_gate_splitk/manifest.tsv Pins attention.py overlay and adds new glm53_indexer_gate.py file (absent in base).
overlay/modules/glm53_indexer_gate_splitk/glm5next_attention.py Replaces the fp32 head-gate torch.mm with the shared head_gate helper import/call.
overlay/modules/glm53_indexer_gate_splitk/glm53_indexer_gate.py Introduces Triton split-K kernel + applicability checks + head_gate wrapper behind env knob.
MEASUREMENTS.md Records offline timing and numerics measurements and notes EXP-9 gating/ceiling.
build/glm53/manifest.tsv Adds built artifacts for the pinned attention overlay and new gate helper/kernel file.
build/glm53/glm5next_attention.py Built snapshot of the attention overlay reflecting the head-gate helper routing.
build/glm53/glm53_prefill_fastpath.py Built snapshot of fastpath with the lazy head-gate helper routing.
build/glm53/glm53_indexer_gate.py Built snapshot of the split-K helper/kernel module.
Review details

Suppressed comments (1)

overlay/modules/glm53_indexer_gate_splitk/glm53_indexer_gate.py:74

  • splitk_applicable doesn't verify tensors are CUDA / on the same device (or even that x and w are 2D and shape-compatible). If VLLM_GLM53_INDEXER_GATE_SPLITK=1 is set in a CPU run, head_gate can route into Triton and fail at runtime.
def splitk_applicable(x: torch.Tensor, w: torch.Tensor) -> bool:
    return (x.shape[0] <= MAX_M and w.dtype == torch.float32 and w.is_contiguous()
            and w.shape[1] <= 16 and w.shape[0] % (_SPLIT * _BLOCK_K) == 0)
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Lite

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


x may be bf16 (cast to fp32 here, as the stock `.float()` does); w is the
stock `_wp_fp32` ([K, N], fp32, contiguous)."""
xf = x.float()

@cursor cursor 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.

Approved: Cursor Bugbot completed successfully with no findings that require human review. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

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