Skip to content

Re-enable fine-grained (64-token) prefix-cache hits (GLM53_FINEGRAINED_APC) - #84

Closed
nood-co1 wants to merge 5 commits into
MiaAI-Lab:mainfrom
nood-co1:pr/apc-fine-grained-hits
Closed

nood-co1 wants to merge 5 commits into
MiaAI-Lab:mainfrom
nood-co1:pr/apc-fine-grained-hits

Conversation

@nood-co1

@nood-co1 nood-co1 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Re-enable fine-grained (64-token) prefix-cache hits (GLM53_FINEGRAINED_APC)

Problem

The hybrid coordinator disables fine-grained hits for the whole model because KpoolTailManager — a per-request scratch that
opts out of prefix caching entirely — is included in the compatibility check. One veto silences three cooperating subsystems
that already operate at hash_block_size = 64 (mamba partial-tail snapshot producer/consumer, scheduler chunk stop). Every
hit snaps to the 3584-token block: a warm re-turn recomputes up to 3583 tokens (0.9–4.0 s measured).

Change

Overlay patch_apc_fine_grained_hits.py (fail-closed, transactional; composes with patch_hybrid_prefix_hit.py both orders):
exclude non-participating managers from the veto; enforce the real invariant hash_block_size % index_kpool == 0
(index_kpool = 4, verified from live specs at init — violations refuse to boot; participating coarse managers still safely
disable). Effective-value receipt line at init; detects a future image where upstream already scopes the veto (vLLM main
e126687a) and no-ops. Kill switch GLM53_FINEGRAINED_APC=0; launcher validates 0/1; 195-check host test.

Live receipts (on top of the per-group retention PR)

before with this PR
re-turn hit, 45–120K conversations 96.4–99.4 % 99.9–100 %
re-turn TTFT 0.9–4.0 s 0.3–0.5 s
falsifiable hit-length prediction (P=33641, +9-token turn) 32256 (3584 grid) 33600 = the 64 grid, exactly as predicted
L5 decode rate after a warm diverging hit — 0.99× cold
temp-0 logprob equivalence (3-cold-pair noise floor, probe_prefix_equivalence.py v3) — PASS: prose cold-vs-warm max Δlogprob 0.183 vs floor 0.176 (≤3×), code 0.47 vs 0.35; position-0 token identical throughout

Audit log

Codex design review (build-with-changes) → applied; final pass (fix-first: capability cross-check, strict ints, 0/1 kill
switch, mixed-layout safe-disable, receipt line, upstream-fixed detection) → applied; confirm: deploy-for-live-test.


Submitted by nood-co1 on behalf of Blockbrain Labs (https://x.com/blockbrain_labs, GitHub org blockbrain-ai). Measured on our 2× NVIDIA DGX Spark deployment.

…(GLM53_FINEGRAINED_APC)

The hybrid coordinator disables fine-grained hits for the whole model because
KpoolTailManager — which opts out of prefix caching entirely (per-request
scratch, never hashed) — is included in the compatibility check. One veto
silences three cooperating subsystems that already operate at
hash_block_size = 64: the mamba partial-tail snapshot producer/consumer and the
scheduler's chunk stop. Every hit therefore snaps to the 3584-token block and a
warm turn recomputes up to 3583 tokens (~3 s on 2x GB10).

Overlay patch_apc_fine_grained_hits.py (fail-closed, transactional apply,
composes with patch_hybrid_prefix_hit.py in either order): exclude
non-participating managers from the veto; enforce the real invariant
hash_block_size % index_kpool == 0 (index_kpool = 4 here), verified from the
live specs at coordinator init — a violating or unverifiable scratch group
refuses to boot (GLM53_FINEGRAINED_APC=0 restores upstream behaviour). The
required alignment is lcm(64, 4, 64) = 64, so _cache_hit_alignment_tokens is
unchanged; an earlier '896 alignment' idea would have overstated hits 14x.
Expected: a re-sent conversation hits at its previous prompt tail (falsifiable:
P=31672 -> cached 31616, control 28672). Launcher knob exported to both ranks;
Dockerfile COPY + test-before-patch + RUN; README/.env.example; host test (86
checks). Live receipts (L1-L5 ledger in docs/) to follow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@a2001eric-web

Copy link
Copy Markdown

Tested successfully on a production-like 2x DGX Spark deployment.

Integration tested:

Boot confirmed:

[glm53-apc-finegrained] Fine-grained prefix-cache hits ENABLED
effective alignment=64 tokens (hash_block_size; scheduler_block_size=3584)
scratch groups checked: {'KpoolTailManager': 4}

The live request had 119,995 prompt tokens and the repeated request reported exactly 119,936 cached tokens:

floor(119,995 / 64) * 64 = 119,936

119,936 is 64-aligned and is not a multiple of 3,584, so this is direct wire-usage evidence that the effective hit grid changed from the scheduler block to the 64-token hash block. Cold TTFT was 174.522s; warm TTFT was 0.581s.

Combined with #83, two distinct 120K conversations were alternated A→B→A→B. Every warm/return request reported 119,936 / 119,995 cached tokens (99.95%) with TTFT 0.567–0.590s.

Additional acceptance passed: forced tool call with required arguments, native vision smoke, both-rank model load, and no new NCCL/CUDA/EngineCore errors.

One combined-wiring hardening suggestion from the deployment: fail closed on both patch artifacts before stopping healthy containers, and pin the overlay order on both ranks as hybrid -> per-group -> fine-grained. We also added a static regression that both ranks receive the same fine-grained/per-group environment values.

Thank you — the 64-token alignment is observable and working as designed on the live fork/image.

qualitycontrol and others added 3 commits September 1, 2026 10:14
Tester feedback (a2001eric-web, production-like 2x Spark run, MiaAI-Lab#83+MiaAI-Lab#84
integrated): `restart` ran `stop` first and only then, inside
start() -> preflight, noticed a missing patch artifact - by which time both
healthy containers were already gone.

- New `validate_overlay_artifacts` (own sentinel block, bash array, refuses
  an empty list): every mounted overlay - patch_hybrid_prefix_hit.py and
  patch_apc_fine_grained_hits.py included - must exist, be non-empty, parse
  as Python (ast.parse, no __pycache__ litter), carry its own distinct
  identity string (MARK / target path / hook marker) and end with its exact
  last non-blank line, so a *_PATCH_HOST pointed at a different overlay, or
  a copy truncated anywhere before EOF (even one that still parses), is
  caught - not just a missing file. The chat template (regular, readable,
  non-empty file) and ablit/LAYER_MAP.json (parses as JSON) are gated too;
  previously a missing template was found only after stop. This is a guard
  against operator error, not a tamper-proof manifest; residual: a
  line-boundary truncation landing on an earlier identical last line while
  still parsing.
- main() runs it next to validate_numeric_config on start|restart, BEFORE
  `restart` reaches `stop`, exiting 2 with nothing stopped. preflight keeps
  its later checks.
- The GLM53_APC_RETENTION_INTERVAL_SWA guard lives with the launcher that
  forwards that knob (PR MiaAI-Lab#83); this launcher validates what it forwards
  (GLM53_FINEGRAINED_APC, already in the guard).
- README: python3 on the head is a stated prerequisite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…anks

Tester feedback (a2001eric-web): pin the overlay order on both ranks as
hybrid -> per-group -> fine-grained. Previously the head and worker inner
scripts each carried their own literal `if [ -f ]; python3` ladder, so the
two ranks could drift and the relative order of the three prefix-cache
overlays (they share the kv_cache_coordinator.py helper insert point) was
implicit.

GLM53_OVERLAY_ORDER is now the single ordered list; emit_overlay_block writes
it verbatim into the head and the worker inner script. The generated apply
block is byte-identical to the previous literal one except for the extra
pinned slot (patch_hybrid_prefix_hit -> patch_apc_per_group_retention ->
patch_apc_fine_grained_hits), which stays a `[ -f ]`-guarded no-op
in-container unless that artifact is mounted. Which artifacts MUST exist is
decided by the overlay artifact guard, not by this list.

tests/test_kpool_tail_slotmap.py and tests/test_xgrammar_termination.py
asserted the literal per-rank ladder (count == 2); they now assert their
patch is an entry of GLM53_OVERLAY_ORDER and that emit_overlay_block feeds
both rank scripts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rder, rank parity)

tests/test_launcher_rank_parity.py drives the shipped start.sh under bash
from an allow-listed environment with docker / ssh / scp / rsync / curl /
ip / nvidia-smi stubbed first on PATH (pytest-collectable too):

  A  GLM53_APC_RETENTION_INTERVAL_SWA guard matrix (accepted: unset, "",
     0, 3584, 0014336 -> 14336, 999936; rejected: non-multiples, > 1e6,
     signs, floats, whitespace, CR, junk) - on the checkout whose launcher
     actually forwards that knob (detected from the -e line, not guessed).
  B  `./start.sh restart` with a bad knob, or with ANY *_PATCH_HOST
     missing or pointed at a different overlay (and empty / unparseable for
     the prefix-cache ones), exits 2 with ZERO docker or ssh calls; a valid
     configuration passes the gate and reaches `stop` on both ranks.
     Also: a valid-prefix truncation (cut right after the identity line),
     a missing or directory chat template and a non-JSON ablit layer map.
  C  GLM53_OVERLAY_ORDER lists hybrid -> per-group -> fine-grained, no
     literal per-rank ladder remains, write_inner_scripts emits the
     identical `[ -f ]`-guarded sequence into head and worker.
  D  launch_cluster dry-run captures both `docker run` lines (head argv,
     worker via the ssh command string) plus every scp, and asserts the
     chain head-mount = scp source = worker-mount for every /opt/glm53
     patch, identical effective GLM53_APC_RETENTION_INTERVAL[_SWA] /
     GLM53_FINEGRAINED_APC (and VLLM_PREFIX_CACHE_RETENTION_INTERVAL[_SWA])
     values, and PRESENCE of every knob the launcher wires; a synthetic
     one-rank mismatch (env, mount, scp source) is shown to be reported.

README: test table row.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nood-co1

nood-co1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the combined-wiring run and the 64-token wire evidence. The hardening you suggested is now on this branch as additive commits on top of the commit you tested — df8942b is preserved in history, nothing was force-pushed:

  1. cf53bb5 — fail closed on both patch artifacts before restart stops anything. main() runs validate_numeric_config and a new validate_overlay_artifacts on start|restart before stop is reached. Every mounted overlay — patch_hybrid_prefix_hit.py and patch_apc_fine_grained_hits.py included — must exist, be non-empty, parse as Python and carry its own distinct identity string ([glm53-finegrained-apc], [glm53-hybrid-apc], target-path / hook markers for the rest), and end with its exact last non-blank line (EOF sentinel), so a *_PATCH_HOST pointed at the wrong overlay, or a copy truncated anywhere before EOF even if it still parses, is caught, not just a missing one; the chat template and ablit/LAYER_MAP.json are gated too; GLM53_FINEGRAINED_APC keeps its exact-0/1 guard. This launcher validates what it forwards, so the GLM53_APC_RETENTION_INTERVAL_SWA rule (empty/0 or a positive multiple of 3584 ≤ 1,000,000) lives with the launcher that wires that knob, Per-KV-cache-group prefix-cache retention: sparse drafter, dense MLA/mamba #83. README now states the head python3 prerequisite.
  2. df9fc04 — overlay order pinned once for both ranks as hybrid -> per-group -> fine-grained. GLM53_OVERLAY_ORDER is the single list (the per-group slot [ -f ]-guarded until Per-KV-cache-group prefix-cache retention: sparse drafter, dense MLA/mamba #83 lands) and emit_overlay_block writes it verbatim into the head and worker inner scripts.
  3. 4014c5c — static + dry-run regression tests/test_launcher_rank_parity.py (104 checks here): restart with a bad GLM53_FINEGRAINED_APC, or with any *_PATCH_HOST missing / pointed at a different overlay / empty / unparseable / truncated to its longest still-parseable prefix, or a missing or directory chat template / non-JSON ablit/LAYER_MAP.json, makes zero docker or ssh calls; the order pin asserted in the list and in both generated scripts; and a launch_cluster dry-run that captures both docker run lines (head argv, worker via the nccl_common[] replay in the ssh command string) plus every scp, asserting head-mount source = scp source = worker-mount for every /opt/glm53 patch and identical, present effective GLM53_FINEGRAINED_APC on both ranks for 0 / 1 / default (knobs this branch does not wire are reported as absent on both rather than assumed). A synthetic one-rank mismatch is shown to be reported.

Local test run (macOS, bash 5.3, pristine kv_cache_coordinator.py pulled from the ghcr image):

=== h84 @ 4014c5c 4014c5c df9fc04 cf53bb5  status: 0 dirty files
  FAIL tests/test_ablit.py
  PASS tests/test_apc_fine_grained_hits.py
  PASS tests/test_bringup_robustness.py
  FAIL tests/test_chat_template.py
  FAIL tests/test_exl3_overlay.py
  PASS tests/test_hybrid_prefix_hit.py
  PASS tests/test_kpool_tail_slotmap.py
  PASS tests/test_launcher_rank_parity.py
  FAIL tests/test_mixed_prefill_decode.py
  PASS tests/test_numeric_config.py
  FAIL tests/test_scheduler_decode_floor.py
  PASS tests/test_start_overrides.py
  PASS tests/test_suppress_stops.py
  PASS tests/test_warm_restart_stdout.py
  PASS tests/test_xgrammar_termination.py
  parity: rc=0 ok=104 fail=0

The five FAIL rows are environment-only on this Mac (no torch / jinja2 / vllm / scheduler.py; test_mixed_prefill_decode.py is a live bench) and fail identically at the tested commit df8942b. Every launcher/overlay test passes, including the two wiring tests (test_kpool_tail_slotmap.py, test_xgrammar_termination.py) that were taught about GLM53_OVERLAY_ORDER.

Dry-run validator receipt on the Spark head (deb8, bash 5.2, Python 3.12). Temp copy of this branch at 4014c5c with the deployed .env, and docker/ssh/scp/rsync stubbed first on PATH so nothing real can be stopped:

== real head container BEFORE: glm53-exl3-head Up About an hour; started=2026-09-01T01:02:34.588631621Z
==== h84 @ 4014c5c0f5f4fbe48aa8e41cd8814ea5da6361de (temp copy /home/blockbrain/harden-receipt/h84, deployed .env, docker/ssh/scp/rsync stubbed first on PATH)
docker on PATH -> /home/blockbrain/harden-receipt/bin/docker
-- missing-finehit: rc=2 stub docker/ssh calls=0
     overlay artifact missing, unreadable or empty: /nonexistent/patch_apc_fine_grained_hits.py
-- mispointed-finehit: rc=2 stub docker/ssh calls=0
     overlay artifact /home/blockbrain/harden-receipt/h84/overlay/patch_glm_video_placeholders.py does not carry its identity string '[glm53-finegrained-apc]' (wrong file?)
-- bad-finegrained: rc=2 stub docker/ssh calls=0
     GLM53_FINEGRAINED_APC must be exactly 0 or 1 (got: yes)
-- missing-hybrid: rc=2 stub docker/ssh calls=0
     overlay artifact missing, unreadable or empty: /nonexistent/patch_hybrid_prefix_hit.py
-- mispointed-video: rc=2 stub docker/ssh calls=0
     overlay artifact /home/blockbrain/harden-receipt/h84/overlay/patch_hybrid_prefix_hit.py does not carry its identity string 'vllm/model_executor/layers/' (wrong file?)
-- mispointed-drafter: rc=2 stub docker/ssh calls=0
     overlay artifact /home/blockbrain/harden-receipt/h84/overlay/patch_glm_video_placeholders.py does not carry its identity string 'vllm/v1/core/kv_cache_utils.py' (wrong file?)
     (truncated hybrid prefix parses as Python; only the EOF sentinel can refuse it)
-- truncated-hybrid: rc=2 stub docker/ssh calls=0
     overlay artifact /home/blockbrain/harden-receipt/log/h84-truncated_hybrid.py does not end with '    sys.exit(main())' (truncated copy? last line: '    return 0')
-- missing-chat-template: rc=2 stub docker/ssh calls=0
-- control-deployed-env: rc=1 stub docker/ssh calls=8
     �[1;31m[glm53-exl3]�[0m ERROR: set NCCL_IB_GID_INDEX (same index both ranks) or HEAD_GID/WORKER_GID (per rank) in .env to populated indices
     control: first stub calls after the gate passed:
       docker rm -f glm53-exl3-head 
       ssh -T -o BatchMode=yes -o ConnectTimeout=15 blockbrain@10.0.22.2 docker rm -f 'glm53-exl3-worker' 
-- tests/test_launcher_rank_parity.py on deb8:
     rc=0 ok=104 fail=0 launcher rank-parity / order / pre-stop gate OK
== real head container AFTER: glm53-exl3-head Up About an hour; started=2026-09-01T01:02:34.588631621Z

Every bad input exits 2 with zero docker/ssh calls; the control run with the deployed .env passes the gate and reaches the (stubbed) stop on both ranks. The live head container's StartedAt is unchanged.

No live reboot was performed. The production pair had been restarted by the owner shortly before this run and is in active use, and the deployed launcher (deploy/dogfood) carries additional knobs beyond this PR, so a boot from a PR checkout would have changed the deployed configuration. Your boot and A/B receipts remain the live evidence for the tested commit; these commits change only the pre-stop gate, the order pin and the tests, and the generated in-container apply block is byte-identical to df8942b apart from the added [ -f ]-guarded slot.

Four adversarial review passes (gpt-5.6) were run on the diff before pushing and their findings folded in; two of its suggestions were deliberately not taken: a per-artifact SHA-256 manifest (this gate targets operator error — missing / mis-pointed / truncated / broken files — not tampering, and a digest manifest would couple every overlay edit to a manifest bump), and dropping the [ -f ]-guarded sibling slot from the order list (you asked for the combined pin on both PRs; the slot is a no-op unless that artifact is present), and adding EOF comment sentinels inside every overlay file (the exact-last-line check covers truncation without touching files this PR does not own; the stated residual is a line-boundary cut landing on an earlier identical last line while still parsing).

@wdkr

wdkr commented Sep 1, 2026

Copy link
Copy Markdown

Thanks for PRs 83 and 84! Big improvement in for example OpenCode sessions. This is what my LLM had to say about it:

Applied both PRs together on 2× DGX Spark (GB10/sm_121, TP=2, EXL3 4bpw,
DFlash2 k=7, MNBT 2048, max_num_seqs 4): boot reports
retention_by_group=[None,None,None,None,None,None,0] (global=None swa_env=0 eagle_min_exempt=[6]) and fine-grained hits ENABLED at alignment 64 with
scratch groups checked: {'KpoolTailManager': 4}. On a 50K→63K conversation
the token-denominated counters land at 554,048 hits against a theoretical
maximum of 554,210 — 99.97% of the ceiling
, i.e. a 16.2 tok/turn shortfall
against a 64-token block, with warm re-turn TTFT 1.11–1.20 s across two runs.

@nood-co1

nood-co1 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for the independent run and the token-level counters — 554,048 / 554,210 (99.97%) on a 50K→63K conversation is excellent evidence, and yours is the second independent 2× Spark setup to exercise #83+#84 together, with retention_by_group=[None×6,0] and fine-grained ENABLED at alignment 64 in the boot lines. We appreciate the careful validation. If you hit anything odd in longer multi-session shapes (the regime #83 targets hardest), receipts like these are the most useful thing you can post.

@nood-co1

nood-co1 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Updated to current main (e25aa70) by merging main into the branch — merge commit 8f103ca, plain push, no force-push; tested history preserved (df8942b and the three hardening commits remain ancestors). Conflicts: start.sh (7 hunks — knob capture/config/bool-flag helper/validator call/-e lines vs main's indexer-workspace/spinwait equivalents, both sides kept; both rank-script apply blocks re-derived onto emit_overlay_block, never keep-both-merged) and README.md (main's newer rows + this PR's fine-grained row). Interaction fixes inside the merge commit (same shape as #83): GLM53_OVERLAY_ORDER += patch_spinwait.py + patch_indexer_workspace.py in main's own position; artifact gate += the spinwait mount; main's two wiring tests adapted to the order-pin; rank-parity harness pre-sets the new knobs. Interaction (a) checked: this PR's fine-grained overlay and the merged #63 template touch different layers — no overlap found, none expected. Also adopted from the update review: (1) the GLM53_FINEGRAINED_APC caller capture is now setness-aware (${VAR+1}), matching the contract main's indexer/spinwait knobs introduced — an explicitly empty caller export now reaches the 0/1 guard and is rejected pre-stop instead of silently losing to .env (new C3/C4 regression checks in tests/test_apc_fine_grained_hits.py cover silent-caller, explicit-empty survival, and the rc=2 rejection); (2) the spinwait gate entry identifies the artifact by its own TARGET path (device_communicators/shm_broadcast.py) rather than the incidental temp-file name. Re-run green: bash -n, tests/test_launcher_rank_parity.py, part-C knob suite, full host suite 17/22 (fails = the 4 known env fails + test_apc_fine_grained_hits needing the in-image kv_cache_coordinator.py, identical at the tested SHA). Host suites re-run green post-merge; no new live-server measurements were taken for this update; the branch's live receipts describe the fine-grained overlay path, which the resolution leaves byte-untouched (the setness fix changes only the launcher's handling of an explicitly empty caller export — previously silently swallowed, now a pre-stop launcher error).

@wdkr

wdkr commented Sep 2, 2026

Copy link
Copy Markdown

I thought I noticed a drop in per-position drafter acceptance in the logs when running PRs 83 and 84, so I tried to benchmark it. Below is what Fable thinks of it:


A/B on 2x GB10 (TP=2), same image and same input rev, only the two overlay patches toggled: fine-grained hits (#84) reduce DFlash2 acceptance on warm turns; #83 alone does not.

Setup: GLM-5.3-Flash EXL3 4bpw, DFlash2 drafter k=7, MNBT 2048, max-num-seqs 4, VLLM_PREFIX_CACHE_RETENTION_INTERVAL_SWA=0 where #83 was on. Four arms, each a fresh boot: stock (neither patch), #83 only, #84 only, both. Per arm, 27 greedy requests with thinking off: 9 cold single-turn prompts, plus 3 six-turn conversations over a document of about 9.4k tokens with fixed assistant turns, so the request bytes are identical across arms. Turn 1 of each conversation is cold, turns 2 to 6 hit the prefix cache. Acceptance is taken from /metrics counter deltas per request (spec_decode_num_accepted_tokens_total / spec_decode_num_drafts_total, plus the per-position counters), so it is drafts-weighted and independent of the client.

arm warm hit fraction cold accept len warm accept len warm pos-7 accept paired warm delta vs stock
stock 0.71 4.53 5.77 0.409 reference
#83 only 0.71 4.61 6.28 0.510 +0.58 (higher in 13/15)
#84 only 0.97 4.72 5.49 0.378 -0.27 (lower in 10/15)
#83 + #84 0.97 4.69 5.42 0.344 -0.35 (lower in 9/15)

Accept len = 1 + accepted / drafts. Warm TTFT went from about 3.5 s (stock, #83) to about 1.1 s (#84, both), so the patch does what it says.

Reading:

Caveats: 3 repeats per cell, thinking off, single-stream only. Happy to share the JSON files and the probe script, or re-run with more repeats or specific settings.

@nood-co1

nood-co1 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the careful A/B — the per-position counter method and the fixed-assistant-turn construction are exactly the right instruments, and your measurement caught something our design doc had flagged as a risk (R4) but never measured. We re-ran your probe shape on our production pair (2× DGX Spark, TP=2, next3 image) with a Codex-reviewed kit: BAAB fresh boots (R_both → R_83 → R_83 → R_both), single-knob contrast — R_83 = fine-grained hits killed via GLM53_FINEGRAINED_APC=0, R_both = enabled, per-group SWA retention pinned identical by value in both arms — with per-boot receipts (head rank: authoritative effective alignment/retention boot lines; worker rank: kill-switch environment parity), reps 2/boot (60 warm turns/arm), acceptance from drafts-weighted /metrics counter deltas like yours.

On your acceptance claim: our result is weakly directional in the same direction as yours (our pre-registered language cap: n = 2 boot pairs; both boot pairs agree in sign, cluster signs are 11/12, not unanimous).

arm cold acc-len (pooled) warm acc-len (pooled) warm TTFT med warm hit frac
R_83 (fine hits off) 2.43 / 2.50 5.693 2.24 s 0.781
R_both (fine hits on) 2.47 / 2.51 5.159 0.50 s 0.992

Boot-pair warm deltas (independent units): −0.361, −0.689; conversation-cluster deltas 11/12 negative (sign-p 0.006, descriptive — clusters are pseudoreplicated). Pooled delta −0.53, a bit larger than your −0.27/−0.35. Cold acceptance is flat across arms (spread 0.08), and — as in your table — each boot's pooled warm acceptance stayed above its pooled cold. Per-position, the arm-pooled rate gap is tail-heavy: ≈0.010 at position 0 growing to ≈0.115 at position 6 (small non-monotonicities at intermediate positions) — same tail-heavy shape as your pos-7 column.

Mechanism (candidate, consistent with source and both datasets, not yet instrumented): on the 3584 grid a warm turn re-prefills a 2.5–3.5k tail ≥ the drafter's 2048-token sliding window, so the drafter's whole window is rebuilt from fresh hidden states every warm turn — an acceptance bonus that costs the multi-second TTFT you measured. A 64-grid hit forgoes that re-prefill; with per-group SWA retention at 0 the drafter resumes on an empty window. Warm-above-cold in both arms is consistent with a forgone bonus, not drafter corruption. Your #83-only +0.58 remains unexplained by us too — open item. Definitive attribution needs drop_eagle_block/eagle_verified receipts from an instrumented boot; on our list, not claimed here.

Since alignment keeps coming up as the obvious knob: coarsening to 896 is not the fix. The gate's invariant does generalize (896 = 14×64), but the fine-grained lookup paths are positionally sound only at alignment == hash_block_size; 896 over a 64 hash-block overstates every fine hit 14× (silent wrong output), and the sound route (--prefix-match-unit 896) is rejected on this layout (896 ∤ 64 drafter SWA block). Even a hypothetical sound 896 grid leaves a grid-rounding remainder of ≤895 tokens (total turn-2 recompute additionally includes the reply and suffix on any grid), still < the 2048 window — so the drafter window still isn't rebuilt. Alignment is the wrong lever for the drafter effect.

Net effect for the trade you surfaced: at median completion length 35 tokens in both arms, median warm-turn wall fell 2.94 s → 1.22 s with fine hits on; decode medians were identical (0.66 vs 0.67 s). The acceptance drop costs ≈1.8 ms per generated token against a 1.7 s TTFT saving — breakeven ≈ 1000-token replies (estimate). In this probe regime #84 is clearly net-positive; broader production workloads remain unmeasured. Your agentic-sweep number (4.82 → 4.10) is the regime where the acceptance side weighs most, and a counterbalanced multi-boot window in that shape is the right next measurement.

On your temp-0 divergence observation: honest status — our equivalence instrument has not yet cleared this deployment's own nondeterminism floor, and we won't claim either direction from it. What we can report, with receipts: on this pair, two cold runs of the byte-identical request (fresh cache-salt namespaces, same boot, idle server) already produce different text at temperature 0. Separated by horizon: short answers are bimodal via single near-tie flips (max |Δlogprob| floor ≈ 1.12 nats); verbose 64-token answers gave cold-vs-cold floors of 8.04 and 11.96 nats in the same boot; independent 400-token cold pairs differed at 349–388 of 400 positions. Three probe designs failed to clear that floor (the first two — natural-EOS length-skew and ignore_eos post-EOS comparison — were themselves unsuitable instruments; the third measured the floor directly). Notably, in every window the warm-vs-cold divergence sat at or below the same boot's cold-vs-cold floor — nothing we measured distinguishes a 64-grid warm hit from an ordinary cold rerun — but identity-level equivalence is unresolvable there, so this is evidence about the floor, not a verdict on lossiness. Practical implication for your planned cold-vs-warm test: benchmark against a same-boot cold-vs-cold pair first; temp-0 text differences alone (your "cannot yet explain" observation) are expected under this floor and don't by themselves indicate a lossy hit. We will design and pre-register a dedicated lossiness protocol built for that statistics (warm-within-cold-distribution testing rather than token identity) and post it on this PR.

Probe script, driver, and the four per-boot JSON receipt files are available — happy to push them to this branch or share directly.

@plotarmordev

Copy link
Copy Markdown
Collaborator

Status: rework — one default change and one trim, then this is the fine-grained candidate we stack on the replay guard.

Verified: read the full diff against current main; the core mechanism is the same veto-scoping as #125 (KpoolTailManager no longer vetoes 64-token hits), here packaged with a runtime-verified scratch invariant and a kill switch. On the acceptance question we are not asking you to re-litigate the thread data — we accept it as established: wdkr's 4-arm fresh-boot A/B (−0.27 / −0.35 warm accept-length, tail-heavy, cold flat, present with and without #83) and your own pre-registered BAAB re-run (boot-pair deltas −0.361 / −0.689, pooled −0.53, same tail-heavy shape) agree in sign and size, and the forgone drafter-window-replay mechanism is consistent with main's MIN_NEW behavior. We also accept your net-wall accounting for the probe regime; the deciding factor for us is that our primary workload is the agentic tool-loop regime, where wdkr measured 4.82 → 4.10 — the acceptance side dominates there.

Change requests:

  1. Default GLM53_FINEGRAINED_APC to 0 (opt-in) until a replay guard lands. Two independent probes show a warm accept-length cost of −0.27…−0.53 in exactly the agentic regime; a change that is on-by-default must not ship a known acceptance regression. Keep the strict 0/1 validation as-is.
  2. Keep the runtime hash % kpool == 0 verification and the kill switch. The _glm53_finegrained_hit_gate cross-check (strict-int parse, contradiction = unverifiable, boot refusal only in the one load-bearing cell) is the genuinely load-bearing hardening — it is what makes a 25-line mechanism safe to ship as an overlay. This is the right kind of defense.
  3. Drop the connector receipt and the upstream-fixed detector. The truncate_computed_blocks reachability assert is a log-only nicety, and the vLLM e126687a no-op detection is speculative future-proofing against a host image we control and pin. Removing both takes the overlay back toward the mechanism + the load-bearing gate.

Waiting on: our cache A/B queue on the 2x GB10 TP=2 E3 kit: #130 (per-group retention + safe DFlash replay, SWA=0, global unset) first; if it passes, the pair experiment — #130 + this PR at the 64 grid with GLM53_FINEGRAINED_APC=1 — under the identical A/B/A2 fresh-boot protocol with the accept-length criterion tightened to ≥ A−0.05. #130's replay clamp is designed to restore exactly the fresh-window condition these two probes identified (recomputing ~2048 tokens instead of a full 3584 page at the 64 grid), so a pass there is the plausible best-of-both: ~1 s warm TTFT with the drafter window rebuilt. If the pair fails on acceptance, this stays opt-in and we revisit.

@plotarmordev plotarmordev added the changes-requested maintainer requested changes; see latest maintainer comment label Sep 10, 2026

@plotarmordev plotarmordev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes — full rationale in #84 (comment). Edit list:

  1. Default GLM53_FINEGRAINED_APC to 0 (opt-in): two independent probes show a warm accept-length regression; keep the strict 0/1 validation as-is.
  2. Keep the runtime hash % kpool verification and the kill switch — that's the load-bearing hardening.
  3. Drop the connector receipt and the upstream-fixed (e126687a) no-op detector.
  4. Rebase onto current main dc6936c (same conflict class as #83; rank-parity test union when stacking).
    Queued behind the #130 A/B as the hardened fine-grained candidate; no merge default-on in any form.

mmizutani added a commit to mmizutani/GLM-5.3-Flash-EXL3-2x-DGX-Sparks that referenced this pull request Sep 11, 2026
Resolved by measurement, not by text:

- Adopt upstream's launcher machinery as-is: overlay artifact gate,
  GLM53_OVERLAY_ORDER, retention knob validation/forwarding, tests, docs,
  start-tp4.sh, numeric-config changes.
- Keep the MiaAI-Lab#83 per-group retention and the pre-MiaAI-Lab#130 hybrid APC overlays.
  The MiaAI-Lab#130 rework measured worse on this kit's agent probe (3x30k repeats
  0.000 vs 1.000 hits; 2x60k 0.955 vs 0.999) across B4/B5 and was isolated
  from our DFlash block-drop patch by B6. Receipts:
  docs/headroom-2026-09-11.md section 12.3.
- Keep our additions: fine-grained 64-token hits (PR MiaAI-Lab#84),
  vLLM #54163 block-drop cherry-pick, adaptive-k default + auto capture
  list, spinwait 16, dual-HCA GID preflight, portable jinja2 host check
  for the new chat-template validation (linuxbrew python3 lacks jinja2),
  long-prefill boot warmup rungs.

Verification: all 12 host suites pass; B7 live re-validation on the merged
launcher reproduces B3 (1x/3x/4x 30k repeats 1.000 at 0.3-0.4s, 2x60k
0.999, 3x5k 0.992; 4-agent x 60k turns 1-3 0.886-0.928, wall 17.7-23.6s).

Merged upstream: origin/main @ 9348755 (PR MiaAI-Lab#130).
mmizutani added a commit to mmizutani/GLM-5.3-Flash-EXL3-2x-DGX-Sparks that referenced this pull request Sep 11, 2026
…ndings

Live 2x GB10 investigation (docs/headroom-2026-09-11.md, logs/headroom-20260911/).
Config and correctness now ship together so a fresh checkout gets the measured best.

Decode / launch:
- adaptive-k (GLM53_ADAPTIVE_K=ema) is the .env.example default; start.sh
  auto-adds the required union capture list when the knob is ema/on/1 (the
  stock list missed the 3- and 5-token graphs). Measured +10.3% hash-map
  prose, structured neutral (A/B/A, median of 5).
- GLM53_SPINWAIT_MS=16 default (frozen sweep winner; re-checked at MNBT 7168).
- dense FP8 documented as opt-in with 2026-09-11 KLD/decode numbers and enabled
  in this kit's .env (provisional numerics).

Warmup:
- boot-shape-warmup.sh: long-prefill rungs (3584/7168/14336/65536) so
  BuildPrefillChunkMetadataKernel does not JIT on a real request, payload
  staging through a file (long prompts exceeded ARG_MAX), and the outcome
  tally ignores the staged payload files.

Prefix caching (the production 8.7% hit-rate cliff):
- adopt PR MiaAI-Lab#83 overlay/patch_apc_per_group_retention.py: per-group retention;
  the EAGLE-exempt DFlash2 drafter no longer spends 33 of the 38 block ids a
  cached 3584-token segment costs and stops evicting the MLA/mamba blocks that
  carry the hit (GLM53_APC_RETENTION_INTERVAL_SWA, default auto).
- adopt PR MiaAI-Lab#84 overlay/patch_apc_fine_grained_hits.py: exclude the KpoolTail
  scratch from the fine-grained veto, restoring 64-token hit alignment
  (GLM53_FINEGRAINED_APC=1).
- cherry-pick vLLM #54163 as overlay/patch_dflash_block_drop.py: DFlash/DSpark
  must not take the EAGLE trailing-block back-off (use_eagle_block_drop);
  otherwise the Mamba state never materializes and every reply recomputes.
- launcher hardening from the PRs: validate_overlay_artifacts fail-closed gate
  before restart stops anything, GLM53_OVERLAY_ORDER emitted identically to
  both rank containers, retention/bool knob validation, Dockerfile COPY/RUN.

Live A/B boot B3 (same probes): 3-4 x 30k repeats 17.2s/0.000 hits -> 0.4s/1.000;
2 x 60k 34s/0.000 -> 0.4s/0.999; 4-agent x 60k turns 1-3 0.000 / wall 150-196s ->
0.916-0.928 / wall 18s; hash-map prose 34.50 tok/s and coherence unchanged.

Host tests pass: test_launcher_rank_parity, test_apc_per_group_retention,
test_apc_fine_grained_hits, test_dflash_block_drop_patch, test_hybrid_prefix_hit,
test_spinwait_patch, test_indexer_workspace, test_kpool_tail_slotmap,
test_xgrammar_termination, test_start_overrides, test_nccl_multi_hca.
mmizutani added a commit to mmizutani/GLM-5.3-Flash-EXL3-2x-DGX-Sparks that referenced this pull request Sep 11, 2026
Resolved by measurement, not by text:

- Adopt upstream's launcher machinery as-is: overlay artifact gate,
  GLM53_OVERLAY_ORDER, retention knob validation/forwarding, tests, docs,
  start-tp4.sh, numeric-config changes.
- Keep the MiaAI-Lab#83 per-group retention and the pre-MiaAI-Lab#130 hybrid APC overlays.
  The MiaAI-Lab#130 rework measured worse on this kit's agent probe (3x30k repeats
  0.000 vs 1.000 hits; 2x60k 0.955 vs 0.999) across B4/B5 and was isolated
  from our DFlash block-drop patch by B6. Receipts:
  docs/headroom-2026-09-11.md section 12.3.
- Keep our additions: fine-grained 64-token hits (PR MiaAI-Lab#84),
  vLLM #54163 block-drop cherry-pick, adaptive-k default + auto capture
  list, spinwait 16, dual-HCA GID preflight, portable jinja2 host check
  for the new chat-template validation (linuxbrew python3 lacks jinja2),
  long-prefill boot warmup rungs.

Verification: all 12 host suites pass; B7 live re-validation on the merged
launcher reproduces B3 (1x/3x/4x 30k repeats 1.000 at 0.3-0.4s, 2x60k
0.999, 3x5k 0.992; 4-agent x 60k turns 1-3 0.886-0.928, wall 17.7-23.6s).

Merged upstream: origin/main @ 9348755 (PR MiaAI-Lab#130).
@plotarmordev plotarmordev added P1 High-impact correctness or reliability work; address next and removed triage/P1 Community triage 2026-09-09: high value, adopt after A/B or conflict resolution labels Sep 12, 2026
@plotarmordev

Copy link
Copy Markdown
Collaborator

Closing as superseded by #171, not rejecting the fine-grained cache work. Direct comparison confirms that the overlay and design document are byte-identical in both PRs. #171 carries that mechanism on the post-#130 base, avoiding this branch's stale launcher/add-add conflicts while preserving the per-group retention work.

The outstanding change requests are now explicitly recorded on #171: default off at every layer, retain the runtime compatibility check and kill switch, canonical patch-owned-region validation, remove the connector receipt and silent upstream-fixed detector, preserve meaningful host/in-image coverage, and rebase after the independent fixes land. #171 remains held; this closure is not an approval to ship its current default-on version.

Your 64-token hit receipts and warm acceptance A/B measurements remain reference evidence for the successor, with their original attribution here. The unresolved acceptance-length and qualification concerns are carried forward rather than discarded. Thank you for establishing the mechanism and measurements.

@plotarmordev plotarmordev added the reviewed Our source review or technical verdict is recorded; not merge approval or runtime qualification. label Sep 15, 2026
plotarmordev added a commit to nood-co1/GLM-5.3-Flash-EXL3-2x-DGX-Sparks that referenced this pull request Sep 15, 2026
Both tables are historical measurements of the configuration named in their own
heading, not current-main numbers. The warm-context table was recorded on a
then-unmerged overlay stack (per-group retention MiaAI-Lab#83 + fine-grained hits MiaAI-Lab#84 +
gate v2 MiaAI-Lab#80); MiaAI-Lab#83 is closed unmerged and main carries per-group retention via
merged MiaAI-Lab#130, where an empty GLM53_APC_RETENTION_INTERVAL_SWA inherits the global
interval instead of applying MiaAI-Lab#83's automatic rule.

Removes the unconditional "capacity envelope, not a bug" conclusion: the ladder
alone does not establish the budget arithmetic as the cause, and later
whole-stack comparisons (MiaAI-Lab#174) neither confirm the attribution nor isolate a
single root cause.
plotarmordev added a commit to mmizutani/GLM-5.3-Flash-EXL3-2x-DGX-Sparks that referenced this pull request Sep 15, 2026
… contrasts

Review follow-up on 81c83fc. Documentation scope only: the recorded tables,
the probes and every measured number are unchanged (B3-B7 table and the
explicit 0/0 rows verified byte-identical by hash).

- Scope note: this PR adds the document and the three probes only; the
  launcher, overlay, .env, README and warmup changes named below are
  local-checkout or separate unmerged-PR work.
- 12.3: replace "B6 isolates the cause" with whole-stack wording; the
  B3-vs-B4/B5/B6 contrast does not by itself identify the responsible
  mechanism and is not a basis for replacing the replay guard main ships
  (MiaAI-Lab#130's versioned DFlash SWA replay clamp).
- 11 / 12.1: label each component's status (PR MiaAI-Lab#83 implementation vs main's
  MiaAI-Lab#130 rework, unmerged PR MiaAI-Lab#84, local vLLM #54163 cherry-pick, local
  launcher/.env/README edits).
- 5 + TL;DR row 3: the long-prefill warmup rungs are separate, unmerged
  PR MiaAI-Lab#170, not main; main's script still has no PREFILL_S rungs.
- 4.4 / 12: present "the cliff stopped reproducing" as a whole-stack
  observation rather than a root cause.

No new run requested or performed; no gates changed; no new performance claims.
plotarmordev pushed a commit that referenced this pull request Sep 15, 2026
…ned overlay order + rank-parity test

Same launcher shape as #83/#84 (tester hardening) and pr/apc-no-store:
  - set-ness aware caller capture before .env is sourced and replay after
    (`_cli_kvcap_set="${GLM53_KV_CAPACITY_LOG+1}"`), so an explicitly empty
    export is captured and then rejected instead of replaced by .env;
    default 1 applies only when UNSET;
  - `_glm53_validate_bool_flag GLM53_KV_CAPACITY_LOG` inside the numeric
    config guard (exactly 0/1) -- runs on start|restart before `restart`
    stops anything;
  - `validate_overlay_artifacts`: every file both ranks mount must exist, be
    non-empty, carry its identity string ([glm53-kv-capacity-log] for the
    new overlay), end with its EOF sentinel and parse as Python; chat
    template + ablit layer map checked too; run on start|restart in main()
    before preflight / ssh / docker / stop;
  - KVCAP_PATCH_HOST, preflight existence check, scp to the worker, read-only
    mount on both ranks, `-e GLM53_KV_CAPACITY_LOG` in nccl_common (both
    ranks), one launcher log line naming the effective value;
  - GLM53_OVERLAY_ORDER: one ordered list emitted verbatim into both rank
    inner scripts by emit_overlay_block (the two literal per-rank ladders are
    gone); patch_kv_capacity_log.py pinned after patch_glm5_drafter_group.py
    (same kv_cache_utils.py) and the coordinator overlays, before xgrammar;
    unmounted entries stay `[ -f ]`-guarded no-ops.

tests/test_launcher_rank_parity.py (116 checks; the #83/#84 static +
dry-run launcher test with the new knob): `restart` with
GLM53_KV_CAPACITY_LOG=yes or explicitly empty, or with ANY artifact missing /
mis-pointed / empty / whitespace / unparseable / truncated, exits 2 with
zero docker or ssh calls; a valid configuration reaches `stop` on both
ranks; the order is pinned in both generated scripts (drafter-group ->
... -> kv-capacity-log -> xgrammar); head mount = scp source = worker mount
for every /opt/glm53 patch; both ranks receive identical
GLM53_KV_CAPACITY_LOG for 0 / 1 / unset (-> 1); a synthetic one-rank
mismatch is shown to be reported.
tests/test_kpool_tail_slotmap.py / test_xgrammar_termination.py: assert
their patch is an entry of GLM53_OVERLAY_ORDER fed to both rank scripts
(they counted the literal ladder before).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
plotarmordev added a commit to nood-co1/GLM-5.3-Flash-EXL3-2x-DGX-Sparks that referenced this pull request Sep 15, 2026
Keep no-store as the only new cache mechanism and remove the absent
fine-grained sibling references:

- start.sh: main's ORDER / artifact gate / guard structure kept; the no-store
  overlay is pinned after patch_apc_per_group_retention and before
  patch_xgrammar_termination; the branch's per-variable caller snapshots give
  way to main's generic caller-exports-win block (MiaAI-Lab#161/MiaAI-Lab#92), which is what now
  carries an explicit empty GLM53_APC_NO_STORE into the 0/1 guard;
  patch_apc_fine_grained_hits / FINEHIT_PATCH_HOST are gone.
- tests/test_launcher_rank_parity.py: main's generic machinery kept; the
  fine-grained scaffolding (FG / GLM53_FINEGRAINED_APC / FINEHIT map entry)
  is replaced by no-store coverage -- part F kill-switch matrix, pinned
  hybrid -> per-group -> no-store order, rank parity and pre-stop gate cases.
- tests/test_apc_no_store.py part D: the caller-precedence claim is now
  exercised behaviourally against the merged launcher (caller export beats
  .env, explicit empty is then rejected); the in-image run skips the
  launcher legs instead of failing on the absent start.sh.
- README.md / docs/DESIGN-apc-no-store.md: the partial-site description no
  longer presents the absent MiaAI-Lab#84 overlay as a co-shipped prerequisite; it
  states the upstream coordinator veto (KpoolTailManager block alignment).
- Dockerfile: main's per-group retention patch kept, no-store applied after
  it, and the in-image no-store test still runs before the overlay it
  validates.

Preserved from main: MiaAI-Lab#130 replay/retention (patch_hybrid_prefix_hit +
patch_apc_per_group_retention) and the generic caller precedence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes-requested maintainer requested changes; see latest maintainer comment P1 High-impact correctness or reliability work; address next reviewed Our source review or technical verdict is recorded; not merge approval or runtime qualification.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants