From 57a91567b450ea7dcfd97e7c5ad74f8c4fa24c86 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Sun, 29 Mar 2026 21:01:03 +0200 Subject: [PATCH] fix(ci): PTX cache invalidation includes build.rs + all kernel dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script only hashed .cu/.cuh in crates/ml/. Missed: - build.rs changes (removing --use_fast_math → stale cubins cached) - crates/ml-dqn/src/*.cu (replay buffer, seg tree kernels) - crates/ml-core/src/cuda_autograd/*.cu - crates/ml-ppo/src/cuda_nn/*.cu Now hashes ALL kernel sources + ALL build.rs files. Any change to nvcc flags or kernel source invalidates the entire PTX cache. Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/ptx-cache-invalidate.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/ptx-cache-invalidate.sh b/scripts/ptx-cache-invalidate.sh index 2192cd526..c32552964 100755 --- a/scripts/ptx-cache-invalidate.sh +++ b/scripts/ptx-cache-invalidate.sh @@ -16,13 +16,17 @@ set -euo pipefail -KERNEL_DIR="crates/ml/src/cuda_pipeline" +KERNEL_DIRS="crates/ml/src/cuda_pipeline crates/ml-dqn/src crates/ml-core/src/cuda_autograd crates/ml-ppo/src/cuda_nn" CACHE_DIR="${1:-${CARGO_TARGET_DIR:+${CARGO_TARGET_DIR}/.ptx_cache}}" CACHE_DIR="${CACHE_DIR:-/tmp/.ptx_cache}" -# Compute content hash of all CUDA source files -HASH=$(find "$KERNEL_DIR" -type f \( -name '*.cu' -o -name '*.cuh' \) \ - -exec sha256sum {} + 2>/dev/null | sort | sha256sum | cut -d' ' -f1) +# Compute content hash of CUDA sources AND build.rs (nvcc flags). +# build.rs changes (e.g. removing --use_fast_math) produce different cubins +# even when .cu source is unchanged — must invalidate cache. +HASH=$( { + find $KERNEL_DIRS -type f \( -name '*.cu' -o -name '*.cuh' \) -exec sha256sum {} + 2>/dev/null + find crates/ml crates/ml-dqn crates/ml-core crates/ml-ppo -maxdepth 1 -name 'build.rs' -exec sha256sum {} + 2>/dev/null +} | sort | sha256sum | cut -d' ' -f1) STAMP_FILE="${CACHE_DIR}/.kernel_hash"