@@ -186,15 +186,40 @@ RUN --mount=type=cache,target=/opt/uv/cache \
186186
187187COPY . .
188188
189- # Install FastVideo Unified Kernel exactly once. build.sh initializes only its
190- # CUTLASS/ThunderKittens submodules, then compiles for TORCH_CUDA_ARCH_LIST
191- # (default Hopper sm_90a) without requiring a live GPU.
189+ # Build immutable FastVideo kernel wheels for the published image. The requested
190+ # architecture remains installed for normal image users; amd64 images also carry
191+ # an SM89 artifact so the predominant L40S Modal lanes can reuse it exactly.
192+ ARG FASTVIDEO_KERNEL_PREBUILT_DIR=/opt/fastvideo-kernel-prebuilt
192193RUN --mount=type=cache,target=/opt/uv/cache \
193194 source $HOME/.local/bin/env && \
194195 source /opt/venv/bin/activate && \
196+ default_arch="${TORCH_CUDA_ARCH_LIST}" && \
197+ default_wheel_dir="${FASTVIDEO_KERNEL_PREBUILT_DIR}/${default_arch}" && \
198+ export TORCH_CUDA_ARCH_LIST="${default_arch}" && \
195199 cd fastvideo-kernel && \
196- CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL} \
197- TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST} ./build.sh
200+ CMAKE_ARGS= CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL} \
201+ ./build.sh --wheel-dir "${default_wheel_dir}" && \
202+ cd /FastVideo && \
203+ CMAKE_ARGS= python fastvideo/tests/modal/kernel_build_cache.py write-build-info \
204+ --wheel-dir "${default_wheel_dir}" \
205+ --output "${default_wheel_dir}/metadata.json" && \
206+ if [[ "${TARGETARCH:-amd64}" == "amd64" && "${default_arch}" != "8.9" ]]; then \
207+ export TORCH_CUDA_ARCH_LIST=8.9 && \
208+ l40s_wheel_dir="${FASTVIDEO_KERNEL_PREBUILT_DIR}/8.9" && \
209+ cd /FastVideo/fastvideo-kernel && \
210+ CMAKE_ARGS= CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL} \
211+ ./build.sh --wheel-dir "${l40s_wheel_dir}" && \
212+ cd /FastVideo && \
213+ CMAKE_ARGS= python fastvideo/tests/modal/kernel_build_cache.py write-build-info \
214+ --wheel-dir "${l40s_wheel_dir}" \
215+ --output "${l40s_wheel_dir}/metadata.json" ; \
216+ fi && \
217+ export TORCH_CUDA_ARCH_LIST="${default_arch}" && \
218+ default_wheel="$(find " ${default_wheel_dir}" -maxdepth 1 -type f \
219+ \( -name 'fastvideo_kernel-*.whl' -o -name 'fastvideo-kernel-*.whl' \) \
220+ | sort | tail -n 1)" && \
221+ uv pip install "${default_wheel}" \
222+ --reinstall-package fastvideo-kernel --no-deps
198223
199224# Install FastVideo itself (editable) now that the source is present, and set up
200225# shell configuration. Dependencies and the local kernel are already installed,
0 commit comments