Recommendation: Changes Requested
The core fix in ignition/cli/environment.py is small, clean, well-placed before library imports, and directly addresses the regression reported in #636 without re-introducing #71's pip-bundle selection bug. Requesting changes before merge for two concrete items: (1) the PR leaves normative policy statements in AGENTS.md:461 and docs/cli-design.md:46-53 directly contradicting the new text it adds at AGENTS.md:468-471 and docs/cli-design.md:1480, and (2) it bundles an unrequested TRITON_PTXAS_PATH behavior change beyond #636 whose blank-value branch is untested and understated in docs/model-preparation.md:128-130 (on an issue still awaiting maintainer triage:design-review and with no CI run recorded on head 682152b).
Merge Risk
Level: Low
- Bounded startup blast radius:
ignition.cli.environment.applyruns synchronously once per process before PyTorch/Triton/b12x imports across five CLI entry points (ignition/cli/serve.py:210, 291, 436, 545andignition/cli/bench.py:205). It introduces no concurrency, runtime hot-path, schema, core-format, or Helios changes, and leaves Windows (os.name == "nt",ignition/cli/environment.py:70-75) untouched. - User-visible default-path behavior change: Because
paths.cudadefaults to""(ignition/cli/config.py:51, 172-175), every non-Windows user without an explicit[paths] cudanow inherits a non-emptyCUDA_HOMEinstead of falling back to/usr/local/cuda, and users with[paths] cudaconfigured now have ambientTRITON_PTXAS_PATHoverridden when<cuda>/bin/ptxasexists. - Process/policy sensitivity: This four-line policy has now changed three times in six weeks (
#71→c9935887→#690), issue #636 carriestriage:design-reviewwith no maintainer decision recorded yet, and head682152bhas no CI check results.
Walkthrough
ignition/cli/environment.py: Adds_DEFAULT_LINUX_CUDA = Path("/usr/local/cuda")(:22) and updates non-Windows toolkit resolution (:58-69) to[paths] cuda→ non-empty stripped inheritedCUDA_HOME→_DEFAULT_LINUX_CUDAwhen that directory exists →os.environ.pop("CUDA_HOME", None). Also updates POSIXTRITON_PTXAS_PATHassignment (:78-81) to set<cuda>/bin/ptxaswheneverconfigured_cuda is not Noneor ambientTRITON_PTXAS_PATHis unset/whitespace.tests/cli/test_environment.py: Adds the first direct unit suite forenvironment.apply()(6 POSIX test functions / 10 parametrized cases) with a leak-freeclean_environmentfixture (:45-58) covering configured override, inherited preservation, presetTRITON_PTXAS_PATH/existingCPATH, missing local toolkit files, fallback to_DEFAULT_LINUX_CUDA, and clearing blankCUDA_HOME.docs/cli-design.md,docs/model-preparation.md,AGENTS.md: Updates the CUDA toolkit row (docs/cli-design.md:1480), preparation setup paragraph (docs/model-preparation.md:123-132), and configuration bullet (AGENTS.md:466-473) to document the new non-Windows precedence.
Pre-merge Checks
- [PASS] Security / malicious screen: No suspicious code, credential access, command execution, or prompt-injection content found in the diff or PR description.
- [WARN] Charter & value fit: Fixes a real reproducible regression (#636) in preparation tooling with minimal footprint, and Principle 10 (
docs/design-review.md:89-92) exempts documented CUDA dependency setup policies, butAGENTS.md:461anddocs/cli-design.md:46-53still contradict the new policy and #636 (triage:design-review) lacks maintainer sign-off. - [PASS] Related / duplicate / conflict check: No duplicate, superseding, or conflicting PRs; does not re-introduce #71's automatic pip-bundle selection.
- [WARN] Tests & verification evidence: All 10 unit cases in
tests/cli/test_environment.pyare well-isolated and exercise the realenvironment.apply()andConfiguration.load(), but results are author-reported with no CI run on682152b, Windows is skipped across all tests, and the new blank/whitespaceTRITON_PTXAS_PATHand padded-non-emptyCUDA_HOMEbranches are untested.
Blockers
None.
Should Fix
- Reconcile the self-contradictory environment-variable policy statements (
AGENTS.md:461,docs/cli-design.md:46-53).AGENTS.md:461still states`CUDA_VISIBLE_DEVICES` is the only variable Flare interpretsin the exact same bullet where this PR addspreserves a non-empty inherited `CUDA_HOME`(AGENTS.md:468-471).docs/cli-design.md:46-53still states "Flare reads none, with one exception:CUDA_VISIBLE_DEVICES" and "Two levels of precedence. Flags override the configuration file, which overrides the recipe. Nothing else exists", directly contradicting the updated CUDA toolkit row atdocs/cli-design.md:1480andignition/cli/environment.py:61, 79.- Because Principle 10 (
docs/design-review.md:91-92) makes the env-var exemption conditional on "the documented CUDA device selection and dependency setup policies", updateAGENTS.md:461anddocs/cli-design.md:46-53(2–3 sentences) so the normative policy matches the decision table and implementation. Also obtain maintainer sign-off on #636 (triage:design-review) and ensurePython CPU testsCI runs green on the updated head.
- Align scope, test coverage, and docs for the
TRITON_PTXAS_PATHchange (ignition/cli/environment.py:58-59, 78-81,docs/model-preparation.md:128-130).- Issue #636 asks only to preserve
CUDA_HOMEahead of/usr/local/cuda. Beyond that,ignition/cli/environment.py:78-81changesmain's"TRITON_PTXAS_PATH" not in os.environso that (a) explicit[paths] cudanow overwrites a non-blank ambientTRITON_PTXAS_PATH(aligning POSIX with WindowsTRITON_PTXAS.EXE_PATHat:72), and (b) blank/whitespaceTRITON_PTXAS_PATHvalues are now populated. - If keeping this change: add a unit test covering blank/whitespace
TRITON_PTXAS_PATH(currently untested — every test intests/cli/test_environment.pysets a non-blank value or leaves it absent) and updatedocs/model-preparation.md:129-130from "populating it when unset" to "populating it when unset or blank". If scoping strictly to #636, seeSubtract / Simplify#1 below.
- Issue #636 asks only to preserve
Subtract / Simplify
- Optional strict-scope deletion (
ignition/cli/environment.py:58-59, 78-81): If maintainers prefer not to changeTRITON_PTXAS_PATHprecedence beyond #636, deleteconfigured_cudaand collapse lines 78–81 back toif ptxas.is_file() and not os.environ.get("TRITON_PTXAS_PATH", "").strip():(ormain's"TRITON_PTXAS_PATH" not in os.environ), removing the extra branch and keeping the PR strictly focused onCUDA_HOME. - Deduplicate the 4-step toolkit precedence prose (
docs/model-preparation.md:123-132): The same toolkit precedence order is now spelled out in three places (docs/cli-design.md:1480,docs/model-preparation.md:123-132,AGENTS.md:466-473) plus a fourth time inignition/cli/environment.py:55-57. Given how frequently this policy has changed, keep the canonical specification indocs/cli-design.mdand shortendocs/model-preparation.md:123-132to a brief summary pointing to[the CLI design](cli-design.md).
Nits
tests/cli/test_environment.py:61, 78, 92, 109, 123, 138: Replace the six identical@pytest.mark.skipif(os.name == "nt", ...)decorators with a single module-levelpytestmark = pytest.mark.skipif(...)matching repo convention (used across 30+ test modules, e.g.,tests/server/test_scheduler.py:23(not opened)), unless a Windows test (e.g., monkeypatchingos.name) is added to this file.tests/cli/test_environment.py: Add a case exercising whitespace-padded non-emptyCUDA_HOME(e.g.," /path/to/cuda ") to cover the.strip()normalization atignition/cli/environment.py:61, 69.ignition/cli/environment.py:54-57: Lines 55–57 restate the 9 lines immediately below them and leave the pre-existing cuTile sentence (:54) slightly orphaned; tighten to one concise comment referencing the policy indocs/cli-design.md.
Dropped on verification
- Unvalidated inherited
CUDA_HOME/ missingis_dir()check (Correctness M1): Dropped. Neither[paths] cuda(ignition/cli/config.py:172-175) nor PyTorch/FlashInfer silently ignores an explicitly supplied nonexistent path. Theis_dir()check on_DEFAULT_LINUX_CUDA(ignition/cli/environment.py:64) exists only because/usr/local/cudais an implicit fallback; silently falling through to/usr/local/cudawhen a user typosCUDA_HOMEwould compile against the wrong toolkit without error. - Claim that
[paths] cudaoverriding ambientTRITON_PTXAS_PATHviolates Principle 10's "explicit user values win over defaults" (Value Prop / Dossier #2 / Correctness M2): Dropped the Principle 10 framing. Underdocs/design-review.md:89-92,[paths] cudainconfig.toml(not opened) is the explicit configuration value rather than a default, and Windows already overwritesTRITON_PTXAS.EXE_PATHunconditionally (ignition/cli/environment.py:72). Retained only the verified scope, blank-value test gap, and doc wording mismatch. - Adding resolved CUDA toolkit to
Plan.to_dict()(Correctness M4): Dropped as scope creep.ignition/planning.py:383-420records no[paths]settings and runs beforeenvironment.apply()(ignition/cli/serve.py:200-210, 430-436);AGENTS.md:456-460applies to experimental recipe flags inPreparationConfig, not host filesystem paths. - Requiring a downstream torch/Triton libdevice test like PR #231 (Value Prop / Correctness M4): Dropped. PR #231 moved libdevice initialization to import time in
ignition/preparation/tuning.py; PR #690 only setsos.environinignition/cli/environment.pybeforeimport torch(ignition/cli/serve.py:291, 305), and CI (ubuntu-24.04in.github/workflows/python-cpu.yml(not opened)) has no CUDA toolkit installed. - Replacing
_ENV_KEYS+clean_environmentwith anos.environ.clear()snapshot fixture (Subtraction F2): Dropped. The proposed replacement both strips unrelated host variables (PATH,TMPDIR) and introduces a pytest teardown-ordering bug:clean_environmenttears down beforemonkeypatch.undo(), so tests callingmonkeypatch.setenv("CUDA_HOME", ...)recordnotsetagainst the cleared env and then delete the restored pre-existingCUDA_HOMEduringmonkeypatch.undo(). The PR's_ENV_KEYSlist (tests/cli/test_environment.py:15-28) covers all 12 keys written byenvironment.apply()and restores both present and absent variables cleanly. - Latent non-idempotency of
environment.apply()(Correctness m1): Dropped as a non-issue. Every call site invokesapply()once per process startup, and repeating it with the same inputs produces identical normalizedCUDA_HOME. - Possible recurrence of PR #71's
cuda-tilepip-bundle-lcudartfailure (Dossier / Correctness Open Question): Verified not triggered by PR #690; unlike pre-#71 code,apply()never auto-discovers a pipnvccbundle and only honors a caller-exportedCUDA_HOMEor/usr/local/cuda.