Repository navigation
Unsloth Studio (AMD, Windows): don't treat a GPU whose multi-arch kernel pack is missing as covered - #13231
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87acac9f78
ℹ️ 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".
| arch = match.group(1).lower() | ||
| # A pack naming a family or generic target could cover devices no token names. | ||
| if not _CONCRETE_GFX_ARCH.match(arch): | ||
| return None | ||
| arches.add(arch) |
There was a problem hiding this comment.
Validate pack versions before declaring an arch covered
On the Windows multi-arch update path, the existence of this filename does not prove that the pack matches the currently imported torch build. If the selected GPU or pinned ROCm tag changes, installing the new extra can leave an unrelated older amd-torch-device-gfx* distribution—and its .kpack file—in the environment; the installer itself checks device-package version specifiers in studio/install_python_stack.py:418-429 for this reason. This loop nevertheless adds that stale arch to supported, so a GPU using it remains selectable and can fail at kernel launch. Resolve the owning device distribution and verify its version against torch, rather than trusting the filename alone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this as is. A stale pack needs both a pinned multi-arch tag bump and a different GPU chosen on the same venv, and on that host main already reads every arch as covered from get_arch_list(), so this reading is never wider than main's. The common case, one pack installed for the chosen card next to an iGPU with none, is what this fixes.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87acac9f78
ℹ️ 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".
| if not _CONCRETE_GFX_ARCH.match(arch): | ||
| return None |
There was a problem hiding this comment.
Keep concrete packs when a family pack is present
On Windows multi-arch installs that contain a family pack alongside the selected leaf pack (for example, torch_gfx110x.kpack plus torch_gfx1101.kpack), this immediately returns None and prevents rocm_gpu_ids_without_torch_kernels() from intersecting the compiled architecture list with any installed packs. The installer explicitly treats family kernel packs as part of a complete device extra (studio/install_python_stack.py:397-435), so this layout can make the new gate inert and leave the reported gfx1036 iGPU selectable even though only the gfx1101 leaf was installed. Preserve the concrete entries while handling or conservatively expanding the family entry instead of discarding the entire inventory.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
No published family pack ships a torch_*.kpack: amd-torch-device-gfx110x / gfx115x for 2.11.0+rocm7.14.0, 2.11.0+rocm7.14.1 and 2.12.0+rocm7.14.1 (win_amd64) carry only torch/lib/aotriton.images/amd-gfx1xxx/, and the leaf packs carry the single torch/.kpack/torch_gfxNNNN.kpack. The bail-out only fires on a layout AMD does not ship today, and there it keeps main's behaviour rather than guessing what a family file covers.
The problem
On Windows, Studio installs AMD's multi-arch PyTorch with only the device pack for the GPU it chose:
torch[device-gfx1101]==2.11.0+rocm7.14.0on a Ryzen desktop with an RX 7800 XT. Each device pack adds one file,torch/.kpack/torch_gfxNNNN.kpack, andlibtorch_hiploads kernels from../.kpack/torch_@[email protected]. So the gfx1036 integrated GPU next to that card has no torch kernels.The training / Transformers arch gate from #8791 (
rocm_gpu_ids_without_torch_kernels) decides coverage fromtorch.cuda.get_arch_list(). In the multi-arch build that list is compiled in and names every arch the build supports, whether its pack is installed or not. Read from the 2.11.0+rocm7.14.0 wheel'slibtorch_python:So on Windows the gate reads the iGPU as covered, automatic selection can put a training run on it, and an explicit pick of it is not refused. That is the failure #8792 fixed for the Linux family wheels, back on the Windows route. It is reachable on the #8847 host: the iGPU's free reading is Windows' shared pool, half of system RAM, so on 32 GB or more it ranks level with or above a 16 GB card.
The change
_torch_kernel_pack_archeslists the installedtorch_gfxNNNN.kpackfiles when torch has a.kpackdirectory. Both the coverage gate and the "has kernels for ... only" message intersectget_arch_list()with that set. It fails open, exactly like the existing gate:.kpackdirectory (pytorch.org wheels, AMD family wheels, Linux): no changetorch_gfx110x.kpackcould cover devices no token names): no changeTests
studio/backend/tests/test_training_gpu_arch_gate.py::TestMultiArchKernelPacks, with the multi-arch arch list above and a real.kpackdirectory:torch_gfx1101.kpack.kpackdir / empty dir / family pack / no pack filesThe first two fail on main and pass here; the others pass on both.
test_gpu_selection.py,test_gpu_selection_sandbox.py,test_training_gpu_arch_gate.py,test_training_vram_coexistence.py,test_rocm_multi_gpu_vram_system_wide.py,test_rocm_live_telemetry_hip_ids.pyandtest_chat_load_during_training.py: 415 passed.On real hardware
AMD Windows 11 runner, Radeon 8060S (gfx1151), Python 3.12.
torch[device-gfx1100]==2.11.0+rocm7.14.0from AMD's multi-arch index, so this GPU has no kernel pack, the same shape as an iGPU beside the card the install chose. One process per checkout:(a * 2 + 1).sum()on the GPUtorch_gfx1100.kpackhipErrorInvalidImage("device kernel image is invalid")get_arch_list()torch_gfx1100.kpackhipErrorInvalidImagepip install amd-torch-device-gfx1151torch_gfx1100.kpack,torch_gfx1151.kpackSo a missing pack really means a failed launch,
get_arch_list()does not reflect it, and the pack files do. The runner has one GPU, so the multi-GPU selection itself is shown by the unit tests above, not here.Related: #8847, #8792