Final review report · NVIDIA/hyperflare-inference #641

Raw Markdown for agents: https://autobot.eidonix.com/p/d915f4ac-f4ac-4ab5-bd19-00704fcf4054.md

Recommendation: Ready To Merge

PR #641 cleanly fixes a verified memory-accounting bug in compiler_resources() and a peer-rank flush ordering gap in ForwardCache._prepare_ranks() without relaxing any headroom invariant, worker budget, or artifact/API contract. The core resample logic, widened worker-cap flush triggers, deadlock-free collective error propagation, and isolated CPU unit tests are all verified sound at head d82fcfc. Only minor optional simplifications (avoiding a redundant second empty_cache() / duplicate POSIX available_bytes() reads) and confirming .github/workflows/python-cpu.yml (not opened) CI is green on d82fcfc remain before merge.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

  1. Optional: avoid the redundant second torch.cuda.empty_cache() on multi-rank (ignition/preparation/aot.py:1070, ignition/preparation/compile_pool.py:55-57). In ForwardCache._prepare_ranks(), every rank already runs torch.cuda.empty_cache() at aot.py:1070 before dist.barrier(group=group), then immediately calls compiler_resources() at aot.py:1076. Because max_workers * worker_bytes is 272 GiB at defaults on unified memory (and 8 GiB on discrete), compile_pool.py:57 immediately invokes a second no-op flush and resamples memory. Allowing _prepare_ranks() to skip re-flushing (e.g., an internal flush_cache=False kwarg, keeping flush_cache=True for single-rank CompilePool.__init__ at aot.py:921 / compile_pool.py:133) avoids the duplicate flush and extra sample pass.
  2. Optional: skip redundant POSIX available_bytes() reads on unified memory (ignition/preparation/compile_pool.py:51-60). On POSIX integrated GPUs, device_memory_info(device) already returns min(total, available_bytes()) (ignition/preparation/host_memory.py:107-110), so calling host_memory.available_bytes() separately before and after device_memory_info() reads /proc/meminfo, /proc/self/cgroup, and /proc/self/mountinfo (host_memory.py:51-100) four times per call instead of two. Matching host_memory.py:154-158 / :177-179 (free = device_memory_info(device)[0]; available = min(host_memory.available_bytes(), free) if os.name == "nt" else free when shared is true) halves procfs reads on Linux while preserving identical POSIX and Windows behavior.

Nits

Dropped on verification