Repository navigation
levers, gpu, model, gpu-gates: BLOOMERY_NVTIER_EVICT=heat takes the NVMe arena's coldest routing count (tierengine S6) - #650
Merged
Conversation
…VMe arena's coldest routing count (tierengine S6) Once no slot is free, a miss of the NVMe tier's arena took the least recently used hot slot (after the transients). BLOOMERY_NVTIER_EVICT=heat ranks the hot slots by a decayed routing count instead, the least recently used among equal counts; tick, the unset word, is the rule as it stands. The tier's books own the counts (RouteCounts): per paged layer and expert, the columns that routed it, halved every 32 columns the layer serves. A step's claim counts each id it names once and moves the layer's clock one column; a prompt's union call counts each id by its columns (TierSlots::note_union now carries the call's columns) and moves the clock by them; a residency victim's fill counts one column and moves no clock. Counts are held as scores scaled by the clock, so a pick compares them with no decay. Under heat a call's own ids are never its victims. The card's residency rule keeps its own counts: they are a stream's kept decode rows, blended across streams and decayed at its plans, where the arena's take every column it serves, a prompt's included. swaprule.rs and tierengine's S6 row say so; docs/serving.md names the lever. gate_nvtier's clause 14 (evict) drives two floor-arena tiers, one each rule, through the same claims and reads which slot each miss took.
Contributor
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix behavior or quality defect found.
Checked
- Duplicates: 25 new definitions checked, including local constants. The one dryer pair maps different levers, so it shares structure only. SwapRule counts kept decode rows per stream; arena counts cover different inputs and clocks.
- Complexity:
evict_clauseis a new gate with sequential setup, claims and assertions (29). Existing-function growth:stepunion_arm42→48 adds a count check;run150→152 adds clauses;of_paged34→36 initializes heat;claim_fill23→24 protects own ids;read46→47 extends scope membership. - Silent failure: 5 optional-count and filtering sites followed to victim selection, statistics and assertions. No Result becomes a default. Poison recovery retains the books.
- Tests, static mutation review: selector assertions reject removing the score comparison at crates/gpu/src/host/nvtier.rs:448. Own-hit eviction assertions reject removing heat's own-id protection at crates/gpu/src/host/nvtier.rs:644.
- Tests, counts: both prefetch-path assertions reject advancing one column instead of four at crates/gpu/src/host/nvtier.rs:1787. Routing-count assertions reject counting duplicate ids twice, advancing the victim clock, or dropping rescaling at crates/gpu/src/host/nvtier.rs:1833.
- Tests, model: prompt-note assertions reject replacing the column count with one at crates/model/src/moe.rs:1790. Step-union assertions reject dropping the full ids or offsets at crates/model/src/moe.rs:3240; updated overlap and refusal tests retain pin-lifetime assertions.
- Tests, levers: accessor and scope assertions reject mapping heat to Tick at crates/levers/src/lib.rs:1151. The dedicated test also rejects changing the unset default or accepting unknown words.
- Gates: no existing pin, tolerance or clause relaxed. The PR supplies fail-first output for tick-only heat eviction and one-column step-union counting.
- Performance: heat adds count updates, miss scans and one books lock per prompt union/layer. Storage is preallocated; no device launch, copy or wait is added. The PR supplies a timed main/tick/heat comparison on RTX 5090.
- Escape catalog: C1–C4 do not match.
Notes
Review was static; tests were not rerun here. The supplied card runs preceded the rebase. The PR states that clippy and contrib-check were not run on this head.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_nvtier.rs, crates/gpu-gates/src/bin/shared/gate_card.rs, crates/gpu/src/host/nvtier.rs … and carries a gate run on the author's card, which counts as verified.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Collaborator
Author
|
The review is done and the contribution check passed, so I'm merging this. |
58 tasks done
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.
NVMe expert 계층이 slot을 비울 때 쓰는 규칙을 옵션
BLOOMERY_NVTIER_EVICT=tick|heat로 고르게 합니다. 기본값은 기존과 같은tick이고,heat는 RTX 5090에서 decode 중 NVMe 읽기를 줄입니다.Part of #565.
What and why
This adds the option
BLOOMERY_NVTIER_EVICT=tick|heat. It picks which slot the NVMe expert tier evicts when it has to read a missing expert from NVMe. Unset meanstick, the current rule: the slot with the oldest last-use tick goes first. Withtickthe tier behaves as on main, down to its counters.heatevicts the slot whose expert has the lowest decayed routing count. The default staystick; turningheaton is the maintainers' call.On the plan I measured,
heatcuts the decode NVMe fills per token by 6.58 % and leaves the output unchanged. The numbers are under "What I ran". The change has three commits: the option, the gate plan that opens the RTX 5090 by name, and a lazy tie-break in theheatcomparator.Background: when routed experts do not fit on the card or in host memory, the NVMe tier keeps them on NVMe and reads the ones a step needs into a fixed arena of pinned host slots. A read that finds no free slot evicts a victim.
heatchanges only the choice of victim.crates/levers/src/registry.rs,crates/levers/src/lib.rs): the rowBLOOMERY_NVTIER_EVICTtakes the wordstickandheat, and unset reads astick. Any other word is refused by name.NvTierLevers.evictcarries the choice toNvTier::of_paged(crates/gpu/src/model.rs).crates/gpu/src/host/nvtier.rs):RouteCountsholds one score per layer and expert, sized at load, so a decode step allocates nothing. Undertickthe table does not exist. A score grows by2^(since/H)per counted column with H, the half-life, set to 32 columns (HEAT_HALF_LIFE), and is rescaled once per 64 half-lives. Comparing two scores therefore needs no decay arithmetic.TierSlots::note_unionincrates/model/src/moe.rs, which now takes the column count) counts each id once per column and moves the clock by that many. A victim read counts one column and leaves the clock alone. The counting sits inside the books lock the claim already holds.heat(pick_slot): a free slot first, then an unpinned transient slot, then the lowest score, with the last-use tick breaking ties. The comparator reads the tie-break keys only when the earlier keys tie, and the order is the same as when it read them all. A call never evicts an id it is itself reading.tickkeeps main's(tick, seq)order.crates/gpu-gates/src/bin/gate_nvtier.rs): the new clauseevictchecks the victim order fortickand forheat, and thestepunionclause checks the counts of a four-column step union. The trait thatcrates/model/tests/alloc.rsimplements gained the column arguments, so that test file follows the new signature.docs/serving.mddescribes the option.docs/research/tierengine.mdrecords the S6 row, andcrates/runtime/src/swaprule.rsgets one doc line. SwapRule keeps its own counts, because it counts only decode rows, blends streams, decays on its own schedule and plans card slots. The arena's counts also cover prompt columns and decay by layer clock, so the two do not share one owner.Release notes: Added:
BLOOMERY_NVTIER_EVICT=heatmakes the NVMe expert tier evict the expert with the lowest decayed routing count, which lowers NVMe fills per decoded token on an RTX 5090. The defaulttickis unchanged.Code shape
Books.countsinnvtier.rs, read throughNvTier::route_count. The gate reads that count and does not recompute it. SwapRule's decayed counts differ in input, schedule and scope, as described above, so they are not a copy.eight_tierholds the bodycard_tierhad.cargo fmt --allpasses.cargo clippyhas not been run on this head, so the lint count is unchecked.Duplication found or removed (
path:line): none. The duplicate scan reported no candidates.What I ran
The PR head is
4ede92943ec3c0ec2aa58e16f840f56c4dc273eb, three commits on mainf02460d1604567d123a9210ffa8f33485cfceca2: the option, the gate plan and the lazy comparator. The A/B, the gates, the PTX comparison and thenvtiertests below ran on the same three commits on main6b0a82f91818bd1213b79a3e1d3ac59a1fb9c7a0. The rebase ontof02460d16touches none of their files.Fail-first for the step union fix: with the two count calls set back to one column, the new unit test fails on the reused step slot (
allocating=false: column clock) and on the allocating fallback (allocating=true: column clock), the model test of the step claim fails (the step claim carries each id's routed columns, including host ids), and the gate clausestepunion counts Heatfails. With the code restored, the unit tests and the gate pass.Unit tests:
These are the
nvtiertests inbloomery-gpu, themoe::tests inbloomery-modeland thebloomery-leverstests. The four ignored tests need a CUDA device.A/B against main, on an RTX 5090 machine. The plan is S12:
--place a BLOOMERY_CARD_BUDGET=12G BLOOMERY_HOST_ROOM=28G. Each arm runsgenerate_qwen3moe --tokens <ids> -n 1024 --ctx 3072 --time --logits --place aon the same fixed 512-token prompt (ids below) withBLOOMERY_DRAFT=off BLOOMERY_RESIDENCY=off, so it decodes 1,024 tokens after a 512 token prompt. The model isQwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguffrom unsloth/Qwen3.8-Flash-Next-GGUF (revision766911a6), with one slot and a context of 3072.mainis a build of upstream main,tickis this branch with the option unset, andheatis the same binary withBLOOMERY_NVTIER_EVICT=heat. The three arms ran three times each, in rotating order after one discarded warm-up, and the table shows medians. The run started after the host's load stayed quiet for 30 s.All nine measured S12 runs have identical generated tokens and reported logits digests. Heat reduces decode NVMe fills by 6.58% against main (17.428 to 16.281 fills/step) [derived].
mainandtick, 16,655 forheatin every run) by 1,023 decode steps.tickmatchesmainin its counters, sotickis main's behavior.heatis +0.730 % faster thantick(95 % interval +0.220 % to +1.240 %) and +0.618 % faster thanmain(+0.180 % to +1.056 %).tickagainstmainis -0.111 % (-0.639 % to +0.418 %).The 512 prompt ids
cargo fmt --allpasses.cargo clippy,just contrib-checkand the pre-push check set have not been run on this head.GPU Evidence
The card is an RTX 5090, driver 595.99.02, CUDA 13.2. These lines are from
nvidia-smion the machine that ran the tests and the gates:just gate-gpu-nvtierpasses with the option unset and withBLOOMERY_NVTIER_EVICT=heat. Theevictclause checks both victim orders, and the step union clause is green:The PTX against main is unchanged (
just canon-check):With the two count calls set back to one column, the step union clause fails, and so does the gate:
Two more fail-first checks ran on an earlier tree that has the same victim order and gate plan. Without the second commit the gate plan did not open this card, so
just gate-gpu-nvtierrefused it and exited with code 1:With the count comparison removed from the
heatvictim order,BLOOMERY_NVTIER_EVICT=heat just gate-gpu-nvtierfails on theevict Heatclause:The change adds no kernel and no launch, copy or synchronize on the decode path. The new work is an addition into a table sized at load, inside a lock the claim already holds, so the timed A/B above is the performance evidence.
What I ran into
This does not block the PR.
hw_a_allocation tests inbloomery-modelran together,hw_a_one_column_miss_allocates_nothingfailed with one allocator call. The tests count allocations process-wide, so a parallel test can add a call. The same test passes alone (test result: ok. 1 passed; 0 failed).cargo clippyandjust contrib-checkhave not been run on this head.Hardware
An RTX 5090 machine (Ryzen 9 9950X, 121 GiB RAM, Samsung 9100 PRO), driver 595.99.02, CUDA 13.2, for the unit tests, the gate and the A/B.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.