Conventions scratchpad · NVIDIA/hyperflare-inference #581

Raw Markdown for agents: https://autobot.eidonix.com/p/7c316d7f-fc97-4135-9c3c-495ade5a9a51.md

#1 [high] Should fix: _graphs duplicates the new PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS constant as literal 9

ignition/preparation/runtime_core.py (PR head, commit 61f64f1):

#2 [high] Should fix: executable-derived flag rejection happens after the graph is already mutated, contradicting the PR claim

PR description claims the tests cover "rejecting unsupported bits on either source before mutating graph state". Code (ignition/preparation/runtime_core.py:224-243, head 61f64f1):

#7 [high] Research summary

Reviewed PR #581 (ignition: set USE_NODE_PRIORITY on exported CUDA graphs) through the conventions-and-duplication lens: read ignition/preparation/runtime_core.py in full, its only caller ignition/preparation/capture.py, the Heliopause/Helios consumers (heliopause/src/export/{capture.rs,mod.rs}, helios/src/runtime_core/{format.rs,mod.rs}), both changed test files, and the governing docs (charter, AGENTS.md, docs/design-review.md, docs/runtime-core-design.md, docs/core-format-design.md, prose skill). Six findings recorded in the scratchpad, none blocking.

Two "should fix" findings. First, the PR introduces PERMITTED_CUDA_GRAPH_INSTANTIATE_FLAGS and uses it twice in record_export_graph, but leaves the pre-existing validator in _graphs (runtime_core.py:245-250) on the bare literal ~9 with the identical error message, so the mask and message now exist in three places in one module — the new constant should be used there, ideally behind one shared validator. Second, the executable-derived flag rejection (lines 238-241) runs after retain_object and instantiate_graph, so it mutates graph state before raising; that contradicts the PR's own claim that unsupported bits are rejected "on either source before mutating graph state", and the new test at test_capture_graph_metadata.py:244-248 asserts only the exception while its neighbours assert no partial mutation.

The remaining findings are nits: the new _executable_instantiation_flags bypasses the pinned cuda.bindings driver API used by capture.py:43-47 and scratch.py:88-99 (and constructs _Cuda, i.e. dlopens libcuda, per call), so it re-hardcodes flag values 1/8 the bindings already name; the fixture monkeypatches that helper, leaving the real cuGraphExecGetFlags call covered only by the opt-in GPU test; the new instantiation_flags=None branch has no production caller, and the description's "startup tuning graphs" path uses capture_graph instead; and the new capture_forwards test clones the existing mocked capture harness in the same file although the end-to-end flag value is already asserted in the CUDA test.

No charter or design-doc violation (the change stays on the preparation side; the 9-bit mask matches helios/src/runtime_core/format.rs:495 and Heliopause's validation), and no evidence of prompt-injection attempts in the PR material.

#8 [high] Context: PR #581 scope, changed files, and verified cross-crate consistency of the 9-bit mask

PR #581 "ignition: set USE_NODE_PRIORITY flag on exported CUDA graphs" (author FujitsuPolycom, open, ready for review, changes requested by voipmonitor, head 61f64f1, base main 167f22c). 3 files, +137/-7:

Verified consistency (so the report can say the change is architecturally aligned):

#3 [medium] Should fix: new CUDA entrypoint bypasses the cuda-python bindings precedent and constructs _Cuda per call

ignition/preparation/runtime_core.py:200-205 (head 61f64f1) adds _executable_instantiation_flags that does:

_Cuda().call("cuGraphExecGetFlags", C.c_void_p(executable), C.byref(flags))

Issues against repository precedent:

  1. _Cuda() loads and dlopens libcuda each call (runtime_core.py:76-90); every other ignition module keeps one instance (core_storage.py:76 self.cuda = _Cuda(), virtual_storage.py:27). Construction per call is gratuitous.
  2. Disk is writeonly set to 8 in Windows loader; on Windows WinDLL("nvcuda.dll", winmode=0x800) gives LOAD_LIBRARY_SEARCH... anyway.
  3. Most important: the repository's established pattern for driver entrypoints when a handle + flags query is needed is the typed cuda.bindings.driver API, which is a pinned dependency (pyproject.toml:26 cuda-python==13.3.1). ignition/preparation/capture.py:43-47 uses from cuda.bindings import driver as cuda; cuda.cuStreamCreate(...) with cuda.CUresult.CUDA_SUCCESS; ignition/preparation/scratch.py:88-99 does the same; ignition/components/readiness.py:33 uses the bindings. _Cuda.call is used for the raw VMM calls that have no bindings alternative in that code path, and it also raises rather than returning a status. The new helper adds a third style for a call for which cuda.bindings exposes cuGraphExecGetFlags(CUgraphExec, ...) and cuda.CUgraphInstantiate_flags enumerators (CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH / USE_NODE_PRIORITY), so the hand-written magic numbers 1/8 and the reimplementation of the flag mask are avoidable. Cite precedent: capture.py:43-47 and scratch.py:88-99. Severity: should fix (duplication of an existing mechanism; also the literals).

#4 [medium] Nit: nothing exercises the real cuGraphExecGetFlags call except the opt-in CUDA test

tests/preparation/test_capture_graph_metadata.py:113 (head 61f64f1) — the fixture does monkeypatch.setattr(runtime_core, "_executable_instantiation_flags", lambda graph: graph.exec_flags). That means the one line that actually calls cuGraphExecGetFlags and the _Cuda path are never executed by any test except the opt-in GPU test test_recorded_export_graph_cuda.py (skipif FLARE_RUN_CUDA_TESTS!=1, line 14) which the PR author reports as skipped (15 skipped) and lists live CUDA export as open qualification. AGENTS.md:194-199 ("Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness") and design-review.md:185-188 apply. Also the fixture's Graph.exec_flags default of AUTO_FREE_ON_LAUNCH bakes in the real-world PyTorch value, so the mocked tests only prove arithmetic, not that cuGraphExecGetFlags returns 1 for a Torch-instantiated graph — which is what the new GPU assertion flags_by_name == {"decode": 9, "tune": 1} depends on. Severity: nit (test-scope note; PR already discloses the open GPU qualification).

#5 [medium] Nit: instantiation_flags parameter has no caller other than tests, and its description misdescribes the tuning-graph path

ignition/preparation/runtime_core.py:208-243 (head 61f64f1): record_export_graph(..., instantiation_flags=CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY) adds a keyword switch, and the None branch at lines 238/240-242 is the only path that preserves executable-derived flags. No production caller passes it: the sole caller is ignition/preparation/capture.py:193 record_export_graph(graph, warmup_storage, owners=(function,)), which takes the default; startup tuning graphs are built through capture_graph + instantiate_graph (runtime_core.py:246-269) and never reach this function, so the "Passing instantiation_flags=None keeps executable-derived flags for startup tuning graphs" sentence in the PR description does not describe anything in this repository (the None case appears only in tests, test_capture_graph_metadata.py:240). AGENTS.md:188-193 rejects "configuration switches without a concrete requirement" and "speculative compatibility". Severity: nit — either drop the parameter (hard-code the priority bit plus executable-derived bits) or name the caller that needs it in the description. Follows the module's own precedent of optional keywords (e.g. capture_graph(*, retain_graphs=False)), so this is a scope nit, not a pattern departure.

#6 [low] Nit: new capture_forwards test duplicates the existing mocked capture harness

tests/preparation/test_capture_graph_metadata.py:258-302 (head 61f64f1) test_capture_forwards_export_sets_node_priority_instantiation_flag repeats, almost line for line, the capture_forwards harness of the existing test_shared_capture_records_after_all_warmups_without_reinstantiation (same file, lines 165-194): same stream = SimpleNamespace(wait_stream=..., synchronize=...), same monkeypatching of torch.cuda.{current_stream,stream,synchronize,graph,mem_get_info,memory_allocated,memory_reserved}, same capture._warmup_stream/capture._seed_warmup_workspaces stubs, same capture_forwards(..., compile_decoder=False, retain_graphs=True) call. It differs only by adding pool=/warmup_storage= and by asserting on _graphs(graphs). The end-to-end claim (a serving graph exports with 9) is already asserted against a real CUDA graph in tests/preparation/test_recorded_export_graph_cuda.py:85-87 (flags_by_name == {"decode": 9, "tune": 1}). Severity: nit. Note that repeating this setup inline is the file's established pattern (also tests/preparation/test_capture_roce_wait.py:37-46, test_preparation_reclamation.py:38-70), so the precedent cuts both ways; a small _capture_streams-style helper as in tests/preparation/test_capture_stream_isolation.py:22-51 would carry the new case without the clone.