Repository navigation
Unsloth Studio (AMD): retry an unpinned llama-server arch crash on the cards the build has kernels for - #16513
Conversation
… have kernels A manual GPU split, or an arch gate that cannot read the installed build's coverage, launches llama-server with no device mask. When a card the build has no kernels for takes part of the split, the child dies with "invalid kernel file" and the existing arch-crash retry skips it because it only handles pinned launches, so every fallback crashes the same way. Name the crashed card from the child's own "current device: N", drop it (and a shared-memory iGPU when a discrete card remains), and respawn on the rest with the positional --tensor-split removed. The Windows crash hint now names HIP_VISIBLE_DEVICES, since ROCR_VISIBLE_DEVICES masks nothing there.
A manual split pins the child's GPU order and the arch gate can pin it to its survivors without setting gpu_indices, so "current device: N" indexes that mask rather than the parent's. Also refresh the retry comment and keep f only on the hint segment with a placeholder.
…ser device pick An inherited UUID/MIG mask resolves to no ids, so the child's ordinal can't be read as a physical id without risking a hidden card; and a user --device or LLAMA_ARG_DEVICE numbers cards by the unnarrowed set, which narrowing would re-point. Both now keep the original error.
… LLAMA_ARG_MAIN_GPU GPU_DEVICE_ORDINAL filters HIP ordinals without showing up in the mask readers, and an inherited LLAMA_ARG_MAIN_GPU survives into the respawn, where narrowing would point it at a different card.
|
Pushed The unpinned retry now maps llama-server's The retry now keeps the original error instead of guessing when the card can't be named safely:
Each of these would otherwise renumber the child's devices out from under it. The Windows hint keeps The hardware runs in the body were measured at |
|
Codex is clean at |
|
CI is clean on the fork mirror at |
|
Ran this on tester at Verdict: each piece of the fix works on the reporter's shape. Not yet run: one Unsloth Studio-driven load end to end.
Full results: LeoBorcherding#706 (comment) |
|
Ran the remaining row on a Windows box with a covered and an uncovered card: RX 6500 XT (gfx1034) + RX 5700 XT (gfx1010), Windows 11, llama.cpp
This is the reporter's situation (one card the build covers, one it doesn't), and the fix recovers it end to end in Unsloth Studio. |
…it through load_model [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 781d21ee4a
ℹ️ 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".
| _crashed, _remaining = self._unpinned_arch_crash_retry( | ||
| _arch_crash_tail, _enumerated, _child_gpu_physical_ids | ||
| ) |
There was a problem hiding this comment.
Remap companion device selections on the unpinned retry
For an unpinned manual ROCm load with --mmproj-device ROCm1 or --spec-draft-device ROCm1, a kernel-image crash on GPU 0 now retries with only physical GPU 1 visible, but retains ROCm1 in argv. The existing _widen_pin_ids_for_companion_devices contract says these tokens use “unpinned numbering,” so the surviving selector must become ROCm0. _cache_target_unknown checks only main-device flags, while _companion_fit_mask remains None on the unpinned path, so the subsequent companion refit is skipped. This leaves an invalid device selector—or selects the wrong GPU with a larger surviving set—and defeats recovery despite the selected companion GPU being usable. Preserve and remap companion selections against the original child order, or decline narrowing when those selections cannot be preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a0da6cb: the unpinned retry now hands the companion refit the child's device order, so a ROCm companion on a surviving card is renumbered (test_a_companion_device_on_the_survivor_is_renumbered).
|
@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: a0da6cb784
ℹ️ 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".
| and any( | ||
| _flag_name(str(tok)) in flags | ||
| for tok in cmd | ||
| for flags in _COMPANION_DEVICE_FLAG_GROUPS |
There was a problem hiding this comment.
Remap the environment-selected projector before narrowing
For an unpinned two-GPU ROCm vision load with MTMD_BACKEND_DEVICE=ROCm1, a kernel-image crash on GPU 0 now retries with only physical GPU 1 visible, but this argv-only check leaves _companion_fit_mask unset and the environment value unchanged. The argv fix does not cover this environment fallback, which the existing projector-placement code recognizes at llama_cpp.py:27135-27142. The survivor is now ROCm0, so the retained projector selector is invalid, defeating recovery despite its chosen GPU being usable. Remap the environment-selected projector through the child's original device order too, or decline narrowing when that selection cannot be preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fbdeb55: a GPU MTMD_BACKEND_DEVICE now opts the unpinned launch out of narrowing like LLAMA_ARG_MAIN_GPU, so its original error stands (test_a_user_device_env_keeps_its_error).
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |

Reported by a Discord user in the help thread: Windows 11, RX 7900 XTX + Radeon AI PRO R9700 + Ryzen iGPU, a manual GPU split. Every load died with "llama-server crashed at startup ... hide it with ROCR_VISIBLE_DEVICES". The log shows
ROCm error: invalid kernel file/current device: 2, and device 2 is the R9700. The installed prebuilt wasgfx110X, which has nogfx1201kernels.Why nothing caught it
#7670 added two guards for this, and both were skipped:
mapped_targetsinUNSLOTH_PREBUILT_INFO.json). The log has noSkipping GPUline, so it couldn't.gpu_indicestruthy). A manual split with no GPU picked is never pinned.So all four retries (flash-attn off, no MTP, CPU projector, text-only) crashed the same way. Then the hint pointed at
ROCR_VISIBLE_DEVICES, which masks nothing on Windows.What changes
current device: N, mapped through any inherited mask. It drops that card, and a shared-memory iGPU when a discrete card remains, then respawns with the positional--tensor-splitremoved. This is the respawn fix(amd): gate ROCm GPU selection and crash recovery on the build's arch coverage #7670 already uses for pinned launches, unchanged. ROCm only: an unmasked CUDA child orders devices by speed, so its ordinal isn't our id._arch_gate_dropped_tensor_split, as the proactive gate does, so the next Apply doesn't reload.HIP_VISIBLE_DEVICES.Tests
The new tests are red on base and green on head: 11 failed / 10 passed vs 21 passed. They're
TestUnpinnedArchCrashRetry, the Windows hint case, and a call-site pin that an unpinned launch reaches the retry and records the drop. Across the related suites (arch gate, crash message, companion widening, placement, load-mode matrix, sidecar reserve, auto tensor split), 2600 pass. Four fail on a macOS box and fail identically on base:test_spec_sidecar_fit_reserve_multi_gpux3 andtest_the_launch_env_masks_the_child_to_them.Hardware
No hosted runner has an AMD GPU. The Strix Halo runner on oobabooga's fork is one gfx1151 APU on Linux, so it can't put a covered and an uncovered discrete card in one Windows box. This table is the test report. Rows A to E: Windows 11, 2x Radeon AI PRO R9700 (gfx1201) + Radeon iGPU (gfx1036), ROCm
b11985prebuilts, Qwen3-0.6B Q4_K_M,gpu_layers=999,tensor_split=1,1,1. Rows F and G: Windows 11, RX 5700 XT (gfx1010, uncovered) + RX 6500 XT (gfx1034, covered), theb11985-mix-c116c32gfx103X build throughLLAMA_SERVER_PATH(no coverage file, so the gate can't read it), SmolLM2-135M Q4_K_M,gpu_layers=999,tensor_split=1,1, same env for both with onlyllama_cpp.pyswapped.073f6e0[0, 1], loads and chatsdevice kernel image is invalidon device 0, no arch retry, load fails (the reported crash)31d4231073f6e0invalid kernel fileon device 0 (5700 XT), only the no-flash retry, same crash, load fails (HTTP 500)186046eServer log, run B (base):
Server log, run C (head):
Bottom line: on real hardware, the crash reproduces on base, and on head the retry drops the uncovered card and the load recovers on the covered one (run G). Not run: Linux ROCm with a mixed pair, where the retry masks through
ROCR_VISIBLE_DEVICESand readscurrent devicethrough that re-indexing.Still unknown: whether the reporter's gate failed because the install file predates
mapped_targetsor because the per-card arch lookup came back empty on Windows. The retry covers both.