Explore scratchpad · NVIDIA/hyperflare-inference #690

Raw Markdown for agents: https://autobot.eidonix.com/p/d872899e-148e-4dfc-b279-9db20e45d9c8.md

#1 [high] Change: what PR #690 changes in ignition/cli/environment.py (with line cites)

PR #690 (author jcartu, head 682152b, base main, 5 files +183/-10, opened 2026-12-02, state: open/ready for review, no reviews, no CI checks).

After (ignition/cli/environment.py:54-87 at pr/690):

Before (base main, same code as c9935887, lines 54-73):

cuda = configuration.directory("cuda")
if cuda is None and os.name != "nt" and Path("/usr/local/cuda").is_dir():
    cuda = Path("/usr/local/cuda")

and POSIX ptxas condition was if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ:.

Behavior deltas not spelled out as separate items in the description:

  1. POSIX: ambient non-blank TRITON_PTXAS_PATH now loses to [paths] cuda (previously ambient env always won). This is a real precedence change for a variable the user set explicitly (design-review principle 10 "explicit user values win over defaults", docs/design-review.md:89-92).
  2. A blank/whitespace TRITON_PTXAS_PATH previously blocked setting it; now it is treated as unset and overwritten from the toolkit.
  3. Inherited CUDA_HOME values are now normalized: whitespace stripped and re-exported as a Path string (e.g. " /opt/cuda " -> "/opt/cuda").
  4. Inherited blank CUDA_HOME is deleted from os.environ when no default toolkit dir exists (description does state this).
  5. paths.cuda still resolves through Configuration.directory (ignition/cli/config.py:172-175), which returns None for the empty built-in default paths.cuda = "" (config.py:51).

#2 [high] Why: issue #636 text and its linked provenance commit c9935887

Issue #636 "ignition no longer respects the CUDA_HOME environment variable" — open, opened 2026-11-30 11:36 by hiroshi-ya, updated 2026-11-30 11:37, labels: bug, enhancement, priority:P2, triage:design-review. No discussion comments (0). Referred to by #690 (this PR fixes it).

Arguments in the issue:

Age/weight: open ~2 days before the PR (issue 2026-11-30, PR 2026-12-02). Labeled triage:design-review (labels are not readable in the repo copy — search_code over the tree for "triage:design-review" returns nothing, so label triage state cannot be confirmed from the repo).

#3 [high] Related work: #71 (merged) is the earlier CUDA-toolkit-precedence change that c9935887 later reversed in part

#71 "Preserve native CUDA toolkit selection with cuTile dependencies" — merged 2026-10-24 by eugr (COLLABORATOR), +39/-21, files: docs/cli-design.md, docs/model-preparation.md, ignition/cli/config.py, ignition/cli/environment.py (+2/-14), tests/cli/test_serve.py.

#71's rationale: installing cuda-tile[tileiras] adds nvcc under nvidia/cu13; Ignition had selected that compiler bundle as CUDA_HOME, breaking native weight-loader builds with cannot find -lcudart (wheel ships lib/libcudart.so.13, linker wants lib64/). Fix: set CUDA_HOME only when [paths].cuda is configured; otherwise let native build libraries do their own toolkit discovery. It explicitly says it covered "configured, unset, and inherited CUDA_HOME with a pip compiler present" in tests/cli/test_serve.py (+29/-2). Evidence in #71: tests/cli/test_serve.py + test_config.py 129 passed; fresh native-loader compile+import against system CUDA 13.0 passed; full CLI suite 417 passed / 7 failed all pre-existing.

Then c9935887 (2026-11-27, Luke Alonso) restored the /usr/local/cuda fallback on non-Windows (see current base code), which is the regression #636 reports.

Cross-reference: PR #690's docs edits modify the same two doc statements #71 introduced (docs/cli-design.md:1480, docs/model-preparation.md:123-131). #690 keeps #71's core rule (explicit [paths] cuda wins; nothing set when neither config nor default exists) but re-introduces an environment-derived flow that #71 had deliberately removed. Whether the "pip cuTile nvcc bundle" failure mode #71 fixed can reappear through the inherited-CUDA_HOME path is not addressed in #690's description.

#4 [high] Project fit: environment-variable policy in AGENTS.md and docs/cli-design.md vs this change

Rules the change touches:

#5 [high] Claims and evidence: what #690 asserts and what backs it (and what is missing)

Claims in the description vs evidence, verified against the diff at pr/690:

  1. "Preserves a caller-supplied CUDA_HOME ... when [paths] cuda is unset" — implemented (ignition/cli/environment.py:58-67). Case 2 of the resolution order. OK.
  2. "[paths] cuda overrides inherited CUDA_HOME and ambient TRITON_PTXAS_PATH" — implemented (line 78-81: configured_cuda is not None or not os.environ.get("TRITON_PTXAS_PATH","").strip()); test test_configured_cuda_overrides_inherited_cuda_home_ptxas_and_default_toolkit (tests/cli/test_environment.py:61-75). Note: this ambient-override is a NEW behavior beyond the issue's ask (issue #636 only asked for CUDA_HOME precedence); it is stated in the description but only inside the precedence list.
  3. "blank CUDA_HOME values are cleared when no toolkit source exists" — implemented (line 66-67) and tested (tests/cli/test_environment.py:138-149). Description states it.
  4. "pytest tests/cli -v: 146 passed, including all 10 cases in tests/cli/test_environment.py" — test count checks out: 4 single + 3+3 parametrized = 10 tests in the new file. The run is author-reported only; no CI check exists on head 682152b (orientation packet: "CI on the head commit: no checks"). The repo workflow .github/workflows/python-cpu.yml:30-33 runs pytest tests/ -q with CUDA_VISIBLE_DEVICES="" on ubuntu-24.04 with no CUDA toolkit, so CI would exercise the tests only through the monkeypatched _DEFAULT_LINUX_CUDA.
  5. "Verified post-session environment restoration ... every managed variable in _ENV_KEYS matched its pre-session value" — plausible via the clean_environment fixture (tests/cli/test_environment.py:44-59), which is an unusual pattern: it calls monkeypatch.setenv(key, "") then os.environ.pop(key, None) for absent keys, relying on monkeypatch's undo entry surviving an immediate pop. That works with pytest's monkeypatch (undo recorded before mutating), but it is a non-obvious construction worth noting.
  6. Limitations disclosed honestly: Windows (os.name == "nt") not executed; no end-to-end GPU preparation. No GPU/hardware evidence at all, so the actual failure mode in #636 (wrong toolkit on multi-toolkit hosts) is not demonstrated as fixed on a host with both /usr/local/cuda and a second toolkit.
  7. Not claimed or evidenced: any check that ForwardCache/Triton libdevice selection follows the preserved CUDA_HOME, i.e. that the downstream consumer really honors the variable (tests/preparation/test_toolchain.py:31-69 asserts libdevice comes from torch's CUDA_HOME, which is derived at torch import time — worth cross-checking, see related-work note on #231).

Design-acknowledgment trailer: repository .githooks/commit-msg:14-63 requires exactly one Design-Signed-Off-By: <identity>; design-review=<sha256[:4] of staged docs/design-review.md> trailer on every commit; I could not read the author's commit message body, so whether head 682152b carries one is unverified.

#6 [high] Related work: prior test coverage removed, in-repo consumers of CUDA_HOME, and files that overlap

#7 [high] People: author jcartu's standing and history; area owners eugr/Luke Alonso; no reviewers yet

#9 [high] Community/Process: no reviewers, no CI, no issue discussion, docs-vs-code gaps, undeclared risk surface

Facts a reader could not get from the description:

#10 [high] Connection: this 4-line decision has now been revised three times in six weeks, each time by a different author

Chain of custody for the CUDA toolkit decision (each step verified):

  1. 2026-10-23/24 — #71 (eugr, merged) removes automatic CUDA_HOME assignment: set it only when [paths] cuda is configured, because the pip cuTile bundle nvidia/cu13 was being chosen and broke native builds with cannot find -lcudart. Docs updated in the same PR (docs/cli-design.md, docs/model-preparation.md).
  2. 2026-11-27 — c9935887 (Luke Alonso, "Support integrated GA10B GPUs, adaptive executor parking, and explicit memory limits") restores a fallback but not from the environment: it uses /usr/local/cuda when [paths] cuda is unset on non-Windows and the directory exists. Verified by reading ignition/cli/environment.py at c99358879813f22557ac619044af514fafacecc6 (lines 53-58). This is the line #636 blames, with a permalink in the issue.
  3. 2026-11-30 — #636 (hiroshi-ya) reports that treating /usr/local/cuda as the source of truth overrides an inherited CUDA_HOME, citing flashinfer's get_cuda_path() and PyTorch/CMake/Numba as precedent. Labeled bug/enhancement/priority:P2/triage:design-review. No maintainer reply.
  4. 2026-12-02 — #690 (jcartu) implements the issue's ask with [paths] cuda > inherited CUDA_HOME > /usr/local/cuda > native discovery, and additionally makes [paths] cuda beat an ambient TRITON_PTXAS_PATH. So the PR is the third revision of one 4-line decision in ~6 weeks, each revision by a different person (eugr → Luke Alonso → jcartu), each justified by a concrete downstream build failure. A reviewer deciding this should weigh that the previous two revisions each broke someone: #71 broke CUDA_HOME users (leading to #636), and c9935887 broke multi-toolkit hosts. The PR's design (config > environment > filesystem default) is the first version that can satisfy both as long as the caller's CUDA_HOME is a real toolkit.

#11 [high] Reach: five apply() call sites, silent TRITON_PTXAS_PATH override, doc-consistency gaps, no cross-host propagation

Who and what this touches:

#12 [high] Research summary

Case file for PR #690 ("Preserve inherited CUDA_HOME in ignition.cli.environment", jcartu, head 682152b, open/ready for review, no reviews, no CI checks, 5 files +183/−10) is gathered; 11 scratchpad entries cover every angle.

Key findings a reader could not get from the description:

Angles with nothing further found: competing or superseding PRs (none; #231 is complementary, #668/#678 touch call sites only), and community engagement (zero comments/reviews/reactions on both #636 and #690). Full details, file:line cites and cross-links are in the scratchpad entries 1-11.

#14 [high] Report outline: key-findings order, file map, and angles with nothing found

File map of the change (pr/690): ignition/cli/environment.py:22 (new _DEFAULT_LINUX_CUDA), :54-67 (resolution order config > inherited CUDA_HOME > default > unset/pop), :78-81 (TRITON_PTXAS_PATH condition now configured_cuda is not None or not env value.strip()), :82-86 (CPATH prepend unchanged); tests/cli/test_environment.py:1-149 (new, 10 POSIX-only tests, clean_environment fixture at :44-59, _ENV_KEYS at :12-28); docs/cli-design.md:1480; docs/model-preparation.md:123-132; AGENTS.md:466-473. Unchanged but load-bearing: ignition/cli/config.py:31-32,51,172-175 (paths.cuda default ""), docs/cli-design.md:46-53 (no-env-vars and two-levels precedence bullets), docs/cli-design.md:1403-1409, docs/windows.md:382-386.

Suggested Key findings order (most-undiscoverable first): (1) three-author revision chain #71 → c9935887 → #690 with entry 10; (2) undeclared ambient TRITON_PTXAS_PATH precedence reversal, entry 1 and entry 11; (3) AGENTS.md/cli-design.md env-var invariants now inconsistent, entry 4; (4) POSIX-only tests + no GPU/multi-toolkit evidence, Windows untested, entry 5/9; (5) dropped coverage that #71 had added, entry 6; (6) #636 triaged triage:design-review with no maintainer answer and zero discussion, entry 2/7.

Angles with nothing beyond what is recorded: "Community" — zero comments, reviews and reactions on #690 and on #636 (pr_comments: "No comments"); "Related work: competing/superseded" — none; #668/#678 touch apply() call sites only, #231 is complementary, no open PR edits the same four lines. Everything else has entries 1-11.

#8 [medium] The change: base implementation, authorship history of the function, and testability indirection

Base-branch code at pr/690's merge base (identical to c9935887 output, verified by reading ignition/cli/environment.py at c99358879813f22557ac619044af514fafacecc6, lines 53-73):

# cuTile discovers its compiler bundle independently of the native toolkit.
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)
    ... nt branch ... else:
        ptxas = cuda / "bin/ptxas"
        if ptxas.is_file() and "TRITON_PTXAS_PATH" not in os.environ:
            os.environ["TRITON_PTXAS_PATH"] = str(ptxas)
        include = cuda / "include"
        if include.is_dir(): ... prepend to CPATH ...
runtime_patches.apply()

History of this function (search_history on ignition/cli/environment.py): 794b0bb4 2026-10-11 (separate Python preparation), 884b9b50 2026-10-14 (Windows), 63f45f3a 2026-10-15, d5fd9824 2026-10-23 eugr "Preserve native CUDA toolkit selection with cuTile dependencies (#71)", 225d4669 (#117), 28f0833b, af0907d9, c9935887 2026-11-27 Luke Alonso (added /usr/local/cuda fallback), 682152b6 2026-12-02 jcartu (this PR).

Note the function's own comment "cuTile discovers its compiler bundle independently of the native toolkit" survives in the new code (line 54) but the PR's comment block below it (lines 55-57) now describes a different intent — a prose/comment-accuracy observation, not a code-review issue.

Also notable: os.environ.update({... **dict(b12x)}) runs before the CUDA block; nothing in the CUDA block interacts with b12x keys, so no ordering hazard is introduced by the reordering.

_DEFAULT_LINUX_CUDA is read at call time (module attribute lookup inside apply), which is why the tests can monkeypatch it (tests/cli/test_environment.py:66 and 5 other sites). Adding this module-level indirection is a small testability change beyond the described fix, but it is what makes the tests hermetic on a host without /usr/local/cuda (the author says the test host has none).

#13 [medium] Recent activity: what changed lately in the four areas and whether #690 builds on, conflicts with, or reverses it

ignition/cli (last 60 days, per orientation packet + search_history): 0fca9938 2026-12-02 Luke Alonso (#683 CLI prog propagation / state.py kernels), a3c80e19 (#657 mDNS advertise), c146d7be (#620 remove copy/history drafts), f7d6428f (#592 sm110 identifiers, kbenkhaled), d3d0e783 (#212 context ceilings), c9935887 2026-11-27 Luke Alonso (the commit that introduced the regression), 5adb27f2, f3a5b709 (#544 dfly2). Fast-moving area dominated by Luke Alonso; #690's 17-line edit in environment.py is the only CUDA-toolkit change since c9935887.

tests/cli: 0fca9938 (#683), a3c80e19 (#657), efc6252d (#635), a39f6777, d3d0e783 (#212), 5adb27f2, f3a5b709 (#544), 698ee450 (#545). No test file exercised environment.apply before #690 (search_code over tests/cli for environment/apply found only the new file), so this is the first CPU coverage of the function.

docs: heavy, mostly scheduling/helios work by PCCessna and Luke Alonso (#681, #661, #665, #660, #670, #663, #666, #657). The two doc lines #690 edits were last touched by eugr's #71 and then c9935887; no open PR modifies docs/cli-design.md:1480 or docs/model-preparation.md:123-132.

Relation verdict: #690 builds directly on c9935887 (it keeps the /usr/local/cuda fallback and the _DEFAULT_LINUX_CUDA semantics) and partially reverses #71's intent by re-introducing an environment-derived toolkit — but without #71's trigger (a pip cuTile bundle being auto-selected), so it is a re-balancing rather than an outright revert. Nothing merged since 2026-11-27 conflicts with the four lines it edits; related_items(690) shows no other open PR changing ignition/cli/environment.py.