#!/usr/bin/env bash # [sm121 vendor] Build the vendored kindlingai/glm-5.3-flash-gx10 image. # # Upstream builds `image/Dockerfile` against the repo root (the `vllm` symlink # into `.submodules/spark-agent` must stay inside the context). At runtime the # `glm53` script stacks eight `experimental/compose/*.yaml` overlays that # mount replacement Python/CUDA files over site-packages — the measured # "arx snapshot adaptive-k fp8 megamoe fixes sp recoverssm" stack. # # sm121 recipes mount no file trees from the node, so this build BAKES those # overlay files into the image: a generated Dockerfile.bake COPY stage # appended after upstream's own Dockerfile (used unmodified — the bake step # runs after verify-base.py). The per-overlay env/args live in the recipes # (recipes/glm53-kindling-*), mirroring the compose environment blocks. # # Deltas vs upstream c748079d45e6: only this file and README.md; every # upstream file is byte-identical. To vendor a new upstream: clone fresh # (with submodules), rsync -a over this dir keeping build.sh + README.md. # # c748079d carries the TP3/TP6 DFlash block-drop fix (drop the restated # SPEC_EXTRA so adaptive-k's copy, with disable_eagle_block_drop, applies) # and the optional dispram overlay (display-RAM KV carveout, no-op without # kindling-spark-os's dispramd — we don't run it, so it stays out of the # bake stack). set -euo pipefail cd "$(dirname "$0")" TAG="${TAG:-spark-glm53:v10}" # Overlay stack (bake order irrelevant: identical target paths). tp3.yaml # carries the only files TP6 needs — the pads activate only when the config # holds tp_pad_orig, a no-op on TP4. OVERLAYS=(arx snapshot adaptive-k fp8 megamoe fixes sp recoverssm tp3) python3 - "${OVERLAYS[@]}" > Dockerfile.bake <<'PY' import re, sys print("# [sm121] generated by build.sh: experimental/ overlays baked in") print("# (content parity with experimental/compose/*.yaml runtime mounts).") seen = set() for name in sys.argv[1:]: for line in open(f"experimental/compose/{name}.yaml"): if not re.match(r"\s*-\s+\.\./experimental/", line): continue parts = line.strip()[len("- ") :].split(":") if len(parts) < 2 or "${" in parts[0]: continue src, dst = parts[0][len("../") :], parts[1] if (src, dst) in seen: continue seen.add((src, dst)) print(f"COPY {src} {dst}") PY cat image/Dockerfile Dockerfile.bake > Dockerfile.sm121 echo "baked $(grep -c '^COPY experimental' Dockerfile.bake) overlay files" # shellcheck disable=SC2086 docker buildx build --progress=plain --load -t "$TAG" -f Dockerfile.sm121 . 2>&1 echo "=== Done: $TAG ==="