#1 [high] Should fix: prior-flag rejection happens after graph mutation (partial mutation on error path)
File: ignition/preparation/runtime_core.py:208-243 (new code at 224-229 validate request, 237 instantiate_graph, 238-242 read+validate prior flags).
Issue: the requested-flag check (lines 224-229) runs before any mutation, but the executable-derived check runs after graph.retain_object((pools, tuple(owners)), synchronize_before_release=True) (236) and instantiate_graph(graph) (237). On prior_flags & ~PERMITTED (240-241) the function raises leaving the graph instantiated and holding newly retained pool/owner references, with no _flare_instantiation_flags set. Caller ignition/preparation/capture.py:193 (record_export_graph inside capture_forwards' try/except) just propagates, so the partially-mutated graph is abandoned mid-capture.
Why it matters: docs/design-review.md testing-hierarchy clause 1 requires Python suites to "validate rejection without partial mutation"; principle 6 ("Make storage and lifetimes explicit") and docs/preparation-development.md:140-150 (executables/pool owners retained until a confirmed native drain) make a half-retained, half-flagged graph a lifetime hazard. The PR description claims "rejecting unsupported bits on either source before mutating graph state", which is not true for the executable-derived source (voipmonitor's review finding 3 flagged the same description inaccuracy).
Verified by code reading; the new test at tests/preparation/test_capture_graph_metadata.py:244-249 only asserts the ValueError, not the post-failure state (contrast the bad case at 251-255 which does assert bad.instantiations == 0 and not bad._retained.objects).
Fix options: (a) check the reason before instantiating is impossible for bit 1 (set by instantiation), so on rejection undo — but torch has no cheap undo other than graph.reset(); (b) accept the mutation but document it and assert the resulting state in the test; (c) drop the executable-derived hard rejection and instead mask/report it. At minimum correct the PR description.
Note the executable-derived flags route is precisely where PyTorch may add bits over time (e.g. CUDA's DEVICE_LAUNCH=2 / UPLOAD=4 / STRICT_PRIORITY=0x10 exist in CUgraphInstantiate_flags), so this path is reachable in principle on other drivers/torch versions — exactly the "existing cores still load / supported targets" dimension of docs/design-review.md principle 13.
#2 [high] Findings verified OK: flag values, Rust-side contract, helios instantiation path
- Flag values: USE_NODE_PRIORITY=8, AUTO_FREE_ON_LAUNCH=1 match CUDA's CUgraphInstantiate_flags (8/0x8 and 0x1). Combined 1|8=9 as the PR says (ignition/preparation/runtime_core.py:192-197).
- Wire acceptance agrees with Rust on both sides: heliopause/src/export/capture.rs:2820-2824 rejects non-recorded graphs with
instantiate_flags.is_some_and(|f| g.graph == 0 || f & !9 != 0); record_graph also requiresflags & !9 == 0(capture.rs:589); helios/src/runtime_core/format.rs:495 usesgraph.flags & !9 != 0; Python_graphs()usesflags & ~9(runtime_core.py:284). So flag 9 is accepted end to end and #581 stays forward/backward compatible with existing cores that record 1 (flags 1 still pass& !9). docs/runtime-core-design.md:620-623 "instantiate each graph with its recorded flags". - Helios really uses the flags: helios/src/runtime_core/mod.rs:1215-1219
cuGraphInstantiateWithFlags(&mut executable, handle, graph.flags). So recording 9 changes instantiation, not just metadata. - Node priorities can actually take effect: heliopause records CU_LAUNCH_ATTRIBUTE_PRIORITY because KERNEL_ATTRIBUTES includes 8 (capture.rs:462, 544-569), encode_kernel emits every non-13 attribute including id 8 (capture.rs:857-887), and helios applies them via cuGraphKernelNodeSetAttribute before instantiation (helios/src/runtime_core/mod.rs:984-1013). The priority attribute originates from ignition/preparation/scratch.py:83-105, which creates
auxiliary_streamat the context's greatest (most negative) priority for small collectives. _graphs()keeps the two export shapes distinct: with_flare_instantiation_flagsit emits {name, graph(template), instantiate_flags} and no executable, satisfying capture_rank's(g.executable == 0) == g.instantiate_flags.is_none()invariant at capture.rs:2822 (0 vs Some -> false == false). heliopause graph_metadata then prefersgraph.instantiate_flagsover reading the live executable (capture.rs:788-794)._Cuda(runtime_core.py:76-91) already handles Windows via nvcuda.dll, socuGraphExecGetFlagsvia ctypes works on the supported Windows target too; the PR does not introduce a platform-specific path.
#3 [high] Should fix: new _flare_instantiation_flags state has no invalidation path (stale flags after reset / re-capture)
File: ignition/preparation/runtime_core.py:238-242 (sets graph._flare_instantiation_flags) and 282-287 (_graphs prefers the attribute over the live executable).
Two related issues, both about this new Python-side state living outside CUDA's own lifecycle:
-
instantiation_flags=Nonekeeps "executable-derived flags", but the implementation merely skips setting the attribute; it never clears an existing one. If a graph has been throughrecord_export_graphonce and the code path later re-records it withinstantiation_flags=None, the stale_flare_instantiation_flagssurvives and_graphs()keeps emittinginstantiate_flags(template-only export, no executable) instead of falling back to the live executable. The author's test at tests/preparation/test_capture_graph_metadata.py:236-242 exercises only a fresh graph, so the clearing branch is untested. -
Nothing clears
_flare_instantiation_flagswhen the executable dies. Every other piece of export-time graph state is invalidated on the same event:_RecordedGraphMetadata.release(runtime_core.py:153-158) zeroesself.executablefrom the destroy callback, andRecordedExportGraph.reset(185-189) drops recorded/pools/owners. Atorch.cuda.CUDAGraphmay bereset()and re-captured; after that,_graphs()still prefers the stale attribute over the new executable, so the core records a flag word computed from an executable that no longer exists — precisely the executable/flags mismatch that capture_rank validates for the non-flag shape (heliopause/src/export/capture.rs:2820-2824 cannot detect this because the mismatch has been erased).
Severity: should fix (latent; the only current caller, capture.py:171-193, allocates a fresh graph per capture, so it is not reachable from capture_forwards today). Fix: clear the attribute (graph.__dict__.pop("_flare_instantiation_flags", None) or set it to None) at the start of record_export_graph and register a destroy callback alongside _RecordedGraphMetadata.release that drops it.
Also minor: _executable_instantiation_flags (200-205) constructs a fresh _Cuda() per graph, re-CDLLs libcuda.so.1 for each of the serving graphs; heliopause caches a single Cuda (capture.rs:745, 756). Nit-level, matches voipmonitor's nit 4.
#5 [high] Research summary
Reviewed PR #581 (ignition: set USE_NODE_PRIORITY flag on exported CUDA graphs) through the correctness lens, reading the changed function in full context, its only caller (capture.py:171-197), and the Rust consumers on both sides of the wire (heliopause export validation and recording, helios format validation and cuGraphInstantiateWithFlags), plus the project's design-review rules.
What checks out: the flag values (1 and 8, combined 9) match CUDA's CUgraphInstantiate_flags and agree with every Rust validation site (capture.rs:589, 2820-2824; format.rs:495), so both old cores recording 1 and new cores recording 9 load; helios actually instantiates with graph.flags (mod.rs:1215-1219) rather than ignoring it; node priorities are genuinely recorded and reapplied (KERNEL_ATTRIBUTES includes 8, encode_kernel emits it, helios sets it before instantiation), so the change is not cosmetic; and _graphs() emits the template+instantiate_flags shape that capture_rank's invariants require. _Cuda already handles Windows, so no new platform path.
Three confirmed findings recorded in the scratchpad: (1) should fix — the executable-derived flag check runs after retain_object + instantiate_graph, so a rejection leaves a half-mutated graph, contradicting the PR's "rejecting unsupported bits on either source before mutating graph state" and the design-review requirement to validate rejection without partial mutation; (2) should fix — the new _flare_instantiation_flags attribute has no invalidation path, so it survives graph reset/re-capture and None re-recording, and _graphs() then prefers a stale flag word over the live executable; (3) should fix / prose — instantiation_flags=None has no production caller (tuning graphs never reach record_export_graph), and the perf benefit is asserted rather than measured, which principle 12 and 16 cover. No blocking correctness defect found in the change itself.
#6 [high] Verdict and finding index for PR #581 correctness review
PR #581, head 61f64f18 ("ignition: set USE_NODE_PRIORITY flag on exported CUDA graphs"), base main 167f22c, 3 files +137/-7. Verdict: no blocking correctness defect in the change itself; three should-fix items. Another reviewer (voipmonitor, CHANGES_REQUESTED) already covers the end-to-end serving qualification and the keep_graph=False validation (his findings 1-2), which are outside my lens findings below.
Findings (my lens), all verified by reading code:
- Should fix — ignition/preparation/runtime_core.py:236-241. The requested-flag validation (224-229) precedes all mutation, but the executable-derived flag check (239-241) runs after
graph.retain_object(...)(236) andinstantiate_graph(graph)(237). On rejection the graph is left instantiated and holding newly retained pool/owner references, with no_flare_instantiation_flags, and capture.py:193 propagates without cleanup. Violates docs/design-review.md testing-hierarchy clause 1 ("validate rejection without partial mutation") and the PR's own claim "rejecting unsupported bits on either source before mutating graph state". Fix: unmask/report instead of hard-rejecting, or reset the graph on that path, or document + assert the post-failure state in the test (the new test at tests/preparation/test_capture_graph_metadata.py:244-249 asserts only the raise, unlike thebadcase at 251-255 which does assert no mutation). - Should fix — ignition/preparation/runtime_core.py:238-242 + 282-287.
_flare_instantiation_flagsis the only export-time graph state with no invalidation:_RecordedGraphMetadata.release(153-158) andRecordedExportGraph.reset(185-189) both clear their state on reset/destroy, but this attribute persists. Consequences: (a)instantiation_flags=Noneonly skips the assignment, so a re-record on a previously recorded graph keeps the stale flags; (b) aftergraph.reset()+ re-capture,_graphs()still prefers the stale attribute over the new executable and emits a template+flags record computed from a dead executable, a mismatch capture_rank (heliopause/src/export/capture.rs:2820-2824) can no longer detect. Not reachable through today's only caller (capture.py:171 allocates a fresh CUDAGraph per capture), hence should fix not blocking. - Should fix / prose — no production caller passes
instantiation_flags=None; tuning graphs use capture_graph+instantiate_graph (capture.py:171,197) and never enter record_export_graph, so the documented "keeps executable-derived flags for startup tuning graphs" branch is dead outside the unit test (tests/preparation/test_capture_graph_metadata.py:236-242). Also theperf/claim is asserted, not measured: the only GPU evidence is the export-side assertion flags_by_name == {"decode": 9, "tune": 1} (tests/preparation/test_recorded_export_graph_cuda.py:85-87), and that test is opt-in behind FLARE_RUN_CUDA_TESTS (line 14). Principle 12 (measured results, complete GPU steps) and 16 (before/after, expected vs measured).
Nit — ignition/preparation/runtime_core.py:200-205 constructs a new _Cuda() (fresh CDLL of libcuda.so.1) per exported graph; heliopause caches one (capture.rs:745,756).
Verified clean: flag constants match CUDA and all Rust acceptance sites (capture.rs:589, 2820-2824; helios/src/runtime_core/format.rs:495); backward compatibility — cores recorded with 1 still pass & !9; helios instantiates with graph.flags (helios/src/runtime_core/mod.rs:1215-1219); node priorities really survive export and replay (KERNEL_ATTRIBUTES includes 8, capture.rs:462/544-569, encode_kernel 857-887, helios set-attribute mod.rs:984-1013, priority stream created in ignition/preparation/scratch.py:83-105); _graphs() emits graph+instantiate_flags with no executable, matching capture_rank's (executable == 0) == instantiate_flags.is_none() (capture.rs:2822); Windows path unchanged (_Cuda handles nvcuda.dll, runtime_core.py:78).
#4 [medium] Should fix: PR claims corrected only partly — dead None path and unmeasured perf claim
Prose/claims in the PR body vs the code (docs/design-review.md principle 16, "distinguish expected benefits from measured results", and testing hierarchy clause 1):
- "rejecting unsupported bits on either source before mutating graph state" — false for the executable-derived source:
retain_object+instantiate_graphalready ran when_executable_instantiation_flagsis checked (runtime_core.py:236-241). Same point as voipmonitor review finding 3. - "Passing
instantiation_flags=Nonekeeps executable-derived flags for startup tuning graphs" — no caller passesNone.record_export_graph's only caller is capture.py:193 (insideif exporting:, i.e.retain_graphs and warmup_storage is not None, the serving graph path). Startup tuning graphs usecapture_graph+instantiate_graph(capture.py:171,197; runtime_core.py:246-269) and never reachrecord_export_graph, so theNonebranch is dead in production code and only exercised by the new unit test at tests/preparation/test_capture_graph_metadata.py:236-242. Either wire a caller or drop the claim; either way the parameter's documented purpose does not match any code path. - The claimed benefit ("Helios requests node priority ... while preserving permitted executable flags") is stated as expected rather than measured: the only GPU evidence is the export-side assertion
flags_by_name == {"decode": 9, "tune": 1}(tests/preparation/test_recorded_export_graph_cuda.py:85-87), which proves recording. No served-graph measurement, and the description itself lists live export/serving as "open GPU qualification". Whether 9 actually improves service is unmeasured — principle 12 requires equivalent baselines for a perf claim, and the title frames this asperf/.
Note: tests/preparation/test_recorded_export_graph_cuda.py is opt-in (FLARE_RUN_CUDA_TESTS=1, line 14), so {"tune": 1} in the assertion depends on the tuning graph keeping AUTO_FREE_ON_LAUNCH only; that assumption is what makes the executable-derived-vs-requested distinction visible, and it holds today.