Skip to content

Unsloth Studio Installer: improve GPU print details (NVIDIA, Intel, AMD) - #8762

Merged
danielhanchen merged 20 commits into
unslothai:mainfrom
LeoBorcherding:feat/studio-installer-gpu-name
Sep 16, 2026
Merged

danielhanchen merged 20 commits into
unslothai:mainfrom
LeoBorcherding:feat/studio-installer-gpu-name

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The GPU line said a different kind of thing per vendor. Two of the three never named the
card, and only one said what it would actually build for:

gpu            NVIDIA GPU detected          <- no name, no compute target
gpu            Intel GPU detected           <- name on the substep below
               Intel Arc A770
gpu            AMD ROCm (gfx1200)           <- arch, but not a name

Every probe already had the answer:

  • nvidia-smi is resolved and run before this point and was simply never asked for a name.
  • compute_cap was already being read, in Get-NvidiaCu126Verdict, which runs on the
    cu128/cu130 path to decide a fallback wheel and returns early otherwise, so it was never
    available where the banner prints.
  • The shell scripts resolve the AMD marketing name into $_gpu_disp_mkt / $_setup_mkt for
    their own name -> arch inference and never print it.
  • The backend prints the real name at startup seconds later:
    Hardware detected: ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XT

So this is an organisation problem, not a detection one.

What

One shape for every vendor: the device on the gpu line, its compute target in parentheses,
the runtime below.

gpu            NVIDIA GeForce RTX 4090 (sm_89)
               Driver: 550.54.15
gpu            Intel Arc A770
gpu            AMD Radeon RX 9060 XT (gfx1200)
               HIP SDK: C:\Program Files\AMD\ROCm\7.1

compute_cap is the counterpart of the gfx arch and the driver version the counterpart of the
HIP SDK line; both come back from the same query that fetches the name, so this costs no extra
call. Each vendor honours its own visible-device mask when picking which card to name
(CUDA_VISIBLE_DEVICES, HIP/ROCR_VISIBLE_DEVICES), so a masked run names the card it is
actually going to use.

Intel keeps the name alone. There is no counterpart to gfx1200 / sm_89 that any probe
here already resolves -- IntelGpuLabel comes from WMI adapter names, and no Xe arch or Level
Zero version is in hand. Inventing one to make the column look even seemed worse than the gap.

On the AMD side the name lives in its own variable rather than folded into $ROCmGpuLabel:
that one doubles as the input to the name -> arch tables, so changing its shape would move
wheel selection. It is read from hipinfo's per-device Name:, amd-smi's Market Name, or the
WMI adapter name, always at the index the arch pick landed on and only when the name and arch
lists line up -- so a format change can mislabel nothing, and the arch that selects the wheel
is never taken from it.

NVIDIA CSV fields are split from the right, because nvidia-smi does not quote its output and
a comma in a device name would otherwise shift every column. A row with fewer fields than
requested falls back to using the whole row as the name, rather than reporting a compute
capability as a driver version.

Also stops setup.ps1 reporting a known ROCm version as unknown. It probed hipconfig then
amd-smi and, on a runtime-only layout with neither on PATH, printed

rocm           ROCm (version unknown)

one line after the summary printed C:\Program Files\AMD\ROCm\7.1. The SDK root is versioned,
so that is now the last-resort source.

Testing

All four scripts parse (Parser::ParseFile for .ps1, bash -n for .sh). The awk field
splitting is covered for a plain row, a comma-in-name row, and a short row, and the
index-picker for a masked device and an out-of-range index.

Not yet run end to end on real hardware. The hipinfo Name:, amd-smi Market Name and
nvidia-smi CSV parses are written against documented output shapes, not observed ones. The
guards mean a mismatch falls back to the old text rather than naming the wrong card, so the
failure mode is "no change" rather than "wrong card" -- but it wants a run on an AMD box and an
NVIDIA box before merge.

Not included

setup.ps1 still re-probes the GPU after install already did, so the block prints twice. It has
to work standalone, so consuming install's result is a contract change rather than a dedup.


Before / after evidence (added by @danielhanchen)

The gpu line on fifteen host shapes. Every line below is real captured output from the
installers' own banner block, spliced back together with each file's real functions and
shell options and driven against fake nvidia-smi / rocminfo / amd-smi probes; nothing
is retyped. BEFORE is the merge base with current main, 66a38c7c2; AFTER is the
head, 3d289eb4e. Both sides are re-run in the same process against the identical fixture,
so a row that comes out identical really is identical.

installer gpu banner before and after

Reading the rows:

  • The NVIDIA rows are the feature working: the card, its sm_ target and the driver in
    place of "NVIDIA GPU detected". The UUID row shows the mask honoured, naming the second
    card rather than row 0, since nvidia-smi itself ignores CUDA_VISIBLE_DEVICES.
  • The AMD rows show the GPU agent being named rather than the CPU agent rocminfo lists
    first. Strix Halo is the sharp case: the CPU agent's own marketing name contains "Radeon
    8060S", so naming the wrong agent there still looks plausible.
  • Two same-arch cards and three GPUs sharing an arch show the device ordinal
    surviving. The arch alone cannot identify the device, so the name and the arch are taken
    from the same per-agent record.
  • The rest are the cases where the banner declines to name a card, which is most of what
    review added. They come in pairs, same host, one thing changed, so the rule is visible
    rather than asserted. An ordinal past the last card selects nothing, because CUDA stops
    enumerating at the first invalid index; in range on that same host it names. An
    abbreviated UUID is valid only when unique, so one matching both cards selects nothing. A
    numeric entry is a CUDA ordinal, and CUDA's default FASTEST_FIRST leaves everything
    after device 0 unspecified while nvidia-smi lists in PCI order, so it identifies a row
    only when the order is pinned to PCI_BUS_ID or the cards are interchangeable. In each of
    these the banner keeps the vendor-only wording and reports the driver alone.
  • Driver too old for compute_cap degrades the same way.
  • The last two rows are controls and must not change. A wedged nvidia-smi still prints
    the vendor-only line and, after the timeout fix, still costs one 10s bound rather than two.
    The CPU-only host is untouched.

The renderer fails rather than emitting a composite unless the set of identical rows is
exactly those two controls, because two halves that agree is the normal failure mode for
evidence like this.

Backing numbers at 3d289eb4e: 126 shell fixture cases across install.sh and
studio/setup.sh, no failures, no hangs; 85 PowerShell cases; test_rocm_support.py +
test_installer_av_shapes.py + test_formatter_fixed_point.py 635 passed, 2 skipped;
tests/sh/ GPU suites and the installer tests/studio/*.ps1 suites passing.

Scope: this composite is the shell side. The Windows banner is the same change in
install.ps1 and studio/setup.ps1, covered by the PowerShell suite and by the Windows
parity and no-compiler lanes in CI rather than by a picture.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@LeoBorcherding LeoBorcherding changed the title Studio: name the actual GPU in install and setup output Unsloth Studio Installer: name the actual GPU in install and setup output Aug 14, 2026
@LeoBorcherding
LeoBorcherding force-pushed the feat/studio-installer-gpu-name branch from 39d05c3 to 3e1a3d7 Compare August 14, 2026 03:21
The GPU line said a different kind of thing per vendor, and on two of the
three it did not say which card:

  gpu            NVIDIA GPU detected          <- no name, ever
  gpu            Intel GPU detected           <- name on the substep below
                 Intel Arc A770
  gpu            AMD ROCm (gfx1200)           <- arch, not a name

Every probe already had the answer. nvidia-smi is resolved and run before
this point and was simply never asked; the shell scripts resolve the AMD
marketing name into $_gpu_disp_mkt / $_setup_mkt for their own name -> arch
inference and never print it; and the backend prints the real name at
startup seconds later:

  Hardware detected: ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XT

One shape for all three now: `step "gpu"` is the device, the runtime detail
drops to a substep.

  gpu            NVIDIA GeForce RTX 4090
  gpu            Intel Arc A770
  gpu            AMD Radeon RX 9060 XT (gfx1200)
                 HIP SDK: C:\Program Files\AMD\ROCm\7.1

Each vendor honours its own visible-device mask when picking which card to
name (CUDA_VISIBLE_DEVICES, HIP/ROCR_VISIBLE_DEVICES), so a masked run names
the card it is actually going to use.

On the AMD side the name is kept in its own variable rather than folded into
$ROCmGpuLabel: that one doubles as the input to the name -> arch tables, so
changing its shape would move wheel selection. It is read from hipinfo's
per-device "Name:", amd-smi's Market Name, or the WMI adapter name, always
at the index the arch pick landed on and only when the name and arch lists
line up, so a format change can mislabel nothing and the arch that selects
the wheel is never taken from it.

Also stops setup.ps1 reporting a known ROCm version as unknown. It probed
hipconfig then amd-smi and, on a runtime-only layout with neither on PATH,
printed

  rocm           ROCm (version unknown)

one line after the summary printed C:\Program Files\AMD\ROCm\7.1. The SDK
root is versioned, so that is now the last-resort source.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@LeoBorcherding LeoBorcherding changed the title Unsloth Studio Installer: name the actual GPU in install and setup output Unsloth Studio Installer: name the actual GPU, whichever vendor it is Aug 14, 2026
The first pass unified the device name across vendors but left AMD as the
only one showing what it would actually compile for:

  gpu            NVIDIA GeForce RTX 4090
  gpu            AMD Radeon RX 9060 XT (gfx1200)
                 HIP SDK: C:\Program Files\AMD\ROCm\7.1

compute_cap is the counterpart of the gfx arch, and the driver version the
counterpart of the HIP SDK line. Both come back from the query that already
fetches the name, so this costs no extra call:

  gpu            NVIDIA GeForce RTX 4090 (sm_89)
                 Driver: 550.54.15

The installer was already reading compute_cap, but only inside
Get-NvidiaCu126Verdict, which runs on the cu128/cu130 path to decide a
fallback and returns early otherwise, so it was never available where the
banner is printed.

Fields are split from the right because nvidia-smi does not quote its CSV,
so a comma in a device name would otherwise shift every column. A row with
fewer fields than requested falls back to using the whole row as the name
rather than reporting a driver version that is really a compute capability.

Intel keeps the name alone. There is no counterpart to gfx1200 / sm_89 that
any probe here already resolves, and inventing one to make the column look
even is worse than the gap.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@LeoBorcherding LeoBorcherding changed the title Unsloth Studio Installer: name the actual GPU, whichever vendor it is Unsloth Studio Installer: give every vendor the same GPU line Aug 14, 2026
@LeoBorcherding

LeoBorcherding commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Old:
image

New now shows the actual amd gpu
image

@LeoBorcherding LeoBorcherding changed the title Unsloth Studio Installer: give every vendor the same GPU line Unsloth Studio Installer: improve GPU print information (NVIDIA, Intel, AMD) Aug 17, 2026
@LeoBorcherding LeoBorcherding changed the title Unsloth Studio Installer: improve GPU print information (NVIDIA, Intel, AMD) Unsloth Studio Installer: improve GPU print details (NVIDIA, Intel, AMD) Aug 17, 2026
@danielhanchen

Copy link
Copy Markdown
Member

The direction is right, but the same nvidia-smi CSV parse is duplicated in all four scripts and the separate ROCm version-unknown fix in studio/setup.ps1 rides along. Could you split that one out and share the parse rather than copying it, and take a look at Core (HF=latest + TRL=latest) and the hf-stack package scan which are green on main?

…ounded

Simulated the banner against fake nvidia-smi / rocminfo / amd-smi on a 74-case
matrix (both shell entry points x NVIDIA / AMD / Intel / CPU-only host shapes),
running the merge base and this branch against identical fixtures. Three
problems only showed up once the name was actually printed.

rocminfo enumerates the CPU as Agent 1, and that agent carries its own
"Marketing Name:". Taking the first match in the stream therefore named the
processor: an RX 7900 XTX box read "AMD Ryzen 9 7950X 16-Core Processor
(gfx1100)". On Strix Halo it is worse, because the CPU agent's name is
"AMD RYZEN AI MAX+ 395 w/ Radeon 8060S" -- it contains a Radeon model, so it
reads like a GPU name, and $_setup_mkt also feeds the name -> arch table. The
parse is now per agent and only an agent whose Device Type is GPU can name the
banner. Agents are collected as gfx/name pairs and the banner takes the name
belonging to the arch that was picked, so an iGPU + dGPU host no longer prints
the integrated name against the discrete arch.

The new nvidia-smi query ran unbounded. Every other nvidia-smi call in these
files goes through _run_bounded / _setup_run_smi / Invoke-NvidiaSmiBounded
precisely because a wedged driver blocks nvidia-smi indefinitely; in the matrix
a hung probe took the whole installer down on this branch while the merge base
finished normally. It now uses the bounded runner, and the shell side reuses the
executable the detection helper already resolved into $_nvsmi rather than
re-resolving with `command -v` -- detection also succeeds via /usr/bin/nvidia-smi
off PATH and via /proc/driver/nvidia/gpus with no nvidia-smi at all, and those
hosts would otherwise silently lose the name.

Placeholder rows are no longer treated as device names. An nvidia-smi too old
for compute_cap answers "[N/A]" rather than failing, which printed a GPU called
"[N/A]"; a short row used the whole row, printing "RTX 4090, 8.9". Short rows now
keep field 1 and the placeholders fall back to the old text.

Also on the AMD side: amd-smi spells the field MARKET_NAME in caps, so the
[Mm]arket.?[Nn]ame class matched no real casing and that probe never yielded a
name at all. Matched case-insensitively now, and the rocminfo and amd-smi calls
in install.sh are bounded like their setup.sh counterparts.

In setup.ps1 the device index is carried forward from Resolve-VisibleGpuIndex
instead of being recovered from the arch value. The arch list is deliberately not
deduplicated, so [array]::IndexOf always returned the first occurrence: two
same-arch cards with different SKUs (RX 7900 XTX + PRO W7900) named the first one
even when the mask selected the second. The WMI adapter name is likewise moved
onto the adapter the arch pick landed on, which the mask, the nameArches[0]
borrow and the shadowing repick can all change.

CPU-only and Intel hosts print exactly what they printed before this branch, and
all 21 tests in tests/studio/*.ps1 pass.
@danielhanchen
danielhanchen self-requested a review as a code owner September 14, 2026 06:44
@danielhanchen

Copy link
Copy Markdown
Member

Went through this one properly and simulated it rather than eyeballing it, since the description says it was never run end to end on hardware. I have pushed the fixes straight to the branch (e8c9efd) so you can see them in context.

What I did

Lifted the banner block out of all four entry points at both the merge base and this head, and ran them against fake nvidia-smi / rocminfo / amd-smi / hipconfig on a controlled PATH: 74 cases across install.sh and studio/setup.sh covering NVIDIA, AMD, Intel and CPU-only hosts, masks, missing probes and wedged probes, plus 22 PowerShell cases. Base and head get identical fixtures, so a difference is attributable to the branch rather than to something that was already there. The AMD fixtures follow AMD's own rocminfo docs and two real-world pastes, not an invented shape.

The direction is right and the NVIDIA line is a clear improvement: 30 of 44 NVIDIA cases now name the device where before every one of them said NVIDIA GPU detected.

What the simulation found

1. The AMD line named the CPU. rocminfo enumerates the CPU as Agent 1 and that agent carries its own Marketing Name:, so taking the first match in the stream picks the processor:

base    gpu   AMD ROCm (gfx1100)
head    gpu   AMD Ryzen 9 7950X 16-Core Processor (gfx1100)
fixed   gpu   AMD Radeon RX 7900 XTX (gfx1100)

Every rocminfo case did this, in both shell scripts. Strix Halo is the sharp edge, because the CPU agent's name is AMD RYZEN AI MAX+ 395 w/ Radeon 8060S: it contains a Radeon model, so it reads like a GPU name, and $_setup_mkt also feeds the name -> arch table, so a CPU string there can mis-infer an arch rather than only mislabel. The parse is now per agent and gated on Device Type: GPU. Agents are collected as gfx/name pairs and the banner takes the name belonging to the arch that was picked, so an iGPU + dGPU host no longer prints the integrated name against the discrete arch.

2. The new query ran unbounded, and a wedged driver took the installer down. Every other nvidia-smi call in these files goes through _run_bounded / _setup_run_smi / Invoke-NvidiaSmiBounded precisely because a wedged driver blocks nvidia-smi indefinitely. With a probe that never returns, the merge base finished normally and this branch hung:

base    rc=0   gpu   NVIDIA GPU detected
head    hung, no banner, installer never reached the next step
fixed   rc=0   gpu   NVIDIA GPU detected

This is the P1 Codex flagged on install.ps1, and it applies to all four files. The shell side now also reuses the executable the detection helper already resolved into $_nvsmi: detection succeeds via /usr/bin/nvidia-smi off PATH and via /proc/driver/nvidia/gpus with no nvidia-smi at all, and re-resolving with command -v silently lost the name on exactly those hosts.

3. Placeholder and short rows became device names. An nvidia-smi too old for compute_cap answers [N/A] rather than failing, so the banner read gpu [N/A]; a two-field row used the whole row and read gpu NVIDIA GeForce RTX 4090, 8.9. Short rows now keep field 1 and the placeholders fall back to the previous text. Worth noting the 470 branch has no compute_cap at all, so this is reachable, not theoretical.

4. amd-smi never yielded a name in the shell scripts. It spells the field MARKET_NAME in caps and [Mm]arket.?[Nn]ame matches no real casing, so that probe silently did nothing. Pre-existing, but it meant the AMD half of this change was inert on any host without rocminfo. Matched case-insensitively now. The PowerShell copies were fine, they use (?i).

5. setup.ps1 named the wrong card on duplicate arches. The arch list is deliberately not deduplicated so a mask can select the second of two same-arch GPUs, but [array]::IndexOf recovers the first occurrence, so an RX 7900 XTX + PRO W7900 box named the XTX even with HIP_VISIBLE_DEVICES=1. The index is now carried forward from Resolve-VisibleGpuIndex. Same fix for the WMI adapter name, which was taken at index 0 and never moved even though the mask, the nameArches[0] borrow and the shadowing repick can all land the arch elsewhere; install.ps1 did not have this problem because it indexes name and arch identically.

Backwards compatibility

CPU-only and Intel hosts print byte-identical output to the merge base, every case completes with rc=0 and no hang, and all 21 tests/studio/*.ps1 pass. Nothing here changes wheel selection: the arch that picks the index is never read from the name.

Still open

Your two points from earlier stand and I have not done them here, since both are bigger than this diff. The CSV parse is now one function per shell script rather than two copies, but it is still mirrored across install.sh / setup.sh and install.ps1 / setup.ps1 the way the rest of these helpers are, since they have to work standalone. And the studio/setup.ps1 ROCm version-unknown fix is still riding along here and wants its own PR.

Two things I could not answer on this box: it has no AMD or Intel GPU and no Windows, so everything above rests on fake probes plus the real tool output shapes, and the branch is ~1200 commits behind main with a CI run old enough that the logs have expired. It wants a rebase and a fresh run, ideally on real AMD and NVIDIA hardware, before merge.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 14, 2026
Three more cases from the review, each reproduced in the fixture matrix before
being changed.

nvidia-smi does not honour CUDA_VISIBLE_DEVICES, so the mask has to be resolved
against its physical rows by hand, and only a numeric token was. A UUID mask
therefore left the index at 0 and named the first card rather than the visible
one. UUIDs are the form NVIDIA recommends over indices, may be abbreviated to
any unique leading portion, and a MIG id (MIG-<GPU-UUID>/<gi>/<ci>) embeds one,
so a non-numeric token is now looked up against --query-gpu=uuid by prefix, with
MIG unwrapped to its parent GPU. A token matching nothing still falls back to
row 0. The lookup runs only on the non-numeric path, so the ordinary case costs
no extra call and the CSV parse keeps its three documented columns.

hipinfo is itself a HIP application, so HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES
have already filtered its output and renumbered the survivors from zero.
install.ps1 indexed that output by the physical token as well, applying the mask
twice and landing on the wrong device; studio/setup.ps1 has always taken entry 0
and says so in a comment. install.ps1 now matches it. This was previously only an
arch selection, which is why it went unnoticed; printing the name made it visible.

setup.sh could resolve a marketing name but no gfx target and then drop the name,
falling through to a bare "AMD ROCm" while install.sh printed the name. The
name-only arm is added below the unsupported-GPU arm, not above it: a card with
no ROCm wheels also arrives here with a name, and naming it quietly would drop
the warning that training will not run.

Matrix is now 80 cases, all completing with no hang; tests/studio/*.ps1 all pass.
@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T08:39:04.968695Z 3d289eb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Two defects in the NVIDIA banner's device selection.

CUDA truncates enumeration at the first invalid index, so the documented "2,-1"
means "device 2, then stop". Both shell scripts classified the WHOLE mask, saw
the minus sign, called it non-numeric and sent a plain ordinal down the UUID
lookup, which matched nothing and named row 0. They now classify the first
entry, which is the one that selects the device. The PowerShell copies already
did this.

A numeric entry is a CUDA ordinal, not an nvidia-smi row. CUDA defaults to
CUDA_DEVICE_ORDER=FASTEST_FIRST, which puts the fastest card at 0 and leaves the
rest unspecified, while nvidia-smi always lists in PCI order. An ordinal
therefore identifies a row only when the order is pinned to PCI_BUS_ID, or when
the cards are interchangeable and every row gives the same answer anyway.
Otherwise the banner keeps the vendor-only wording and reports the driver alone,
which is what the AMD path already does when the mask and the records disagree.
A UUID or MIG id identifies the device outright, so it is unaffected.
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 14, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…its name

Two more selection defects.

NVIDIA accepts an abbreviated UUID only when it is a unique leading portion, so
a prefix matching two cards selects no device at all. The helper returned the
first match, and both PowerShell copies stopped at the first hit, so the banner
named one of them. They now count matches and resolve only on exactly one.

That exposed the same wrong assumption one level up: an identity mask that does
not resolve, whether ambiguous or naming a card that is not present, was falling
back to row 0. Row 0 is not a fallback for "CUDA selected nothing", it is a
different card. Those masks now keep the vendor-only wording.

In studio/setup.ps1, an unmappable adapter ahead of a supported one leaves
$nameArches shorter than $gpuNames, which skipped the block that moves the
banner name onto the adapter the arch came from. A generic integrated Radeon in
front of an RX 9070 therefore printed the integrated name against the discrete
arch. The source adapter is now recorded while $nameArches is built, so a
borrowed arch takes its own card's name with it.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 14, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 14, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 14, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 14, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 14, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

Rebased onto current main (ca4a695ce) and re-measured. main had moved 44 commits and the PR was CONFLICTING.

The conflict

One file, studio/setup.sh, two hunks, both from #10909 splitting the NVIDIA probe in two: _setup_has_physical_nvidia_gpu for "present, mask or no mask" and _setup_has_usable_nvidia_gpu for that plus the CUDA_VISIBLE_DEVICES check. My branch had added the wedged-driver detection to the old combined function.

Resolved by taking main's split and moving the wedge detection into _setup_has_physical_nvidia_gpu, which is where the bounded -L call now lives and which both entry points reach. main's wrapper is kept verbatim. Net installer delta against main is +686/-32 across the four scripts.

Performance

112 fixture cases, five runs each, merge base vs head, timing only the installer process and taking the minimum:

host shape extra probe processes wall delta
NVIDIA, 70 shapes 0 to 2 +0.2 to +24.7 ms
AMD, 34 shapes 0 -2.3 to +4.7 ms
CPU only 0 +0.2 to +1.5 ms

AMD adds nothing because main already computes the marketing name. NVIDIA adds one --query-gpu call, and a second only when the mask is a UUID or MIG id that has to be resolved against the physical rows. No case adds more than two.

The wedged-driver cases, where cost is bounded rather than measured in milliseconds:

install  nv/WEDGED-driver      1 probe  -> 1 probe    10013 ms -> 10015 ms
setup    nv/WEDGED-driver      2 probes -> 2 probes   20016 ms -> 20020 ms
install  amd/WEDGED-rocminfo   2 probes -> 2 probes   18024 ms -> 18025 ms
setup    amd/WEDGED-rocminfo   1 probe  -> 1 probe    10126 ms -> 10129 ms

One thing worth a separate look

setup nv/WEDGED-driver costs 20s rather than 10s, on both sides. That is not this PR: #10909 calls _setup_has_physical_nvidia_gpu and then _setup_has_usable_nvidia_gpu back to back, and the second call re-runs the bounded nvidia-smi -L, so a wedged driver pays the 10s bound twice before setup is classified. install.sh calls its probe once and still pays 10s.

I have not touched it here. Memoizing the probe would halve that stall, but the second call also exists to re-check after a PATH gap or driver-init race, which is exactly what a cached answer would hide, so it deserves its own change rather than a quiet one inside this PR.

Verification at ca4a695ce: 112 shell fixture cases and 75 PowerShell cases, no failures; test_rocm_support.py + test_installer_av_shapes.py + test_formatter_fixed_point.py 635 passed, 2 skipped; five installer tests/studio/*.ps1 suites passing; eight tests/sh/ GPU suites passing, including test_install_gpu_summary_probe_sources.sh (28), test_setup_gpu_summary_probe_sources.sh (37) and test_rocminfo_gpu_name_7307.sh (23). PR is MERGEABLE again and cross-platform CI is staged at this head.

CUDA stops enumerating at the first invalid index, so CUDA_VISIBLE_DEVICES=1 on
a one-GPU host exposes no device at all. The row pick clamps an out-of-range
index to 0 so the driver version still reads, and the banner then named row 0:
a card the process cannot use.

An ordinal past the last row now counts as unresolved, the same as an identity
mask that matches nothing, so the banner keeps the vendor-only wording.

The existing out-of-range fixture did not catch this. It used two different
cards under CUDA's default order, so the ordering guard suppressed the name for
an unrelated reason and the range bug stayed invisible. The new fixtures pin
CUDA_DEVICE_ORDER and use identical cards, which disables that guard and leaves
the range check as the only thing that can answer.
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 15, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The previous fix only moved the banner name when the arch was BORROWED from
another adapter. A visible-device mask selecting a supported adapter that sits
behind an unmappable one resolves the arch directly, so the borrow never fires,
$nameArches is still shorter than $gpuNames, and neither naming branch ran:
HIP_VISIBLE_DEVICES=1 over ["AMD Radeon Graphics", "AMD Radeon RX 9070"]
printed the integrated name against the discrete arch.

One index now records which adapter supplied the arch in either case.

It is spelled `if ($pickedName -and $_archSrcIdx -lt 0)` rather than a bare
truthiness test because `if ($pickedName) {` is the end anchor
TestSetupPs1ShadowingParity slices the borrow block on. A second copy closed
that window early and hid the pinned-mask guard from it, which failed the test
on the first attempt. A new case pins the occurrence count so the anchor cannot
be shadowed again.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 63eeb29b01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Self-review turned up two ways a numerically valid ordinal slipped past the
checks added over this review.

awk subscripts arrays by the STRING form of the key, so a["0000"] is a different
cell from a[0]. Rows are stored with a[n++], whose keys are "0", "1", so a
CUDA_VISIBLE_DEVICES of "0000" or "01" read an empty cell, the row came back
blank and the banner degraded to the vendor wording with no driver line. Six
sites across the two scripts, NVIDIA and AMD alike; every one now forces numeric
context on the subscript.

The bash test builtin parses with strtol and errors on a value wider than a
long. An all-digit ordinal that overflows printed a shell diagnostic into the
user's terminal and skipped the out-of-range check entirely, so it named row 0,
the exact case that check exists to refuse. The ordinal is now clamped to 9999,
which is past any real host, so it stays out of range and declines.

Eight fixtures pin the non-canonical spellings, with the cards differing and the
device order pinned so only the ordinal can decide the outcome.
@danielhanchen
danielhanchen force-pushed the feat/studio-installer-gpu-name branch from 0cc87e0 to 3d289eb Compare September 15, 2026 08:34
@danielhanchen

Copy link
Copy Markdown
Member

Self-review pass over the accumulated diff while CI was queued, hunting the defect class that has shown up repeatedly here: a guard that is individually right but that another path walks around. Two found, both fixed in 3d289eb4e.

awk subscripts by the string form of the key. Rows are stored with a[n++], whose keys are "0", "1", so a["0000"] is a different cell entirely. A CUDA_VISIBLE_DEVICES of 0000 or 01 read an empty cell, the row came back blank, and the banner fell back to the vendor wording with no driver line at all. Six sites across the two scripts, NVIDIA and AMD alike, all mine from earlier in this review. Every one now forces numeric context on the subscript.

The [ builtin parses with strtol and errors on a value wider than a long. An all-digit ordinal that overflows printed a shell diagnostic into the user's terminal and skipped the out-of-range check added last round, so it named row 0, which is the exact case that check exists to refuse:

before:  CUDA_VISIBLE_DEVICES=99999999999999999999999
         install.sh: line 2114: [: 99999999999999999999999: integer expression expected
         gpu   NVIDIA GeForce RTX 4090 (sm_89)
after:   gpu   NVIDIA GPU detected

The ordinal is clamped to 9999 before anything compares or subscripts with it. Clamped rather than rejected, because 9999 is past any real host, so it stays out of range and declines, which is the answer we want anyway.

Both were invisible to the existing fixtures because every mask they used was already canonical. The eight new cases use non-canonical but all-digit spellings, with the cards differing and CUDA_DEVICE_ORDER pinned so nothing except the ordinal can decide the outcome:

0000                      ->  NVIDIA GeForce RTX 4090 (sm_89)     row 0
01                        ->  NVIDIA RTX A6000 (sm_86)            row 1
007                       ->  NVIDIA GPU detected                 out of range
99999999999999999999999   ->  NVIDIA GPU detected                 out of range, no shell error

126 shell fixture cases and 85 PowerShell cases, no failures; test_rocm_support.py + test_installer_av_shapes.py 626 passed, 1 skipped; four tests/sh/ GPU suites passing.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 3d289eb4ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

install.ps1 and studio/setup.ps1 both conflicted at the same place: main grew a
Get-NvidiaLibraryInventory promotion that sets $HasNvidiaSmi when the driver lists a GPU
nvidia-smi cannot, and this branch added the naming query, both appended after the same
nvidia-smi resolution loop and both closed by the same brace.

Kept both, promotion first. The naming block is gated on $NvidiaSmiExe, which is assigned
only where Test-NvidiaSmiHasGpu answered, so a host promoted through the driver library
alone has no exe and keeps the vendor-only wording instead of querying a binary that is
absent or was rejected.

install.sh and studio/setup.sh merged without conflict and keep main's reflection emit in
the WSL shortcut path: no Add-Type, no ExecutionPolicy Bypass.
@danielhanchen
danielhanchen merged commit 32c01c8 into unslothai:main Sep 16, 2026
74 of 76 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…MD) (unslothai#8762)

* Unsloth Studio Installer: name the actual GPU, whichever vendor it is

The GPU line said a different kind of thing per vendor, and on two of the
three it did not say which card:

  gpu            NVIDIA GPU detected          <- no name, ever
  gpu            Intel GPU detected           <- name on the substep below
                 Intel Arc A770
  gpu            AMD ROCm (gfx1200)           <- arch, not a name

Every probe already had the answer. nvidia-smi is resolved and run before
this point and was simply never asked; the shell scripts resolve the AMD
marketing name into $_gpu_disp_mkt / $_setup_mkt for their own name -> arch
inference and never print it; and the backend prints the real name at
startup seconds later:

  Hardware detected: ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XT

One shape for all three now: `step "gpu"` is the device, the runtime detail
drops to a substep.

  gpu            NVIDIA GeForce RTX 4090
  gpu            Intel Arc A770
  gpu            AMD Radeon RX 9060 XT (gfx1200)
                 HIP SDK: C:\Program Files\AMD\ROCm\7.1

Each vendor honours its own visible-device mask when picking which card to
name (CUDA_VISIBLE_DEVICES, HIP/ROCR_VISIBLE_DEVICES), so a masked run names
the card it is actually going to use.

On the AMD side the name is kept in its own variable rather than folded into
$ROCmGpuLabel: that one doubles as the input to the name -> arch tables, so
changing its shape would move wheel selection. It is read from hipinfo's
per-device "Name:", amd-smi's Market Name, or the WMI adapter name, always
at the index the arch pick landed on and only when the name and arch lists
line up, so a format change can mislabel nothing and the arch that selects
the wheel is never taken from it.

Also stops setup.ps1 reporting a known ROCm version as unknown. It probed
hipconfig then amd-smi and, on a runtime-only layout with neither on PATH,
printed

  rocm           ROCm (version unknown)

one line after the summary printed C:\Program Files\AMD\ROCm\7.1. The SDK
root is versioned, so that is now the last-resort source.

* Give NVIDIA the same compute target and runtime line as AMD

The first pass unified the device name across vendors but left AMD as the
only one showing what it would actually compile for:

  gpu            NVIDIA GeForce RTX 4090
  gpu            AMD Radeon RX 9060 XT (gfx1200)
                 HIP SDK: C:\Program Files\AMD\ROCm\7.1

compute_cap is the counterpart of the gfx arch, and the driver version the
counterpart of the HIP SDK line. Both come back from the query that already
fetches the name, so this costs no extra call:

  gpu            NVIDIA GeForce RTX 4090 (sm_89)
                 Driver: 550.54.15

The installer was already reading compute_cap, but only inside
Get-NvidiaCu126Verdict, which runs on the cu128/cu130 path to decide a
fallback and returns early otherwise, so it was never available where the
banner is printed.

Fields are split from the right because nvidia-smi does not quote its CSV,
so a comma in a device name would otherwise shift every column. A row with
fewer fields than requested falls back to using the whole row as the name
rather than reporting a driver version that is really a compute capability.

Intel keeps the name alone. There is no counterpart to gfx1200 / sm_89 that
any probe here already resolves, and inventing one to make the column look
even is worse than the gap.

* Installer GPU banner: name the GPU, not the CPU, and keep the probe bounded

Simulated the banner against fake nvidia-smi / rocminfo / amd-smi on a 74-case
matrix (both shell entry points x NVIDIA / AMD / Intel / CPU-only host shapes),
running the merge base and this branch against identical fixtures. Three
problems only showed up once the name was actually printed.

rocminfo enumerates the CPU as Agent 1, and that agent carries its own
"Marketing Name:". Taking the first match in the stream therefore named the
processor: an RX 7900 XTX box read "AMD Ryzen 9 7950X 16-Core Processor
(gfx1100)". On Strix Halo it is worse, because the CPU agent's name is
"AMD RYZEN AI MAX+ 395 w/ Radeon 8060S" -- it contains a Radeon model, so it
reads like a GPU name, and $_setup_mkt also feeds the name -> arch table. The
parse is now per agent and only an agent whose Device Type is GPU can name the
banner. Agents are collected as gfx/name pairs and the banner takes the name
belonging to the arch that was picked, so an iGPU + dGPU host no longer prints
the integrated name against the discrete arch.

The new nvidia-smi query ran unbounded. Every other nvidia-smi call in these
files goes through _run_bounded / _setup_run_smi / Invoke-NvidiaSmiBounded
precisely because a wedged driver blocks nvidia-smi indefinitely; in the matrix
a hung probe took the whole installer down on this branch while the merge base
finished normally. It now uses the bounded runner, and the shell side reuses the
executable the detection helper already resolved into $_nvsmi rather than
re-resolving with `command -v` -- detection also succeeds via /usr/bin/nvidia-smi
off PATH and via /proc/driver/nvidia/gpus with no nvidia-smi at all, and those
hosts would otherwise silently lose the name.

Placeholder rows are no longer treated as device names. An nvidia-smi too old
for compute_cap answers "[N/A]" rather than failing, which printed a GPU called
"[N/A]"; a short row used the whole row, printing "RTX 4090, 8.9". Short rows now
keep field 1 and the placeholders fall back to the old text.

Also on the AMD side: amd-smi spells the field MARKET_NAME in caps, so the
[Mm]arket.?[Nn]ame class matched no real casing and that probe never yielded a
name at all. Matched case-insensitively now, and the rocminfo and amd-smi calls
in install.sh are bounded like their setup.sh counterparts.

In setup.ps1 the device index is carried forward from Resolve-VisibleGpuIndex
instead of being recovered from the arch value. The arch list is deliberately not
deduplicated, so [array]::IndexOf always returned the first occurrence: two
same-arch cards with different SKUs (RX 7900 XTX + PRO W7900) named the first one
even when the mask selected the second. The WMI adapter name is likewise moved
onto the adapter the arch pick landed on, which the mask, the nameArches[0]
borrow and the shadowing repick can all change.

CPU-only and Intel hosts print exactly what they printed before this branch, and
all 21 tests in tests/studio/*.ps1 pass.

* Resolve UUID and MIG GPU masks, and read hipinfo at logical device zero

Three more cases from the review, each reproduced in the fixture matrix before
being changed.

nvidia-smi does not honour CUDA_VISIBLE_DEVICES, so the mask has to be resolved
against its physical rows by hand, and only a numeric token was. A UUID mask
therefore left the index at 0 and named the first card rather than the visible
one. UUIDs are the form NVIDIA recommends over indices, may be abbreviated to
any unique leading portion, and a MIG id (MIG-<GPU-UUID>/<gi>/<ci>) embeds one,
so a non-numeric token is now looked up against --query-gpu=uuid by prefix, with
MIG unwrapped to its parent GPU. A token matching nothing still falls back to
row 0. The lookup runs only on the non-numeric path, so the ordinary case costs
no extra call and the CSV parse keeps its three documented columns.

hipinfo is itself a HIP application, so HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES
have already filtered its output and renumbered the survivors from zero.
install.ps1 indexed that output by the physical token as well, applying the mask
twice and landing on the wrong device; studio/setup.ps1 has always taken entry 0
and says so in a comment. install.ps1 now matches it. This was previously only an
arch selection, which is why it went unnoticed; printing the name made it visible.

setup.sh could resolve a marketing name but no gfx target and then drop the name,
falling through to a bare "AMD ROCm" while install.sh printed the name. The
name-only arm is added below the unsupported-GPU arm, not above it: a card with
no ROCm wheels also arrives here with a name, and naming it quietly would drop
the warning that training will not run.

Matrix is now 80 cases, all completing with no hang; tests/studio/*.ps1 all pass.

* Pick amd-smi's market name by device index, and unbreak the hipinfo probe test

Two findings from the last review round, both on the previous commits here.

The amd-smi fallback took the first MARKET_NAME in the output while the arch was
taken at the masked index, so a multi-AMD host with no rocminfo and
HIP_VISIBLE_DEVICES=1 paired GPU 0's name with GPU 1's arch. The rocminfo path
was already fixed by pairing name to agent, and the PowerShell paths by carrying
the index forward, but the shell amd-smi fallback still read only the first name.
It now collects every device's name and selects at the same index the arch came
from. In the fixture matrix the masked two-GPU case goes from "Radeon RX 7900 XTX
(gfx1100)" to "Radeon PRO W7900 (gfx1100)", and the unmasked case still names the
XTX.

_assert_accepts_partial_hipinfo_output sliced a fixed 1600 characters from the
hipinfo probe and asserted the gcnArchName diagnostic was inside it. The name
selection added here pushed that diagnostic past the cut, so
test_setup_accepts_hipinfo_gcnarchname_on_nonzero_exit and its install.ps1 twin
failed against correct code. The slice is now bounded at the catch that closes the
probe's own try, which does not move when the parse gains a branch.

tests/studio/install/test_rocm_support.py is 492 passed, 1 skipped; the fixture
matrix is 82 cases with no hang; tests/studio/*.ps1 all pass.

* Resolve opaque MIG UUIDs, and keep the device index when arches repeat

Three findings from the last round, all on the previous commits here.

Since R470 each MIG instance carries its OWN opaque UUID, MIG-<UUID>, which
contains nothing of the parent GPU; only the pre-R470 name embedded one as
MIG-<GPU-UUID>/<gi>/<ci>. The unwrap added earlier assumed the legacy form, so a
modern MIG mask matched no --query-gpu=uuid row and the banner fell back to GPU 0.
The two forms are now split: the legacy one still resolves through the embedded
parent, and the opaque one resolves through the GPU nesting in `nvidia-smi -L`,
which is the documented way to map an instance back to its card.

Two places still recovered a device index from an arch VALUE, which is not unique.
On rocminfo the agent lookup exited on the first agent carrying the selected arch,
and in the setup.ps1 WMI fallback IndexOf did the same over $nameArches. Two cards
of one arch with different names (RX 7900 XTX and PRO W7900 are both gfx1100) then
named the first regardless of the mask. Both now keep the index that was actually
selected, falling back to the arch match only where a shadowing repick moved the
arch off it, so the name and the arch always describe the same device.

Found while testing the above rather than by review: the new agent lookup wrote
a[n] with n unset, and an unset awk variable subscripts as "" rather than 0, so
a[0] was never assigned and the unmasked two-card case named the second GPU. The
counter is initialised explicitly now. The sibling snippets use a[n++], where the
increment forces numeric context, and were unaffected.

Matrix is 88 cases with no hang, PowerShell 36 cases, test_rocm_support.py 492
passed 1 skipped, tests/studio/*.ps1 all passing.

* Do not pay the probe timeout twice when nvidia-smi is wedged

Detection already runs nvidia-smi -L under the 10s bound, and a host whose
driver is wedged still detects as an NVIDIA GPU through /proc/driver/nvidia.
The banner then asked the same hung binary for a name and waited out the bound
again, so the installer stalled 20s where main stalled 10.

Detection now records the timeout (timeout's 124, and the PowerShell runner's
own 124) and the banner skips its query when it is set, falling back to the
vendor-only wording main already printed. Measured over the 88-case fixture
matrix: the wedged case is back to 10s, every other case adds at most one probe
process and 25ms.

* Do not name an NVIDIA card that CUDA_VISIBLE_DEVICES hides

CUDA_VISIBLE_DEVICES=-1 or "" hides every device. The Windows resolver matched
neither the numeric nor the MIG form, so -1 fell through to the UUID branch,
spent a probe that can never match, and left the index at 0 -- naming row 0 and
printing its compute target while CUDA exposes no GPU at all. The shell
installers already treat both spellings as all-hidden in _cvd_hides_nvidia.

Only the naming is skipped. HasNvidiaSmi still drives wheel selection, as on
main, so the banner falls back to the vendor-only wording main already printed
rather than claiming a card that is not there.

* Judge the CUDA mask by its first entry, and do not guess a CUDA ordinal

Two defects in the NVIDIA banner's device selection.

CUDA truncates enumeration at the first invalid index, so the documented "2,-1"
means "device 2, then stop". Both shell scripts classified the WHOLE mask, saw
the minus sign, called it non-numeric and sent a plain ordinal down the UUID
lookup, which matched nothing and named row 0. They now classify the first
entry, which is the one that selects the device. The PowerShell copies already
did this.

A numeric entry is a CUDA ordinal, not an nvidia-smi row. CUDA defaults to
CUDA_DEVICE_ORDER=FASTEST_FIRST, which puts the fastest card at 0 and leaves the
rest unspecified, while nvidia-smi always lists in PCI order. An ordinal
therefore identifies a row only when the order is pinned to PCI_BUS_ID, or when
the cards are interchangeable and every row gives the same answer anyway.
Otherwise the banner keeps the vendor-only wording and reports the driver alone,
which is what the AMD path already does when the mask and the records disagree.
A UUID or MIG id identifies the device outright, so it is unaffected.

* An unresolved GPU identity is not row 0, and a borrowed arch carries its name

Two more selection defects.

NVIDIA accepts an abbreviated UUID only when it is a unique leading portion, so
a prefix matching two cards selects no device at all. The helper returned the
first match, and both PowerShell copies stopped at the first hit, so the banner
named one of them. They now count matches and resolve only on exactly one.

That exposed the same wrong assumption one level up: an identity mask that does
not resolve, whether ambiguous or naming a card that is not present, was falling
back to row 0. Row 0 is not a fallback for "CUDA selected nothing", it is a
different card. Those masks now keep the vendor-only wording.

In studio/setup.ps1, an unmappable adapter ahead of a supported one leaves
$nameArches shorter than $gpuNames, which skipped the block that moves the
banner name onto the adapter the arch came from. A generic integrated Radeon in
front of an RX 9070 therefore printed the integrated name against the discrete
arch. The source adapter is now recorded while $nameArches is built, so a
borrowed arch takes its own card's name with it.

* An out-of-range CUDA ordinal selects nothing, not GPU 0

CUDA stops enumerating at the first invalid index, so CUDA_VISIBLE_DEVICES=1 on
a one-GPU host exposes no device at all. The row pick clamps an out-of-range
index to 0 so the driver version still reads, and the banner then named row 0:
a card the process cannot use.

An ordinal past the last row now counts as unresolved, the same as an identity
mask that matches nothing, so the banner keeps the vendor-only wording.

The existing out-of-range fixture did not catch this. It used two different
cards under CUDA's default order, so the ordering guard suppressed the name for
an unrelated reason and the range bug stayed invisible. The new fixtures pin
CUDA_DEVICE_ORDER and use identical cards, which disables that guard and leaves
the range check as the only thing that can answer.

* Name the adapter that supplied the arch, selected or borrowed

The previous fix only moved the banner name when the arch was BORROWED from
another adapter. A visible-device mask selecting a supported adapter that sits
behind an unmappable one resolves the arch directly, so the borrow never fires,
$nameArches is still shorter than $gpuNames, and neither naming branch ran:
HIP_VISIBLE_DEVICES=1 over ["AMD Radeon Graphics", "AMD Radeon RX 9070"]
printed the integrated name against the discrete arch.

One index now records which adapter supplied the arch in either case.

It is spelled `if ($pickedName -and $_archSrcIdx -lt 0)` rather than a bare
truthiness test because `if ($pickedName) {` is the end anchor
TestSetupPs1ShadowingParity slices the borrow block on. A second copy closed
that window early and hid the pinned-mask guard from it, which failed the test
on the first attempt. A new case pins the occurrence count so the anchor cannot
be shadowed again.

* Canonicalise the device ordinal before subscripting or comparing with it

Self-review turned up two ways a numerically valid ordinal slipped past the
checks added over this review.

awk subscripts arrays by the STRING form of the key, so a["0000"] is a different
cell from a[0]. Rows are stored with a[n++], whose keys are "0", "1", so a
CUDA_VISIBLE_DEVICES of "0000" or "01" read an empty cell, the row came back
blank and the banner degraded to the vendor wording with no driver line. Six
sites across the two scripts, NVIDIA and AMD alike; every one now forces numeric
context on the subscript.

The bash test builtin parses with strtol and errors on a value wider than a
long. An all-digit ordinal that overflows printed a shell diagnostic into the
user's terminal and skipped the out-of-range check entirely, so it named row 0,
the exact case that check exists to refuse. The ordinal is now clamped to 9999,
which is past any real host, so it stays out of range and declines.

Eight fixtures pin the non-canonical spellings, with the cards differing and the
device order pinned so only the ordinal can decide the outcome.

---------

Co-authored-by: danielhanchen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants