Compare commits

...
Sign in to create a new pull request.

14 commits

Author SHA1 Message Date
Daniel Han
6f5f2e4ef4 Merge remote-tracking branch 'origin/main' into dh/recover-3324-rocm-dockerfile 2026-07-27 13:18:03 +00:00
Daniel Han
ba209f8539 docker: fix the ROCm bitsandbytes install and make the final check able to fail
The image did not build. bitsandbytes pins scikit-build-core unbounded in
build-system.requires, so the builder always resolves the newest release.
1.0.0 (2026-07-06) added a PEP 660 gate to the setuptools plugin backend that
bitsandbytes uses, rejecting editable installs unless pyproject sets
editable.mode = "inplace". The pin here is from March and predates upstream
adding that line, so pip install -e . dies in prepare_metadata_for_build_editable
with "setuptools editable installs require editable.mode = 'inplace'".
Verified by version bisection in the image: 0.11.6 and 0.12.2 install cleanly,
1.0.0, 1.0.1 and 1.0.3 all fail.

Install non-editable instead. Upstream's own install docs annotate the -e as
being for bitsandbytes development and say to leave it out otherwise, and an
editable checkout buys nothing in an image while tying the build to a
scikit-build-core knob that keeps moving. CMakeLists writes the library
straight into the package dir, so setuptools package-data ships exactly what
cmake built: the installed libbitsandbytes_rocm64.so is md5 identical to the
compiled one and its .hip_fatbin still holds a single gfx942 bundle.

The verification step could not fail. pip show passes on dist-info alone, so a
missing or unloadable HIP library left it green on precisely the broken image
it exists to catch. Load the artifacts instead. bitsandbytes cannot self-report
here: with no AMD GPU on the builder get_cuda_specs returns None, it loads
libbitsandbytes_cpu.so and hands back a healthy BNBNativeLibrary even after the
ROCm library is deleted, so the check globs for libbitsandbytes_rocm*.so beside
the installed package and ctypes.CDLL loads it. unsloth_zoo raises
NotImplementedError on import without a torch accelerator, so it and unsloth
are resolved with importlib.util.find_spec rather than executed.

Deleting the library now fails the check; the intact image passes.

The amdgpu-arch warning at configure time is benign and left alone. It comes
from hip-config-amd.cmake, pulled in by find_package(hipblas), and only governs
--offload-arch on the hip::device interface for CXX sources. bitsandbytes links
hip::host and compiles its kernels as HIP, taking the arch from
CMAKE_HIP_ARCHITECTURES, which BNB_ROCM_ARCH sets before enable_language(HIP).
The built library contains gfx942 and no gfx906.
2026-07-26 16:07:28 +00:00
Daniel Han
19de4695b8 Dockerfile.rocm: trim comments that restate the adjacent line
Drop the commented-out GPU_ARCH arg, the shallow-fetch note, and the
install verification banner, and fold the huggingfacenotorch note onto
one line. The bitsandbytes commit pin note stays: it records the
upstream 4-bit GEMV NaN behaviour on AMD.

No build instruction changed.
2026-07-26 15:41:45 +00:00
Daniel Han
82d126c0c8 Merge remote-tracking branch 'origin/main' into dh/recover-3324-rocm-dockerfile
One conflict: studio/backend/tests/test_gguf_load_cache_reuse.py. Took
main's assertion, which anchors on the _resolve_inherited_extra_args
call site. This branch does not touch studio/backend/routes/inference.py,
so the merged source is main's, and that is the landmark it now carries.
2026-07-26 14:27:27 +00:00
Daniel Han
5c6fb65fa1 tests: align the gguf order test with main
Main fixed the stale ordering assertion in PR 7252; adopting its
version verbatim removes this file from the branch diff entirely and
avoids a conflict on the next main merge. 32 tests pass.
2026-07-20 00:21:59 +00:00
Daniel Han
a7aefe8848 tests: anchor the inheritance order check on the call, not the definition
source.index("_resolve_inherited_extra_args(") matched the function
definition, which always precedes the endpoint, so the ordering
assertion was vacuously true. Anchoring on "= _resolve_inherited_
extra_args(" pins the first call site inside the load endpoint (line
4505), which is the statement whose position relative to the GGUF
branch the test is meant to guard. 32 tests pass.
2026-07-19 16:22:15 +00:00
Daniel Han
4df46dcea2 tests: track the moved pass-through inheritance in the gguf order check
Main moved the llama_extra_args pass-through inheritance out of the
GGUF branch into _resolve_inherited_extra_args, which runs before it,
so the source-order assertion's "if request.llama_extra_args is None"
anchor no longer exists inside the branch and the check failed after
the main merge. The test now asserts the same property in the current
shape: inheritance before the GGUF branch (a carried --no-mmproj still
shapes the hub guard's companion requirement), and marker, hub guard,
unload in order within the branch. Full file passes (32 tests).
2026-07-19 15:36:33 +00:00
Daniel Han
0d9f617e6a docker: tighten rocm dockerfile comments 2026-07-19 14:59:10 +00:00
Daniel Han
7815f2f08e Merge remote-tracking branch 'origin/main' into r4223 2026-07-19 13:20:39 +00:00
Daniel Han
66f912625d docker: fix bnb GEMV floor and install the HF training stack in the ROCm image
Two review items, both reproduced before fixing.

The pinned bitsandbytes commit (0.48.0.dev0, 2025-09-15) predates bnb PR
1887, which enabled the 4-bit GEMV kernels on AMD CDNA; every build at or
below 0.49.2 NaNs at the GEMV decode shape on AMD GPUs, the exact floor
install.sh already enforces for its ROCm wheel. BNB_COMMIT now defaults
to the PR 1887 merge commit (0.50.0.dev0), which carries the fix.

The unsloth install used bare pip install -e ., which pulls only the CLI
dependencies (typer, rich, pydantic, pyyaml, nest-asyncio); the pip show
probe passed on metadata alone while transformers, trl, peft, datasets,
and accelerate were all absent, so the image built green but could not
train. It now installs the huggingfacenotorch extra, which delivers the
full HF training stack without torch or torchvision so the ROCm torch in
the vLLM base image is never clobbered by a PyPI CPU/CUDA build.
2026-07-18 13:09:44 +00:00
Daniel Han
abfe2b680c Tighten Dockerfile.rocm comments 2026-07-18 08:12:00 +00:00
Daniel Han
976cfedf31 docker: tighten the ROCm Dockerfile layers
Combine apt-get update/install into one RUN with --no-install-recommends and
list cleanup (a cached standalone update layer goes stale for later installs),
fetch only the pinned bitsandbytes commit instead of cloning the default branch
first, and fold the three pip verification probes into a single layer.
2026-07-16 04:53:35 +00:00
Daniel Han
3ac70a9669 Merge remote-tracking branch 'origin/main' into r4223 2026-07-16 04:50:40 +00:00
billishyahao
eb93dda4fc add rocm dockerfile
(cherry picked from commit 6d6ab6bfaf)
2026-03-12 07:48:58 +00:00

69
docker/Dockerfile.rocm Normal file
View file

@ -0,0 +1,69 @@
ARG BASE_DOCKER=rocm/vllm-dev:nightly_main_20250914
FROM $BASE_DOCKER
WORKDIR /unsloth-workspace
# Single RUN so the apt index can't go stale; cleanup keeps the layer small.
RUN apt-get update \
&& apt-get install -y --no-install-recommends zip unzip wget build-essential cmake \
&& rm -rf /var/lib/apt/lists/*
ARG COMPUTE_BACKEND="hip"
ARG BNB_ROCM_ARCHS="gfx942"
# bnb PR #1887 floor (0.50.0.dev0); earlier builds NaN at 4-bit GEMV decode on AMD.
ARG BNB_COMMIT="713a3b83e405d32449e1cb392e5e25985ab927c6"
ARG BNB_REPO="https://github.com/bitsandbytes-foundation/bitsandbytes.git"
# Plain install, not `-e`: upstream reserves editable for bnb development, and
# scikit-build-core 1.0.0 rejects it unless pyproject opts into
# editable.mode = "inplace", which this pin predates. cmake already dropped the
# .so into the package dir, so setuptools package-data ships it as built.
RUN mkdir bitsandbytes \
&& cd bitsandbytes \
&& git init \
&& git remote add origin ${BNB_REPO} \
&& git fetch --depth 1 origin ${BNB_COMMIT} \
&& git checkout FETCH_HEAD \
&& rm -rf .git \
&& cmake -S . -B build \
-DCOMPUTE_BACKEND=${COMPUTE_BACKEND} \
-DBNB_ROCM_ARCH="${BNB_ROCM_ARCHS}" \
&& cmake --build build -j"$(nproc)" \
&& pip install . \
&& rm -rf build
ARG UNSLOTH_REPO="https://github.com/unslothai/unsloth.git"
ARG UNSLOTH_BRANCH="main"
# huggingfacenotorch skips torch/torchvision so the base image's ROCm torch survives; bare `-e .` can't train.
RUN git clone --branch ${UNSLOTH_BRANCH} --depth 1 ${UNSLOTH_REPO} unsloth \
&& cd unsloth \
&& rm -rf .git \
&& pip install -e '.[huggingfacenotorch]'
ARG UNSLOTH_ZOO_REPO="https://github.com/unslothai/unsloth-zoo.git"
ARG UNSLOTH_ZOO_BRANCH="main"
RUN git clone --branch ${UNSLOTH_ZOO_BRANCH} --depth 1 ${UNSLOTH_ZOO_REPO} unsloth-zoo \
&& cd unsloth-zoo \
&& rm -rf .git \
&& pip install -e .
# pip show reads dist-info only, so it stayed green on an image whose freshly
# compiled HIP library was missing. bitsandbytes is no help either: with no AMD
# GPU on the builder it falls back to libbitsandbytes_cpu.so and reports
# success, so load the ROCm library explicitly. unsloth_zoo refuses to import
# without a torch accelerator, so only resolve it and unsloth.
# Still uncaught: a wrong-arch build loads fine here and only fails once a
# 4-bit GEMV runs on real AMD silicon.
RUN python3 -c "import ctypes, importlib.util, pathlib; \
import bitsandbytes; \
pkg = pathlib.Path(bitsandbytes.__file__).parent; \
libs = sorted(pkg.glob('libbitsandbytes*.so')); \
assert any('_rocm' in so.name for so in libs), f'no libbitsandbytes_rocm*.so in {pkg}'; \
[ctypes.CDLL(str(so)) for so in libs]; \
missing = [m for m in ('unsloth', 'unsloth_zoo') if importlib.util.find_spec(m) is None]; \
assert not missing, f'not importable: {missing}'"