Convert to multi-stage build to reduce runtime image size#39
Closed
Lafunamor wants to merge 6 commits into
Closed
Conversation
added 6 commits
April 16, 2026 18:17
Builder stage retains the full ROCm SDK + LLVM/Clang toolchain, vLLM source tree, and bitsandbytes sources needed for compilation. Runtime stage starts from a clean Fedora base and receives only /opt/rocm and /opt/venv via COPY --from=builder, shedding gcc, cmake, ninja, *-devel packages, all source trees and build caches. Expected reduction: ~20-30GB.
Triton compiles GPU kernels at runtime using ROCm Clang and requires system C headers (stdlib.h). These were implicitly available in the single-stage build via gcc but missing from the runtime stage.
Removes ~6-7GB of content not needed at runtime: - Test and benchmark client suites (/opt/rocm/clients, /opt/rocm/tests) - Profiler and video decode tooling (rocprofiler-systems, rocdecode, rdc) - Static libraries (.a files) in /opt/rocm/lib and /opt/rocm/lib/llvm/lib - Test/bench/validate binaries and gtest data in /opt/rocm/bin - Build tools (hipify-clang, rocblas-gemm-tune)
Triton compiles Python extension modules (hip_utils.cpython-*.so) at runtime using ROCm Clang, which requires Python.h from python3.12-devel.
The final chmod created a 22GB layer by touching every file in /opt/rocm and /opt/venv. Using --chmod=755 on the COPY instructions applies permissions inline with no extra layer, saving ~22GB from the image.
8b0333b to
92aa2c2
Compare
Author
|
Closing in favour of the more focused #41 (chmod fix) which addresses the image size issue more conservatively. The multi-stage build approach needs more validation before it's ready to contribute upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
transformers==5.3.0override (also covered by Remove pinned transformers==5.3.0 #38 — if that merges first, this PR's diff will be cleaner)What changes
Builder stage retains everything needed for compilation:
Runtime stage starts from a clean Fedora base and receives only:
/opt/rocm— full copy, kept generous to avoid runtime surprises/opt/venv— compiled venv with vLLM, PyTorch, flash-attention, bitsandbytes, rayEverything else is shed: compiler toolchain, source trees, build caches,
*-develheaders.Expected impact
~20-30GB reduction in final image size. The main saving is the LLVM/Clang compiler bundled in
/opt/rocm/llvmplus build tools that are only needed at compile time.Transformers pin removal
The
transformers==5.3.0pin is removed because vLLM PR #30566 (merged 2026-04-15) updated the constraint from< 5to!= 5.0.*..5.5.0. The pin was both redundant and actively conflicting with the new constraint since5.3.0is now explicitly excluded.