Skip to content

fix(studio): correct the AMD GPU name to gfx table against AMD's own device lists - #17904

Merged
danielhanchen merged 8 commits into
unslothai:mainfrom
bezabyte:codex/issue-17874-amd-registry-detection
Nov 16, 2026
Merged

danielhanchen merged 8 commits into
unslothai:mainfrom
bezabyte:codex/issue-17874-amd-registry-detection

Conversation

@bezabyte

@bezabyte bezabyte commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17874

What changed

On Windows, AMD's multi-arch index ships PyTorch GPU kernels per exact chip (torch[device-gfxNNNN]; the amd-torch-device-gfx1030 wheel carries only torch_gfx1030.kpack). When the installer can only read the GPU's marketing name (driver-only hosts, no HIP SDK), the name table decides which chip's kernels get installed. Since #11846 moved Windows RDNA onto that index, the table's coarse RDNA 2 grouping gave several cards kernels for a different chip, and a few other rows were wrong or missing.

Every row was checked against AMD-maintained and upstream sources, not against the other copies of the table:

Wrong chip (fixed)

GPU die before after
RX 6700S, RX 6800S, RX 6750 GRE 10GB Navi 23 gfx1030 gfx1032
RX 6700, 6700 XT, 6750 XT, 6750 GRE 12GB, 6700M, 6800M, 6850M XT Navi 22 gfx1030 gfx1031
Ryzen Z2 Extreme (Zen 5 + RDNA 3.5, 16 CU) Strix Point gfx1103 gfx1150
Ryzen AI 5 330 / Radeon 820M / Krackan Point 2 (Windows) Krackan 2 gfx1152 or none gfx1153

The RX 6750 GRE is one name on two dies (amdgpu.ids 73DF Navi 22 for 12GB, 73FF Navi 23 for 10GB). TheRock names gfx1153 "AMD Radeon 820M iGPU", and AMD ships a Windows gfx1153 device pack; Linux keeps its existing Krackan Point 2 handling (no Linux gfx1153 wheel), so the gfx1153 row is only in the Windows and Python copies.

Recognised now (previously CPU torch on driver-only hosts)

RX 7400, RX 7300, Radeon Pro W7400, Steam Machine (gfx1102); RX 9050 (gfx1200); Radeon AI PRO R9600D (gfx1201); Radeon 6550S (gfx1034); Radeon Pro V620 (gfx1030).

Deliberately left unmapped

Radeon 680M / 660M / 610M (RDNA 2 iGPUs) stay on CPU torch: ROCm training on RDNA 2 APUs is unmeasured and gfx1033 computes wrong answers (studio/ROCM_RDNA2_APU.md); a test pins this. "Radeon 840M" ships on both Krackan (gfx1152) and Krackan 2 (gfx1153) per amdgpu.ids 1114 / 1902, so the name alone cannot tell them apart; it keeps gfx1152 and hipinfo still decides when present.

All six copies change together (install.ps1, studio/setup.ps1, studio/install_python_stack.py, studio/backend/utils/hardware/hardware.py, install.sh, studio/setup.sh). On Linux every moved arch still resolves to the same wheel family, and the Krackan Point 2 lspci / cpuinfo paths are unchanged.

Validation

  • Sweep of all 113 AMD-maintained RDNA names in amdgpu.ids through the table: 9 resolved to the wrong chip before, 0 now; the 6 unmatched names are the deliberate iGPUs above, the Steam Deck (gfx1033, kept off ROCm), and two server parts.
  • tests/studio/install/test_rocm_arch_table_parity.py: the sourced arches are now checked in every copy; the gfx1031 spoof exemption is removed; the RDNA 2 iGPUs are pinned unmapped.
  • tests/studio/install/test_windows_amd_name_detection.py: a WMI name resolves to its own torch[device-gfxNNNN] pack, gfx1153 included.
  • tests/studio/test_amd_name_arch_r9700.ps1: the same names through PowerShell's own -match.
  • 25 of these tests fail on the merge base and pass here; 0 fail only on this branch. Installer shell and PowerShell suites pass on both sides.

@bezabyte

Copy link
Copy Markdown
Contributor Author

@danielhanchen Could you review this AMD detection fix? The fork account cannot execute GitHub reviewer requests, so I am tagging you here.

@danielhanchen danielhanchen self-assigned this Nov 16, 2026
…s; registry fallback only when WMI fails

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T13:15:07.792816Z 29b338c 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efa7d63dea

ℹ️ 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".

Comment thread studio/install_python_stack.py Outdated
Comment on lines +2260 to +2263
_registry_tokens = [
_arch for _name in _registry_names if (_arch := _gfx_arch_from_gpu_name(_name)) is not None
]
_registry_pick = _dedup_pick(_registry_tokens, warn = False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve adapter indices in the registry fallback

When WMI fails on a hybrid AMD machine and the registry contains AMD Radeon(TM) Graphics followed by AMD Radeon RX 6700S, HIP_VISIBLE_DEVICES=0 currently yields gfx1032: the first name is discarded before _dedup_pick indexes the list. This silently selects the dGPU despite the iGPU being pinned, and _ensure_rocm_torch can install the wrong per-arch device pack. Resolve the mask over the full adapter-name list and only borrow another adapter's arch when unpinned, matching the WMI path above.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ac6d70d: the mask now indexes the full registry adapter list, and another adapter's arch is borrowed only when unpinned, matching the WMI path.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac6d70d0c2

ℹ️ 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".

Comment thread studio/install_python_stack.py Outdated
Comment on lines +2270 to +2272
if _registry_pick:
_safe_print(f" gfx arch inferred from GPU registry: {_registry_pick}")
return _registry_pick

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply registry recovery before the PowerShell stale-venv check

On a driver-only Windows host whose WMI remains unavailable, this recovery exists only in the Python stage: setup.ps1 still has no arch and publishes a CPU expectation. After ROCm is installed using this result, the next studio update treats the ROCm venv as stale (studio/setup.ps1:6693–6709) and force-reinstalls CPU torch (studio/setup.ps1:8309–8317) before Python repairs it back to ROCm. The bundled hipInfo.exe does not prevent this because setup explicitly excludes venv copies at studio/setup.ps1:4264–4266. Reuse registry recovery before setup's stale-venv and index decisions so subsequent updates do not repeatedly replace a working GPU build with CPU and then ROCm again.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cf94aba by removing the registry fallback: the name table change covers the reported card, and a Python-only fallback would make setup.ps1 swap the venv back to CPU on every update.

Comment thread studio/install_python_stack.py Outdated
_registry_names[_pick_visible_index(len(_registry_names), warn = False)]
)
else:
_registry_pick = _dedup_pick(_registry_tokens, warn = False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Translate the unpinned mask hint back to adapter indices

The pinned branch fixes the earlier report, but this unpinned branch still gives _dedup_pick a shortened list even though that helper prints a device-index hint. With WMI unavailable and registry order [AMD Radeon 780M Graphics, AMD Radeon RX 580, AMD Radeon RX 6700 XT], it selects gfx1031 but recommends HIP_VISIBLE_DEVICES=1, because the unmapped RX 580 was removed from _registry_tokens. Following that advice makes the next invocation's pinned registry branch resolve index 1 to the RX 580 and return None instead of gfx1031. Translate the suggested index back to the original adapter list—index 2 here—rather than exposing an index into the compressed token list.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The registry fallback is removed in cf94aba, so this hint path no longer exists.

@danielhanchen danielhanchen changed the title fix(studio): recover AMD detection from Windows registry fix(studio): route RX 6700S / 6800S and Navi 22 cards to their own AMD Windows device packs Nov 16, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: cf94abae8b

ℹ️ 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".

danielhanchen added a commit that referenced this pull request Nov 16, 2026
…apper above it (rest shard red on main) (#17952)

## Summary

`Repo tests (CPU, rest)` fails on current main (seen on #17921, #17934
and the staging run of #17904) in:

```
tests/test_flex_mask_graph_breaks.py::test_compiled_flex_mask_has_no_graph_breaks_and_matches_eager
E   torch._dynamo.exc.Unsupported: Data-dependent branching
E     File ".../unsloth_zoo/temporary_patches/misc.py", line 1318, in flex_attention_mask
E       return original(*bound.args, **bound.kwargs)
E     File ".../unsloth/import_fixes.py", line 2471, in flex_attention_mask
E       return original(*args, **kwargs)
E     File ".../transformers/masking_utils.py", line 685, in flex_attention_mask
E       if attention_mask is not None and not fast_all(attention_mask):
```

It started with unslothai/unsloth-zoo#2551 (the test passes with zoo at
its parent and fails at it). That PR wraps the registered
`flex_attention` mask builder to keep the padding `mask_mod` during
training, and forwards every call as `original(*bound.args,
**bound.kwargs)`, i.e. by position. The wrapper it sits on is Unsloth's
`fix_transformers_flex_mask_graph_breaks` patch, which only handled
keyword calls: with any positional argument it called transformers
directly, so while Dynamo traces the `fast_all(attention_mask)` branch
came back and `fullgraph` tracing broke.

Both patches are right on their own; the Unsloth one was fragile about
how it is called, so this hardens it rather than changing zoo.

## Change

- `unsloth/import_fixes.py`: the flex mask patch binds positional
arguments to the original's signature and continues with keywords (new
helper `_keyword_arguments`, which merges `**kwargs` parameters and
returns `None` for anything it cannot express as keywords; then the call
goes through unchanged, as before).
- `tests/test_flex_mask_graph_breaks.py`: new
`test_a_wrapper_forwarding_by_position_keeps_the_compiled_path`
registers a wrapper that forwards by position above the patch (as zoo's
does) and checks the `fullgraph` compile of a padded batch matches
eager. It does not depend on which zoo is installed.

## Testing

| unsloth | unsloth_zoo | `test_flex_mask_graph_breaks.py` |
|---|---|---|
| main | main | 1 failed (the CI failure) |
| this PR | main | 4 passed, 1 skipped |
| this PR | before #2551 | 4 passed, 1 skipped |
| main | before #2551 | 1 failed: the new positional-wrapper test |

CPU, torch 2.10, transformers 5.17 (the CI pins for this shard).
danielhanchen added a commit that referenced this pull request Nov 16, 2026
…he gloo shard (2100 s cap) (#17969)

## Summary

`Repo tests (CPU, gloo)` is timing out again: the shard's pytest runs
under `timeout --signal=INT 2100` and recent runs were cut off there
with nothing failing:

| run | result |
|---|---|
| #17934 (upstream) | 257 passed, 3 skipped in 2089.55 s, exit 124 |
| staging run of #17904 | 258 passed, 3 skipped in 2095.11 s, exit 124 |
| staging run of #17957 | 251 passed, 1 failed in 2096.44 s, exit 124 |

For comparison the same shard ran 241 tests in 1292 s when #17892 merged
this morning. Since then #17886
(`test_tp_dpo_peft_ref_adapter_gloo.py`), #17930
(`test_cp_ulysses_media_towers_gloo.py`),
`test_cp_ulysses_dynamic_len_gloo.py` and the DeepSeek-V4.1 additions to
`test_parallel_deepseek_v41_gloo.py` landed in it, and a slower runner
now goes over the cap. Every one of those tests passes; the shard just
no longer fits.

## Change

- `.github/workflows/studio-backend-ci.yml`:
`tests/test_tp_[!n]*gloo*.py` (the non-native tensor parallel files:
`tp_env`, `tp_eval`, `tp_full_finetune`, `tp_replica`,
`tp_kv_replicated`, `tp_moe_dropout`, `tp_dpo_peft_ref_adapter`, ...; 12
files) moves out of `gloo` into a new `gloo-tp-env` shard. `gloo` keeps
its other three globs (19 files). Comment added with the numbers above.
- `tests/studio/test_backend_ci_parallel_isolation.py`: the command
scan's expected counts go from 15 parallel runs / 10 repo-root shards to
16 / 11, as its message asks when a shard is added.

## Why that split

Measured locally on main with the shard's exact command (`-n 4 --dist
loadgroup`): 275 passed in 1302.83 s. Of the 40 slowest tests (2815
worker-seconds), 2716 s are in `tests/test_tp_[!n]*gloo*.py`; out of
about 5200 worker-seconds in total, so these 12 files are well over half
of the shard. Each half now has room under the cap on a slower runner.

## Testing

- `tests/test_ci_repo_cpu_shards.py` (every repo test file collected by
exactly one shard, every glob matches a file): 15 passed.
- All 15 test files that read `studio-backend-ci.yml`: 341 passed, 3
skipped.
- The new shard's first run on this PR is the timing check.
@danielhanchen danielhanchen changed the title fix(studio): route RX 6700S / 6800S and Navi 22 cards to their own AMD Windows device packs fix(studio): correct the AMD GPU name to gfx table against AMD's own device lists Nov 16, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c8bea9925

ℹ️ 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".

Comment thread studio/setup.sh
*"860M"*|*"840M"*|*"Krackan"*|*"AI 7 35"*|*"AI 5 34"*|*"AI 7 PRO 35"*|*"AI 5 33"*) _sup_gfx_out="gfx1152" ;; # RDNA 3.5 (Krackan Point: Radeon 860M/840M, Ryzen AI 7 350 / AI 5 340)
*"RX 7600"*|*"RX 7700S"*|*"RX 7650"*|*"PRO W7600"*|*"PRO W7500"*) _sup_gfx_out="gfx1102" ;; # RDNA 3 (Navi 33)
*"890M"*|*"880M"*|*"Strix Point"*|*"HX 37"*|*"AI 9 HX"*|*"AI 9 36"*|*"Z2 Extreme"*) _sup_gfx_out="gfx1150" ;; # RDNA 3.5 (Strix Point: Radeon 890M/880M, Ryzen AI 9 HX 370/375)
*"860M"*|*"840M"*|*"Krackan"*|*"AI 7 35"*|*"AI 5 34"*|*"AI 7 PRO 35"*) _sup_gfx_out="gfx1152" ;; # RDNA 3.5 (Krackan Point: Radeon 860M/840M, Ryzen AI 7 350 / AI 5 340)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the Krackan peer regression with the name-table change

The existing Linux regression tests/studio/install/test_setup_sh_gfx1153_lspci_peer.py::test_marketing_name_block fails for its RX 7900 peer case after this removal: _setup_supported_gfx_from_name no longer matches AMD Ryzen AI 5 330 w/ Radeon 820M, leaving _setup_gfx empty rather than the test's expected gfx1152. The same case passes on the parent commit. .github/workflows/studio-backend-ci.yml includes this test in the studio-install shard (lines 354–356 and 526–536), so update the regression to reflect the intended corrected behavior alongside this table change; otherwise the installer CI remains failing.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 29b338c: the covered lspci peer now decides the arch (gfx1100 for the RX 7900 case), matching install_python_stack._linux_amd_gfx_from_lspci; the old gfx1152 expectation came from the wrong 'AI 5 33' row.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen added a commit to Etherll/unsloth that referenced this pull request Nov 16, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 29b338c200

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No AMD GPU Detected

3 participants