Skip to content

Commit 5acefb4

Browse files
committed
feat: Add rosetta-maxtext Dockerfile
1 parent 1da45d2 commit 5acefb4

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

rosetta/Dockerfile.maxtext

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# syntax=docker/dockerfile:1-labs
2+
ARG BASE_IMAGE=ghcr.io/nvidia/jax-mealkit:upstream-pax
3+
4+
ARG GIT_USER_NAME=NVIDIA
5+
# If set to "true", then will pull new local patches, the manifest.yaml and create-distribution.sh (in case it was updated).
6+
# This is useful for development if you run `./bump.sh -i manifest.yaml` manually and do not want to trigger a full rebuild all
7+
# the way up to the jax build.
8+
ARG UPDATE_PATCHES=false
9+
# It is common for TE developers to test a different TE against the LLM application. This is a knob to override what's in the manifest
10+
# Accepts git-ref's from NVIDIA/TransformerEngine or pull requests (pull/$number/head)
11+
ARG UPDATED_TE_REF=""
12+
13+
# Rosetta and optionally patches are pulled from this
14+
FROM scratch AS jax-toolbox
15+
16+
###############################################################################
17+
### Download source and add auxiliary scripts
18+
################################################################################
19+
20+
FROM ${BASE_IMAGE} AS mealkit
21+
ARG GIT_USER_EMAIL
22+
ARG GIT_USER_NAME
23+
ARG UPDATE_PATCHES
24+
ARG UPDATED_TE_REF
25+
26+
ENV ENABLE_TE=1
27+
28+
RUN --mount=target=/mnt/jax-toolbox,from=jax-toolbox <<"EOF" bash -exu
29+
MANIFEST_DIR=$(dirname ${MANIFEST_FILE})
30+
if [[ "${UPDATE_PATCHES}" != "true" && "${UPDATE_PATCHES}" != "false" ]]; then
31+
echo "UPDATE_PATCHES can only be true or false"
32+
exit 1
33+
fi
34+
if [[ "${UPDATE_PATCHES}" == "true" ]]; then
35+
cp -r /mnt/jax-toolbox/.github/container/patches ${MANIFEST_DIR}/
36+
cp /mnt/jax-toolbox/.github/container/manifest.yaml ${MANIFEST_DIR}/manifest.yaml
37+
cp /mnt/jax-toolbox/.github/container/create-distribution.sh ${MANIFEST_DIR}/create-distribution.sh
38+
# TODO: remove
39+
cp /mnt/jax-toolbox/.github/container/pip-finalize.sh /usr/local/bin/
40+
fi
41+
cp -r /mnt/jax-toolbox/rosetta /opt/rosetta
42+
43+
if [[ -n "${UPDATED_TE_REF}" ]]; then
44+
TE_INSTALL_DIR=/opt/transformer-engine
45+
yq e ".transformer-engine.latest_verified_commit = \"${UPDATED_TE_REF}\"" -i $MANIFEST_FILE
46+
# Install from source instead of pre-built wheel
47+
sed -i -E 's@( file:///opt/transformer-engine)/dist/[^ ]*@\1@' /opt/pip-tools.d/requirements-te.in
48+
git -C $TE_INSTALL_DIR fetch -a
49+
if [[ "${UPDATED_TE_REF}" =~ ^pull/ ]]; then
50+
PR_ID=$(cut -d/ -f2 <<<"${UPDATED_TE_REF}")
51+
git -C $TE_INSTALL_DIR fetch origin ${UPDATED_TE_REF}:PR-${PR_ID}
52+
git -C $TE_INSTALL_DIR checkout PR-${PR_ID}
53+
else
54+
git -C $TE_INSTALL_DIR checkout ${UPDATED_TE_REF}
55+
fi
56+
fi
57+
58+
# Setting the username/email is required to author commits from patches
59+
git config --global user.email "${GIT_USER_EMAIL}"
60+
git config --global user.name "${GIT_USER_NAME}"
61+
62+
bash ${MANIFEST_DIR}/create-distribution.sh \
63+
--manifest ${MANIFEST_FILE} \
64+
--package maxtext
65+
# Remove .gitconfig to avoid end-user authoring commits as the "build user"
66+
rm -f ~/.gitconfig
67+
EOF
68+
69+
WORKDIR /opt/rosetta
70+
71+
###############################################################################
72+
### Install accumulated packages from the base image and the previous stage
73+
################################################################################
74+
75+
FROM mealkit as final
76+
77+
RUN pip-finalize.sh

0 commit comments

Comments
 (0)