Repository navigation
gpu: cover pageable snapshot copies and resumed token bits - #730
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: The test changes add byte and recurrent-bit checks without changing production behavior.
Non-blocking
⚠ Demonstrate the added assertions failing: saved.rs:985. The reported FAIL-first run fails a temporary precondition probe, not an added assertion. Attach failing output with recurrent signed zero normalized and with a copy row omitted. This establishes the regression signal while the test inputs are available.
Checked
Duplicates: 0 new function/type/constant definitions; the local token closure reuses the existing argmax launcher. Grep found no duplicated implementation; dryer reported 0 pairs.
Complexity: crapper flagged no changed functions; changes are confined to two existing tests.
Silent failure: 0 added default/error-suppression sites; new fallible calls use named expectations.
Tests (static mutation analysis): dropping the recurrent copy at saved.rs:471 or saved.rs:521 fails the saved/restored bit assertions. Reducing Height at tensor.rs:314 to rows - 1 fails the plane assertions. Signed-zero normalization also fails bit comparison. These mutants were not executed.
Gates: no pins moved or coverage removed; slice equality retains the removed length check. Both tests remain hw_-prefixed and ignored.
Escape catalog: no patterns matched. No production hot path changed.
Notes
CUDA gates were not run during this review. The PR reports GB10 and RTX 5090 runs, but omits both tested commit hashes; GPU evidence is incomplete. The token check applies argmax directly to recurrent values; it does not exercise a model forward, as the PR body states.
Card check: needs-gpu. This pull request changes crates/gpu/src/checkpoint/saved.rs, crates/gpu/src/tensor.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. |
프롬프트 캐시 스냅샷 복사가 일반(pageable) 호스트 메모리에서도 바이트와 복원 토큰을 그대로 지키는지 GPU 회귀 시험으로 고정합니다.
Part of #565. Tracked in #699.
What and why
The synchronous prompt-cache snapshot path hands ordinary
Vecstorage to the 2-D device-to-host copy wrapperdtoh_2d. When that wrapper came in (f8f7c3c), its documentation required page-locked host memory, so these calls broke the stated contract. A plainVecthat the CPU has written is not page-locked. The CUDA documentation forcuMemcpy2DAsyncdoes not forbid pageable host memory, and #706 removed the requirement.This PR adds regression coverage for that path: pageable and pinned 2-D copies, exact recurrent bits in a saved and restored snapshot (signed zero included), and the next token read from a restored state. It changes no production code: no new public item, no
unsafeblock, allocation, sync or transfer.The change:
hw_a_2d_copy_moves_the_bytes_of_the_planes_one_by_one(crates/gpu/src/tensor.rs) now runs its read and write loop twice, once on a plainVec<u8>and once on aPinnedHostBuffer. Each round checks the bytes of every plane, the gap bytes the copy must leave alone, and the device offset.hw_a_state_goes_and_comes_back(crates/gpu/src/checkpoint/saved.rs) saves a recurrent state with values[5.0, -0.0, 7.0, -2.0]and compares raw bits after the save and after the restore, so a-0.0turned into+0.0is caught. It also runsenqueue_argmax_finite_faulton the state before the save and after the restore, and compares the token and fault readback. It does not run a model forward after the restore.Where the fix goes: both tests live in the existing
testsmodules, next to the code they check. The callers ofdtoh_2dandhtod_2dareread_into,put_from,saveandloadinsaved.rs, the staging tests incheckpoint/staging.rsand the copy test intensor.rs. The asynchronous path keeps borrowing pinned extents from staging, so a pageable fallback does not add a pin, a copy or a sync there.Release notes: Under the hood: the GPU tests for snapshot copies now cover pageable host memory, recurrent bits and the resumed token.
Code shape
Gpu,SeqState,dtoh_2dandhtod_2downers. The expected bytes come from the plane values, not from a second copy of the transfer.SAFETYcomments say what each host buffer holds.cargo fmtis clean on what I touched, and I ran no clippy (see "What I ran").Duplication found or removed (
path:line), or "none": none.What I ran
Both machines ran the two changed tests through the gate wrapper, then
cargo fmt. The tests are#[ignore]and need a CUDA device.DGX Spark, one GB10:
checkpoint::saved::tests::hw_tests:test result: ok. 6 passed; 0 failed.test result: ok. 1 passed; 0 failed.cargo fmt --all -- --checkpassed, and the run ended withSNAPSHOT-CONTRACT PASS.RTX 5090 machine:
checkpoint::saved::tests::hw_tests:test result: ok. 6 passed; 0 failed.test result: ok. 1 passed; 0 failed.cargo fmt --all -- --checkpassed, and the run ended withSNAPSHOT-CONTRACT PASS.just gate-gpu-lib, not run: the same ignored tests it selects ran directly throughtools/gate.shas shown above.FAIL-first: the production code is unchanged, so the new asserts also hold on the code in main, and none of them is a FAIL-first case. What I did observe is the old precondition itself. A temporary probe in
dtoh_2d, right before the copy is submitted, askedcuMemHostGetFlagsabout a plainVecthat the CPU had already written. The call returned 1 where the CUDA success code is 0, so the memory is not page-locked, and the probe stopped on its assert:That run was on a GB10, and its raw test exit code was 101. The old documented precondition did not hold for a plain
Vec, and the passing runs above show the driver accepts pageable memory.Not run: clippy,
t0and the rest of the check suite, which I leave to the PR chain, and any timing run, because the change adds no production code and I claim no speed change. I did not run a model forward after a restore.What I ran into
Nothing here blocks this PR. The end of the saved-state copy event and the staging error path sit in the same
saved.rs, in code this PR does not touch, and I did not change them.Hardware (if the change is for a machine)
NVIDIA GB10, driver 595.84, CUDA 13.3.NVIDIA GeForce RTX 5090, driver 595.99.02, CUDA 13.2.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.