Hardware test plan — PR #641: resample host memory after flushing the CUDA cache
1. Bottom line
Two hardware runs matter, and they cost about 2 hours of GPU time on cn7 and 40 minutes on cn4's cn5 node:
| Machine | What it uniquely proves | Why it is the right box |
|---|---|---|
| cn7 (GB10, SM121, integrated/unified) | The actual bug: torch.cuda.empty_cache() is called, host memory is re-sampled afterwards, the reclaimed bytes reach worker admission, preparation does not crash, and the new near-unconditional flush has no measurable cost |
Only integrated-memory GPU we have. torch.cuda.get_device_properties(...).is_integrated is true here and false everywhere on cn5, so this is the only machine that executes lines compile_pool.py:59-60 and the only one that ever hits the widened trigger on unified memory |
| cn5 (4× RTX PRO 6000 96 GiB, SM120, discrete) | Zero-cost control for the widened trigger on discrete GPUs, plus live proof that the new aot.py:1070 flush-ordering change works on real CUDA |
96 GiB of free VRAM means the discrete gate (compile_pool.py:55-56: free - headroom_bytes < 8 GiB) is false, so the PR must add zero flushes. Any flush there is a regression |
Do not plan an A/B timing experiment to "measure the claimed speedup". There is no speedup in this change: the motivation is an export that used to fail with MemoryError (compile_pool.py:96-97, "no capacity for a forward compiler") and now fits. The case file and final review both flag the author's "unlocking additional compiler workers" wording as unsupported by their own [1,1,1] numbers. The metric that matters is flush count, success/failure, and wall-clock parity, not tokens/s. A tokens/s benchmark would burn GPU time measuring nothing (the serving hot path is untouched — allocate_workers() and CompilerResources are byte-identical in behavior).
Also note two hard limits so nobody over-claims afterwards:
- cn7 hands out 60 GiB (cgroup-capped;
host_memory.available_bytes()honours finite cgroup-v2 ancestors,host_memory.py:51-79,82-100), not the author's 121 GiB GB10. Their exact repro (available8435 MiB, headroom 8192 MiB) cannot be reproduced here. - >1 compiler worker per host cannot be demonstrated on live hardware: on GB10 the gate is
8 × 34 GiB = 272 GiB, so a second worker requiresavailable − headroom ≥ 34 GiBand a 272 GiB host that does not exist. The multi-worker claim stays CPU-test-only.
2. Scenarios to test (ranked, with the reason each is worth GPU time)
S1 — cn7: flush count + host resample on unified memory (highest value, ~6 min, no model, no weights)
Exercises compile_pool.py:46-64 on a real integrated GPU with zero model download. A throwaway script (no repo edit) counts flushes and records what the sampler sees in three states: (a) clean, (b) after allocating a large CUDA tensor and freeing it to the caching allocator, (c) after the pool is sized.
# on cn7, repo at PR head d82fcfc, same checkout for both arms
cd ~/hyperflare-inference && git checkout -q d82fcfc && uv sync --extra prepare --extra test
cat > /tmp/probe641.py (not opened) <<'EOF'
import argparse, torch, sys
from ignition.preparation import compile_pool as cp, host_memory as hm
p = argparse.ArgumentParser(); p.add_argument("--headroom-gib", type=int, default=4)
p.add_argument("--balloon-gib", type=int, default=0); a = p.parse_args()
flushes = []
real = torch.cuda.empty_cache
def counted():
flushes.append(1); real()
torch.cuda.empty_cache = counted # count only; behavior unchanged
dev = "cuda:0"; total = torch.cuda.mem_get_info(dev)[1]
print("integrated", torch.cuda.get_device_properties(dev).is_integrated,
"total GiB", total / 2**30, "MemAvailable MiB", hm.available_bytes() >> 20)
balloon = torch.empty(int(a.balloon_gib * 2**30), dtype=torch.uint8, device=dev) if a.balloon_gib else None
if balloon is not None: balloon.zero_()
before = (hm.available_bytes(), hm.device_memory_info(dev)[0])
r = cp.compiler_resources(dev, headroom_bytes=a.headroom_gib << 30)
after = (hm.available_bytes(), hm.device_memory_info(dev)[0])
print(f"flushes={len(flushes)} available {before[0]>>20}->{after[0]>>20} MiB free {before[1]>>20}->{after[1]>>20} MiB")
print("resources capacity=%d available=%d MiB limit=%d worker_bytes=%d headroom=%d MiB"
% (r.capacity, r.available >> 20, r.limit, r.worker_bytes >> 20, r.headroom >> 20))
try:
print("admitted", cp.allocate_workers([r], [r.limit], ["host"]))
except MemoryError as e:
print("MemoryError:", e)
EOF
# PR arm
.venv/bin/python /tmp/probe641.py (not opened) --headroom-gib 4
# main arm (same script, behavior of main/compile_pool.py (not opened))
git stash -q && git checkout -q main && uv sync --extra prepare --extra test -q
.venv/bin/python /tmp/probe641.py (not opened) --headroom-gib 4
Expected (per the code): PR flushes=1; main flushes=0 (on integrated, main gates on free - headroom_bytes < 2 GiB, and free already equals the MemAvailable-capped value, host_memory.py:107-109). PR available after > before by the allocator-cached host bytes; main's available unchanged. Both must exit 0 and print an admitted list. A deviation is a finding — e.g. PR flushes=0 on GB10 would contradict compile_pool.py:55 (272 GiB vs 60 GiB).
Then the failure/recovery pair, which is the actual bug and the one run that reproduces MemoryError cheaply. No model, no compiler workers — ~2 min per arm:
# push `available` into [8,12) GiB: main's floor needs 4 GiB and never flushes, so this raises MemoryError
.venv/bin/python /tmp/probe641.py (not opened) --headroom-gib 8 --balloon-gib 46 # PR arm
# then the same with `git checkout main` built as above # main arm
Tune --balloon-gib in 2 GiB steps so the printed available lands in [8,12) GiB; record the value each arm needs. Pass: PR exits 0 (flushes, resamples, admits 1 worker via the floor at compile_pool.py:87-94); main raises MemoryError quoting available/headroom in MiB. This is the defensible before/after evidence the PR is missing, obtained in minutes instead of a 22-minute export.
S2 — cn7: real TP1 export, both arms, byte-identical settings (the end-to-end check, ~15–25 min/arm)
Proves the change survives the real pipeline (bind → warm → capture → publish), not just a direct function call. Model: google/gemma-4-e4b-it (on cn7). Pin the same recipes commit for both arms — official recipes live in the external local-inference-lab/hyperflare-recipes (docs/model-preparation.md:310-314), and the review already dinged the author for evidence from a combined stack.
export RECIPES=/path/to/hyperflare-recipes # same commit for both arms, record `git -C $RECIPES rev-parse HEAD`
# baseline core name and kernel cache copied to a second prefix so the arms cannot contaminate each other
cp -a ~/.cache/flare/kernels ~/.cache/flare/kernels-warm && cp -a ~/.cache/flare/cores ~/.cache/flare/cores-warm
# ARM A (main) — pin the clone to main
cd ~/hyperflare-inference && git checkout -q main && uv sync --extra prepare --extra test -q
/usr/bin/time -v .venv/bin/ignition export google/gemma-4-e4b-it --gpus 0 --verbose \
--config ~/.config/flare/config.toml (not opened) 2>&1 | tee /tmp/export-main.log
# record: final core path, "compiler workers" line, elapsed, Maximum resident set size
# ARM B (PR) — restore caches to the pre-A state, then checkout d82fcfc
rm -rf ~/.cache/flare/{kernels,cores} && cp -a ~/.cache/flare/kernels-warm ~/.cache/flare/kernels \
&& cp -a ~/.cache/flare/cores-warm ~/.cache/flare/cores
git checkout -q d82fcfc && uv sync --extra prepare --extra test -q
/usr/bin/time -v .venv/bin/ignition export google/gemma-4-e4b-it --gpus 0 --verbose 2>&1 | tee /tmp/export-pr.log
(Exports need an unused destination — docs/model-preparation.md:275-282 — so delete or rename the arm-A entry before arm B; the two tee logs preserve the arm-A path. If a faster deterministic loop is wanted, add --autotune-effort off to both arms to remove kernel races from the timing — docs/model-preparation.md:211-214.)
Pass criteria: both arms succeed; the admitted-worker line (aot.py:1088 prints N compiler workers; per rank [...]) is identical; arm B wall clock within ±10 % of arm A (marginally faster is the expected direction, since arm A can fail here); arm B's peak MemAvailable dip is no worse than arm A's. Distribution evidence for the flush (NVML reports no VRAM on GB10, docs/model-preparation.md:489-495, so watch host memory): while sleep 2; do grep MemAvailable /proc/meminfo; done beside each arm. Fail: arm B slower by >10 %, or fails, or admits fewer workers.
S3 — cn5: discrete zero-cost control + live flush-ordering (2 short runs)
cd ~/hyperflare-inference && git checkout -q d82fcfc
# (a) discrete: the widened trigger must NOT fire — zero added flush, unchanged free/available
.venv/bin/python /tmp/probe641.py (not opened) --headroom-gib 4 # expect flushes=0 on 96 GiB free
# (b) live CUDA exercise of aot.py:1070 (release_unused -> empty_cache -> barrier -> compiler_resources)
CUDA_VISIBLE_DEVICES=0 FLARE_RUN_CUDA_TESTS=1 .venv/bin/python -m pytest -q \
"tests/preparation/test_inductor_tuning_cuda.py::test_cooperative_vision_validation_freezes_and_restores[single]"
# (c) true multi-rank path (real coordinator => _prepare_ranks) on two GPUs, torchrun local:
CUDA_VISIBLE_DEVICES=0,1 FLARE_RUN_CUDA_TESTS=1 FLARE_RUN_TP_CUDA_TESTS=1 \
.venv/bin/torchrun --nproc_per_node=2 -m pytest -q \
"tests/preparation/test_inductor_tuning_cuda.py::test_cooperative_vision_validation_freezes_and_restores[tp2]"
(c) matters because no local multi-GPU export on cn5 reaches _prepare_ranks (a coordinator is built only by the multi-host ignition export --ranks N --rendezvous path or by these torchrun tests, ignition/cli/serve.py:403-421). These two tests use tiny forwards (a 1024×768 pixel op, a 3072-float vector) and one Inductor function, so they are the cheapest live proof of the new aot.py:1070-1074 ordering. Pass: both green, no hang at the barrier; on failure the run must exit with the collective RuntimeError (aot.py:1084-1085,1130-1131), never hang.
S4 — cn7: the no-flush skip path on integrated hardware (1 test, ~4 min)
tests/preparation/test_capture_order_cuda.py:44 runs capture_forwards with requested_compile_workers=1, so max_workers = 1 and the gate becomes 34 GiB. With ~50 GiB available under the 60 GiB cap the gate is false, so the PR takes the skip branch on a real integrated GPU (the only non-flush integrated coverage in the PR is a mock needing a 300 GiB host — tests/preparation/test_compile_pool.py:626-642).
CUDA_VISIBLE_DEVICES=0 FLARE_RUN_CUDA_TESTS=1 .venv/bin/python -m pytest -q \
tests/preparation/test_capture_order_cuda.py::test_capture_pool_reuses_larger_compiled_request_on_fresh_and_cached_load
Pass: green, with cache-hit behavior on the second loop unchanged.
S5 — CPU gate, no GPUs, run first (5 min, blocks everything else)
The final review asks for this before merge and it is still unreported on d82fcfc.
CUDA_VISIBLE_DEVICES="" .venv/bin/python -m pytest tests/preparation/test_compile_pool.py -q # PR's 5 new tests
CUDA_VISIBLE_DEVICES="" .venv/bin/python -m pytest tests/ -q # = .github/workflows/python-cpu.yml:30-33 (not opened)
The new mock tests are Windows/POSIX + discrete + ordering only; the Windows clamp (os.name == "nt") cannot be validated on any machine we have — record it as unrun rather than passing it.
3. Budget and sequencing
- S5 (CPU, 5 min) → S1 probe (~20 min including the balloon pair) on cn7. Stop and report if the PR does not flush, or if
maindoes not raiseMemoryErrorin the balloon case: the premise of the PR is then unproven and an export would waste GPU time. - S2 export pair (~50 min) on cn7. Only if S1 passed.
- S3 (a)(b) (~15 min) on cn5; (c) only if a discrete rank-ordering question remains (~10 min).
- S4 (~5 min) on cn7, can ride along with S2.
Total ≈ 2 h on cn7 + 25 min on cn5, two model-less probes doing most of the work, one model at one checkpoint size on one layout (TP1) — deliberately not the author's TP3 stack, since the point of hardware here is branch coverage, not re-running their benchmark.
4. Preconditions, confounds, and what not to do
- Same checkout per arm, recorded commit (
git rev-parse HEADinto the log), same Python env (uv sync --extra prepare --extra testafter each checkout), same recipes commit, same config file. Reset~/.cache/flare/{kernels,cores}to an identical state between arms or a warm kernel cache will make arm B look faster for reasons unrelated to this PR (ignition/cli/environment.py:39-50(not opened)). - Keep
--autotune-effortand--compile-workersidentical between arms. A differentcompile-workerschangesmax_workersand therefore the discrete gate (8 GiB at defaults, 12 GiB at 12, 32 GiB at 32) — an easy way to manufacture a fake before/after. - Do not read a speedup into export wall clock. The only cost this PR can add is one
torch.cuda.empty_cache()per rank (and on a multi-rank prepare it is a second one, sinceaot.py:1070also flushes — the review's optional simplification). Bound it, don't celebrate it. - Do not report
[1,1,1]-style worker counts as a fix. On cn7 the floor atcompile_pool.py:87-94supplies the single worker; the resample supplies the accurately-reportedavailable. If a run reports 2+ workers, check whetheravailable − 8 GiB ≥ 34 GiBbefore crediting the PR. - cn5 cannot exercise: integrated/unified memory, the Windows clamp, or host-memory resampling. cn7 cannot exercise: >1 worker per host, the discrete 1 GiB capacity recovery, or the author's 121 GiB scenario (60 GiB cap). cn7's ARM (arm64) environment must build cleanly; if
uv syncfails there, S1/S2 move to any other GB10-class host and cn5 covers only S3.
5. Findings the test engineer should confirm or refute (with citations)
- On Linux integrated GPUs the moved clamp is inert —
host_memory.py:107-109already returnsmin(total, available_bytes()), somin(available, free)(compile_pool.py:53-54,59-60) changes nothing on cn7; the substantive fix is the post-flush resample at:60. S1 will show this: the PR's gain must come fromavailablerising after the flush, not from the clamp. - The widened trigger is unconditional on GB10 — 8 × 34 GiB = 272 GiB vs 60 GiB cap (
compile_pool.py:48-56). S1'sflushes=1and S2's parity timing are the whole cost argument. - On discrete GPUs at defaults the PR adds zero flushes — 8 × 1 GiB = 8 GiB, free is far above it on a 96 GiB card (
compile_pool.py:55-56). S3(a) proves the "newly flushes discrete hosts" concern is limited to low-free or high---compile-workersstates. - The
MemoryError→success transition is the defensible claim, reproducible with the S1 balloon probe in ~2 minutes, and far cheaper than the PR's own 2.5-second-failure export evidence. - Residual risk that hardware cannot close: the Windows clamp (
os.name == "nt") has mock-only coverage (tests/preparation/test_compile_pool.py:595-602) and no machine here runs Windows; draft PR #639 lowers_DISCRETE_WORKER_DEVICE_BYTESto 704 MiB and would invalidate the discrete expectations intests/preparation/test_compile_pool.py:608-610, so whichever lands second needs a rebase and a re-run of S3.
Detail notes with all citations are in my scratchpad (entries 1–3): code behavior per line, invocation surface, and the machine-to-branch mapping with predictions.