Repository navigation
gpu, model, gpu-gates: keep host tier reads protected through copies and page drops - #746
Conversation
Protect every resident id in a claim and count heat selections at their original column positions.
There was a problem hiding this comment.
Verdict: CLEAN: The two supported findings are non-blocking; no must-fix item remains.
Non-blocking
⚠ Measure the added synchronization: nvtier.rs:2412 adds one shared drop-queue lock per non-host expert read. While that layer has a pending drop, each read also allocates the marks, ranges and output vectors, plus any nonempty run vectors. xstream.rs:1438 adds one host drain per streamed expert on the fallback path.
These terms affect decode and prefill overlap. Attach the owning gate results and the same-lease base/head A/B required for dispatch changes. Measuring now isolates these costs before later changes obscure them.
⚠ Assert the CPU heat clock: deleting columns = 0 at tier_cpu.rs:90 advances the clock once per served slot. The CPU-tier fixture selects Tick at tier_cpu/tests.rs:262, so its output assertions do not detect that mutant.
Exercise Heat and assert routing counts after a column with two served slots and an all-HOST column. This protects the new counting rule before another callback change can regress it.
Checked
Evidence: compared the cited synchronization changes against the base and traced pending-drop planning through layer_marks and runs_of.
Silent failure: range-planning, source/enqueue, drain and read-release errors propagate. A failed fallback drain retains the source and its open read.
Tests: inspected the CPU fixture's policy, selections and assertions. The heat-clock coverage gap remains advisory under the fix-PR recurrence-prevention rule.
Escape catalog: C1–C4 do not match these findings. No ledger lessons are in force.
Notes
Validation was static; project tests were not run. The supplied GPU logs omit the tested base/head commit hashes and a timed base/head A/B.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_deepseek41_step.rs, crates/gpu-gates/src/bin/gate_hybrid.rs, crates/gpu-gates/src/bin/gate_nvtier.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)
|
The review is done and the contribution check passed, so I'm merging this. |
호스트 expert 계층에서 복사 원본이 너무 일찍 풀리거나, 같은 요청의 다음 hit이 밀려나거나, prompt 분할이나 card와 host 분할 방식에 따라 heat 순위가 뒤집히는 결함 네 개를 고칩니다.
Part of #565. Tracked in #699.
What and why
This fixes four defects in the host expert tier (
XStream,NvTierand theTierSlotsheat counts). Each one has a test that was written first and shown to fail without its fix.XStreamfalls back to a copy from an unpinned source, it released the source read before the copy stream finished. A reused slot could then change the bytes the copy was still reading. The fallback now keeps the read until the stream drains, on the normal path and on the path where only some copies were enqueued. If the drain itself returns an error, the source and its read stay held, so a copy in flight never reads memory that was already handed back.drop_layerfollows the same rule.tickpolicy, a miss early in a claim could evict a resident expert that a later column of the same claim needed, and that expert was then read again. Every claim kind and eviction policy now protects the claim's resident ids from its own misses.BLOOMERY_NVTIER_EVICT=heatcounted a whole union at one moment, so the same routing history split into different calls ranked experts differently. Heat now takes each selection's original column position and decays from there, and a call whose columns route no host expert still advances the clock. A routed column advances the clock once even when the card and host legs serve it separately: a host tail reuses the column its card ticket already counted, and on the CPU tier only the first per-slot call for a column counts it. A CPU-tier column whose slots all go to the host makes its empty claim only on a layer the NVMe tier covers, so a layer kept resident in RAM never asks the tier for an arena it does not have. Prompt and multi-column step claims share this throughTierSlots, andgate_nvtierexpects the same per-position decay.The default tick order of routed ids, the weight bytes and the output arithmetic are unchanged. The heat option is still opt-in; only the order in which it evicts changes, so one routing history gives one ranking however it is split. Nothing depends on the rank count, and no model file gained a branch.
Release notes: Fixed: the host expert tier keeps a copy's source read until the copy lands, no longer drops pages under a newer read, keeps a claim's later hits resident, and ranks heat the same however a prompt is split.
Code shape
XStream,NvTier,TierSlotsandLayerCounts. The only new helper isLayerCounts::add_columns, which both the prompt and the step path call.moe.rschanges only how it hands columns to the sharedTierSlotsowner. No model file gained a branch, flag or trait method for one model.drop_markedandexperts_into_residentwrappers are removed, and so is the drop queue'srunningflag, which no reader outside its mutex could observe. EveryTierSlotsimplementation and caller, includinggate_nvtier, follows the new signature.PIN(...)comment, and the new test-only pinned source view carries aSAFETYnote and itstools/unsafe-ratchet.txtpin.cargo fmtis clean on what I touched.cargo clippyhas not been run on this head, so the lint count is unchecked.Duplication found or removed (
path:line): none. The duplicate scan flagged a test-localLAYERconstant, which is not a copy of a shared routine.What I ran
Fail-first, then the fix, for each defect. The test names are in
crates/gpu/src/host/nvtier.rsandcrates/gpu/src/host/xstream.rs.Tier claim, queued drop and heat ranking, on a Linux host with the fix removed (only the new tests fail):
With the fix, the same host:
These are the
host::nvtier,host::xstreamandmoe::tests. The ignored tests need a CUDA device and are not counted here.These runs were on an earlier head of this branch. The card and host legs were then made to count a column once. Its test,
a_card_claim_and_its_host_tail_count_one_column, run against the code before that change on an x86-64 Linux host, fails on the heat value:With the change, that test, the four
heat_counts_keep_the_same_rank_across_*tests (prompt splits, step splits, resident columns, card and host legs) andan_active_dropper_finishes_before_a_new_read_openspass:On a two-slot fixture holding experts [2, 7], a claim for [1, 2] misses twice on main and once with the fix, because the hit on 2 is no longer evicted by the first miss. That is one fewer refill in this fixture and says nothing about throughput or latency.
The CPU tier's empty claim, on the GPU below.
hw_held_node_nvme_host_run_keeps_eager_and_captured_rowskeeps layer 1 resident and pages layer 0, then sends all-host columns on both layers through the CUDA host callback, eagerly and under graph replay, for F32 and Q8 activations. Without the coverage check the callback fails on the resident layer:With the check, the output stays at its expected value on both layers and later normal service on the same executor passes:
Fallback copy source, on the GPU below. The test
hw_held_a_fallback_copy_keeps_its_source_until_it_landsoverwrites a pinned source slot while the fallback copy is in flight and checks the destination bytes. Without the fix the destination holds the overwrite:With the fix, covering the normal copy and the partial enqueue error:
The GPU run was done before a later rebase. The final head's
xstream.rsis the same blob those runs tested, so I did not rerun it.Compile check of everything on this head, including integration tests, benches and gate binaries, on an RTX 5090 machine with the full feature list of the upstream check recipe:
cargo fmtwas run on the changed Rust files andgit diff --checkis clean.cargo clippyandjust contrib-checkhave not been run on this head.GPU Evidence
The card is a DGX Spark GB10, driver 595.84, CUDA 13.3. These lines are from
nvidia-smibefore the fail-first run and the fixed run:Commands:
The result lines are in the section above.
just gate-gpu-libnot run: the ignored GPU test went throughtools/gate.shon the card instead.The change adds no kernel and touches no arithmetic, so I added no PTX comparison. Whether the page-drop and heat changes move decode speed was not measured in this PR.
What I ran into
This does not block the PR.
gate_nvtierclauses for the changed heat expectations were not run on a GPU for this head. Host unit tests and the all-targets compile cover them.Hardware
A DGX Spark (GB10, driver 595.84, CUDA 13.3) for the GPU fail-first and fix runs, x86-64 Linux hosts for the tier tests, and an RTX 5090 machine for the all-targets compile check.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.