Skip to content

Docker ROCm image: reach the GPU through WSL2's DXG bridge, not only /dev/kfd - #11212

Merged
danielhanchen merged 18 commits into
unslothai:mainfrom
LeoBorcherding:feat/rocm-docker-wsl-dxg
Sep 20, 2026
Merged

danielhanchen merged 18 commits into
unslothai:mainfrom
LeoBorcherding:feat/rocm-docker-wsl-dxg

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Closes part of #5405.

The ROCm image refused to start on Windows because its entrypoint gates on /dev/kfd, which WSL2 never has. The card is still reachable: AMD's DXG bridge (/dev/dxg plus librocdxg) is what install.sh already uses on a WSL host, and a container can use it too.

The real blocker was rocprofiler, not DXG. torch 2.12.1+rocm7.2 from pytorch.org bundles librocprofiler-sdk.so, which enumerates GPUs from the KFD sysfs topology and aborts when that disagrees with HSA:

F agent.cpp:1093] Found 0 rocprofiler agents and 2 HSA agents.

AMD's per-arch wheels bundle no rocprofiler, and torch 2.11.0+rocm7.2 ships only the harmless -register.so. So on WSL this is a per-arch image (ROCM_GFX=<gfx> bash docker/build.sh --rocm) until the gfx tags are published.

What changed

  • entrypoint-rocm.sh: with no /dev/kfd, accept /dev/dxg plus librocdxg and export HSA_ENABLE_DXG_DETECTION=1. Before the first torch.cuda call, refuse a torch that bundles librocprofiler-sdk with a message instead of a glog abort. On the bridge, skip the rocm-smi advisory (it needs amdgpu sysfs), and when torch cannot see the device give the bridge's own two causes instead of the amdgpu driver advice. Every message that hands a WSL user to run.sh names the per-arch build, since run.sh defaults to the published image. The KFD checks are unchanged.
  • run.sh --rocm: on a WSL host pass --device /dev/dxg, HSA_ENABLE_DXG_DETECTION=1, the host's librocdxg, and /usr/lib/wsl/lib with LD_LIBRARY_PATH set, for the libdxcore it dlopens. The image cannot ship librocdxg: its build needs Windows SDK headers.
  • README and the Docker Hub page: the WSL run command, the per-arch build it needs, and which arches that build exists for (gfx1150/1151/1152/1200/1201). RDNA3 has no bridge path yet because Dockerfile.rocm does not map gfx110X-all; that is a separate change.
  • Tests: 11 new in tests/python/test_docker_rocm.py, 48 passed 1 skipped at 981f8af9e2 (pre-commit.ci line splits on top of f5ee8ce9ec). The DXG library search and the WSL lib dir are injectable, so a test cannot answer for the runner's own ROCm.

Measured

One box: Radeon AI PRO R9700 (gfx1201), Windows 11 26200, WSL2 Ubuntu 24.04 (kernel 6.6.114, only /dev/dxg), host ROCm 7.2.1, docker 29.8.1 inside the distro, unsloth/unsloth-rocm:latest (sha-1811677).

what result at
rocminfo in a container, DXG only gfx1201, AMD Radeon AI PRO R9700 86f691e9c7
torch 2.12.1+rocm7.2 (pytorch.org) over DXG rocprofiler LOG(FATAL), abort 86f691e9c7
torch 2.11.0+rocm7.2 (same index) over DXG is_available() True 7182546
torch from repo.amd.com gfx120X-all over DXG True, 31.7 GB, fp16 matmul finite 86f691e9c7
bash docker/run.sh --rocm python /workspace/smoke_test_rocm.py 5 LoRA steps, loss 2.8083 → 1.2449, 128/128 tensors updated, same curve as the gfx1151 run in #10820 86f691e9c7
librocdxg mounted without /usr/lib/wsl/lib hsa_init Failed, Failed to load libdxcore.so; with it, gfx1201 aa86470e84
docker run --device /dev/kfd on WSL the daemon rejects it before the entrypoint runs ef21f162f9
Docker Desktop's own engine (desktop-linux) has neither /dev/dxg nor /dev/kfd ef21f162f9
rocm-smi --showid in a container over DXG Driver not initialized (amdgpu not found in modules) 782ead3c28
new entrypoint over DXG, generic image bridge accepted, rocm-smi skipped, refused on librocprofiler-sdk.so, no abort 782ead3c28

run.sh's DXG flags are the same set the smoke run used; later commits changed only how it probes for the WSL lib dir and what it says when that is missing.

Not covered

  • One host, one arch. The per-arch torch was pip-installed over the published image, not a ROCM_GFX=gfx1201 build from build.sh: same index, same absence of rocprofiler, different layer order.
  • gfx1151 under WSL. RDNA3 has no path at all until the Dockerfile maps it.
  • The Linux /dev/kfd path ran only in the staged-device-tree tests, not on a Linux AMD host. Its branches are unchanged apart from the UNSLOTH_ROCM_DEV_PATH == kfd guard.
  • No hosted runner has an AMD GPU, and the Strix Halo runner on ooba's fork is gfx1151 on Linux with /dev/kfd, so it cannot see this path. The table above is the test report.

@LeoBorcherding

LeoBorcherding commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merged main; head 6bcebed7. Hardware rows in the description were measured at 86f691e9c7 and not re-run. Every red check here is red on main at e43b2bae too (the accelerator skip-guard test, the five test_st_save_merged_signature cases, the bitdefender AV-shape test, the workflow-trigger lint), except test_llama_cpp_wait_for_health::…after_its_last_work, a wall-clock assert (2.1 <= 1.10) on a loaded runner. None touch this diff.

@LeoBorcherding

LeoBorcherding commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

Pushed 7182546. The rocprofiler pre-check matched any rocprof* filename and so refused torch 2.11.0+rocm7.2, which ships only librocprofiler-register.so and runs on the bridge. Only librocprofiler-sdk.so walks the KFD topology and aborts, so the check now matches that library alone. Measured in one container from unsloth/unsloth-rocm:latest (R9700, WSL2, /dev/dxg only): torch 2.12.1+rocm7.2 carries -register.so and -sdk.so and aborts; torch 2.11.0+rocm7.2 carries -register.so only and reports True. Two tests added; the second fails against the old check.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed docker/entrypoint-rocm.sh still refuses on a host with only /dev/dxg, and the new branch leaves the /dev/kfd path untouched, with tests covering both. Will get this reviewed.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at 89c26a4a6c there, which is this PR's 8587951b2 replayed onto main df18fa7bd. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

1 finding, inline below where the line is on this diff.

Comment thread docker/entrypoint-rocm.sh Resolved
LeoBorcherding added a commit to LeoBorcherding/unsloth that referenced this pull request Sep 18, 2026
…its header a launch line that works

The workflow built only Dockerfile.rocm, so Dockerfile.studio-rocm was never
published and the comment saying CI pins its refs described a job that did not
exist. build-studio now layers it on the base this run pushed, by digest and
with the same UNSLOTH_REF / zoo ref, and tag-studio gives it every base tag
with a -studio leaf under the same gates (:studio beside :latest). The Hub
page syncs once both moved and documents the tag.

The header pointed WSL2 users at `docker/run.sh --rocm`, which has no DXG path
on main (that is unslothai#11212), picks :latest, and publishes no port; the by-hand
line passed group names, which the image cannot resolve. Both lines now say
what actually works, and WSL2 is named as waiting on unslothai#11212.
librocdxg dlopens libdxcore from /usr/lib/wsl/lib, which the image does not
have on its search path. A container started by hand with only the librocdxg
mount from the old message passed check 1 and then failed hsa_init. The
message now carries both mounts and LD_LIBRARY_PATH, matching run.sh, and
stops claiming the image should have shipped the library.
@LeoBorcherding

LeoBorcherding commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Pushed aa86470e84 on a merge of main at df18fa7bd. The DXG recovery message listed only the librocdxg mount, but librocdxg dlopens libdxcore from /usr/lib/wsl/lib, which is not on the image's search path. With that mount alone rocminfo prints Failed to load libdxcore.so; adding -v /usr/lib/wsl/lib:/usr/lib/wsl/lib:ro -e LD_LIBRARY_PATH=/usr/lib/wsl/lib gives gfx1201. The message now points at run.sh --rocm first and gives the by-hand command with both mounts. Pinned in the refuse test.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at 01e0a1fb58 there, which is this PR's aa86470e8 replayed onto main df18fa7bd. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

1 finding, inline below where the line is on this diff.

Comment thread docker/run.sh Resolved
…Docker Hub page

README.md said the ROCm image needs native Linux, and the Docker Hub quick start
built its flags from an unconditional --device /dev/kfd, which the daemon rejects
on WSL before the entrypoint runs. Both now carry the DXG path: the /dev/dxg node,
the runtime opt-in, the librocdxg and libdxcore mounts run.sh passes, and the
per-architecture build the generic image's torch makes necessary. A test pins
the flags to the ones run.sh emits.
@LeoBorcherding

LeoBorcherding commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Pushed ef21f162f9 on a merge of main at 9f76c5a3e. README said the ROCm image needs native Linux, and the Docker Hub quick start passed --device /dev/kfd unconditionally, which the daemon rejects on WSL before the entrypoint runs. Both now document the WSL path with the same flags run.sh emits, and say to build a per-arch image, since Docker Hub has no gfx tag yet. Docker Desktop's own engine has neither /dev/dxg nor /dev/kfd (measured). The five red CI jobs at aa86470e84 are the same five red on main at df18fa7bd.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at 5b2ee32b33 there, which is this PR's ef21f162f replayed onto main 9f76c5a3e. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

1 finding, inline below where the line is on this diff.

Comment thread docker/DOCKERHUB-ROCM.md Resolved
run.sh defaults to unsloth/unsloth-rocm:latest, the generic image the entrypoint
refuses on DXG, so the Hub page's launcher and smoke-test commands sent a WSL
user straight back to the refusal after telling them to build a per-arch image.
Both now pass UNSLOTH_IMAGE=unsloth-rocm:latest on WSL, as build.sh prints after
a build, and the README's launcher sentence says the same. Test pinned.
@LeoBorcherding

LeoBorcherding commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Pushed b48cbbafc1. The Hub page told a WSL user to build a per-arch image and then handed them bash run.sh --rocm, which defaults to unsloth/unsloth-rocm:latest, the generic image the entrypoint refuses on the bridge. The launcher and smoke-test commands now name the local build with UNSLOTH_IMAGE=unsloth-rocm:latest, as build.sh prints after a build. README says the same.

Dockerfile.rocm maps only gfx1150/1151/1152 and gfx1200/1201 to AMD's per-arch
indexes, so the docs and the DXG refusal message were sending an RDNA3 owner to
a build that fails at once. They now name the covered set and say RDNA3 has no
bridge path until the Dockerfile maps gfx1100-gfx1103 to gfx110X-all, as
install.sh already does for a bare host. Pinned in the docs test.
@LeoBorcherding

LeoBorcherding commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Pushed d47296cb70. Dockerfile.rocm maps only gfx1150/1151/1152/1200/1201 to AMD's per-arch indexes, so an RDNA3 owner was being sent to a build that fails on the spot. README, the Hub page and the DXG refusal message now name that set and say RDNA3 has no bridge path yet. Mapping it to gfx110X-all is left for its own PR: install.sh routes that family to torch below 2.11 where the Dockerfile pins 2.11, no RDNA3 card is on hand, and whether those wheels are free of librocprofiler-sdk is unmeasured.

CI at d47296cb70 ran on a staging copy, LeoBorcherding#35, while upstream was queued: every failure is on main by test name (test_video_step_cache_auto_toggles_on_actual_steps, the two test_relative_imports_resolve mlx cases, test_no_test_file_spawns_powershell_directly), plus one studio race test that passes 3 of 3 locally and is untouched here.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at bbfd4bcb1d there, which is this PR's d47296cb7 replayed onto main 9f76c5a3e. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

Codex found no major issues. Its comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/6#issuecomment-5736271841

…n.sh passes

Over the bridge rocm-smi prints 'Driver not initialized (amdgpu not found in
modules)' (measured in the container), and check 2 then advised --device
/dev/dri and group ids, neither of which exists on WSL. The entrypoint now
skips it on that path with a one-line note.

run.sh probed /usr/lib/wsl/lib on the real root, ignoring UNSLOTH_DEV_ROOT, so
no test could assert the libdxcore mount and LD_LIBRARY_PATH and a Linux
runner passed without them. The probe honours the dev root, a missing dir is
named instead of silently dropped, and both flags are pinned.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at 4ddd91939d there, which is this PR's 782ead3c2 replayed onto main c7d8980a2. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

1 finding, inline below where the line is on this diff.

Comment thread docker/entrypoint-rocm.sh Outdated
librocdxg instead. The image cannot ship that library (its build needs Windows
SDK headers), so it comes off the host, along with the libdxcore it dlopens from
WSL's own lib directory. The bundled wrapper mounts both:
bash docker/run.sh --rocm <cmd>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

P2 Keep the per-architecture image in DXG recovery

When a WSL user reaches this error after starting their locally built per-architecture image without the bridge mount, the suggested bash docker/run.sh --rocm silently switches to unsloth/unsloth-rocm:latest via run.sh:147; that generic image is then deliberately rejected by the DXG rocprofiler check at lines 177-190. Fresh evidence after the earlier documentation finding is that DOCKERHUB-ROCM.md:52-57 now correctly supplies UNSLOTH_IMAGE=unsloth-rocm:latest, while this newly added recovery path-and the manual command immediately below it-still omit the local image. Include the same image override here so the advertised recovery can actually start.

Codex's original comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/6#discussion_r4051179680

…un.sh

run.sh defaults to unsloth/unsloth-rocm:latest, which the bridge refuses, so
the librocdxg recovery, the missing-kfd Windows note and the rocprofiler
refusal all sent a WSL user back to the generic image. Each now gives
UNSLOTH_IMAGE=unsloth-rocm:latest bash docker/run.sh --rocm, and the by-hand
command names the local build. Pinned in the refuse tests.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Pushed 79bb30f303 on a merge of main at c7d8980a2.

Three entrypoint messages handed a WSL user to bash docker/run.sh --rocm, which defaults to unsloth/unsloth-rocm:latest, the generic image the bridge refuses: the librocdxg recovery, the missing-kfd note for Windows, and the rocprofiler refusal itself (it said how to build the per-arch image but not how to run it). Each now gives UNSLOTH_IMAGE=unsloth-rocm:latest bash docker/run.sh --rocm <cmd>, and the by-hand command names the local build. Pinned in the two refuse tests. 47 passed, 1 skipped.

…gpu advice

When torch.cuda.is_available() was False on the bridge, the branch said the
host amdgpu advice did not apply and then printed it anyway: rocm-smi,
dkms, rebuild against the host ROCm. WSL has no host amdgpu stack. It now
names the two causes measured on the bridge, a libdxcore that cannot load
(the /usr/lib/wsl/lib mount) and the Windows driver, and exits. Test added.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Pushed f5ee8ce9ec.

When torch.cuda.is_available() was False on the bridge, check 3 said the host amdgpu advice did not apply and then printed it anyway: rocm-smi --version, dkms status, rebuild against the host's ROCm. WSL has no host amdgpu stack. That branch now names the two causes measured on the bridge, a libdxcore that cannot load (the /usr/lib/wsl/lib mount, which run.sh passes) and the Windows driver, and exits. Test added: 48 passed, 1 skipped.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at fe3b8fe870 there, which is this PR's f5ee8ce9e replayed onto main 768d64403. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

Codex found no major issues. Its comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/6#issuecomment-5742931857

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#6. It looked at 4757a73a34 there, which is this PR's 981f8af9e replayed onto main 768d64403. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

Codex found no major issues. Its comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/6#issuecomment-5742971602

@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author
image

@danielhanchen

Copy link
Copy Markdown
Member

Review record for #11212, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#24.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1 — reviewed mirror d93b03ffd (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

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

Reviewed commit: d93b03ffdc

No triage reaction was recorded on the mirror

chatgpt-codex-connector[bot] (on the mirror)

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: d93b03ffdc

View security finding report

Only the user who started this review can view the report in Codex.

No triage reaction was recorded on the mirror

Verdict

The round did not reach a clean review on the mirror before it closed.

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit 2223ec9 into unslothai:main Sep 20, 2026
20 checks passed
danielhanchen added a commit that referenced this pull request Sep 20, 2026
#11218)

* Docker ROCm image: ship Unsloth Studio, as the CUDA image already does

* Assert the base ROCm leaf, not the exact torch version, in the Studio venv

* Publish the ROCm Studio image from docker-publish-rocm.yml, and give its header a launch line that works

The workflow built only Dockerfile.rocm, so Dockerfile.studio-rocm was never
published and the comment saying CI pins its refs described a job that did not
exist. build-studio now layers it on the base this run pushed, by digest and
with the same UNSLOTH_REF / zoo ref, and tag-studio gives it every base tag
with a -studio leaf under the same gates (:studio beside :latest). The Hub
page syncs once both moved and documents the tag.

The header pointed WSL2 users at `docker/run.sh --rocm`, which has no DXG path
on main (that is #11212), picks :latest, and publishes no port; the by-hand
line passed group names, which the image cannot resolve. Both lines now say
what actually works, and WSL2 is named as waiting on #11212.

* ROCm Studio image: survive a restart with UNSLOTH_STUDIO_PASSWORD set, tell install.sh the gfx, and move no stable tag before both builds exist

The CMD handed Studio UNSLOTH_STUDIO_PASSWORD on every start. It only sets the
first admin password and `unsloth studio` exits 1 when given one after that, so
a `docker restart` with the variable still set (a Compose file) never came back
up. studio_launch_rocm.sh is now the CMD: as the CUDA launcher does, it writes
the value to a root-only file that studio_run.sh hands over only while no
password is stored, and drops it from Studio's environment. The copied
studio_password.sh went, since nothing ran it and it waits on JupyterLab.

install.sh only skips bitsandbytes on gfx906 when told the arch, and the
GPU-less builder cannot probe it, so a gfx906-studio image would have shipped a
4-bit backend with no kernels. The base's ROCM_GFX is forwarded as
UNSLOTH_ROCM_GFX_ARCH, and the build asserts a gfx906 Studio venv has no
bitsandbytes.

The base tags moved before build-studio ran, so a Studio failure or a second
overlapping run could leave :latest and :studio from different builds. Both
digests are now built first, and the tag job creates both manifests back to
back; tag-studio and its job-scheduling gap are gone.

* Hub page: name the -studio twins, since latest's is :studio and not latest-studio

* Serialize stable tag promotion, so latest and studio cannot split

The workflow concurrency group carries github.run_id on main, deliberately, so a
dispatch runs alongside the cron instead of discarding it. That was harmless
while one stable tag moved. This workflow now promotes two, and
DOCKERHUB-ROCM.md documents them as a pair: `studio` is the Studio twin of
`latest`.

Unserialized, two runs interleave: A writes latest, B writes latest and studio,
A writes studio, and the pair stays sourced from different builds until the next
run. Reachable rather than theoretical, since the cadence is a weekly cron plus
dispatch and a ROCm run takes hours.

The tag job gets its own group with no run_id, so stable promotion queues across
runs. cancel-in-progress stays false: a cancelled promotion is the split this
exists to prevent.

The existing test comment claimed one job "back to back" was enough for another
run not to land between the two writes. That is true within a run and not across
runs, so it is corrected rather than left to reassure the next reader.

Negative control: with the test present and the concurrency block reverted,
test_stable_tag_promotion_is_serialized_across_runs fails (1 failed, 44 passed);
with the fix, 45 pass.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Revert the job-level concurrency group; it loses whole runs

6f19113 added a shared concurrency group to the tag job to stop two runs
splitting the latest/studio pair. That trades a small window for a bigger loss:
GitHub concurrency is not a queue. A shared group holds one running job and one
pending job, and a third arrival cancels the pending one, which this repo has
already written down twice in
tests/studio/test_main_runs_survive_merge_bursts.py ("any existing pending job
or workflow in the same concurrency group will be canceled"). For an override
build the tag job is the only step that writes the run's SHA tags, so a
cancelled one leaves two pushed digests with no tags at all.

The pairing window itself is not this workflow's to close. docker-publish.yml
promotes latest and core from the same per-run group with no job-level group, so
the shape is repo-wide and accepted; closing it needs a real lock that preserves
every arrival, not concurrency, and that belongs in its own change against both
workflows.

The test comment stays corrected, because the claim that started this ("one job,
back to back, so another run cannot land between them") is true within a run and
false across runs, and it is what hid the window. It now says what is actually
true, including why the obvious fix is worse.

---------

Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit to LeoBorcherding/unsloth that referenced this pull request Sep 21, 2026
…ion of it

This branch is stacked on unslothai#11218, which has since been squash-merged, so main
and the branch carry the same work under different SHAs and three files
conflicted: the ROCm publish workflow, the Hub page and Dockerfile.studio-rocm.
No commit on main has touched any of them since that merge, so the branch side
is the later revision in each case and is kept.

Two places needed more than "keep ours":

The Hub page. The branch predates unslothai#11212, so taking its copy wholesale silently
reverted the WSL2 section that PR added: the /dev/dxg flags, the librocdxg
mount and the per-architecture build note. Rebuilt from main instead, with only
this branch's three real additions applied (the studio tag row, the studio
paragraph, and 8888 in the run command). test_the_hub_page_gives_the_same_wsl_
flags_as_run_sh caught the revert.

Two tests in test_docker_rocm.py still pinned unslothai#11218's shape, which this PR
deliberately replaces:

- the image now runs the shared studio_launch.sh under supervisord rather than
  the single-service studio_launch_rocm.sh, so the assertion follows the
  Dockerfile, and the supervisord program list is covered by the new suite.
- the auto-merge left TWO copies of the publish test, the branch's updated one
  and main's older one, which asserts `"tag-studio" not in wf["jobs"]`. That is
  exactly the job this PR adds, so the stale copy is removed rather than the
  survivor weakened.

778 docker tests pass, 2 skipped.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…/dev/kfd (unslothai#11212)

* Docker ROCm image: reach the GPU through WSL2 DXG, not only /dev/kfd

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refuse only librocprofiler-sdk on the DXG bridge, not every rocprofiler name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Name the libdxcore mount in the DXG recovery message, not only librocdxg

librocdxg dlopens libdxcore from /usr/lib/wsl/lib, which the image does not
have on its search path. A container started by hand with only the librocdxg
mount from the old message passed check 1 and then failed hsa_init. The
message now carries both mounts and LD_LIBRARY_PATH, matching run.sh, and
stops claiming the image should have shipped the library.

* Document the WSL2 DXG path where users actually read: README and the Docker Hub page

README.md said the ROCm image needs native Linux, and the Docker Hub quick start
built its flags from an unconditional --device /dev/kfd, which the daemon rejects
on WSL before the entrypoint runs. Both now carry the DXG path: the /dev/dxg node,
the runtime opt-in, the librocdxg and libdxcore mounts run.sh passes, and the
per-architecture build the generic image's torch makes necessary. A test pins
the flags to the ones run.sh emits.

* Name the local per-arch image in the WSL launcher and smoke commands

run.sh defaults to unsloth/unsloth-rocm:latest, the generic image the entrypoint
refuses on DXG, so the Hub page's launcher and smoke-test commands sent a WSL
user straight back to the refusal after telling them to build a per-arch image.
Both now pass UNSLOTH_IMAGE=unsloth-rocm:latest on WSL, as build.sh prints after
a build, and the README's launcher sentence says the same. Test pinned.

* Say which arches the WSL per-arch build covers: no RDNA3 yet

Dockerfile.rocm maps only gfx1150/1151/1152 and gfx1200/1201 to AMD's per-arch
indexes, so the docs and the DXG refusal message were sending an RDNA3 owner to
a build that fails at once. They now name the covered set and say RDNA3 has no
bridge path until the Dockerfile maps gfx1100-gfx1103 to gfx110X-all, as
install.sh already does for a bare host. Pinned in the docs test.

* DXG path: skip the rocm-smi advisory, and test the libdxcore mount run.sh passes

Over the bridge rocm-smi prints 'Driver not initialized (amdgpu not found in
modules)' (measured in the container), and check 2 then advised --device
/dev/dri and group ids, neither of which exists on WSL. The entrypoint now
skips it on that path with a one-line note.

run.sh probed /usr/lib/wsl/lib on the real root, ignoring UNSLOTH_DEV_ROOT, so
no test could assert the libdxcore mount and LD_LIBRARY_PATH and a Linux
runner passed without them. The probe honours the dev root, a missing dir is
named instead of silently dropped, and both flags are pinned.

* Name the per-arch image in every DXG message that hands the user to run.sh

run.sh defaults to unsloth/unsloth-rocm:latest, which the bridge refuses, so
the librocdxg recovery, the missing-kfd Windows note and the rocprofiler
refusal all sent a WSL user back to the generic image. Each now gives
UNSLOTH_IMAGE=unsloth-rocm:latest bash docker/run.sh --rocm, and the by-hand
command names the local build. Pinned in the refuse tests.

* DXG torch failure: give the bridge's own causes and stop, not the amdgpu advice

When torch.cuda.is_available() was False on the bridge, the branch said the
host amdgpu advice did not apply and then printed it anyway: rocm-smi,
dkms, rebuild against the host ROCm. WSL has no host amdgpu stack. It now
names the two causes measured on the bridge, a libdxcore that cannot load
(the /usr/lib/wsl/lib mount) and the Windows driver, and exits. Test added.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <[email protected]>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
unslothai#11218)

* Docker ROCm image: ship Unsloth Studio, as the CUDA image already does

* Assert the base ROCm leaf, not the exact torch version, in the Studio venv

* Publish the ROCm Studio image from docker-publish-rocm.yml, and give its header a launch line that works

The workflow built only Dockerfile.rocm, so Dockerfile.studio-rocm was never
published and the comment saying CI pins its refs described a job that did not
exist. build-studio now layers it on the base this run pushed, by digest and
with the same UNSLOTH_REF / zoo ref, and tag-studio gives it every base tag
with a -studio leaf under the same gates (:studio beside :latest). The Hub
page syncs once both moved and documents the tag.

The header pointed WSL2 users at `docker/run.sh --rocm`, which has no DXG path
on main (that is unslothai#11212), picks :latest, and publishes no port; the by-hand
line passed group names, which the image cannot resolve. Both lines now say
what actually works, and WSL2 is named as waiting on unslothai#11212.

* ROCm Studio image: survive a restart with UNSLOTH_STUDIO_PASSWORD set, tell install.sh the gfx, and move no stable tag before both builds exist

The CMD handed Studio UNSLOTH_STUDIO_PASSWORD on every start. It only sets the
first admin password and `unsloth studio` exits 1 when given one after that, so
a `docker restart` with the variable still set (a Compose file) never came back
up. studio_launch_rocm.sh is now the CMD: as the CUDA launcher does, it writes
the value to a root-only file that studio_run.sh hands over only while no
password is stored, and drops it from Studio's environment. The copied
studio_password.sh went, since nothing ran it and it waits on JupyterLab.

install.sh only skips bitsandbytes on gfx906 when told the arch, and the
GPU-less builder cannot probe it, so a gfx906-studio image would have shipped a
4-bit backend with no kernels. The base's ROCM_GFX is forwarded as
UNSLOTH_ROCM_GFX_ARCH, and the build asserts a gfx906 Studio venv has no
bitsandbytes.

The base tags moved before build-studio ran, so a Studio failure or a second
overlapping run could leave :latest and :studio from different builds. Both
digests are now built first, and the tag job creates both manifests back to
back; tag-studio and its job-scheduling gap are gone.

* Hub page: name the -studio twins, since latest's is :studio and not latest-studio

* Serialize stable tag promotion, so latest and studio cannot split

The workflow concurrency group carries github.run_id on main, deliberately, so a
dispatch runs alongside the cron instead of discarding it. That was harmless
while one stable tag moved. This workflow now promotes two, and
DOCKERHUB-ROCM.md documents them as a pair: `studio` is the Studio twin of
`latest`.

Unserialized, two runs interleave: A writes latest, B writes latest and studio,
A writes studio, and the pair stays sourced from different builds until the next
run. Reachable rather than theoretical, since the cadence is a weekly cron plus
dispatch and a ROCm run takes hours.

The tag job gets its own group with no run_id, so stable promotion queues across
runs. cancel-in-progress stays false: a cancelled promotion is the split this
exists to prevent.

The existing test comment claimed one job "back to back" was enough for another
run not to land between the two writes. That is true within a run and not across
runs, so it is corrected rather than left to reassure the next reader.

Negative control: with the test present and the concurrency block reverted,
test_stable_tag_promotion_is_serialized_across_runs fails (1 failed, 44 passed);
with the fix, 45 pass.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Revert the job-level concurrency group; it loses whole runs

6f19113 added a shared concurrency group to the tag job to stop two runs
splitting the latest/studio pair. That trades a small window for a bigger loss:
GitHub concurrency is not a queue. A shared group holds one running job and one
pending job, and a third arrival cancels the pending one, which this repo has
already written down twice in
tests/studio/test_main_runs_survive_merge_bursts.py ("any existing pending job
or workflow in the same concurrency group will be canceled"). For an override
build the tag job is the only step that writes the run's SHA tags, so a
cancelled one leaves two pushed digests with no tags at all.

The pairing window itself is not this workflow's to close. docker-publish.yml
promotes latest and core from the same per-run group with no job-level group, so
the shape is repo-wide and accepted; closing it needs a real lock that preserves
every arrival, not concurrency, and that belongs in its own change against both
workflows.

The test comment stays corrected, because the claim that started this ("one job,
back to back, so another run cannot land between them") is true within a run and
false across runs, and it is what hid the window. It now says what is actually
true, including why the obvious fix is worse.

---------

Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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