Files
foxhunt/docs
jgrusewski f2335b3e50 test(iqn-sync): real GPU runtime test for sync_target_from_online (replaces static test)
Replace the proposed static `include_str!` regression guard for the
fold-boundary IQN target hard-sync (issue #84, root-cause fix in commit
`7c19b5903`) with a real GPU runtime test that exercises the contract
end-to-end. The static guard only caught literal deletion of the call
line — a stub body returning `Ok(())`, a copy against the wrong buffer,
the wrong copy direction, or a queue against the wrong stream all pass
the textual assertion silently.

Test
(`cuda_pipeline::gpu_iqn_head::tests::iqn_sync_target_from_online_makes_target_equal_online`):
  1. Construct a `GpuIqnHead` with default `GpuIqnConfig` on the
     default CUDA stream.
  2. Fill `online_params` ← 0.42 and `target_params` ← 0.99 via a
     single mapped-pinned staging buffer + `cuMemcpyDtoDAsync`. No
     HtoD copy is issued; the host write through `MappedF32Buffer::host_ptr`
     reaches the GPU through the device-mapped alias and the DtoD
     copies the staged values into each parameter buffer. The
     witnesses 0.42 / 0.99 are arbitrary distinct fp32 constants —
     the contract asserted is buffer equality, independent of magnitude.
  3. Sanity: read both buffers back via fresh mapped-pinned destinations
     + DtoD, assert they differ pointwise.
  4. Call `iqn.sync_target_from_online()`.
  5. `stream.synchronize()` so the queued DtoD has retired.
  6. Read both buffers back and assert bit-for-bit equality across all
     `total_params` slots using `f32::to_bits` (so any future NaN-bearing
     implementation also fails loud).

Per `feedback_no_htod_htoh_only_mapped_pinned.md`, all CPU↔GPU
communication routes through `cuMemHostAlloc(DEVICEMAP|PORTABLE)`
mapped pinned memory. Tests are not exempt — fills and read-backs
both use `MappedF32Buffer` + `cuMemcpyDtoDAsync`.

Buffer access exposed via four new `#[cfg(test)] pub(crate)` accessors
on `GpuIqnHead` (`online_params_slice`, `target_params_slice`,
`total_params_for_test`, `stream_for_test`) so the public API is not
widened.

Test carries `#[ignore = "gpu"]` matching the smoke-test convention
already used in `regression_detection.rs`. `cargo test -p ml --lib`
on a CPU-only host (the worktree environment) skips it cleanly; the
L40S smoke validation pool runs it via `--ignored`.

Paired with a strengthened doc-block at the call site in
`fused_training.rs::reset_for_fold` (boxed `DO NOT DELETE` warning +
reference to the new test name and issue #84) so anyone touching the
line sees the regression context inline before deleting.

Touched: `gpu_iqn_head.rs` (4 cfg(test) accessors + tests mod with
helpers + the runtime test, +217 LOC), `fused_training.rs` (boxed
comment + test reference, +16 LOC, no behaviour change),
`docs/dqn-wire-up-audit.md` (audit entry replacing the
static-test entry from the previous proposal, +33 LOC).

Verified:
  * `cargo check -p ml --lib` — clean at 13 warnings (workspace
    baseline).
  * `cargo test -p ml --lib --no-run` — clean at 24 warnings (test
    profile baseline).
  * `cargo test -p ml --lib state_reset_registry` — 3/3 existing
    tests pass (no 4th static-source test added).
  * `cargo test -p ml --lib gpu_iqn_head` — 1 test discovered,
    correctly reports `ignored, gpu` on this CPU-only worktree.

Local run not attempted — worktree environment lacks a GPU. The test
runs as part of L40S smoke validation via `--ignored`.

No fingerprint change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 20:31:08 +02:00
..