Correctness, Contracts & System-Level Consequences — PR #690
Key findings
- Major — a stale/nonexistent inherited
CUDA_HOMEsilently disables the whole toolkit environment.ignition/cli/environment.py:60-67(snapshot) accepts the inherited value on truthiness alone, with nois_dir()check, unlike the/usr/local/cudabranch two lines below which does checkis_dir(). On a host that previously worked through/usr/local/cuda, a leftover exportedCUDA_HOMEnow produces noTRITON_PTXAS_PATHand noCPATHat all — strictly worse thanmain— and the new testtests/cli/test_environment.py:109-120freezes that no-op as the contract. No doc states the no-existence-check rule. - Major (conditional on which commit is really at head) —
TRITON_PTXAS_PATHprecedence reversal. In the snapshot this environment resolves,environment.py:78-81overwrites a non-blank ambientTRITON_PTXAS_PATHwhenever[paths] cudais set, whereasmain:67never touches an ambient value.test_environment.py:62-75asserts the new, reversed behaviour. This directly contradicts the PR body's "TRITON_PTXAS_PATH… unchanged". The Discovery Dossier reports this exact condition was removed at head39796ea; it must be re-checked against the true head before merge. - Minor — the three docs are not mutually consistent in this snapshot.
docs/cli-design.md:46-51still reads "No environment variables. Flare reads none, with one exception:CUDA_VISIBLE_DEVICES", whileAGENTS.md:461-472already documentsCUDA_HOMEpreservation. The dossier reports both were reconciled at39796ea; same re-check applies. - Minor —
apply()cannot distinguish an inheritedCUDA_HOMEfrom one it wrote itself (:61reads the sameos.environslot that:69writes), so a second call in one process can never un-set a value a previous call wrote. - Clean: Windows parity, blank-value removal,
[paths] cudaprecedence, and the absence of any concurrency, latency, memory, metric, or contract impact — stated plainly in §4 below.
0. Citation basis — important discrepancy, please read
The pr/690 ref that this environment resolves is not the head the Dossier describes. Concretely:
ignition/cli/environment.pyin the resolvable snapshot containsconfigured_cuda = configuration.directory("cuda")and the ptxas guardif ptxas.is_file() and (configured_cuda is not None or not os.environ.get("TRITON_PTXAS_PATH", "").strip()):(:58,:78-81) — the exact construct the Dossier says was retracted/removed at39796ea.docs/cli-design.md:46-51in the snapshot still carries the pre-PR text, whileAGENTS.md:461-472carries the post-PR text — mutually contradictory, which the Dossier says was resolved at39796ea.tests/cli/test_environment.pyis 150 lines with 6 test functions and 10 parametrized cases and per-test@pytest.mark.skipif(os.name == "nt")decorators (:61, :78, :92, :109, :123, :138); the Dossier reports 176 lines, a module-levelpytestmark, and 12 cases at the head.search_historyonpr/690fails:error: git: error: Could not read c513e46a79f3b6ac510235aaf09bcf055b841958 / fatal: Failed to traverse parents of commit 682152b61e5a3364d7403870c47be7d0512bde7b, andread_filerejects the 7-digit short SHA39796ea(a ref is a 40-digit commit id, "main" …, or "pr/<number>"). I could not open the stated head by SHA.
Each finding below is therefore tagged [snapshot-verified] (I opened the lines myself this session) or [head-cited] (from the prior research pass at 39796ea, not re-openable here). Findings 1 and 4 are unaffected by the discrepancy; findings 2 and 3 are the ones that hinge on it.
1. Correctness, safety & platform parity
F1 — Major — inherited CUDA_HOME is never existence-checked, so a stale value silently disables toolkit env [snapshot-verified]
ignition/cli/environment.py:58-69 (whole resolution block, quoted verbatim as read at pr/690):
configured_cuda = configuration.directory("cuda")
cuda = configured_cuda
if cuda is None and os.name != "nt":
inherited_cuda = os.environ.get("CUDA_HOME", "").strip()
if inherited_cuda:
cuda = Path(inherited_cuda)
elif _DEFAULT_LINUX_CUDA.is_dir():
cuda = _DEFAULT_LINUX_CUDA
else:
os.environ.pop("CUDA_HOME", None)
if cuda is not None:
os.environ["CUDA_HOME"] = str(cuda)
Compare with main (ignition/cli/environment.py:54-58 at main):
cuda = configuration.directory("cuda")
if cuda is None and os.name != "nt" and Path("/usr/local/cuda").is_dir():
cuda = Path("/usr/local/cuda")
if cuda is not None:
os.environ["CUDA_HOME"] = str(cuda)
The /usr/local/cuda branch is validated (_DEFAULT_LINUX_CUDA.is_dir(), :64); the inherited branch (:62-63) is not. The subsequent derivations then no-op because the paths do not exist: :78 if ptxas.is_file() and … and :83 if include.is_dir().
The new test pins this as intended behaviour — tests/cli/test_environment.py:109-120, verbatim:
def test_inherited_cuda_home_without_local_files_does_not_fall_back_to_default(clean_environment, monkeypatch):
inherited = clean_environment / "custom-cuda" # never created
default = _make_toolkit(clean_environment / "default-cuda")
monkeypatch.setattr(environment, "_DEFAULT_LINUX_CUDA", default)
monkeypatch.setenv("CUDA_HOME", str(inherited))
environment.apply(_load_config(clean_environment), ())
assert os.environ["CUDA_HOME"] == str(inherited)
assert "TRITON_PTXAS_PATH" not in os.environ
assert "CPATH" not in os.environ
Impact. For the population of hosts that main served correctly through /usr/local/cuda and that also carry a stale CUDA_HOME (shell profile left over from another toolkit, container env, a previous project), this PR removes TRITON_PTXAS_PATH and CPATH entirely, where main set both from /usr/local/cuda. It is the mirror image of #636: #636 complains that an explicit CUDA_HOME is ignored; this silently honours one that points at nothing. Downstream, the bogus root is handed to torch.utils.cpp_extension.CUDA_HOME-derived paths: ignition/preparation/kv_codec.py:21-38 reads it as its first candidate (:26-28 candidates.append(Path(CUDA_HOME) / "bin" / "nvcc")). Note the blast radius is bounded there because :32 unconditionally appends Path("/usr/local/cuda/bin/nvcc") as a last candidate — so _find_nvcc will usually still succeed; the damage is to include/library roots that trust CUDA_HOME with no fallback. The docs read as a validated chain and do not disclose the rule: AGENTS.md:468-471 "when [paths] cuda is unset on non-Windows hosts, it preserves a non-empty inherited CUDA_HOME before falling back to /usr/local/cuda" — "non-empty", never "existing".
Fix (pick one, and make the other docs match):
- Preferred:
if inherited_cuda and Path(inherited_cuda).is_dir():— a nonexistent inherited path then falls through to the/usr/local/cudabranch and finally to thepop, restoringmain's behaviour for the stale-env population while still fixing #636. - Or keep the as-is policy and make it explicit: state "a non-empty inherited
CUDA_HOMEis used verbatim, without an existence check" indocs/cli-design.mdandAGENTS.md:468-471, and rename the test so it asserts a documented policy rather than freezing an accident.
F2 — Major (snapshot only) — TRITON_PTXAS_PATH precedence reversal [snapshot-verified here; Dossier says removed at head]
ignition/cli/environment.py:77-81 (snapshot) versus main:66-68:
ptxas = cuda / "bin/ptxas"
if ptxas.is_file() and (
configured_cuda is not None or not os.environ.get("TRITON_PTXAS_PATH", "").strip()
):
os.environ["TRITON_PTXAS_PATH"] = str(ptxas)
main is if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ:. The snapshot therefore overwrites an ambient, non-blank TRITON_PTXAS_PATH any time [paths] cuda is configured. The test asserts it — tests/cli/test_environment.py:62-75:
def test_configured_cuda_overrides_inherited_cuda_home_ptxas_and_default_toolkit(clean_environment, monkeypatch):
...
monkeypatch.setenv("TRITON_PTXAS_PATH", "/ambient/ptxas")
...
assert os.environ["TRITON_PTXAS_PATH"] == str(configured / "bin/ptxas")
Impact. A user pinning ptxas from a specific toolkit gets silently redirected to [paths] cuda's ptxas — the wrong assembler version for their GPU, which surfaces as JIT build failures or a wrong-architecture cubin in flashinfer/Triton builds rather than a clear error. It also contradicts the PR body verbatim: "TRITON_PTXAS_PATH (if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ), CPATH prepending, and Windows (os.name == "nt") behavior are unchanged."
Status. The Discovery Dossier's amendment #1 reports this condition was removed at 39796ea, that this finding was "RETRACTED", and that environment.py:75 at pr/690 equals main:67. My snapshot contradicts that. Fix: restore if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ: and adjust test_environment.py:62-75 to assert the ambient value is kept. Action for adjudication: confirm the true content of :75-81 at 39796ea before relying on the retraction.
F3 — Minor — doc self-contradiction in this snapshot [snapshot-verified]
docs/cli-design.md:46-51:
- **No environment variables.** Flare reads none, with one exception:
`CUDA_VISIBLE_DEVICES` restricts which GPUs the caller exposed, which changes
the GPU each index names, so Flare inspects it to interpret `--gpus`.
versus AGENTS.md:468-471, which already documents the exception. A reader following docs/cli-design.md (the canonical spec, and what model-preparation.md points to) is told the new CUDA_HOME read violates the design. The Dossier reports this was reconciled at the head (docs/cli-design.md:46-57 rewritten) — same re-check as F2. Note also the residual, unchanged nit that AGENTS.md:452-455 still states the unqualified prohibition ("Flare, Helios, recipes, and components never read an environment variable to choose behavior … including temporary ones") with no pointer to the :461 carve-out.
F4 — Minor — apply() reads its own output as "inherited"; a second call cannot un-set a value a prior call wrote [snapshot-verified]
environment.py:61 inherited_cuda = os.environ.get("CUDA_HOME", "").strip() reads the same key that :69 os.environ["CUDA_HOME"] = str(cuda) writes. Once any call has written CUDA_HOME (including the /usr/local/cuda fallback), a later call in the same process sees that value as inherited and takes the :62-63 branch instead of :64-67 — so it can never pop a value it previously set, even if [paths] cuda has since disappeared from the configuration object. Today every call site is single-shot per CLI command — ignition/cli/serve.py:210, 291, 436, 545 and ignition/cli/bench.py:205 — so this is latent, not a live defect. Fix: capture the pre-existing value once (module-level constant or an explicit parameter) and treat the os.environ write as output only.
Platform parity — clean
The Windows branch is untouched: environment.py:70-75 (CUDA_PATH, TRITON_PTXAS.EXE_PATH, os.add_dll_directory) is the same code as main:59-64, and the new logic is correctly gated by os.name != "nt" at :60. The PR body's Windows claim holds by inspection. Windows remains untested — every test is @pytest.mark.skipif(os.name == "nt", …) — but that is unchanged from main, not a regression.
2. Unintended system-level consequences — none found
I traced every call site: serve.py:210, 291, 436, 545 and bench.py:205. apply() is a synchronous, once-per-process, pre-import step — verified at serve.py:291-292, environment.apply(configuration, plan.gpus, plan.recipe.b12x_environment) immediately followed by import flare_heliopause, i.e. before the runtime/torch stack loads, which is exactly the ordering the change needs to work at all. Consequently:
- No contention/lock/queue/HOL-blocking surface: no new lock, thread, queue, or shared mutable state beyond the process env dict that already existed; the function runs before anything concurrent starts.
- No memory/buffering/IO amplification: the change adds one
os.environ.get, onePath(...)construction, and at most one dict assignment. No new allocation on any hot path, no cache or disk IO. - No failure-propagation blast radius change: the only failure path reachable is the pre-existing
runtime_patches.apply(); the resolution block cannot raise (nostaton the inherited path in the snapshot — which is precisely F1's defect). - Metric / rate / admission-pricing span check: N/A. This PR changes no rate, latency, or admission metric, no sampling span, and no
inbound_rate/estimated_seconds-style threshold input. Nothing downstream of a metric changes.
3. Architecture, contracts & charter compliance
- No wire/proto/captured-graph/public contract is touched. The change is 10 lines inside one function plus docs and tests; it does not alter any graph kind, export format, or Helios interface.
- Layer placement is right.
ignition/cli/environment.pyis the designated place where Flare sets dependency-environment variables before importing the libraries that read them (AGENTS.md:466-468explicitly namesignition.cli.environmentfor this). - Principle 10 exception is legitimate in substance.
docs/design-review.md:89-92[head-cited] prohibits environment-variable behaviour switches "except for the documented CUDA device selection and dependency setup policies" —CUDA_HOMEselecting the native CUDA toolkit is dependency setup, not a Flare behaviour toggle, so the carve-out genuinely covers this change rather than being stretched. Note the tension F1 sits in: the same principle says "explicit user values win over defaults", which is what justifies honouring an inheritedCUDA_HOMEover/usr/local/cuda— but an inherited value that does not exist is not an explicit user value in any useful sense, which is the argument foris_dir(). - No previously blocked design choice is being re-landed. The history (dossier §5: #71 removing automatic
CUDA_HOME, thenc9935887adding the/usr/local/cudafallback) is a revision of the same four-line policy, not a revert of a rejected design. - Charter evidence requirement is only partly met. No end-to-end evidence shows the preserved
CUDA_HOMEactually steers flashinfer's JIT/nvcc; the tests assert the environment dictionary only. #231's review asked for exactly that end-to-end check. This is carried from the dossier, not newly derived.
4. Tests & claim accuracy
Accurate claims. "Unset otherwise, removing any blank/whitespace CUDA_HOME from os.environ" — verified: :66-67 pops, and tests/cli/test_environment.py:138-149 covers None/""/" ". "Explicit [paths] cuda overrides inherited CUDA_HOME" — verified :58-59 and tested :62-75. configuration.directory() returning None for empty [paths] cuda is the default that makes this branch reachable (ignition/cli/config.py:172-175: value = self.get(f"paths.{name}").value; return Path(value).expanduser() if value else None).
Inaccurate or unverifiable claims. "TRITON_PTXAS_PATH … unchanged" — false in the snapshot (F2). The test-count figure "12" is 10 parametrized cases in the 150-line snapshot (6 functions: :62, :79, :93, :109, :125×3, :140×3); the Dossier's 12 refers to the head. "148 passed" remains author-reported; CI status is not observable from here.
Coverage gaps worth noting. (a) No test covers [paths] cuda pointing at a directory that does not exist — directory() does not validate existence (config.py:172-175), so a typo'd config silently behaves like F1. Pre-existing on main, but the PR now has a test file that could cover it. (b) The [paths] cuda test (:62-75) asserts behaviour that is unchanged on main when the ptxas reversal is removed, i.e. it is regression cover, not evidence for the fix. (c) The clean_environment fixture (:45-58) is genuinely leak-free — it registers an undo entry for originally-absent keys via monkeypatch.setenv(key, ""); os.environ.pop(key, None) — and stubs runtime_patches.apply (:47), so the suite is host-independent and does run in PR CI (.github/workflows/python-cpu.yml:30-33 (not opened) runs pytest tests/ -q with CUDA_VISIBLE_DEVICES: "").
5. Open questions
- Which commit is really at head? The
pr/690content available here contradicts the Dossier on F2, F3 and the test counts. If39796eareally containsmain's ptxas line and the reconciledcli-design.md, then F2 and F3 are withdrawn and only F1 and F4 stand. - Should a nonexistent inherited
CUDA_HOMEfall back to/usr/local/cuda? F1's fix choice (addis_dir()vs. document the verbatim policy) needs one decision, and the test at:109-120must move with it. - Does a maintainer endorse #636's premise that
CUDA_HOMEoutranks/usr/local/cuda? Still nothing recorded on the issue; the PR carriestriage:reviewwhile #636 carriestriage:design-review. - Will anyone run the multi-toolkit reproduction from #636, or is env-dict-only coverage accepted?
6. What I could not verify
- The stated head
39796eacould not be opened:read_filerejects 7-digit SHAs andsearch_history/pr_difffail withCould not read c513e46a79f3b6ac510235aaf09bcf055b841958/Failed to traverse parents of commit 682152b…. Findings were verified against the resolvablepr/690ref andmain, and cross-checked against the Dossier's head citations. docs/design-review.md:89-92(Principle 10) and.github/workflows/python-cpu.yml:30-33(not opened) are cited from the prior research pass; I did not re-open them this session.- Commit-trailer compliance (
.githooks/commit-msg,Design-Signed-Off-By) is unverifiable here. - Windows execution and end-to-end GPU preparation were not run (unchanged from the PR's own stated limitations).