Skip to content

ctxfloor R3: a sequence past Qwen3.8's KV floor takes card bytes from the experts (release_tail, StackRoom, the fit's retry) - #1186

Merged
midagedev merged 2 commits into
mainfrom
ctxfloor
Nov 8, 2026
Merged

midagedev merged 2 commits into
mainfrom
ctxfloor

Conversation

@midagedev

Copy link
Copy Markdown
Owner

Qwen3.8 KV가 floor를 넘어 자라면 residency가 각 층의 꼬리 slot을 회수해 카드 페이지를 돌려주고 fit을 다시 시도; 전문가 스택은 VMM room.

What and why

The third step toward a context that grows on demand. When Qwen3.8's KV store grows past the plan's floor and the card has no page left, the residency machine now frees card bytes. It demotes the coldest experts of every layer and packs the live slots low (SwapMachine::release_tail). The top slots become Withdrawn. A residency load from the file builds each layer's routed expert stacks as VMM rooms (StackRoom), so the pages wholly past the withdrawn slots go back to the driver. Room::fit's NoRoom then retries once. restore_tail gives the slots back; the engine does not call it yet.

Release notes: Changed — Qwen3.8 with BLOOMERY_KV_FLOOR and BLOOMERY_RESIDENCY: a sequence past the floor takes card bytes from the experts instead of stopping at the room's refusal.

Code shape

  • No second copy. The release, the pack and the withdrawn state live in the common machine (crates/gpu/src/host/swap.rs) behind SwapSource; the room code is room.rs's.
  • Model code holds only architecture facts. Qwen3.8's part is the fit's retry in body38.rs (its stores are the rooms).
  • Dead code is gone.
  • No silent failure. A release past the floor, with a call open or a flip in flight, is refused by name; a fit the machine cannot cover ends in NoRoom naming what the machine freed.
  • Comments state what is true now.
  • No relaxed gate. The stack-room test reads the device's free bytes, so it runs alone (hw_held_).
  • fmt and clippy are clean (just remote-static origin/main: ok).

Duplication found or removed: none.

What I ran

  • Narrowed just affected (tools/narrow-scan.sh origin/main: ptx-scan identical for every bin), fixture tier on the box: DONE total=181 red=0 tier=fixture skipped=0 wall=2186s deferred=247
  • Real tier, the gates the fixture tier defers that this change reaches: gate-placement, gate-q38-serve-rules, gate-gpu-gates-lib: DONE total=3 red=0 tier=real
  • gate-gpu-qwen38-residency (real only) on the byte-equal /models copy of the profile's file (BLOOMERY_REF_MODEL=/models/Qwen3.8-Flash-Next/…): gate_qwen38_residency: every clause passed; kvfloor: with no page left, the machine withdrew Some(1) slots a layer over 48 layers, 190840832 B in the reports against 190840832 B derived true, after the restore every layer's withdrawn count is 0 true, the rooms' released bytes 0: PASS, the third run bit for bit the first. The recipe as written opens the /data/moved copy on the HDD, where one load takes 594–874 s, so it cannot finish in its 900 s bound; that is the file's location, not this change.
  • gate-gpu-swap: tail pages release_tail(2) freed 6291456 B … the device's free bytes 50630492160 -> 50636783616 true.
  • FAIL-first, each red on the box: r3b-room-release-nothing (gate-gpu-lib, the stack-room test), r3b-machine-release-skipped, r3b-restore-stacks-skipped, r3a-withdrawn-spare, r3a-restore-noop, r3a-pack-skip, r3a-pinned-victim (gate-gpu-swap), r3b-fileswap-release-noop, r3b-fit-retry-removed, r3b-load-no-rooms, r3b-restore-stacks-skipped (gate-gpu-qwen38-residency, the kvfloor clause).
  • just remote-static origin/main: rc 0.

Hardware

Box: RTX A6000 + RTX 3090 (250 W cap).

🤖 Generated with Claude Code

https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A

midagedev and others added 2 commits November 9, 2026 03:36
…live slots low, so its top k slots are Withdrawn (never filled until restore_tail); the boundary report counts them

The slot half of demote-for-bytes. Qwen3.8's per-part slot is smaller than a page and not a multiple of one, so a heat-ordered
victim set alone frees no page; packing the survivors below k leaves the stack's tail whole for the next round to unmap.
gate_swap's tail clauses (pack, withdrawn, floors, restore), each red under its .mutants/r3a-* patch; the rule's coldest/take/give.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A
…StackRoom), a released tail gives its pages back, and Qwen3.8's store fit past the card's free bytes asks the machine to free them and fits once more

- room: StackRoom, a stack reserved whole and backed at load; release_from gives back the pages wholly past a slot,
  restore backs them again zeroed; hw_held_ test (device-wide free bytes, run alone).
- weights/model: a Mid residency load from the file builds each card's stacks as rooms.
- swap: SwapSource release/restore with defaults, free_bytes(n) withdraws the same top slots of every layer (the
  fewest covering n, within the floor), Released.freed_bytes, PassReport.withdrawn_bytes; Withdrawal bundles the
  release's rule outcome; R3a fixes (write_changed borrow, record part order).
- body38: fit_stores on NoRoom asks free_bytes(asked - free + page) and fits once more; NoRoom carries asked/free/page.
- gates: gate_swap tail_pages clause; gate_qwen38_residency kvfloor clause (squeeze stops at a page the card refuses).
- mutants: r3b-* (6) and the r3a ones regenerated against this tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A
@midagedev
midagedev merged commit 004a23b into main Nov 8, 2026
4 checks passed
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset labels Nov 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: the release, the pack and the restore are one owner in the common machine, every failure path I could reach ends in a named refusal, and the new clauses carry their mutants.

Non-blocking

⚠ A Vec per layer per boundary: the report sums released_bytes over the machine's layers at every boundary (swap.rs:2727), and FileSwap's answer builds a fresh Vec through rooms_of per layer (swap_source.rs:1306, 1071). Term: ~48 allocations per boundary ≈ 2–5 µs on a ~4.7 ms decode step, ~0.1 %, under the ±1 % ruler. Direction: a running total beside the rooms (their counters are already atomic) or an iterator that does not collect.

⚠ The restore half has no engine caller: swap_restore_tail is called only by the gates, so in production every kvfloor release shrinks all layers' card capacity for the rest of the load (the floor of pinned + 1 live bounds it). The body says the engine does not call it yet; name the round that wires it.

⚠ also 2 minor: StackRoom::restore_from is pub with one in-crate test caller (R13); the kvfloor squeeze swallows non-OOM errors while chunk > page (gate-side; the page-sized attempt names them).

Checked

Duplicates: 12 new items checked, none duplicated — coldest reuses keep_best/vict_before (the Live half of plan's loop, doc-linked); StackRoom reuses Room/Roomed; asks, zero_on, upload_rows are layered on their owners. Dryer did not run.
Complexity: crapper did not run; by eye withdraw, tail_checked and tail_pages grow by refusal arms and asserts — even growth, no split asked.
Silent failure: 7 default sites followed to their consumers (the four SwapSource 0-defaults, SlotLedger::withdrawn's out-of-ledger 0, the gate's unwrap_or(0)/usize::MAX) — all documented or gate-side; the k-search's row - withdrawn - k cannot underflow (k ≤ live − pinned − 1).
Tests: every new test names its mutant and the committed .mutants/ patches name the clause that turns red; r3b-room-release-nothing trips the freed-bytes, backed, released() and free-growth asserts; r3a-pinned-victim turns coldest(0,2) into [0,3].
Gates: no pin moved; the new hw_held_ test is #[ignore]d with its alone-reason; the record kind grew two opt parts, schema regenerated.
Escape catalog: no shell in the diff; none matched.

Notes

Dryer and crapper did not run (ModuleNotFoundError; diagnostics.md). The body's card evidence lacks the nvidia-smi line and both commit hashes, so gpu.json records false. The kvfloor gate ran on a byte-equal /models copy because the recipe's /data/moved copy cannot load inside its 900 s bound (stated in the body).

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen38_residency.rs, crates/gpu-gates/src/bin/gate_swap.rs, crates/gpu-gates/src/record.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added the needs-gpu Changes code a card must check, and carries no gate run on a card label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant