From c5e1caeb892e31a8816dab3c769fbfc4cb332206 Mon Sep 17 00:00:00 2001 From: MauroFab Date: Tue, 18 Aug 2026 17:02:13 -0300 Subject: [PATCH] test(gpu): assert the parts-download counter is zero on the happy path The device-only cliff recoveries replace hard aborts with a silent download-and-continue, so the counters are now the only thing that surfaces a gate/dispatch lockstep break. GPU_DEVICE_ONLY_DOWNGRADES (trace side) already has its == 0 guard here; its parts-side counterpart did not, and its only readers were the > 0 assertions in cuda_fallback_tests, which run with a fault deliberately armed. Without this, a decline in the R2 comp-poly tree build on a device-only table recovers, verifies and passes green, while every such table pays a full parts D2H plus a CPU commit_bit_reversed and loses the resident composition tree. The R4 DEEP site is already covered transitively (it needs the trace to be device-only too, which moves the trace counter), so this closes the R2 commit and R3 parts-OOD sites. Zero is the right expectation: materialize_composition_parts_host early-returns without bumping when the part evals are already populated, so the counter only moves for a device-only table that had to pull its parts back. The message names both causes rather than blaming the gate, matching the counter's own doc, which now allows a transient VRAM decline as well as a gate miss. --- prover/tests/cuda_path_integration.rs | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/prover/tests/cuda_path_integration.rs b/prover/tests/cuda_path_integration.rs index 7ae50afad..29f0070d8 100644 --- a/prover/tests/cuda_path_integration.rs +++ b/prover/tests/cuda_path_integration.rs @@ -181,15 +181,16 @@ fn gpu_opening_gather_fires_and_verifies() { /// The full-residency Stage-3 device-only path fires: at least one table keeps /// its round-1 LDE device-resident (the host D2H is skipped), and the proof -/// still verifies. This exercises every `host_trace_empty` hard-abort guard on -/// the happy path (none may fire) plus the GPU-only R2/R3/R4 paths reading the -/// device LDE with no host trace behind them. A regression that silently -/// reverts to the host D2H drops the counter to 0 (while the proof would still -/// verify). A mis-gate that forces a host fallback shows up one of two ways: -/// at R3/R4 it panics one of the guards, while at R2 and the R1 resident-aux -/// commit it recovers silently and is caught by the downgrade-counter -/// assertions below — one per site, since the R1 counter also covers tables the -/// device-only gate never cleared. +/// still verifies. This exercises the GPU-only R2/R3/R4 paths reading the +/// device LDE with no host trace behind them, plus the `host_trace_empty` +/// hard-abort guards that remain on the R4 opening path (none may fire). A +/// regression that silently reverts to the host D2H drops the counter to 0 +/// (while the proof would still verify). A mis-gate that forces a host +/// fallback does not panic at the R2 commit, R3 or the R4 DEEP loop: those +/// sites download the resident data and continue host-backed, so the counter +/// assertions below are the only thing that surfaces one — one per site, since +/// the R1 counter also covers tables the device-only gate never cleared, and +/// the parts counter covers the H part evaluations rather than the trace. #[test] #[ignore = "requires GPU; run with --ignored --nocapture"] fn gpu_device_only_residency_fires_and_verifies() { @@ -207,6 +208,15 @@ fn gpu_device_only_residency_fires_and_verifies() { path (its R2 dispatch declined at runtime: the gate should mirror the \ missing condition)" ); + assert_eq!( + stark::gpu_lde::gpu_composition_parts_downloads(), + 0, + "a device-only table's composition-poly parts were downloaded back to \ + the host on the happy path (the R2 commit, the R3 parts OOD or the R4 \ + DEEP H terms fell back to the host part evals: either the gate should \ + mirror a missing dispatch condition, or the dispatch declined \ + transiently under VRAM pressure)" + ); assert_eq!( stark::gpu_lde::gpu_resident_aux_downgrades(), 0,