Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a55a0899c | ||
|
|
666297d09c | ||
|
|
202f108f33 |
+13
-10
@@ -153,22 +153,25 @@ RUN --mount=type=cache,target=/usr/local/share/uv/cache \
|
||||
&& rm /tmp/prime-cli-overrides.txt \
|
||||
&& /app/.venv/bin/python -c 'import pathlib, verifiers; assert pathlib.Path(verifiers.__file__).is_relative_to("/app/deps/verifiers"), verifiers.__file__'
|
||||
|
||||
# Optional: build NIXL from source against the UCX 1.19 baked above. The PyPI
|
||||
# nixl wheel ships its own UCX which segfaults on prefill→decode KV transfer
|
||||
# (#2883); rebuilding against our UCX is the documented fix. Only needed for
|
||||
# the disaggregated P/D path — default off so training-only / single-node
|
||||
# inference builds are unaffected. Enable via `--build-arg INCLUDE_NIXL_FROM_SOURCE=1`.
|
||||
ARG INCLUDE_NIXL_FROM_SOURCE=0
|
||||
# Build NIXL from source against the UCX 1.19 baked above. The PyPI nixl wheel
|
||||
# ships its own UCX which segfaults on prefill→decode KV transfer (#2883);
|
||||
# rebuilding against our UCX is the documented fix. The rename is required: an
|
||||
# unrenamed source build is `nixl_cu12`, and the `nixl` shim imports nixl_cu13
|
||||
# (the PyPI wheel) first, so the fix would silently not apply. Libraries carry
|
||||
# RUNPATH=/opt/ucx/lib, so no LD_LIBRARY_PATH is needed at runtime.
|
||||
# Opt out via `--build-arg INCLUDE_NIXL_FROM_SOURCE=0`.
|
||||
ARG INCLUDE_NIXL_FROM_SOURCE=1
|
||||
ARG NIXL_VERSION=0.10.1
|
||||
RUN if [ "$INCLUDE_NIXL_FROM_SOURCE" = "1" ]; then \
|
||||
VIRTUAL_ENV=/app/.venv uv pip install pip \
|
||||
&& git clone --depth 1 --branch ${NIXL_VERSION} https://github.com/ai-dynamo/nixl.git /tmp/nixl \
|
||||
&& cd /tmp/nixl \
|
||||
&& uv run --no-project --with tomlkit python contrib/tomlutil.py --wheel-name nixl-cu13 pyproject.toml \
|
||||
&& PKG_CONFIG_PATH=/opt/ucx/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/opt/ucx/lib:/opt/ucx/lib/ucx \
|
||||
/app/.venv/bin/python -m pip wheel . --no-deps --wheel-dir=/app/deps \
|
||||
&& VIRTUAL_ENV=/app/.venv uv pip install --reinstall --no-deps /app/deps/nixl_cu13-*.whl \
|
||||
&& rm -rf /tmp/nixl /app/deps/nixl_cu13-*.whl; \
|
||||
/app/.venv/bin/python -m pip wheel . --no-deps --wheel-dir=/tmp/nixl-whl \
|
||||
&& VIRTUAL_ENV=/app/.venv uv pip install --reinstall --no-deps /tmp/nixl-whl/nixl_cu13-*.whl \
|
||||
&& ldd /app/.venv/lib/python3.12/site-packages/.nixl_cu13.mesonpy.libs/plugins/libplugin_UCX.so | grep -q /opt/ucx/lib/libucp.so \
|
||||
&& rm -rf /tmp/nixl /tmp/nixl-whl; \
|
||||
fi
|
||||
|
||||
# Trim the CUDA toolkit to the nvcc-JIT essentials in a separate stage, so the runtime
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ dependencies = [
|
||||
"transformers==5.6.2",
|
||||
"wandb>=0.26.1",
|
||||
"wandb-workspaces>=0.4.3",
|
||||
"prime-sandboxes>=0.3.0",
|
||||
"prime-sandboxes>=0.3.2",
|
||||
"prime-runs[train]>=0.1.3",
|
||||
"pyzmq>=27.1.0",
|
||||
"aiolimiter>=1.2.1",
|
||||
|
||||
+119
-45
@@ -5,67 +5,141 @@ set -e
|
||||
ulimit -n 32000 2>/dev/null || echo "Warning: Could not set ulimit (may need --ulimit flag in docker run)"
|
||||
|
||||
# Allow runtime override of the prime-rl source itself.
|
||||
# PRIME_RL_REF can be a git tag, branch, or commit hash. PRIME_RL_REPO
|
||||
# PRIME_RL_REF can be a git tag, branch, or full commit hash. PRIME_RL_REPO
|
||||
# optionally points at a fork; defaults to the upstream repo.
|
||||
#
|
||||
# We clone into a per-ref dir under /tmp, seed the venv from the baked
|
||||
# /app/.venv so heavy wheels (flash-attn, mamba-ssm, …) survive, then
|
||||
# `uv sync --inexact` re-installs prime_rl from the override source.
|
||||
# Workdir + PATH swap so the chart's `uv run trainer/inference/orchestrator`
|
||||
# resolves the entrypoints from the override venv.
|
||||
# The ref is fetched shallowly under /tmp and synced INTO the baked
|
||||
# /app/.venv: uv re-points the first-party editables (prime_rl, verifiers,
|
||||
# renderers, ...) at the checkout and reinstalls only third-party pins
|
||||
# that differ from the image's lockfile, so the heavy prebuilt wheels
|
||||
# (flash-attn, deep-ep, mamba-ssm, ...) are never rebuilt. A container
|
||||
# starts from a fresh filesystem, so mutating /app/.venv in place is safe.
|
||||
# The pods of the prime-rl-fft chart run this with a sha pinned by the
|
||||
# dispatcher; the exported PRIME_RL_SOURCE_COMMIT records what ran.
|
||||
if [ -n "$PRIME_RL_REF" ]; then
|
||||
PRIME_RL_REPO="${PRIME_RL_REPO:-https://github.com/PrimeIntellect-ai/prime-rl.git}"
|
||||
# Slug + content hash for the cache dir name. Slug keeps the path
|
||||
# Slug + content hash for the checkout dir name. Slug keeps the path
|
||||
# human-readable; the hash (over repo + ref) prevents collisions
|
||||
# between distinct refs that slugify the same way (e.g. `feat/foo`
|
||||
# vs `feat-foo`) and between the same ref on different forks.
|
||||
REF_SLUG="${PRIME_RL_REF//\//-}"
|
||||
REF_HASH=$(echo -n "${PRIME_RL_REPO}|${PRIME_RL_REF}" | md5sum | cut -c1-12)
|
||||
DEST="/tmp/prime-rl-${REF_SLUG}-${REF_HASH}"
|
||||
# Rewrite ssh://git@github.com URLs to https so submodules listed
|
||||
# with SSH URLs (deps/verifiers, deps/renderers, deps/research-envs)
|
||||
# can be cloned from the pod without ssh keys.
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
if [ ! -d "$DEST/.git" ]; then
|
||||
echo "[prime-rl] cloning ${PRIME_RL_REPO} for ${PRIME_RL_REF}"
|
||||
rm -rf "$DEST"
|
||||
git clone --recurse-submodules "$PRIME_RL_REPO" "$DEST"
|
||||
# Rewrite git@github.com URLs to https so submodules listed with SSH
|
||||
# URLs (deps/verifiers, deps/renderers, deps/prime-envs) clone from the
|
||||
# pod without ssh keys. Via GIT_CONFIG_* rather than `git config
|
||||
# --global`: the pod's HOME may not be writable by its uid.
|
||||
export GIT_CONFIG_COUNT=1
|
||||
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf"
|
||||
export GIT_CONFIG_VALUE_0="git@github.com:"
|
||||
rm -rf "$DEST"
|
||||
git init --quiet "$DEST"
|
||||
git -C "$DEST" remote add origin "$PRIME_RL_REPO"
|
||||
# Depth-1 fetch of the ref itself: GitHub serves branches, tags and
|
||||
# full commit shas alike (abbreviated shas are not fetchable), and
|
||||
# prime-rl's history (~700 MB of .git) is not needed to run it.
|
||||
echo "[prime-rl] fetching ${PRIME_RL_REF} from ${PRIME_RL_REPO}"
|
||||
git -C "$DEST" fetch --quiet --depth 1 origin "$PRIME_RL_REF"
|
||||
git -C "$DEST" checkout --quiet --force --detach FETCH_HEAD
|
||||
# Same public submodules the image build inits (build_image.yaml);
|
||||
# a pinned commit that isn't the submodule's branch tip is fetched by
|
||||
# sha, which GitHub allows.
|
||||
git -C "$DEST" submodule sync --quiet --recursive
|
||||
git -C "$DEST" submodule update --quiet --init --recursive --depth 1 -- \
|
||||
deps/pydantic-config deps/verifiers deps/renderers deps/prime-envs
|
||||
PRIME_RL_SOURCE_COMMIT=$(git -C "$DEST" rev-parse HEAD)
|
||||
export PRIME_RL_SOURCE_COMMIT
|
||||
echo "[prime-rl] source overlay at ${PRIME_RL_SOURCE_COMMIT}"
|
||||
|
||||
# Give the verifiers/renderers editables the same versions the image
|
||||
# build does (Dockerfile.cuda): resolve them with the repo's script
|
||||
# (git describe, else the highest `>=` floor any pyproject declares),
|
||||
# then bake them into hatch-vcs's fallback-version and drop the
|
||||
# submodules' git metadata so the fallback is what gets used. The
|
||||
# shallow clones carry no tags, so hatch-vcs would otherwise stamp
|
||||
# them 0.0.1.dev1 and every `verifiers>=…` floor in the tree would be
|
||||
# unmet, letting the CLI install below swap the editable for a wheel.
|
||||
if [ -f "$DEST/scripts/docker-editable-pretend-versions.sh" ]; then
|
||||
eval "$(bash "$DEST/scripts/docker-editable-pretend-versions.sh" --shell "$DEST")"
|
||||
rm -f "$DEST/deps/verifiers/.git" "$DEST/deps/renderers/.git"
|
||||
sed -i "s/fallback-version = \"0.0.0\"/fallback-version = \"${VERIFIERS_PRETEND_VERSION}\"/" "$DEST/deps/verifiers/pyproject.toml"
|
||||
sed -i "s/fallback-version = \"0.0.0\"/fallback-version = \"${RENDERERS_PRETEND_VERSION}\"/" "$DEST/deps/renderers/pyproject.toml"
|
||||
fi
|
||||
# Always fetch + checkout so mutable refs (branches/tags) pick up new
|
||||
# commits between pod restarts. No-op for immutable SHAs.
|
||||
echo "[prime-rl] refreshing ${PRIME_RL_REF}"
|
||||
git -C "$DEST" fetch --quiet --tags --force origin
|
||||
git -C "$DEST" checkout --quiet --force "$PRIME_RL_REF"
|
||||
# Fast-forward to upstream tip when PRIME_RL_REF is a branch name.
|
||||
# Silently no-ops for SHAs/tags (no `origin/<sha>` exists).
|
||||
git -C "$DEST" reset --hard --quiet "origin/${PRIME_RL_REF}" 2>/dev/null || true
|
||||
# Refresh submodules to whatever the parent commit pins. `sync`
|
||||
# picks up URL changes in .gitmodules between checkouts on cache
|
||||
# hit; `update --init --recursive` applies the pinned SHAs.
|
||||
git -C "$DEST" submodule sync --recursive
|
||||
git -C "$DEST" submodule update --init --recursive
|
||||
if [ ! -d "$DEST/.venv" ]; then
|
||||
# Seed from the baked venv so the heavy wheels (flash-attn,
|
||||
# mamba-ssm, …) don't have to be rebuilt. Plain `cp -a` (no
|
||||
# hardlinks): a subsequent `uv sync` writes into this tree, and
|
||||
# hardlinks would leak those writes back into /app/.venv when
|
||||
# /tmp and /app share a filesystem.
|
||||
cp -a /app/.venv "$DEST/.venv"
|
||||
fi
|
||||
echo "[prime-rl] running uv sync --inexact (this may take a few minutes on cold checkout)"
|
||||
# --inexact keeps the seeded venv's pre-built wheels (flash-attn-3,
|
||||
# deep-ep, mamba-ssm) in place; uv only rebuilds them if the override's
|
||||
# lockfile pins different versions.
|
||||
( cd "$DEST" && uv sync --inexact --no-dev --all-packages --all-extras --group mamba-ssm )
|
||||
export VIRTUAL_ENV="$DEST/.venv"
|
||||
export PATH="$DEST/.venv/bin:$PATH"
|
||||
|
||||
# Wheels the in-place sync cannot rebuild: a lockfile that pins any of
|
||||
# these differently from the image needs a real image build. Fail here
|
||||
# rather than minutes later inside a half-installed torch. Stdlib only;
|
||||
# --project /app pins the interpreter to the baked venv whatever the cwd.
|
||||
uv run --no-sync --project /app python - "$DEST/uv.lock" /app/uv.lock <<'HEAVY_PINS_PY'
|
||||
import sys
|
||||
import tomllib
|
||||
|
||||
HEAVY = {
|
||||
"torch", "torchvision", "torchaudio", "triton", "vllm", "vllm-router",
|
||||
"flash-attn", "flash-attn-3", "flashinfer-python", "tilelang",
|
||||
"deep-ep", "deep-gemm", "mamba-ssm", "nixl", "prime-kernels", "quack-kernels",
|
||||
}
|
||||
|
||||
|
||||
def pins(path):
|
||||
with open(path, "rb") as f:
|
||||
lock = tomllib.load(f)
|
||||
out = {}
|
||||
for pkg in lock.get("package", []):
|
||||
if pkg.get("name") in HEAVY:
|
||||
source = repr(sorted((pkg.get("source") or {}).items()))
|
||||
out.setdefault(pkg["name"], set()).add((pkg.get("version"), source))
|
||||
return out
|
||||
|
||||
|
||||
ref_pins, image_pins = pins(sys.argv[1]), pins(sys.argv[2])
|
||||
drift = sorted(name for name in HEAVY if ref_pins.get(name) != image_pins.get(name))
|
||||
if drift:
|
||||
print(
|
||||
f"[prime-rl] {sys.argv[1]} pins {', '.join(drift)} differently from the image; "
|
||||
"the runtime source overlay cannot rebuild these. Build an image for this ref "
|
||||
"(build_image.yaml) or run it on an image whose lockfile matches.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
HEAVY_PINS_PY
|
||||
|
||||
# Sync the checkout into the baked venv. Same extras as Dockerfile.cuda
|
||||
# so an unchanged lockfile is a no-op for third-party packages (keep
|
||||
# the two lists in sync). --inexact leaves packages the checkout
|
||||
# doesn't declare in place instead of uninstalling them.
|
||||
export UV_PROJECT_ENVIRONMENT=/app/.venv
|
||||
export VIRTUAL_ENV=/app/.venv
|
||||
echo "[prime-rl] syncing ${DEST} into /app/.venv"
|
||||
( cd "$DEST" && uv sync --inexact --locked --no-dev --all-packages \
|
||||
--extra gpu --extra dashboard --extra flash-attn --extra flash-attn-3 \
|
||||
--extra flash-attn-cute --extra disagg --extra quack --extra kernels \
|
||||
--group mamba-ssm )
|
||||
# Replay the image's post-sync step (Dockerfile.cuda; keep the two in
|
||||
# sync): the prime CLI pulls prime-traces / prime-sandboxes / openai
|
||||
# past the lock's pins, and the --locked sync above just rolled them
|
||||
# back, which leaves `prime env install` unable to import.
|
||||
#
|
||||
# FIXME(prime#940): workaround, remove once the prime CLI drops
|
||||
# verifiers as a dependency
|
||||
# (https://github.com/PrimeIntellect-ai/prime/pull/940). The CLI pins
|
||||
# verifiers==0.2.0, which would swap the editable for the PyPI wheel
|
||||
# and break prime-rl's imports; the --overrides file ignores that one
|
||||
# requirement. When removing it, drop the overrides file and the
|
||||
# --overrides flag here and in Dockerfile.cuda.
|
||||
echo "[prime-rl] installing the prime CLI"
|
||||
printf 'verifiers\n' > /tmp/prime-cli-overrides.txt
|
||||
uv pip install --overrides /tmp/prime-cli-overrides.txt 'prime>=0.7'
|
||||
# The chart's `uv run --no-sync <entrypoint>` commands resolve the
|
||||
# project from the cwd; the venv itself stays /app/.venv via
|
||||
# UV_PROJECT_ENVIRONMENT above.
|
||||
cd "$DEST"
|
||||
fi
|
||||
|
||||
# Allow runtime override of the verifiers package version.
|
||||
# VERIFIERS_VERSION can be a git tag, branch, or commit hash. Runs after the
|
||||
# PRIME_RL_REF swap so when both are set the install lands in the override
|
||||
# venv (uv pip install targets $VIRTUAL_ENV when exported).
|
||||
# PRIME_RL_REF overlay so when both are set verifiers is installed last
|
||||
# (uv pip install targets $VIRTUAL_ENV, which is /app/.venv either way).
|
||||
if [ -n "$VERIFIERS_VERSION" ]; then
|
||||
echo "Installing verifiers version: $VERIFIERS_VERSION"
|
||||
uv pip install --reinstall-package verifiers \
|
||||
|
||||
@@ -82,6 +82,10 @@ else
|
||||
fi
|
||||
cd "$NIXL_SRC"
|
||||
git checkout "$NIXL_VERSION"
|
||||
# Name the wheel nixl-cu13 (pyproject says nixl-cu12): the `nixl` shim imports
|
||||
# nixl_cu13 first, so a nixl_cu12 build would sit unused next to the PyPI wheel.
|
||||
git checkout -- pyproject.toml
|
||||
uv run --no-project --with tomlkit python contrib/tomlutil.py --wheel-name nixl-cu13 pyproject.toml
|
||||
|
||||
export PKG_CONFIG_PATH="$UCX_INSTALL/lib/pkgconfig"
|
||||
export LD_LIBRARY_PATH="$UCX_INSTALL/lib:$UCX_INSTALL/lib/ucx:${LD_LIBRARY_PATH:-}"
|
||||
@@ -92,5 +96,5 @@ mkdir -p "$WHEEL_DIR"
|
||||
uv pip install pip 2>/dev/null
|
||||
"$PYTHON" -m pip wheel . --no-deps --wheel-dir="$WHEEL_DIR"
|
||||
|
||||
WHEEL=$(ls "$WHEEL_DIR"/nixl*.whl | head -1)
|
||||
WHEEL=$(ls "$WHEEL_DIR"/nixl_cu13-"$NIXL_VERSION"-*.whl | head -1)
|
||||
echo "=== NIXL wheel built at: $WHEEL ==="
|
||||
|
||||
@@ -5049,7 +5049,7 @@ requires-dist = [
|
||||
{ name = "prime-rl", extras = ["quack"], marker = "extra == 'all'" },
|
||||
{ name = "prime-rl-configs", editable = "packages/prime-rl-configs" },
|
||||
{ name = "prime-runs", extras = ["train"], specifier = ">=0.1.3" },
|
||||
{ name = "prime-sandboxes", specifier = ">=0.3.0" },
|
||||
{ name = "prime-sandboxes", specifier = ">=0.3.2" },
|
||||
{ name = "prometheus-client", specifier = ">=0.20.0" },
|
||||
{ name = "psutil", specifier = ">=7.0.0" },
|
||||
{ name = "pyarrow", specifier = ">=21.0.0" },
|
||||
@@ -5141,7 +5141,7 @@ train = [
|
||||
|
||||
[[package]]
|
||||
name = "prime-sandboxes"
|
||||
version = "0.3.0"
|
||||
version = "0.3.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "aiofiles" },
|
||||
@@ -5153,9 +5153,9 @@ dependencies = [
|
||||
{ name = "pyqwest" },
|
||||
{ name = "tenacity" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/b6/46/2d118d8bbb901b729f3bc0678725eb28088d757a872db04cffa1492d0208/prime_sandboxes-0.3.0.tar.gz", hash = "sha256:c99075ed82a9bbfe5a453cee84b9f09565a7f6b07fd5ace072401cce59a1fe08", size = 132759, upload-time = "2026-09-18T01:32:31.263Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f8/fe/69195c7c9e3d0f938e84ae54a8ffd386529019fb7635cad65d318e96271d/prime_sandboxes-0.3.2.tar.gz", hash = "sha256:6ded2497cbff8b5760e3f7897e1f00f2b789463daa397481620361bb148bfc45", size = 135266, upload-time = "2026-09-25T21:35:16.33Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/04/c77c7f260babf93978f912b85511e76f63a3cfa5bb11a8c34108177d5825/prime_sandboxes-0.3.0-py3-none-any.whl", hash = "sha256:19078ff508fa72de8f565422918faf367e2831ed8a2f26a5a6a98110e4062941", size = 71441, upload-time = "2026-09-18T01:32:30.062Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/26/fc/6eefb673bbcbdd33105b5d14e8d7329a0b10a30c893ac8c74a8f2373a477/prime_sandboxes-0.3.2-py3-none-any.whl", hash = "sha256:d47f07fe90e662464ddd33468fa538f37c962e7bec5c2cbbbd170eb57d0ef89e", size = 72421, upload-time = "2026-09-25T21:35:14.99Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in New Issue
Block a user