Dockerfile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # syntax=docker/dockerfile:1.7
  2. # Solar Open2 250B NVFP4 (Nota) — self-contained build for DGX Spark (aarch64/sm_121a)
  3. #
  4. # Stack mirrors glm52-nf3-hybrid (cu130, pinned torch/NCCL/flashinfer/cutlass-dsl)
  5. # minus the b12x / NF3-hybrid suite: Solar is a stock vLLM serve using the
  6. # UpstageAI solar_open2 fork (solar_open2 reasoning/tool parsers + logits
  7. # processor). NVFP4 (compressed-tensors) is auto-detected from the model config.
  8. #
  9. # All build inputs pinned in versions.env and locks/. No external repo needed
  10. # beyond the package registries and git repos each stage clones.
  11. #
  12. # Build: cd docker-images/solar-open2-nvfp4 && bash build.sh
  13. ARG CUDA_BASE_IMAGE
  14. ARG CUDA_BASE_DIGEST
  15. FROM ${CUDA_BASE_IMAGE}@${CUDA_BASE_DIGEST} AS apt-base
  16. ARG UV_VERSION
  17. ARG PYTORCH_INDEX_URL
  18. ARG PYPI_INDEX_URL
  19. ARG TORCH_CUDA_ARCH_LIST=12.1a
  20. ENV DEBIAN_FRONTEND=noninteractive \
  21. PIP_BREAK_SYSTEM_PACKAGES=1 \
  22. UV_SYSTEM_PYTHON=1 UV_BREAK_SYSTEM_PACKAGES=1 UV_LINK_MODE=copy \
  23. TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST} \
  24. TRITON_PTXAS_PATH=/usr/local/cuda/bin/ptxas
  25. COPY locks/apt-sources.list /tmp/apt-sources.list
  26. COPY locks/apt-packages.txt /tmp/apt-packages.txt
  27. COPY locks/python-bootstrap.txt /tmp/python-bootstrap.txt
  28. COPY locks/python-build.txt /tmp/python-build.txt
  29. RUN rm -f /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources \
  30. && cp /tmp/apt-sources.list /etc/apt/sources.list \
  31. && apt-get update \
  32. && grep -vE '^\s*(#|$)' /tmp/apt-packages.txt \
  33. | xargs apt-get install -y --no-install-recommends \
  34. && rm -rf /var/lib/apt/lists/* \
  35. && python3 -m pip install --no-cache-dir --require-hashes --no-deps \
  36. -r /tmp/python-bootstrap.txt --index-url ${PYPI_INDEX_URL}
  37. FROM apt-base AS torch-base
  38. RUN --mount=type=cache,id=uv-cache,target=/root/.cache/uv \
  39. uv pip install --require-hashes -r /tmp/python-build.txt \
  40. --index-url ${PYPI_INDEX_URL} --extra-index-url ${PYTORCH_INDEX_URL} \
  41. --index-strategy unsafe-best-match
  42. FROM torch-base AS base
  43. ARG TORCH_VERSION TORCHVISION_VERSION TORCHAUDIO_VERSION TRITON_VERSION
  44. ARG NCCL_REPO NCCL_REF
  45. RUN git clone --depth 1 -b ${NCCL_REF} ${NCCL_REPO} /opt/nccl \
  46. && cd /opt/nccl \
  47. && make -j $(nproc) src.build \
  48. NVCC_GENCODE="-gencode=arch=compute_121,code=sm_121" \
  49. && make install PREFIX=/usr/local && ldconfig
  50. FROM base AS flashinfer-builder
  51. ARG FLASHINFER_REPO FLASHINFER_REF
  52. ARG FLASHINFER_CUDA_ARCH_LIST=12.1a
  53. ARG SOURCE_DATE_EPOCH BUILD_JOBS
  54. ENV FLASHINFER_CUDA_ARCH_LIST=${FLASHINFER_CUDA_ARCH_LIST}
  55. RUN git clone --recursive ${FLASHINFER_REPO} /workspace/flashinfer \
  56. && cd /workspace/flashinfer \
  57. && git checkout ${FLASHINFER_REF} \
  58. && git submodule update --init --recursive
  59. WORKDIR /workspace/flashinfer
  60. RUN --mount=type=cache,id=uv-cache,target=/root/.cache/uv \
  61. --mount=type=cache,id=ccache,target=/root/.ccache \
  62. _j="${BUILD_JOBS:-$(nproc)}" \
  63. && export MAX_JOBS="${_j}" CMAKE_BUILD_PARALLEL_LEVEL="${_j}" \
  64. && sed -i '/^license-files/d' pyproject.toml \
  65. && sed -i 's|^license = .*|license = {text = "Apache-2.0"}|' pyproject.toml \
  66. && uv build --no-build-isolation --wheel . --out-dir=/wheels -v \
  67. && cd flashinfer-cubin \
  68. && sed -i '/^license-files/d' pyproject.toml \
  69. && sed -i 's|^license = .*|license = {text = "Apache-2.0"}|' pyproject.toml \
  70. && uv build --no-build-isolation --wheel . --out-dir=/wheels -v \
  71. && cd ../flashinfer-jit-cache \
  72. && sed -i '/^license-files/d' pyproject.toml \
  73. && sed -i 's|^license = .*|license = {text = "Apache-2.0"}|' pyproject.toml \
  74. && uv build --no-build-isolation --wheel . --out-dir=/wheels -v
  75. FROM base AS vllm-builder
  76. ARG VLLM_REPO VLLM_REF VLLM_COMMIT
  77. ARG SOURCE_DATE_EPOCH BUILD_JOBS
  78. RUN git clone --recursive ${VLLM_REPO} /workspace/vllm \
  79. && cd /workspace/vllm \
  80. && git checkout ${VLLM_REF} \
  81. && git submodule update --init --recursive
  82. WORKDIR /workspace/vllm
  83. RUN --mount=type=cache,id=uv-cache,target=/root/.cache/uv \
  84. --mount=type=cache,id=ccache,target=/root/.ccache \
  85. _j="${BUILD_JOBS:-$(nproc)}" \
  86. && export MAX_JOBS="${_j}" CMAKE_BUILD_PARALLEL_LEVEL="${_j}" \
  87. && python3 use_existing_torch.py \
  88. && sed -i '/^license-files/d' pyproject.toml \
  89. && sed -i 's|^license = .*|license = {text = "Apache-2.0"}|' pyproject.toml \
  90. && uv build --no-build-isolation --wheel . --out-dir=/wheels -v
  91. FROM base AS runner
  92. ARG TORCH_CUDA_ARCH_LIST=12.1a
  93. ARG PYTORCH_INDEX_URL PYPI_INDEX_URL
  94. ARG CUTLASS_DSL_VERSION
  95. COPY locks/python-runtime.txt /tmp/python-runtime.txt
  96. WORKDIR /workspace
  97. COPY checksums/tiktoken.sha256 /tmp/tiktoken.sha256
  98. RUN mkdir -p tiktoken_encodings \
  99. && wget -O tiktoken_encodings/o200k_base.tiktoken https://openaipublic.blob.core.windows.net/encodings/o200k_base.tiktoken \
  100. && wget -O tiktoken_encodings/cl100k_base.tiktoken https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken \
  101. && cd tiktoken_encodings && sha256sum -c /tmp/tiktoken.sha256
  102. ENV TIKTOKEN_ENCODINGS_BASE=/workspace/tiktoken_encodings
  103. RUN apt-get update && apt-get install -y --no-install-recommends libboost-dev libaio-dev \
  104. && rm -rf /var/lib/apt/lists/*
  105. # Install all wheels
  106. RUN --mount=type=bind,from=flashinfer-builder,source=/wheels,target=/fi-wheels \
  107. --mount=type=bind,from=vllm-builder,source=/wheels,target=/vllm-wheels \
  108. --mount=type=cache,id=uv-cache,target=/root/.cache/uv \
  109. uv pip install --require-hashes -r /tmp/python-runtime.txt \
  110. --index-url ${PYPI_INDEX_URL} --extra-index-url ${PYTORCH_INDEX_URL} \
  111. --index-strategy unsafe-best-match \
  112. && pip install --no-cache-dir /fi-wheels/*.whl /vllm-wheels/*.whl
  113. # cutlass-dsl (used by flashinfer/vllm CuTeDSL paths at runtime)
  114. RUN pip install --no-cache-dir \
  115. nvidia-cutlass-dsl==${CUTLASS_DSL_VERSION} \
  116. nvidia-cutlass-dsl-libs-cu13==${CUTLASS_DSL_VERSION}
  117. # NCCL symlink for torch
  118. RUN rm -f /usr/local/lib/python3.12/dist-packages/nvidia/nccl/lib/libnccl.so.2 \
  119. && ln -s /usr/local/lib/libnccl.so.2 \
  120. /usr/local/lib/python3.12/dist-packages/nvidia/nccl/lib/libnccl.so.2
  121. ENTRYPOINT []
  122. CMD ["bash"]