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
- Unqualified global GPU scheduling change without
flare runserving 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_graphenablesCUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY(8) by default for every serving graph exported throughcapture_forwards(capture.py:193).- The repo's high-priority stream,
ScratchArena.auxiliary_stream(ignition/preparation/scratch.py:83-105, created withcuStreamCreateWithPriority(..., 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). TurningUSE_NODE_PRIORITYon globally changes GPU CTA scheduling/preemption for every kernel captured onauxiliary_streamacross all recipes. - The PR provides no
flare runlatency measurements and no live Helios instantiation/replay check (its own limitations note that live CUDA export, nondefault priority instantiation across target drivers, and signed-coreflare runreplay remain open). - This violates the Charter ("Bring real evidence. Performance PRs need benchmarks showing an actual speedup over
mainon a served workload (#210)"),docs/design-review.md:106-115(Principle 12: performance claims require equivalent baselines and actual Helios service measurements), anddocs/performance-work.md:142-144("Measure complete graph latency, including synchronization and resource contention, at each relevant row capacity"). Priority reviewer@voipmonitorhas already issuedCHANGES_REQUESTEDon this requirement. - Required before merge: Qualify an exported TP/overlap core end-to-end via
flare runwith before/after serving latency (covering both collective overlap and heavyauxiliary_streamcompute branches to confirm no scheduling regression), and confirm that the Helios-instantiated executable reportscuGraphExecGetFlags == 9.
Should Fix
-
record_export_graphsilently breakskeep_graph=False/_flare_graph_metadatagraphs until export (ignition/preparation/runtime_core.py:208-243,:256-269,:282-292).record_export_graphcallsinstantiate_graph(graph)(which explicitly accepts_flare_graph_metadatagraphs created bycapture_graph(retain_graphs=True)withkeep_graph=False, whose CUDA template Torch releases upon instantiation) and then unconditionally setsgraph._flare_instantiation_flags = prior_flags | instantiation_flags.- On
main,_graphs()fell through to lines 288-292 and emittedgraph=0, executable=executable, which Heliopause resolved viarecorded_graph(graph.executable)(heliopause/src/export/capture.rs:775-786). With this PR,_graphs()(runtime_core.py:282-287) takes theflags is not Nonebranch first and callsint(graph.raw_cuda_graph()), crashing late withRuntimeError("template was released") or emittinggraph=0withinstantiate_flags=9(rejected atheliopause/src/export/capture.rs:2823). - Fix: When
instantiation_flags is not None(or unconditionally if the kwarg is removed), validate up front beforeretain_object(...)andinstantiate_graph(...)thatgetattr(graph, "_flare_graph_metadata", None) is Noneand thatgraph.raw_cuda_graph()returns a live nonzero template handle (matching@voipmonitorMajor #2), and add a unit test covering that rejection.
-
Stale
_flare_instantiation_flagssurvivesinstantiation_flags=Nonere-recording andgraph.reset()(ignition/preparation/runtime_core.py:238-243,:282-287,:153-166).- Unlike
_RecordedGraphMetadata.executable, which clears itself on reset viaregister_destroy_callback(runtime_core.py:166),_flare_instantiation_flagsis never cleared whenrecord_export_graphis called withinstantiation_flags=Noneon a previously recorded graph, nor whengraph.reset()tears down the graph. Because_graphs()prefers_flare_instantiation_flagsover the live executable, a reused graph would silently serialize stale flags. - Fix: Clear any pre-existing
_flare_instantiation_flagsoninstantiation_flags=None(or at entry after pre-validation), and clear it on reset via aweakref-guarded destroy callback (do not capture a strong reference tographin the callback, which would break GC reclamation tested intest_export_graph_retains_external_owners_until_releaseattests/preparation/test_capture_graph_metadata.py:335-339).
- Unlike
-
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_graphrunsgraph.retain_object(...)andinstantiate_graph(graph)before querying_executable_instantiation_flags(graph)and validatingprior_flags(necessarily, sincecuGraphExecGetFlagsrequires an instantiatedCUgraphExec). On unsupportedprior_flags,graphremains instantiated with owners retained and_flare_instantiation_flagsunset. While retaining owners until reset is consistent withtest_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", andtest_capture_graph_metadata.py:244-248asserts nothing about post-failure state forunsupported_exec.- Two additional description statements contradict the code (
AGENTS.md:88-112,docs/design-review.mdPrinciple 16):- "Passing
instantiation_flags=Nonekeeps executable-derived flags for startup tuning graphs" is false: startup tuning graphs callcapture_graph+instantiate_graph(tests/preparation/test_recorded_export_graph_cuda.py:62-65) and never callrecord_export_graph. - Before: misstates
main(record_export_graphonmainrecorded no flags;_graphs()passedexecutableto Heliopause, which readexecutable_flagsatheliopause/src/export/capture.rs:791-794).
- "Passing
- Fix: Assert the intended post-failure contract for
unsupported_execintests/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
-
Remove the unused
instantiation_flagskeyword 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 noinstantiation_flagsargument, and the only caller cited forinstantiation_flags=Nonein the PR description (startup tuning graphs) does not callrecord_export_graph. Removing the speculative kwarg, itsNone/0branches, and its duplicated input-validation guard trims ~15 production lines (AGENTS.md:188-190). Keep it only if a concrete caller (for example inhyperflare-recipes) actually requires per-call overrides — and name that caller in the PR description.
- The sole in-repo production caller (
-
Reuse
PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGSin_graphs()(ignition/preparation/runtime_core.py:284)._graphs()still hardcodesflags & ~9with the identicalValueErrorstring duplicated fromrecord_export_graph:229. Replace~9with~PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGSso the permitted mask has one definition in Python (matching@voipmonitorNit #4).
Nits
- Lazily cache
_Cuda()instead of reopeninglibcuda.so.1/nvcuda.dllper graph (ignition/preparation/runtime_core.py:200-205,:76-78)._executable_instantiation_flagsconstructs a fresh_Cuda()on every call, whereasCoreStorage(ignition/preparation/core_storage.py:76) andVirtualStorage(ignition/preparation/virtual_storage.py:27) instantiate_Cuda()once and reuse it. Cache a module-level_Cudainstance lazily (matching@voipmonitorNit #4).
Verified passes
- Layer boundary & runtime simplicity: The flag decision stays in Ignition (
ignition/preparation/runtime_core.py); Helios stays model-agnostic with zero Rust changes (helios/src/runtime_core/format.rs:495,helios/src/runtime_core/mod.rs:984-1013,:1215-1219). - Core compatibility & downstream wiring: Existing
flags=1cores still load unchanged;main's Heliopause and Helios validators already acceptflags & !9 == 0(heliopause/src/export/capture.rs:589,:2823;helios/src/runtime_core/format.rs:495),heliopause/src/export/capture.rs:462,544-569already captures kernel-node attribute8(CU_LAUNCH_ATTRIBUTE_PRIORITY), andhelios/src/runtime_core/mod.rs:984-1013already replays it. - No new captured-graph op family or per-model branch: No new op contract approval is implicated, and no recipe allowlist or per-model switch is added.
- Live SM120 CUDA export FFI confirmed: Priority reviewer
@voipmonitorranFLARE_RUN_CUDA_TESTS=1 pytest -q tests/preparation/test_recorded_export_graph_cuda.pyon SM120 (1 passed,3.29s), confirming realcuGraphExecGetFlagsFFI andflags_by_name == {"decode": 9, "tune": 1}. - Windows portability:
_Cuda(ignition/preparation/runtime_core.py:78) already handlesnvcuda.dllonnt. - PR metadata: Required four-part ordering,
Discord: Doonercontact line, and honest disclosure of unrun live GPU qualification are present.
Dropped on verification
- Candidate B2 as a Blocker (unused
instantiation_flagskwarg / duplicated guard): Downgraded to Subtract / Simplify; an optional kwarg on a publicignitionhelper (potentially consumable by externalhyperflare-recipes) is not a correctness, safety, or broken-contract blocker, and capture-timeprior_flagsvalidation fails earlier with a distinct message than_graphs(). - Candidate B1's "enable only when a recorded node carries a priority attribute" trigger & Value Proposition's "make it an opt-in switch": Refuted; on graphs without
auxiliary_stream, all nodes already have default priority0matching Helios's default-priority launch stream (docs/prefix-cache-offload.md:855-857), soUSE_NODE_PRIORITYis already a no-op there — the real regression risk is on graphs that do capture heavy compute onScratchArena.auxiliary_stream(docs/core-design.md:852-853,docs/performance-work.md:133-138), where a priority-attribute trigger would still fire; andAGENTS.md:209-212/docs/design-review.md:58disallow rescuing unmeasured changes with default-false opt-ins. - Candidate T2 (delete
_executable_instantiation_flagsand hardcode8, dropping bit1AUTO_FREE_ON_LAUNCH): Dropped; whileheliopause/src/export/capture.rs:607-679currently rejects MemAlloc/MemFree node kinds (CUDACUgraphNodeTypekinds 10/11, not 3/4 as upstream stated), stripping bit1changes exported metadata from9to8, diverges from PyTorch's instantiated flags andtune: 1, and alters the PR's stated flag-preservation semantics rather than removing dead code. - Candidate T3 (delete
test_capture_forwards_export_sets_node_priority_instantiation_flag): Dropped;tests/preparation/test_capture_graph_metadata.py:258-303is the only CPU integration test exercising theexporting=Truebranch ofcapture_forwards(ignition/preparation/capture.py:170,192-193) into_graphs()(the neighboring test at lines 165-194 passeswarmup_storage=None). - Candidate S4 (monkeypatched
_executable_instantiation_flags/ opt-in CUDA test gap): Dropped;@voipmonitorverified the realcuGraphExecGetFlagsFFI on SM120 viaFLARE_RUN_CUDA_TESTS=1 pytest -q tests/preparation/test_recorded_export_graph_cuda.py, matching the repo's opt-in GPU test convention, and adding a mock for_Cuda.callprovides minimal signal (AGENTS.md:194-196). - Candidate S5's "
_Cudabypassescuda.bindings" claim: Dropped;_Cuda(ignition/preparation/runtime_core.py:76-90) is an established driver-API helper in this module already used byignition/preparation/core_storage.py:76andignition/preparation/virtual_storage.py:27(only the per-call_Cuda()instantiation survives as a Nit). - Candidate N1(d) ("Candidate
61f64f18onmain" phrasing): Dropped as mechanical prose nitpick with no technical impact.