Final review report · NVIDIA/hyperflare-inference #581

Raw Markdown for agents: https://autobot.eidonix.com/p/b9048f9e-6895-4f3e-98d3-2a38f341700d.md

Recommendation: Changes Requested

The downstream Heliopause/Helios pipeline already accepts USE_NODE_PRIORITY (8) and replays captured node priority attributes with full core compatibility, and live SM120 export passes ({"decode": 9, "tune": 1}). However, this PR globally enables CTA-priority scheduling on every exported serving graph without any live flare run serving measurement, silently breaks keep_graph=False / _flare_graph_metadata graphs passed to record_export_graph, leaves stale _flare_instantiation_flags across reset() / None, and makes two factually incorrect behavioral claims in the PR description.


Blockers

  1. Unqualified global GPU scheduling change without flare run serving evidence (ignition/preparation/runtime_core.py:208-243, ignition/preparation/capture.py:170-193, ignition/preparation/scratch.py:83-105, docs/core-design.md:852-863, docs/performance-work.md:133-144).
    • record_export_graph enables CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY (8) by default for every serving graph exported through capture_forwards (capture.py:193).
    • The repo's high-priority stream, ScratchArena.auxiliary_stream (ignition/preparation/scratch.py:83-105, created with cuStreamCreateWithPriority(..., greatest)), is used not only for small TP collectives, but also for heavy overlapped compute branches across recipes — shared experts up to 256 rows, Qwen GDN input projections, and QSA index selection (docs/core-design.md:852-853, docs/performance-work.md:133-138). Turning USE_NODE_PRIORITY on globally changes GPU CTA scheduling/preemption for every kernel captured on auxiliary_stream across all recipes.
    • The PR provides no flare run latency measurements and no live Helios instantiation/replay check (its own limitations note that live CUDA export, nondefault priority instantiation across target drivers, and signed-core flare run replay remain open).
    • This violates the Charter ("Bring real evidence. Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)"), docs/design-review.md:106-115 (Principle 12: performance claims require equivalent baselines and actual Helios service measurements), and docs/performance-work.md:142-144 ("Measure complete graph latency, including synchronization and resource contention, at each relevant row capacity"). Priority reviewer @voipmonitor has already issued CHANGES_REQUESTED on this requirement.
    • Required before merge: Qualify an exported TP/overlap core end-to-end via flare run with before/after serving latency (covering both collective overlap and heavy auxiliary_stream compute branches to confirm no scheduling regression), and confirm that the Helios-instantiated executable reports cuGraphExecGetFlags == 9.

Should Fix

  1. record_export_graph silently breaks keep_graph=False / _flare_graph_metadata graphs until export (ignition/preparation/runtime_core.py:208-243, :256-269, :282-292).

    • record_export_graph calls instantiate_graph(graph) (which explicitly accepts _flare_graph_metadata graphs created by capture_graph(retain_graphs=True) with keep_graph=False, whose CUDA template Torch releases upon instantiation) and then unconditionally sets graph._flare_instantiation_flags = prior_flags | instantiation_flags.
    • On main, _graphs() fell through to lines 288-292 and emitted graph=0, executable=executable, which Heliopause resolved via recorded_graph(graph.executable) (heliopause/src/export/capture.rs:775-786). With this PR, _graphs() (runtime_core.py:282-287) takes the flags is not None branch first and calls int(graph.raw_cuda_graph()), crashing late with RuntimeError ("template was released") or emitting graph=0 with instantiate_flags=9 (rejected at heliopause/src/export/capture.rs:2823).
    • Fix: When instantiation_flags is not None (or unconditionally if the kwarg is removed), validate up front before retain_object(...) and instantiate_graph(...) that getattr(graph, "_flare_graph_metadata", None) is None and that graph.raw_cuda_graph() returns a live nonzero template handle (matching @voipmonitor Major #2), and add a unit test covering that rejection.
  2. Stale _flare_instantiation_flags survives instantiation_flags=None re-recording and graph.reset() (ignition/preparation/runtime_core.py:238-243, :282-287, :153-166).

    • Unlike _RecordedGraphMetadata.executable, which clears itself on reset via register_destroy_callback (runtime_core.py:166), _flare_instantiation_flags is never cleared when record_export_graph is called with instantiation_flags=None on a previously recorded graph, nor when graph.reset() tears down the graph. Because _graphs() prefers _flare_instantiation_flags over the live executable, a reused graph would silently serialize stale flags.
    • Fix: Clear any pre-existing _flare_instantiation_flags on instantiation_flags=None (or at entry after pre-validation), and clear it on reset via a weakref-guarded destroy callback (do not capture a strong reference to graph in the callback, which would break GC reclamation tested in test_export_graph_retains_external_owners_until_release at tests/preparation/test_capture_graph_metadata.py:335-339).
  3. Post-failure mutation ordering and inaccurate PR description claims (ignition/preparation/runtime_core.py:236-242, tests/preparation/test_capture_graph_metadata.py:244-255).

    • record_export_graph runs graph.retain_object(...) and instantiate_graph(graph) before querying _executable_instantiation_flags(graph) and validating prior_flags (necessarily, since cuGraphExecGetFlags requires an instantiated CUgraphExec). On unsupported prior_flags, graph remains instantiated with owners retained and _flare_instantiation_flags unset. While retaining owners until reset is consistent with test_export_instantiation_failure_retains_owners_until_reset (test_capture_graph_metadata.py:342-363), it directly contradicts the PR description's statement "rejecting unsupported bits on either source before mutating graph state", and test_capture_graph_metadata.py:244-248 asserts nothing about post-failure state for unsupported_exec.
    • Two additional description statements contradict the code (AGENTS.md:88-112, docs/design-review.md Principle 16):
      • "Passing instantiation_flags=None keeps executable-derived flags for startup tuning graphs" is false: startup tuning graphs call capture_graph + instantiate_graph (tests/preparation/test_recorded_export_graph_cuda.py:62-65) and never call record_export_graph.
      • Before: misstates main (record_export_graph on main recorded no flags; _graphs() passed executable to Heliopause, which read executable_flags at heliopause/src/export/capture.rs:791-794).
    • Fix: Assert the intended post-failure contract for unsupported_exec in tests/preparation/test_capture_graph_metadata.py:244-248 (either owners retained until reset, or explicit cleanup), and update the PR description so its before/after, caller, and non-mutation claims match the code.

Subtract / Simplify

  1. Remove the unused instantiation_flags keyword parameter unless a concrete caller needs it (ignition/preparation/runtime_core.py:208-230, :238).

    • The sole in-repo production caller (ignition/preparation/capture.py:193) passes no instantiation_flags argument, and the only caller cited for instantiation_flags=None in the PR description (startup tuning graphs) does not call record_export_graph. Removing the speculative kwarg, its None/0 branches, and its duplicated input-validation guard trims ~15 production lines (AGENTS.md:188-190). Keep it only if a concrete caller (for example in hyperflare-recipes) actually requires per-call overrides — and name that caller in the PR description.
  2. Reuse PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS in _graphs() (ignition/preparation/runtime_core.py:284).

    • _graphs() still hardcodes flags & ~9 with the identical ValueError string duplicated from record_export_graph:229. Replace ~9 with ~PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS so the permitted mask has one definition in Python (matching @voipmonitor Nit #4).

Nits

  1. Lazily cache _Cuda() instead of reopening libcuda.so.1 / nvcuda.dll per graph (ignition/preparation/runtime_core.py:200-205, :76-78).
    • _executable_instantiation_flags constructs a fresh _Cuda() on every call, whereas CoreStorage (ignition/preparation/core_storage.py:76) and VirtualStorage (ignition/preparation/virtual_storage.py:27) instantiate _Cuda() once and reuse it. Cache a module-level _Cuda instance lazily (matching @voipmonitor Nit #4).

Verified passes


Dropped on verification