LEDGER P1 in-boot correction; arm switch validated; resident host + DRAM-persist tooling #146

Merged
Grok merged 13 commits from serving-throughput into master 2026-10-02 17:39:01 +02:00
Owner

This PR corrects the master LEDGER P1 headline: measured in one boot it is -0.92% at B8/32k, not the -2.41% from fresh boots, which included ~0.75% boot-to-boot variance. The PP gain holds.

It also records three validations:

  • The arm switch: switched vs unswitched within 0.21%, the must-fail switch REFUSED, equiv NEAR_TIE after a switch.
  • --b-cells against per-B boots: the gap is MTP acceptance, not op cost.
  • The resident host and the DRAM-persistence research, merged as tooling (hardware validation is queued).

🤖 Generated with Claude Code

This PR corrects the master LEDGER P1 headline: measured in one boot it is -0.92% at B8/32k, not the -2.41% from fresh boots, which included ~0.75% boot-to-boot variance. The PP gain holds. It also records three validations: - The arm switch: switched vs unswitched within 0.21%, the must-fail switch REFUSED, equiv NEAR_TIE after a switch. - `--b-cells` against per-B boots: the gap is MTP acceptance, not op cost. - The resident host and the DRAM-persistence research, merged as tooling (hardware validation is queued). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Grok added 13 commits 2026-10-02 17:39:00 +02:00
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Before: B=4/B=1 cells were measured on max_num_seqs=B boots, assumed equivalent to B
concurrent requests on the production B=8 server. On one B=8 boot, B1/4k TG is -8.9%
and B4/4k +5.0% vs per-B boots: different decode configs. b-cells is the
production-faithful measurement and 3x fewer boots.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
We believed weights could not outlive a tt-metal process because "a new open resets the allocator"
(RESEARCH-KERNEL-WORKBENCH 2.4). Reading the served pk3r tree says the allocator reset is host
bookkeeping only: nothing on the default path writes the DRAM allocator range at open or close, and
MeshBuffer::create(..., address) already builds an externally-owned buffer (ttnn's own reshape view
uses it). What was missing to attach to bytes a previous process left behind is a Python way to wrap
an address in a ttnn.Tensor. This binds exactly that, with range/alignment checks and a once-per-process
banner (TTNN_TENSOR_AT_ADDRESS engaged). Host-only, in _ttnn.so; no kernel, no program hash.

Built incrementally in its own tree (nixos pk3r-dp, a copy of pk3r) so the shared pk3r tree and its
uncommitted 0036 were left alone: 2 compiles, 35 s ninja; packaged with STRING_OK and the import smoke
in vllm-tt:k2-mr-pk3r. Not shipped to cfx-llm2 (the probe ships it).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner wants weights loaded once (113 s today, 1044 cache files) and then iterate forever. Source says
the host side allows it (no DRAM scrub unless TT_METAL_CLEAR_DRAM, deterministic first-fit allocator,
trace region at the top so bottom-up addresses ignore its size), and ttsim confirms the host half:
two processes replay to identical addresses incl. a refilled hole and DRAM width-sharded tensors, and
0039 views read back bitwise with a must-fail one page off (SIM_GATE PASS). What source cannot settle
is the hardware: UMD's ~LocalChip and the KMD's last-close re-aggregation power the GDDR PHY down on
every close, and no public firmware doc says whether the contents survive that. So the probe measures
it on card 1: write 12 GiB of G2-shaped tensors, close cleanly, then replay/view from new processes,
a new container, a keeper round that holds the PHY awake, and a deliberate tt-smi -r under our own slot
(expected lost). Not run; record on every exit path; hang -> graceful stop + slot reset + settle.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Before: `ttx ab --control` could switch runtime- and rebinder-class flags in place, and
everything else (a forward Python edit, a kernel edit, a draft-vocab variant, a smaller
max_num_seqs) cost a full boot (~300 s, 45% of queue time). We also believed
ClearKernelCache was enough for an in-process kernel edit; c85b showed it is not:
llrt::get_risc_binary caches ELF images per process, keyed by path, so the device keeps
running the old image.

Now, behind TTX_RESIDENT=1 (dev mode + the armswitch tree, never production):
- resident.py adds ttx_reload (forward-path module reload + live class swap, refused with
  needs=rebuild for loader / module-level edits), ttx_kernels_reload (release, program
  cache, ClearKernelCache, ELF eviction, re-warm; refused without patch 0036),
  ttx_variant (QWEN36_MTP_DRAFT_VOCAB heads built at boot, flipped by pointer),
  ttx_rebuild (model re-created with weights from an as_tensor registry) and
  ttx_reconfig (max_num_seqs / max_model_len / KV down from the boot: model rebuild at the
  new sizes, the engine's own _initialize_kv_caches, a new Scheduler). Every change logs
  the arm_switch contract, so ttx identifies it the same way.
- Reloads compile from source into an empty pycache prefix: a same-size edit within one
  second otherwise reloads the OLD bytecode (found by the fake-host test).
- patch 0036 (llrt.cpp only) moves the ELF cache into a struct and exports
  tt_stack_evict_risc_binaries / _entries / _evicted; built incrementally on nixos
  (1 TU + relink), import smoke STRING_OK. Manifest pk3r+0033+0034+0035+0036.json.
- arm_switch.py: rewarm / finish / failed factored out for resident.py.
- warm_codediff.rebind_objects / tree_hash (shared with warm_server), mounted in the
  container as vllm_tt_plugin/ttx_codediff.py.
- lib/resident_lease.py: the box-side lease (flock), per-run use lock with dead-holder
  reclaim.
- switchclass.resident_class: switch | variant | rebuild | reconfig | reboot per flag, with
  file:line for every flag that stays reboot.

Nothing here has run on hardware; bench/queues/resident-validate.txt is the gate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Before: every queue step booted its own server, and an A/B that was not a pure flag switch
reloaded 27B of weights per arm. Nothing let a second agent use a server another agent
had already loaded.

Now `ttx resident up <arm>` boots one long-lived mesh process (dev mode, the 0036 store,
optional --variant / --kernels-live) and writes a lease on the box. `ttx resident run`
plans the change from what the lease says is served (planner: kernels -> reload|rebuild
-> reconfig -> variant, flags on one carrier step; reboot for a weight set, a .so, a new
overlay file, plugin/vLLM Python, RESIDENT_REBOOT flags or sizes above the boot), syncs the
live overlay in place, runs each step over /collective_rpc, proves identity over the whole
change segment (carried banners from the last model build, parked variant builds
excluded), then measures on the same process. Records carry boot_id, switched_from,
switch_kind, switch_s and a resident block. Each --seqs B is a reconfig.

Fail closed: a refused step never reaches a measurement; a poisoned change writes REFUSED /
FAILED records, downs the host and re-ups it on the last good arm; a dead host falls back
to an ordinary fresh boot marked resident.fallback; --expect refused makes a must-fail step
pass only when it is refused (a must-fail that passes is not measured).

Also: switch.identify_switch(seg_from=), arm [overlay] store_exclude, ttx run --stem (and
suites.run now passes stem to sweep32k, which it silently dropped), queue timeout class
"ttx resident", tools/ttx/resident-mustfail.py (probe / must-fail sources, anchors checked),
tools/ttx/resident-verdict.py (floors TG 0.1%, makespan 0.5%, TTFT@32k 1%, equiv
BIT_EXACT), tests/test_resident.py (39 fake-host tests), DEV-LOOP 2f, tt-box-coordination
section 5 (queue onto the host, never preempt it).

bench/queues/resident-validate.txt is written and NOT run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
STATUS c160c + LEDGER: arm switch validated; P1 re-measured in one boot at B8/32k -0.92%
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Successful in 13s
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 20s
tt-stack-ci / Build simulators and check the host module (push) Failing after 6s
tt-stack-ci / Report upstream drift (push) Successful in 7s
624431cec0
Before: A/B bands came from separate boots, assumed comparable within the 0.5% floor.
Three fresh cm-so1 boots spread 0.75% at B8/32k, while a switched vs unswitched control
in one boot differ by 0.21%. The P1 headline (-2.41%) shrinks to -0.92% in one boot;
the PP gain (+2.6-3.1%) holds. One-boot ttx ab is now the default A/B.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Grok merged commit 624431cec0 into master 2026-10-02 17:39:01 +02:00
Author
Owner

agent-gateway closeout (merged): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (merged): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!146
No description provided.