unsloth/docker
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
..
Dockerfile.rocm docker: fix the ROCm bitsandbytes install and make the final check able to fail 2026-07-26 16:07:28 +00:00