build.sh 2.6 KB

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