Repository navigation
ignition: set USE_NODE_PRIORITY flag on exported CUDA graphs - #581
FujitsuPolycom wants to merge 1 commit into
Conversation
voipmonitor
left a comment
There was a problem hiding this comment.
Review & Live SM120 CUDA Test Report (commit 61f64f18)
Verdict: Request changes — end-to-end Heliopause/Helios wiring is already in place (flags & !9 == 0, kernel-node attribute id = 8 CU_LAUNCH_ATTRIBUTE_PRIORITY, forward- and backward-compatible with existing cores) and the live SM120 CUDA export test passes, but two items need attention before merge.
Automated & Live SM120 CUDA Test Results
- CPU
pytest -q tests/preparation/test_capture_graph_metadata.py— 12 passed, 0 failed. - Live SM120 CUDA
FLARE_RUN_CUDA_TESTS=1 pytest -q tests/preparation/test_recorded_export_graph_cuda.py— 1 passed (3.29s), confirming realcuGraphExecGetFlagsDriver API FFI andflags_by_name == {"decode": 9, "tune": 1}.
Findings
- [Major] Qualify live exported-core
flare runbehavior (docs/design-review.mdPrinciple 12):
EnablingCUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITYglobally activates CTA-level preemption for every kernel captured onScratchArena.auxiliary_stream(ignition/preparation/scratch.py:83-105) across all recipes. That is desirable for small TP collectives, but any recipe launching heavy compute onauxiliary_streamcould see scheduling regressions. Please verify with an end-to-end exported TP core served viaflare run(and ideally add a Helios load+replay check assertingcuGraphExecGetFlags == 9on the Helios-instantiated executable). - [Major]
record_export_graphdoes not validatekeep_graph=False/_flare_graph_metadatagraphs (ignition/preparation/runtime_core.py:208-242):
record_export_graphcallsinstantiate_graph(graph)(which supports_flare_graph_metadata/keep_graph=False) and then unconditionally setsgraph._flare_instantiation_flags = prior_flags | instantiation_flags. If a caller passes akeep_graph=Falsegraph,record_export_graphsucceeds and fails later in_graphs()/ Heliopause (graph=0). Wheninstantiation_flags is not None, validate up front thatgetattr(graph, "_flare_graph_metadata", None) is Noneandint(graph.raw_cuda_graph()) != 0. Also consider clearing any pre-existing_flare_instantiation_flagswheninstantiation_flags=None. - [Minor] PR description inaccuracies (Principle 16):
- States "rejecting unsupported bits on either source before mutating graph state" — for
prior_flags,graph.retain_object(...)andinstantiate_graph(graph)have already run before_executable_instantiation_flags(graph)is checked. - States "Passing
instantiation_flags=Nonekeeps executable-derived flags for startup tuning graphs" — startup tuning graphs do not callrecord_export_graphat all (they callcapture_graph+instantiate_graph).
- States "rejecting unsupported bits on either source before mutating graph state" — for
- [Nit] Reuse
PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGSin_graphs()(runtime_core.py:279) instead of hardcodingflags & ~9, and lazily cache_Cuda()instead of reopeninglibcuda.so.1per graph.
|
A case file has been opened for 581. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Why:
Exported serving graphs capture overlap branches on high-priority CUDA
streams such as `ScratchArena.auxiliary_stream`, which require CUDA's
`USE_NODE_PRIORITY` instantiation flag (`8`) so Helios honors captured
kernel-node priorities during `cuGraphInstantiateWithFlags` without
discarding permitted flags already present on the captured executable.
Explicit instantiation flags also require a retained CUDA graph template
(`keep_graph=True` without post-instantiation release metadata) so export
fails up front instead of producing a zero template handle in Heliopause.
What:
- `ignition/preparation/runtime_core.py`:
- Before: `record_export_graph` retained owners and instantiated the
graph without serializing `USE_NODE_PRIORITY`, so exported serving
graphs kept only executable-derived flags (`1`).
- After: When `instantiation_flags` is an integer bitmask (default `8`,
`CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY`), `record_export_graph`
validates `instantiation_flags` against
`PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS` (`9`, bits `1` and `8`),
rejects graphs carrying `_flare_graph_metadata` or a released/zero
`raw_cuda_graph()` handle, and checks pool ownership before retaining
owners or instantiating the graph. After instantiation, it queries
`cuGraphExecGetFlags` via a lazily cached `_Cuda` driver wrapper,
validates executable flags against
`PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS`, and records
`prior_flags | instantiation_flags`. Passing `instantiation_flags=None`
clears any prior `_flare_instantiation_flags` attribute so callers fall
back to executable-derived or recorded graph metadata. `_graphs` also
reuses `PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS` and rejects zero
template handles when `_flare_instantiation_flags` is present.
- `helios/src/runtime_core/` and `tests/preparation/`:
- Add CPU unit coverage for template-retention guards, clearing stale
`_flare_instantiation_flags`, `_Cuda` caching, and Helios flag bounds,
plus an end-to-end signed-core CUDA fixture and Helios
`NativeResources::load` + `ReplayWorker` test verifying via CUPTI that
`cuGraphInstantiateWithFlags` receives `9` on the serving graph and `1`
on the startup tuning graph (while `cuGraphExecGetFlags` retains
`AUTO_FREE_ON_LAUNCH` `1`), alongside exact replay of main- and
auxiliary-stream branches.
- Compatibility: Existing signed cores keep their recorded graph flags and
load without re-export or re-signing. Startup tuning graphs continue to
use `capture_graph` and `instantiate_graph` directly (`flags = 1`).
Result:
Expected benefit: Helios instantiates newly exported serving graphs with
`USE_NODE_PRIORITY` (`8`) while preserving `AUTO_FREE_ON_LAUNCH` (`1` ->
`9`) when set on the captured executable. Single-GPU signed-core load,
instantiation-flag verification, and replay were validated on SM120; live
multi-GPU serving throughput was not measured in isolation on this commit.
Evidence:
- `python -m pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py tests/preparation/test_capture_graph_metadata.py tests/preparation/test_runtime_core.py tests/preparation/test_preparation_reclamation.py tests/preparation/test_capture_stream_isolation.py`: 70 passed, 14 skipped, 0 failed.
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib runtime_core`: 182 passed, 11 ignored, 0 failed.
- `FLARE_RUN_CUDA_TESTS=1 python -m pytest -q -rs tests/preparation/test_recorded_export_graph_cuda.py` on `1x NVIDIA GeForce RTX 5090` (SM120): 2 passed, 0 skipped, 0 failed (verifying `flags_by_name == {"decode": 9, "tune": 1}`, negative auxiliary-stream kernel priority, CUPTI-observed `cuGraphInstantiateWithFlags` flags `9` on Helios-instantiated `"decode"` and `1` on `"tune"`, retained `cuGraphExecGetFlags == 1`, and bit-exact `ReplayWorker` outputs).
- Limitations: Multi-GPU tensor-parallel `flare run` serving and per-recipe `ScratchArena.auxiliary_stream` scheduling qualification remain open hardware qualification.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4); design-review=c3a9
Signed-off-by: FujitsuPolycom <[email protected]>
61f64f1 to
18312bd
Compare
|
@voipmonitor Addressed at
Could you take another look at |
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe downstream Heliopause/Helios pipeline already accepts
Have your agent review the Full Review for complete verified findings, To opt out, include |
Why
Serving forwards capture overlap branches on high-priority CUDA streams such as
ScratchArena.auxiliary_stream(cuStreamCreateWithPriorityat the context's greatest priority), which recordsCU_LAUNCH_ATTRIBUTE_PRIORITY(id = 8) on those kernel nodes. During native serving startup, Helios must pass CUDA'sCUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY(8) tocuGraphInstantiateWithFlagsso captured per-node priorities are honored instead of inheriting the launch stream's priority, without discarding permitted flags already carried by the captured executable (CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH,1). In addition, explicit instantiation flags require a retained CUDA graph template (keep_graph=Truewithout post-instantiation release metadata) so invalid callers fail up front rather than serializing a zero template handle into Heliopause.What changed
ignition/preparation/runtime_core.py:record_export_graphretained owners and instantiated the graph without settingUSE_NODE_PRIORITY, so exported serving graphs recorded only executable-derived flags (1), and_Cuda()reopened the CUDA driver library on each call.instantiation_flagsis an integer bitmask (default8,CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY),record_export_graphvalidatesinstantiation_flagsagainstPERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS(9, bits1and8matchinghelios/src/runtime_core/format.rs), rejects graphs carrying_flare_graph_metadata(keep_graph=Falsepost-instantiation recording) or a released/zeroraw_cuda_graph()handle, and checks CUDA pool ownership before callingretain_objectorinstantiate_graph. After instantiation, it clears any prior_flare_instantiation_flagsattribute, readsprior_flagsviacuGraphExecGetFlagsthrough a lazily cached_Cudawrapper (_cuda_driver), validatesprior_flagsagainstPERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS, and setsgraph._flare_instantiation_flags = prior_flags | instantiation_flags(1 | 8 = 9when bit1was present). Passinginstantiation_flags=Noneclears any pre-existing_flare_instantiation_flagsoverride ongraphso_graphsfalls back to executable-derived or_flare_graph_metadataflags._graphsalso reusesPERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGSand rejects zeroraw_cuda_graph()handles when_flare_instantiation_flagsis present.helios/src/runtime_core/,helios/tests/node_priority_core_fixture.py, andtests/preparation/:_flare_graph_metadata/keep_graph=False/raw_cuda_graph() == 0rejection prior to graph mutation, clearing stale_flare_instantiation_flagsoninstantiation_flags=Noneor unsupportedprior_flags,_cuda_drivercaching across graphs, andCore::validateflag bounds inhelios/src/runtime_core/format.rs.helios/tests/node_priority_core_fixture.py) and Helios runtime test (helios/src/runtime_core/node_priority_tests.rs, driven fromtests/preparation/test_recorded_export_graph_cuda.py) that captures a"decode"graph with both main-stream (priority = 0) andScratchArena.auxiliary_stream(priority < 0) kernel nodes alongside a"tune"TuningGraph(capture_graph+instantiate_graph,flags = 1), loads the signed payload core throughNativeResources::load, verifies via CUPTI (cuGraphInstantiateWithFlagsexit callback) that Helios instantiates"decode"withflags = 9and"tune"withflags = 1(whilecuGraphExecGetFlagsretainsAUTO_FREE_ON_LAUNCH1), and verifies bit-exactReplayWorkerexecution across poisoned-output replays.record_export_graph; they continue to usecapture_graphandinstantiate_graphdirectly (flags = 1).Claimed benefit and result
USE_NODE_PRIORITY(8) combined with permitted executable flags (1 | 8 = 9whenAUTO_FREE_ON_LAUNCHis present), honoring capturedCU_LAUNCH_ATTRIBUTE_PRIORITYattributes while preserving startup tuning graph flags (1) and existing signed-core compatibility. End-to-end single-GPU signed-core load,cuGraphInstantiateWithFlagsverification, andReplayWorkerexecution were validated on1x NVIDIA GeForce RTX 5090 (SM120); multi-GPU serving throughput was not measured in isolation on this PR.Supporting evidence and limitations
Tested at candidate commit
18312bd04a34df8750637b8500b17e1eca50984aatopmain(ba3afb13a7e9836080c23eadf8e1c17ee96e6e7a):python -m pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py tests/preparation/test_capture_graph_metadata.py tests/preparation/test_runtime_core.py tests/preparation/test_preparation_reclamation.py tests/preparation/test_capture_stream_isolation.py: 70 passed, 14 skipped, 0 failed.cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib runtime_core: 182 passed, 11 ignored, 0 failed (0warnings in touched files).1x NVIDIA GeForce RTX 5090, SM120, CUDA 13):FLARE_RUN_CUDA_TESTS=1 python -m pytest -q -rs tests/preparation/test_recorded_export_graph_cuda.py: 2 passed, 0 skipped, 0 failed. Verifies staged rank sources (flags_by_name == {"decode": 9, "tune": 1}), signed payload coreCU_LAUNCH_ATTRIBUTE_PRIORITY(id = 8) node attributes (priority < 0onScratchArena.auxiliary_streamand0on the main stream), CUPTI-observedcuGraphInstantiateWithFlagsarguments (9on"decode"and1on"tune", while CUDA'scuGraphExecGetFlagsretainsAUTO_FREE_ON_LAUNCH1after consumingUSE_NODE_PRIORITY8at instantiation), and0-ULPbit-exactReplayWorkeroutputs across poisoned-buffer replays.1x NVIDIA GeForce RTX 5090(SM120, single-rank runtime core). Multi-GPU tensor-parallelflare runserving and per-recipeScratchArena.auxiliary_streamCTA-preemption scheduling qualification across full model checkpoints remain open hardware qualification.Reproduction commands (plain local NVMe verified)
Discord: Dooner