Dockerfile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # syntax=docker/dockerfile:1.7
  2. # GLM-5.3-Flash NVFP4 (local-inference-lab quant) on DGX Spark (SM121/GB10), TP=2.
  3. #
  4. # Same day-0 base + NoPE-MLA mod as docker-images/glm53-flash-nvfp4, PLUS the
  5. # four lab-checkpoint patches from FujitsuPolycom/glm53-flash-tp2-spark
  6. # (Apache-2.0, attribution in patches/UPSTREAM.md):
  7. # * model.patch — checkpoint naming shim (attn_hc.* submodules,
  8. # forget_gate flatten, fused [3C,1,4] conv1d split)
  9. # * modelopt.patch — MTP MIXED_PRECISION fix: the draft model
  10. # resolves quantization across the checkpoint /
  11. # target-mapper namespaces (without it:
  12. # KeyError model.layers.45.mtp_block...w2_weight_scale)
  13. # * sparse_attn_indexer*.patch — disable persistent_topk / cooperative
  14. # workspace on CC 12.x (requests 62 blocks vs 48,
  15. # 128 KB smem vs GB10's 99 KB)
  16. #
  17. # NOT vendored (base-image or fabric specific, see recipe header): the upstream
  18. # image-layer patches (flashkda prefill, mm-renderer), their bundled NCCL 2.30.7
  19. # (direct-cabled ring), and the instanttensor loader (optional speed-up).
  20. #
  21. # Verification markers: `[quantprobe]` in modelopt.py (runtime log must show
  22. # algo=MXFP8 for the MTP layer), `hc_attn_base` in model.py.
  23. ARG BASE_IMAGE
  24. FROM ${BASE_IMAGE}
  25. # 1) NoPE-MLA rope-pad + sm120 sparse-MLA topk mod (anchors self-assert).
  26. COPY patches/patch_mla.py /tmp/patch_mla.py
  27. # 2) FujitsuPolycom lab-checkpoint patches (unmodified upstream .patch files).
  28. COPY patches/model.patch patches/modelopt.patch \
  29. patches/sparse_attn_indexer.patch patches/sparse_attn_indexer_kpool.patch /tmp/
  30. RUN set -eux; \
  31. B=/usr/local/lib/python3.12/dist-packages/vllm; \
  32. python3 /tmp/patch_mla.py; \
  33. patch "$B/models/glm5next/nvidia/model.py" /tmp/model.patch; \
  34. patch "$B/model_executor/layers/quantization/modelopt.py" /tmp/modelopt.patch; \
  35. patch "$B/model_executor/layers/sparse_attn_indexer.py" /tmp/sparse_attn_indexer.patch; \
  36. patch "$B/model_executor/layers/sparse_attn_indexer_kpool.py" /tmp/sparse_attn_indexer_kpool.patch; \
  37. grep -q quantprobe "$B/model_executor/layers/quantization/modelopt.py"; \
  38. grep -q hc_attn_base "$B/models/glm5next/nvidia/model.py"; \
  39. python3 -m py_compile \
  40. "$B/models/glm5next/nvidia/model.py" \
  41. "$B/model_executor/layers/quantization/modelopt.py" \
  42. "$B/model_executor/layers/sparse_attn_indexer.py" \
  43. "$B/model_executor/layers/sparse_attn_indexer_kpool.py"; \
  44. rm -f /tmp/patch_mla.py /tmp/*.patch