Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- main
paths:
- 'docker/Dockerfile'
- 'third_party/sglang'
- 'third_party/Megatron-LM'

schedule:
# Every 12 hours: midnight and noon UTC
Expand Down Expand Up @@ -118,6 +120,21 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

# The submodules under third_party/ are gitfile-linked (`.git` is a file
# pointing at <outer>/.git/modules/...), which Docker COPY would carry
# into the image as a dangling reference. Replace each gitlink with the
# SHA the submodule points at, then drop the gitlink itself — the image
# only needs the source tree, not git history.
- name: Strip submodule .git pointers for Docker COPY
run: |
set -eux
for sub in third_party/sglang third_party/Megatron-LM; do
git -C "$sub" rev-parse HEAD > "$sub/.miles-submodule-sha"
rm -f "$sub/.git"
done

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
path = examples/experimental/swe-agent/mini-swe-agent
url = https://github.com/yueming-yuan/nv-mini-swe-agent
branch = miles-swe-agent
[submodule "third_party/sglang"]
path = third_party/sglang
url = git@github.com:sgl-project/sglang.git
branch = sglang-miles
[submodule "third_party/Megatron-LM"]
path = third_party/Megatron-LM
url = git@github.com:radixark/Megatron-LM.git
branch = miles-main
33 changes: 15 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ ARG SGLANG_IMAGE_TAG=v0.5.10
FROM lmsysorg/sglang:${SGLANG_IMAGE_TAG} AS sglang

# ======================================== Arguments =============================================

ARG SGLANG_BRANCH=sglang-miles
ARG SGLANG_COMMIT=""

ARG MEGATRON_REPO=radixark/Megatron-LM
ARG MEGATRON_BRANCH=miles-main
#
# sglang and Megatron-LM are pulled from the miles repo's git submodules
# under third_party/, so their versions are recorded by the submodule
# pointers rather than by branch/commit build args.

ARG ENABLE_CUDA_13=0

Expand Down Expand Up @@ -105,9 +103,8 @@ RUN if [ "${ENABLE_CUDA_13}" = "1" ] && [ -d /tmp/patches/cu13 ]; then \
# apex
RUN pip install /tmp/wheels/apex-*.whl

RUN git clone https://github.com/${MEGATRON_REPO}.git --recursive -b ${MEGATRON_BRANCH} Megatron-LM && \
cd Megatron-LM && \
pip install -e .
COPY third_party/Megatron-LM /root/Megatron-LM
RUN cd /root/Megatron-LM && pip install -e .

RUN pip install git+https://github.com/fzyzcjy/torch_memory_saver.git@d64a639 --no-cache-dir --force-reinstall
# RUN pip install git+https://github.com/fzyzcjy/Megatron-Bridge.git@dev_rl --no-build-isolation
Expand All @@ -133,15 +130,15 @@ RUN rm -rf /root/.cache/pip /root/flash-attention

# ====================================== Install sglang-miles ============================================

# Install sglang from sglang-miles branch
RUN cd /sgl-workspace/sglang && \
git fetch origin ${SGLANG_BRANCH} && \
if [ -n "${SGLANG_COMMIT}" ]; then \
git checkout ${SGLANG_COMMIT}; \
else \
git checkout FETCH_HEAD; \
fi && \
pip install -e "python[all]" --no-deps
# Overlay the sglang source from the third_party/sglang submodule onto the
# base image's /sgl-workspace/sglang directory. The submodule pointer is
# the source of truth for which sglang revision the image carries. The
# base image ships a stale `.git/` dir at this path — drop it before COPY
# so the resulting image isn't carrying a git index that disagrees with
# the working tree.
RUN rm -rf /sgl-workspace/sglang/.git

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The COPY command merges the source directory contents into the destination if it already exists. Since the base image lmsysorg/sglang already contains an installation in /sgl-workspace/sglang, simply removing the .git directory might leave behind stale source files or artifacts that are not present in the submodule (e.g., if files were renamed or removed in the submodule version). To ensure a clean state where the directory contains exactly what is in the submodule, it is safer to remove the entire directory before copying.

RUN rm -rf /sgl-workspace/sglang

COPY third_party/sglang /sgl-workspace/sglang
RUN cd /sgl-workspace/sglang && pip install -e "python[all]" --no-deps

# ====================================== Install main package ============================================

Expand Down
1 change: 1 addition & 0 deletions third_party/Megatron-LM
Submodule Megatron-LM added at 23924a
1 change: 1 addition & 0 deletions third_party/sglang
Submodule sglang added at 363403
Loading