GLM-5.2 speculative drafting: native MTP head beats GLM-4-9B, + opt-in MLA-latent KV cache#5
Open
joelovestech wants to merge 1 commit into
Open
GLM-5.2 speculative drafting: native MTP head beats GLM-4-9B, + opt-in MLA-latent KV cache#5joelovestech wants to merge 1 commit into
joelovestech wants to merge 1 commit into
Conversation
…ext prefill - glm_swarm_nvfp4_kv.py: MLA 'absorb' latent cache (MLA_LATENT=1) — caches the kv_lora latent + shared rope key, absorbs kv_b into q/o, ~70x less KV; unblocks 32k/100k context + concurrency. GLM_MAXPOS sizes the RoPE table for long context. Opt-in; original full-head path unchanged when MLA_LATENT is unset. - ring_mtp.py: GLM-5.2 native MTP head as the coordinator draft + --diag convention sweep. Beats a standalone GLM-4-9B AR draft at every context (0.85-0.88 vs 0.79/0.82/0.75), margin widens with context. - ring_long.py: chunked teacher-forced prefill (8k/32k/100k) + blocked lm_head argmax. - mla_latent.py: offline proofs that the absorb + chunked cache are equivalent to full-head (errs ~1e-13). - pod_9b_dump.py, draft_accept_bench.py, h1_bench.py: the acceptance harness. - docs/research: findings report for peers, process+test-plan docs, serving-optimization roadmap. Fork of leyten/shard (Apache-2.0; NOTICE preserved). See SHARDV2.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
joelovestech
marked this pull request as ready for review
June 27, 2026 21:35
This was referenced Jul 14, 2026
leyten
added a commit
that referenced
this pull request
Jul 20, 2026
leyten
added a commit
that referenced
this pull request
Jul 20, 2026
… silent hang (#120) Mitigation ladder for the 2026-07-14 residential-tail EAGLE hang; root cause unknown by design — every EAGLE-implicated stall class now ends in worst-case-slower or a clean fast fail. L1: draft-budget watchdog flips a slow drafter to n-gram mid-job (M25_DRAFT_BUDGET_S, flag-latch, pipelining restored). M1: the tail ret socket gets a per-progress stall bound (M25_RET_STALL_S; per-sendmsg semantics — a slow-but-draining uplink never trips) so one wedged send can no longer hang the whole warm ring. Reset now carries eagle:0/1 and every stage silences aux for degraded sessions — the degraded arm equals the plain ring on the wire. L2: shard.coordinate runs one degraded retry on a mandatory fresh re-dial, resuming committed tokens under the same settlement nonce (no delta dup/gap; receipts sweep once); EAGLE/TREE sticky-off after; JobRejected never retries. L3: per-job stall backstop (M25_JOB_STALL_S, auto timeout+60s; prefill replies count as progress) with an unconditional exception-proof os._exit so the daemon restarts and fail-closes. Verified by a design panel + independent adversarial pass (1 defect found and fixed: the backstop emit could block its own kill). 22 new tests incl. a real-os._exit subprocess proof; full suite 584 passed, 1 skipped.
leyten
added a commit
that referenced
this pull request
Jul 20, 2026
…her (#122) The watchdog env flags from #120 were unreachable in a real deployment — the launcher only forwards ENG_ENV to stages/gateway, and M25_RET_STALL_S (tail), M25_DRAFT_BUDGET_S/M25_JOB_STALL_S (coordinator), M25_REPLY_TIMEOUT werent in it. Adds them so the tail gets its stall bound and a --serve gateway coordinator can tune the budgets.
leyten
added a commit
that referenced
this pull request
Jul 20, 2026
…123) Controlled-ring validation closes P0-#5: shipped #120 build + #122 knobs serve M2.5 over a real 3-region WAN ring (degraded=false, receipts chained under one nonce); the sustained-backpressure M1 wedge is not reproducible on a fast datacenter ring by construction (depth-1 EAGLE, 4-6MB buffers, no NET_ADMIN) — proven offline in test_ret_stallguard.py. Marks P0-#5 DONE, adds the receipt.
leyten
added a commit
that referenced
this pull request
Jul 22, 2026
leyten
added a commit
that referenced
this pull request
Jul 22, 2026
… silent hang (#120) Mitigation ladder for the 2026-07-14 residential-tail EAGLE hang; root cause unknown by design — every EAGLE-implicated stall class now ends in worst-case-slower or a clean fast fail. L1: draft-budget watchdog flips a slow drafter to n-gram mid-job (M25_DRAFT_BUDGET_S, flag-latch, pipelining restored). M1: the tail ret socket gets a per-progress stall bound (M25_RET_STALL_S; per-sendmsg semantics — a slow-but-draining uplink never trips) so one wedged send can no longer hang the whole warm ring. Reset now carries eagle:0/1 and every stage silences aux for degraded sessions — the degraded arm equals the plain ring on the wire. L2: shard.coordinate runs one degraded retry on a mandatory fresh re-dial, resuming committed tokens under the same settlement nonce (no delta dup/gap; receipts sweep once); EAGLE/TREE sticky-off after; JobRejected never retries. L3: per-job stall backstop (M25_JOB_STALL_S, auto timeout+60s; prefill replies count as progress) with an unconditional exception-proof os._exit so the daemon restarts and fail-closes. Verified by a design panel + independent adversarial pass (1 defect found and fixed: the backstop emit could block its own kill). 22 new tests incl. a real-os._exit subprocess proof; full suite 584 passed, 1 skipped.
leyten
added a commit
that referenced
this pull request
Jul 22, 2026
…her (#122) The watchdog env flags from #120 were unreachable in a real deployment — the launcher only forwards ENG_ENV to stages/gateway, and M25_RET_STALL_S (tail), M25_DRAFT_BUDGET_S/M25_JOB_STALL_S (coordinator), M25_REPLY_TIMEOUT werent in it. Adds them so the tail gets its stall bound and a --serve gateway coordinator can tune the budgets.
leyten
added a commit
that referenced
this pull request
Jul 22, 2026
…123) Controlled-ring validation closes P0-#5: shipped #120 build + #122 knobs serve M2.5 over a real 3-region WAN ring (degraded=false, receipts chained under one nonce); the sustained-backpressure M1 wedge is not reproducible on a fast datacenter ring by construction (depth-1 EAGLE, 4-6MB buffers, no NET_ADMIN) — proven offline in test_ret_stallguard.py. Marks P0-#5 DONE, adds the receipt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi leyten — findings plus one additive engine change from running your dense sm120 ring against GLM-5.2, packaged as a single commit on top of
master. Opt-in and non-breaking: your original paths are untouched when the new flag is off.TL;DR
MLA_LATENT=1). The dense ring caches decompressed full-head K/V and tops out ~16–24k context on an 8×96GB pod (OOM at 32k, any chunk size). The standard DeepSeek "absorb" caches the kv-latent + shared rope key and runs attention in latent space — ~70x smaller KV (32k: ~88GB → ~1.3GB/stage), clears 32k at 38GB vs a 94GB OOM. Opt-in env flag; full-head path is byte-identical when unset, and the absorb was proven equivalent offline (errors ~1e-13) before any GPU.These are two independent wins — MTP is the draft, MLA is the target-side cache; one does not depend on the other.
What's in the diff (one commit, +~2.25k / -29)
SHARDV2.md— overview + reproduce commandsdocs/research/GLM52-draft-and-MLA-findings-for-peers.md— full methodology, tables, the convention-bug warning, and why the 9B is architecturally absent past 32kdocs/research/{H1-process-and-results,H1-test-plan-v2,serving-optimization-plan}.mdresearch/—mla_latent.py(offline equivalence proofs),ring_mtp.py(MTP head +--diagconvention sweep),ring_long.py(chunked driver, blocked argmax),h1_bench.py,draft_accept_bench.py,pod_9b_dump.py,ring_target_dump.py, dumps + testsresearch/glm_swarm_nvfp4_kv.py— theMLA_LATENT=1latent-cache attention path (additive)One reproducibility trap
GLM-5.2's MTP wants the post-
model.normhidden, concat[enorm(emb); hnorm(h)]. The pre-norm hidden gives 0.53 — a plausible-but-wrong "9B wins" number. HF transformers doesn't implement 5.2's NEXTN, so we settled the convention by sweep (ring_mtp.py --diag).Start at
SHARDV2.md. Happy to walk through any of it.