fetch-deps.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env bash
  2. # Fetch every vLLM build sub-dependency for the r27 image at the pins the
  3. # r27 tree itself declares (cmake/external_projects/*.cmake + CMakeLists.txt).
  4. #
  5. # No fallbacks: each clone fetches the pinned ref directly and fails the
  6. # build loudly on any mismatch. Before cloning, every pin printed below is
  7. # grep-verified against the cloned vLLM tree — if a pin has drifted from
  8. # what the tree expects, the mismatch aborts with the offending pin(s).
  9. #
  10. # Runs INSIDE the build container: /workspace/vllm must already contain the
  11. # gated r27 tree (see Dockerfile `vllm-clone` stage). Populates /deps2.
  12. set -euo pipefail
  13. WORK=${WORK:-/workspace/vllm}
  14. DEPS=${DEPS:-/deps2}
  15. git config --global protocol.version 0
  16. fetch() { # repo ref dst
  17. local repo="$1" ref="$2" dst="$3"
  18. echo "[deps] $dst @ $ref ($repo)"
  19. git init -q "$dst"
  20. git -C "$dst" fetch -q --depth 1 "$repo" "$ref"
  21. git -C "$dst" checkout -q FETCH_HEAD
  22. git -C "$dst" config --global --add safe.directory "$dst"
  23. }
  24. gate() { # file:pattern ... — every pin must appear verbatim in the tree
  25. local missing=0
  26. for g in "$@"; do
  27. local file="${g%%:*}" pattern="${g#*:}"
  28. local fp="$WORK/cmake/external_projects/$file"
  29. [ -f "$fp" ] || fp="$WORK/$file" # CMakeLists.txt lives at the root
  30. if ! grep -Fq "$pattern" "$fp"; then
  31. echo "GATE FAILED: pin '$pattern' not found in $file (tree/pin drift)" >&2
  32. missing=1
  33. fi
  34. done
  35. [ "$missing" = 0 ] || { echo "aborting: staged pins drifted from the tree" >&2; exit 1; }
  36. echo "[deps] all pins verified against the r27 tree"
  37. }
  38. # ---- 1. Verify our pins against the tree's own declarations ----
  39. gate CMakeLists.txt:nvidia/cutlass.git \
  40. CMakeLists.txt:v4.4.2 \
  41. deepgemm.cmake:deepseek-ai/DeepGEMM \
  42. deepgemm.cmake:8b1392b978f5a03c828dd1711090d7fb50958b8a \
  43. flashkda.cmake:3b225bf26bb8e218928a1fe14751cb48cf31d11b \
  44. flashmla.cmake:a8f794d1251cbfd88a5011445dd5582289c727e4 \
  45. fmha_sm100.cmake:087c161814d4d9c735b46c21212a09e5f8eb92fa \
  46. qutlass.cmake:e74319e3405ce6d71965732880f5dc1f52371f64 \
  47. tml_fa4.cmake:b206834606ed5b5f21f8eed6b0683f528ea9cf7d \
  48. vllm_flash_attn.cmake:f3e1a4f74c99145c0717709860bf765de1703779 \
  49. vllm_flash_attn.cmake:vllm-project/flash-attention \
  50. triton_kernels.cmake:triton-lang/triton \
  51. triton_kernels.cmake:v3.5.1
  52. mkdir -p "$DEPS"
  53. # ---- 2. Clone deps at the tree's pins ----
  54. fetch https://github.com/nvidia/cutlass.git v4.4.2 "$DEPS/cutlass"
  55. fetch https://github.com/vllm-project/flash-attention.git \
  56. f3e1a4f74c99145c0717709860bf765de1703779 "$DEPS/flash-attention"
  57. fetch https://github.com/vllm-project/MSA.git \
  58. 087c161814d4d9c735b46c21212a09e5f8eb92fa "$DEPS/MSA"
  59. fetch https://github.com/vllm-project/FlashMLA.git \
  60. a8f794d1251cbfd88a5011445dd5582289c727e4 "$DEPS/FlashMLA"
  61. fetch https://github.com/vllm-project/FlashKDA.git \
  62. 3b225bf26bb8e218928a1fe14751cb48cf31d11b "$DEPS/FlashKDA"
  63. fetch https://github.com/IST-DASLab/qutlass.git \
  64. e74319e3405ce6d71965732880f5dc1f52371f64 "$DEPS/qutlass"
  65. fetch https://github.com/vllm-project/tml-fa4.git \
  66. b206834606ed5b5f21f8eed6b0683f528ea9cf7d "$DEPS/tml-fa4"
  67. fetch https://github.com/triton-lang/triton.git v3.5.1 "$DEPS/triton"
  68. # ---- 3. Sub-module populations the tree's install steps require ----
  69. # Several deps vendor cutlass via a 160000 gitlink and their cmake install
  70. # steps require the tree to EXIST (r18 lesson: an empty stub dies at cmake
  71. # INSTALL — and r27's FlashMLA addendum died at compile). Generic rule: walk
  72. # every dep's tree recursively and populate each gitlink at its pinned SHA.
  73. # AMD-only trees (composable_kernel, aiter) are skipped explicitly — the
  74. # CUDA cmake path never references them. All gitlinks so far vendor
  75. # nvidia/cutlass; anything else aborts loudly, keeping the contract explicit.
  76. populate_gitlinks() {
  77. local d path sha
  78. for d in flash-attention MSA FlashMLA FlashKDA qutlass tml-fa4; do
  79. while IFS=$'\t' read -r path sha; do
  80. [ -n "${path:-}" ] || continue
  81. case "$path" in
  82. */composable_kernel|composable_kernel|*/aiter|aiter)
  83. echo "[deps] skip AMD-only gitlink $path (CUDA path unused)"; continue ;;
  84. esac
  85. case "$(basename "$path")" in
  86. cutlass) ;; # expected vendor
  87. *) echo "ABORT: unhandled gitlink '$path' in $d (populate explicitly)" >&2; exit 1 ;;
  88. esac
  89. # a gitlink path EXISTS in the worktree as an EMPTY dir (git's
  90. # clone behavior) — the gate is "did WE populate it", .git marker.
  91. # Skipping on plain -d reproduces the r18 empty-stub failure.
  92. if [ ! -e "$DEPS/$d/$path/.git" ]; then
  93. fetch https://github.com/nvidia/cutlass.git "$sha" "$DEPS/$d/$path"
  94. fi
  95. done < <(git -C "$DEPS/$d" ls-tree -r -t HEAD | awk '$1=="160000" {print $4"\t"$3}')
  96. done
  97. echo "[deps] gitlink populations verified"
  98. }
  99. populate_gitlinks
  100. # ---- 4. Triton into the layout the Dockerfile/build expects ----
  101. mv "$DEPS/triton/python/triton_kernels/triton_kernels" "$DEPS/triton_kernels"
  102. rm -rf "$DEPS/triton"
  103. # ---- 5. Manifest ----
  104. echo "[deps] staged:"
  105. for d in cutlass flash-attention MSA FlashMLA FlashKDA qutlass tml-fa4 triton_kernels; do
  106. printf ' %-16s %s\n' "$d" "$(git -C "$DEPS/$d" rev-parse HEAD 2>/dev/null | cut -c1-12)"
  107. done