motif64

m64_610762301be1 / Dockerfile

101 lines, 7.9 KBraw
1# opencode-nemotron35bolt-tf-gb10: opencode 1.18.23 driving Nemotron 3.5 Bolt served by TensorFold in the same container.2# The engine stages are the nemotron35-bolt-tensorfold-gb10 capsule's, line for line (MiaAI-Lab's DGX Spark recipe);3# the harness lines are opencode-inkling2mini-tf-v2-gb10's.4# nemotron35-bolt-tensorfold-gb10: TensorFold's Zig engine (tensorfold-native) with libbolt, the Nemotron 3.5 Bolt5# backend, built for the DGX Spark's GB10 (linux-aarch64, sm_121) exactly as MiaAI-Lab's recipe does it:6#   github.com/MiaAI-Lab/Nemotron-3.5-Bolt-TensorFold-DGX-Spark @ 6b064a31dd47e4f959e9041d6129eb2bad8304817# - TensorFold v1.1.6 (Apache-2.0) from github.com/ashhart/TensorFold at eea9dc9c, plus the recipe's8#   patches/0002-register-bolt.patch and its engine/ sources (libbolt, Apache-2.0), taken from the recipe's tarball at9#   that commit (SHA-256 checked).10# - Zig 0.17.0 (checked by SHA-256), FFmpeg 9.0.2 for libtfvideo (TensorFold's own build script, SHA-256 checked),11#   libjpeg-turbo 3.1.4.1 (SHA-256 checked), xgrammar v0.2.8 at its pinned commit for libtfgrammar.so.12# - Base: NVIDIA's PyTorch 26.07 container (CUDA 13, nvcc with sm_121a), pinned by digest.13# One change from the recipe: its final stage also pip-installs huggingface_hub for downloads; m64 fetches the weights.1415FROM nvcr.io/nvidia/pytorch@sha256:2140e699b3beaf7f96a0081fd9c9406bc3832b435cdb60dfa2d261f7d2f34a1c AS build16ARG ZIG_VERSION=0.17.017ARG ZIG_SHA256=9e8d11661d4ae3bd57702a3832781e23ad151dde5798e16a5ccd503f65234ff818RUN curl -fsSL -o /tmp/zig.tar.xz "https://ziglang.org/download/${ZIG_VERSION}/zig-aarch64-linux-${ZIG_VERSION}.tar.xz" && \19    echo "${ZIG_SHA256}  /tmp/zig.tar.xz" | sha256sum -c - && \20    mkdir -p /opt/zig && tar -xJf /tmp/zig.tar.xz -C /opt/zig --strip-components=1 && rm /tmp/zig.tar.xz && \21    /opt/zig/zig version22ARG TF_REPO=https://github.com/ashhart/TensorFold.git23ARG TF_REF=eea9dc9c9c8b459c0a03de7f6fe0c6f4835d69ab24RUN git init -q /tensorfold && cd /tensorfold && git remote add origin "${TF_REPO}" && \25    git fetch -q --depth 1 origin "${TF_REF}" && git checkout -q --detach FETCH_HEAD && \26    test "$(git rev-parse HEAD)" = "${TF_REF}"27# the decoders libtfvideo needs (FFmpeg 9.0.2, upstream's script) and the JPEG library the pictures need (libjpeg-turbo 3.1.4.1)28RUN cd /tensorfold && tools/zig/build_ffmpeg.sh /opt/ffmpeg >/tmp/ffmpeg.log 2>&1 && \29    curl -fsSL -o /tmp/jt.tgz https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.1.4.1/libjpeg-turbo-3.1.4.1.tar.gz && \30    echo "ecae8008e2cc9ade2f2c1bb9d5e6d4fb73e7c433866a056bd82980741571a022  /tmp/jt.tgz" | sha256sum -c - && \31    tar -xzf /tmp/jt.tgz -C /tmp && cd /tmp/libjpeg-turbo-3.1.4.1 && \32    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC=0 -DWITH_TURBOJPEG=1 -DCMAKE_INSTALL_PREFIX=/opt/jpeg >/dev/null && \33    cmake --build build -j"$(nproc)" >/dev/null && cmake --install build >/dev/null && rm -rf /tmp/jt.tgz /tmp/libjpeg-turbo-3.1.4.134# structured output (response_format, forced tool_choice) loads libtfgrammar, built from the xgrammar release the pinned35# tree names (v0.2.8), checked against its commit36ARG XGRAMMAR_REF=97787376faee5ed8466cfad57c99855e4ce2f6aa37RUN tag="$(sed -n 's/^pub const pinned = "\(.*\)";/\1/p' /tensorfold/zig/src/platform/grammar_library.zig)" && test "$tag" = v0.2.8 && \38    git clone -q --branch "$tag" --recurse-submodules https://github.com/mlc-ai/xgrammar /opt/xgrammar && \39    test "$(git -C /opt/xgrammar rev-parse HEAD)" = "${XGRAMMAR_REF}"40ARG RECIPE_COMMIT=6b064a31dd47e4f959e9041d6129eb2bad83048141ARG RECIPE_SHA256=eb5e70782f4b4ca9a5aa7665c222eb450f3d7bfe83ea87c00fe0eac262394edd42RUN curl -fsSL -o /tmp/recipe.tgz "https://github.com/MiaAI-Lab/Nemotron-3.5-Bolt-TensorFold-DGX-Spark/archive/${RECIPE_COMMIT}.tar.gz" && \43    echo "${RECIPE_SHA256}  /tmp/recipe.tgz" | sha256sum -c - && \44    mkdir -p /opt/recipe && tar -xzf /tmp/recipe.tgz -C /opt/recipe --strip-components=1 && rm /tmp/recipe.tgz && \45    cp -a /opt/recipe/patches /opt/tf-patches && cp -a /opt/recipe/engine /opt/bolt-engine && \46    mkdir -p /opt/tensorfold/share/doc/recipe && cp /opt/recipe/LICENSE /opt/recipe/NOTICE /opt/recipe/CREDITS.md /opt/tensorfold/share/doc/recipe/47RUN cd /tensorfold && \48    for p in /opt/tf-patches/*.patch; do [ -e "$p" ] || continue; echo "applying $p"; git apply --check "$p" && git apply "$p" || exit 1; done && \49    cp /opt/bolt-engine/bolt_native.zig /opt/bolt-engine/bolt_api.zig zig/src/families/nemotron/50RUN cd /tensorfold && /opt/zig/zig build -Dnvcc=/usr/local/cuda/bin/nvcc -Dbolt-src=/opt/bolt-engine -Dffmpeg=/opt/ffmpeg \51      -Dxgrammar=/opt/xgrammar -Doptimize=fast --prefix /opt/tensorfold -j"$(nproc)" install native bolt video grammar && \52    cp -a /opt/jpeg/lib/libturbojpeg.so.0* /opt/tensorfold/native/lib/ && \53    test -x /opt/tensorfold/native/bin/tensorfold-native && \54    test -f /opt/tensorfold/native/lib/libbolt.so && test -f /opt/tensorfold/native/lib/libtfvideo.so && \55    test -f /opt/tensorfold/native/lib/libturbojpeg.so.0 && test -f /opt/tensorfold/native/lib/libtfgrammar.so56RUN mkdir -p /opt/tensorfold/share/doc/tensorfold && cd /tensorfold && \57    for f in LICENSE LICENSE.md LICENSES NOTICE THIRD_PARTY_NOTICES.md; do \58      if [ -e "$f" ]; then cp -a "$f" /opt/tensorfold/share/doc/tensorfold/ || exit 1; fi; done && \59    mkdir -p /opt/tensorfold/share/doc/tensorfold/LICENSES && \60    cp /opt/xgrammar/LICENSE /opt/tensorfold/share/doc/tensorfold/LICENSES/xgrammar-Apache-2.0.txt && \61    cp /opt/xgrammar/NOTICE /opt/tensorfold/share/doc/tensorfold/LICENSES/xgrammar-NOTICE.txt && \62    cp /opt/xgrammar/3rdparty/dlpack/LICENSE /opt/tensorfold/share/doc/tensorfold/LICENSES/dlpack-Apache-2.0.txt6364FROM nvcr.io/nvidia/pytorch@sha256:2140e699b3beaf7f96a0081fd9c9406bc3832b435cdb60dfa2d261f7d2f34a1c65COPY --from=build /opt/tensorfold /opt/tensorfold66RUN ln -s /opt/tensorfold/native/bin/tensorfold-native /usr/local/bin/tensorfold-native && \67    test -x /opt/tensorfold/native/bin/tensorfold-native68ENV PYTHONUNBUFFERED=1 LD_LIBRARY_PATH=/opt/tensorfold/native/lib6970RUN apt-get update -qq && apt-get install -y --no-install-recommends \71      ca-certificates git ripgrep jq curl xz-utils unzip file less procps build-essential python3-venv \72    && rm -rf /var/lib/apt/lists/*7374# Node 22.23.2, official arm64 build, checked against nodejs.org's SHASUMS256.txt.75RUN curl -fsSL https://nodejs.org/dist/v22.23.2/node-v22.23.2-linux-arm64.tar.xz -o /tmp/node.tar.xz \76 && echo "fff4078c5def658577f92c88db7db3bc0072924bfb93fe52c1e744a54e94abb8  /tmp/node.tar.xz" | sha256sum -c - \77 && mkdir -p /opt/node && tar xJf /tmp/node.tar.xz -C /opt/node --strip-components=1 && rm /tmp/node.tar.xz \78 && ln -s /opt/node/bin/node /opt/node/bin/npm /opt/node/bin/npx /usr/local/bin/79ENV PATH=/opt/node/bin:$PATH8081RUN npm install -g opencode-ai@1.18.23 && npm cache clean --force8283# Everything opencode would otherwise fetch at run time (models.dev catalogue, LSP servers,84# self-update) is disabled. The npm packages it installs on a project's first use are85# warmed here, where the build has network (warm_opencode.sh); start.sh copies them into86# the throwaway HOME. Without this, every run would log a blocked registry.npmjs.org.87ENV OPENCODE_DISABLE_AUTOUPDATE=1 \88    OPENCODE_DISABLE_LSP_DOWNLOAD=1 \89    OPENCODE_DISABLE_MODELS_FETCH=1 \90    OPENCODE_DISABLE_SHARE=191COPY opencode.json /etc/opencode/opencode.json92COPY warm_opencode.sh /tmp/warm_opencode.sh93RUN bash /tmp/warm_opencode.sh && rm /tmp/warm_opencode.sh9495# Gateway deps, the same pinned set as the other agent capsules' gateways (the vLLM image had them; this base does not).96RUN python3 -m venv /opt/gateway && /opt/gateway/bin/pip install --no-cache-dir \97      fastapi==0.115.14 uvicorn==0.32.1 httpx==0.28.1 \98      starlette==0.46.2 pydantic==2.14.1 pydantic_core==2.50.1 annotated-types==0.8.0 \99      typing_extensions==4.16.0 typing-inspection==0.4.4 anyio==4.15.1 idna==3.20 \100      certifi==2026.10.23 httpcore==1.0.9 h11==0.16.0 click==8.5.0101WORKDIR /scratch