Skip to content

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
leyten:masterfrom
dllmnetwork:master
Open

GLM-5.2 speculative drafting: native MTP head beats GLM-4-9B, + opt-in MLA-latent KV cache#5
joelovestech wants to merge 1 commit into
leyten:masterfrom
dllmnetwork:master

Conversation

@joelovestech

Copy link
Copy Markdown

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

  1. GLM-5.2's native MTP head beats a standalone GLM-4-9B draft at every context, and the margin widens. Per-position greedy acceptance on the ring: 1k 0.849 vs 0.793, 8k 0.879 vs 0.820, 32k 0.883 vs 0.745 (accept-len 8.5 vs 3.9 — >2x accepted tokens per traversal), 100k 0.881 (the 9B is 32k-trained and can't reach it at all). MTP is also cheaper — shares the target's embed/lm_head, no separate model on the coordinator.
  2. MLA-latent KV cache (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 commands
  • docs/research/GLM52-draft-and-MLA-findings-for-peers.md — full methodology, tables, the convention-bug warning, and why the 9B is architecturally absent past 32k
  • docs/research/{H1-process-and-results,H1-test-plan-v2,serving-optimization-plan}.md
  • research/mla_latent.py (offline equivalence proofs), ring_mtp.py (MTP head + --diag convention sweep), ring_long.py (chunked driver, blocked argmax), h1_bench.py, draft_accept_bench.py, pod_9b_dump.py, ring_target_dump.py, dumps + tests
  • research/glm_swarm_nvfp4_kv.py — the MLA_LATENT=1 latent-cache attention path (additive)

One reproducibility trap

GLM-5.2's MTP wants the post-model.norm hidden, 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.

…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
joelovestech marked this pull request as ready for review June 27, 2026 21:35
leyten added a commit that referenced this pull request Jul 20, 2026
…watchdog (#118)

P1-#1 done (map live, sim fallback); P1-#2 code-complete (epoch settlement #37). Next: EAGLE P0-#5 mitigation-first.
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
LAUNCH.md blocker #5 progress note + M25_ENGINE.md RESUME-HERE 07-20 LATEST-3 block: the four mitigation layers with env knobs, the untimed-ret prime suspect, verification trail, pay-model #41 merged, and the controlled-ring validation arms as the one next action.
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
…watchdog (#118)

P1-#1 done (map live, sim fallback); P1-#2 code-complete (epoch settlement #37). Next: EAGLE P0-#5 mitigation-first.
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
LAUNCH.md blocker #5 progress note + M25_ENGINE.md RESUME-HERE 07-20 LATEST-3 block: the four mitigation layers with env knobs, the untimed-ret prime suspect, verification trail, pay-model #41 merged, and the controlled-ring validation arms as the one next action.
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.
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.

1 participant