Repository navigation
engram: coalesce row advice into distinct page runs - #661
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect is established in the changed code.
Non-blocking
⚠ Complete the timing evidence: crates/engram/src/lib.rs:641 adds three temporary vectors per valid nonempty page_runs call on the PLE advice path [derived]: sorted IDs, row runs and page spans. The GB10 timing tables omit the server and Nsight commands and their output. Add those commands and a steady-decode base/head comparison to measure the allocation cost against fewer syscalls.
Checked
Duplicates: page coalescing reuses adjacent_runs; dryer reported 0 candidate pairs. Complexity: crapper flagged no function.
Silent failure: invalid rows, allocation failures and advice failures return errors; the helper sends failures back to its caller.
Tests, source-based mutation analysis:
- crates/engram/src/lib.rs:646: disable merging; the new page-run assertions fail.
- crates/engram/src/rows.rs:446: remove sorting; the added group assertion fails.
- crates/gpu/src/checkpoint.rs:163: restore lazy allocation; the added slot-count assertion fails.
- crates/gpu/src/checkpoint.rs:278: remove the restorable check; the changed restore test's expected error fails.
- crates/gpu/src/checkpoint.rs:413: accept an incomplete copy; the changed open/seal test's expected error fails.
Gates: no bands, pins or test clauses relaxed. The PR reports FAIL-first for the three new contract checks.
Adversarial checks: empty and invalid IDs, disjoint page ranges, repeated cross-file rows, and cleared or unfilled slots are covered by the existing guards.
Escape catalog: no pattern matches.
Notes
Rust/CUDA tests were not rerun during validation.
GPU evidence is incomplete: the PR explicitly omits just gate-gpu-lib and provides no executed just gate-* command with output.
Card check: needs-gpu. This pull request changes crates/gpu/src/checkpoint.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)
Filed outside this PR: #662
|
The review is done and the contribution check passed, so I'm merging this. |
Qwen3.8 서버의 첫 요청에서 체크포인트 슬롯 할당을 없애고, per-layer embedding 행 힌트를 서로 다른 페이지 묶음으로 합쳐 호스트 대기를 줄입니다.
Part of #565.
What and why
Two host-side gaps sit in the prompt path of the Qwen3.8 server on GB10.
Checkpoints::sequencenow pins every slot its existing sequence budget allows when it is built, andtake,open_takeandadoptreuse those slots. The separate allocation code inadoptis gone. The refusal of an unfilled slot, the copy-completion rule and the save guards stay as they were.TableBytes::page_runsnow reusesadjacent_runs, merges overlapping or adjacent pages, and both advice and populate use it. No page between two disjoint ranges is added.RunTable::eachgroups an order-independent operation by source run, repeated ids still count repeatedly, andcopy_rowskeeps the request order.No model, kernel, scheduler, precision, gate band or runtime flag changes.
On one GB10, the first request after a load had 73 pinned allocations (38.479 ms) before this change and none after it, and the PLE wait on three consecutive prompts fell from 94.630, 134.872 and 163.012 ms to 81.792, 59.164 and 59.425 ms (tables below). The checkpoint change moves that cost to load: the body phase of the load grew from 0.11 s to 0.39 s.
Release notes: Changed: on GB10, the Qwen3.8 server pins its checkpoint slots at load instead of during the first request, and groups PLE row advice by page, which cuts the host waits in the prompt path.
Code shape
TableBytes::page_runsreusesadjacent_runs, and one owner serves advice and populate. The duplicate slot allocation inadoptis removed.make_slotand the lazy-allocation branches intake,open_takeandadoptare removed.Checkpoints::sequence. The named errors for an unfilled slot and an unfinished copy stay.cargo fmtis clean on what I touched.Duplication found or removed (
path:line), or "none": removed the second slot allocation incrates/gpu/src/checkpoint.rs(adopt).python3 tools/dup-scan.pyfound no candidates in the diff.What I ran
Head
bb4c1aad4, base main69b66367c. The timing, traces and checks below ran on18db2ba82, the same two commits on main6e7f43fa9. The head only rebases them (git range-diffshows both commits as equal, and the three edited files are unchanged by the rebase).GPU Evidence
On an NVIDIA GB10:
just gate-gpu-libnot run: the checkpoint tests that recipe wraps ran throughtools/gate.shinstead.These cover slot reuse, refusal of an unfinished copy, open, seal and abandon, saved state and staging. The host tests for the row advice ran on a Linux host machine:
Host waits over three prompts
Three different 4096-token code windows ran back to back on the main build and on the head build, one generated token each, with no prompt-cache hit and Nsight Systems attached. The PLE wait is the time the host spent in
Prefetcher::wait.The PLE wait is smaller on head and still present. Profiling changes timings, so these traces explain where the host waited and are not the speed measurement.
First-request TTFT
One load per arm, main then head, two different 4096-token code windows per load, two generated tokens, temperature 0, context 16896, parallel 1, draft off. Model
nvidia/Qwen3.8-Flash-Next-NVFP4atfc694b54fb0174e0913e6adf86691ef85a4ead47, loaded from its checkpoint folder, on one GB10 (driver 595.84, CUDA 13.3.1 image,sm_121, release binaries, OS page cache not dropped). Prefill rate is the server's own report.The first request was 51.907 ms faster in this pair; the subsequent request did not improve. This is not a statistically established steady-throughput gain.
Each arm is one load and one first request, so these are single observations with no spread. The server load took 205.187 s on main and 206.156 s on head, and the body phase of the load took 0.11 s on main and 0.39 s on head, because every budgeted slot is now pinned during load.
Correctness
hw_a_sequence_holds_the_budget_of_its_contextfailed withleft: 0, right: 2. With sorted coalescing removed,page_runs_advise_each_requested_page_oncefailed, and with file grouping removed,a_run_table_reads_each_row_from_its_runfailed. All three passed again on the restored code.What I ran into
This does not block the PR. A call that advises many disjoint ranges in one syscall,
process_madvise, returnedEPERMinside the container on this machine (errno=1), so I kept the per-run advice and added no vector path. Most of the request time is inbf16_tile_gemm(16688.004 ms over the three profiled requests), which this PR does not touch.Hardware
One NVIDIA DGX Spark (GB10, compute capability 12.1, unified memory), driver 595.84, CUDA 13.3.1 image. Builds use
BLOOMERY_ARCH=sm_121. The engram host tests ran on a Linux host machine.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.