Files
leleka/scripts/test-cuda-projection-family-driver.sh
Pavlo Ratushnyi bb8ff44667 Sealed PTX: scrub engine/strata from four PTX header comments and their sm_86 companions, re-pin (STRA-407)
bf16_f32_mmvf, iq3_s_q8_1, moe_group_iq3_s, moe_group_iq3_s_nc4 (sm_120 in src/, sm_86 in ptx-sm86/) change in // header comments only (proof: identical after comment
stripping, no .file/.loc directive or string carries the path). The sm_86 companions are re-derived with sm86_assets.retarget + ptxas -arch=sm_86 (== the edited files);
MANIFEST.json (sm120/sm86 sha256 and byte counts of the four, the -I flags of the one recompiled companion) and the five-part sm86_table rows (new keys, re-sorted, same 27/27/27/27/23
layout) follow; FORMER_TABLE_DIGEST is recomputed with the algorithm of its test (reproduces the old value on main). Rust pins that cover the changed bytes:
bf16_receipt_types.rs BF16_RECEIPT (.cu source_sha256 and bf16_f32_mmvf.ptx ptx_sha256; a Receipt, not a PtxPin, so patched token by token), the frozen-artifact hash of
iq3_s_q8_1.ptx in context_handle.rs and in scripts/test-cuda-projection-family-driver.sh. Instruction streams, entry names and pinned symbol names are untouched.
2026-11-23 22:37:24 +01:00

46 lines
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# New bounded common CPU gate; original bootstrap/Q5/Q6 gates remain unchanged.
set -euo pipefail
[[ $# == 2 && "$1" == --inside && -f /.dockerenv && "$(id -u)" == 65532 ]]
[[ "$(awk '/^Cap(Eff|Prm|Bnd):/{print $2}' /proc/self/status)" == $'0000000000000000\n0000000000000000\n0000000000000000' ]]
for device in /dev/nvidia* /dev/dri/*; do [[ ! -e "$device" ]]; done
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
[[ ! -e "$root/engine" && ! -e "$root/control-plane" ]]
! command -v nvcc >/dev/null
[[ "$2" == /tmp/* && ! -e "$2" ]]
work="$2"; mkdir -p "$work/family"
export CARGO_TARGET_DIR="$work/target"
cd "$root"
cc -std=c11 -Wall -Wextra -Werror -Wno-misleading-indentation -ffp-contract=off -fno-fast-math -shared -fPIC "$root/crates/cuda-driver/tests/projection_family_mock_cuda.c" -lm -o "$work/family/libcuda.so.1"
sha256sum "$work/family/libcuda.so.1"
echo '341abbd0113919d573241b1dc47886514ea7aa1d4d3f1a867024e7664b501a0a crates/cuda-driver/src/q8_0_q8_1.ptx' | sha256sum --check
echo '294f3ad5fdddf796941346c9144fc49d4cff5478a88daad6b8941fbd4bb240cb crates/cuda-driver/src/q4_k_q8_1.ptx' | sha256sum --check
echo 'ebfcabd456b8cf16608c529b906849e4391096322a88e5a665ac87657a91dde6 crates/cuda-driver/src/iq3_s_q8_1.ptx' | sha256sum --check
echo 'f9c10814f37b75babcaee1028b4a1375e530220f863ab3801beb8fcb5a19733f crates/cuda-driver/src/iq3_xxs_q8_1.ptx' | sha256sum --check
echo 'a31e653da8c222e1671cf25ed19017eeb0b3ef4d890c0142b181f3d5bcfcfb2c crates/cuda-driver/src/iq2_s_q8_1.ptx' | sha256sum --check
echo '189b02cee8186379fb7b0bd07a831e1fb2764d29a98a17fd2b516c5459f9d4ce crates/cuda-driver/src/iq4_nl_q8_1.ptx' | sha256sum --check
echo '2c853bade2bb62b67167b7cbe00324616c7287c60ab5fb8a41d2b5690197f1b4 crates/cuda-driver/src/iq4_xs_q8_1.ptx' | sha256sum --check
echo '8e81dbbaa76d8516476339c168f1d9c172341a78ccecda08714a13a5687e3b6e crates/cuda-driver/src/q2_0_q8_1.ptx' | sha256sum --check
cargo test --offline --locked -p leleka-cuda-driver --lib
cargo test --offline --locked -p leleka-cuda-driver --test projection_family_oracle
cargo test --offline --locked -p leleka-cuda-driver --features cuda-driver --lib --no-run --message-format=json > "$work/unit.jsonl"
unit="$(python3 - "$work/unit.jsonl" <<'PYS'
import json,sys
rows=[json.loads(l) for l in open(sys.argv[1])]
found=[r['executable'] for r in rows if r.get('reason')=='compiler-artifact' and r.get('profile',{}).get('test') and r.get('executable') and r['target']['kind']==['lib']]
assert len(found)==1
print(found[0])
PYS
)"
LD_LIBRARY_PATH="$work/family" MOCK_CUDA_VECTOR=1 MOCK_CUDA_TRACE="$work/public.trace" MOCK_CUDA_FAMILY_PTX="$root/crates/cuda-driver/src/q8_1_quantize.ptx" MOCK_CUDA_FAMILY_Q8_PTX="$root/crates/cuda-driver/src/q8_0_q8_1.ptx" MOCK_CUDA_FAMILY_Q4K_PTX="$root/crates/cuda-driver/src/q4_k_q8_1.ptx" MOCK_CUDA_FAMILY_IQ3S_PTX="$root/crates/cuda-driver/src/iq3_s_q8_1.ptx" MOCK_CUDA_FAMILY_IQ3XXS_PTX="$root/crates/cuda-driver/src/iq3_xxs_q8_1.ptx" MOCK_CUDA_FAMILY_IQ2S_PTX="$root/crates/cuda-driver/src/iq2_s_q8_1.ptx" MOCK_CUDA_FAMILY_IQ4NL_PTX="$root/crates/cuda-driver/src/iq4_nl_q8_1.ptx" MOCK_CUDA_FAMILY_IQ4XS_PTX="$root/crates/cuda-driver/src/iq4_xs_q8_1.ptx" MOCK_CUDA_FAMILY_Q2_PTX="$root/crates/cuda-driver/src/q2_0_q8_1.ptx" LELEKA_FAMILY_IQ3XXS_ENABLED=1 LELEKA_FAMILY_IQ3S_ENABLED=1 LELEKA_FAMILY_IQ2S_ENABLED=1 LELEKA_FAMILY_IQ4NL_ENABLED=1 LELEKA_FAMILY_IQ4XS_ENABLED=1 LELEKA_FAMILY_Q4K_ENABLED=1 LELEKA_FAMILY_Q8_ENABLED=1 LELEKA_FAMILY_Q2_ENABLED=1 LELEKA_CUDA_MOCK_HARNESS=1 LELEKA_FAMILY_ROOT="$work" LELEKA_FAMILY_UNIT_ELF="$unit" cargo test --offline --locked -p leleka-cuda-driver --features cuda-driver --test projection_family_mock -- --exact common_protocol_matrix --ignored --test-threads=1 --nocapture
cargo clippy --offline --locked -p leleka-cuda-driver --all-targets --all-features -- -D warnings
rlib="$(find "$work/target/debug/deps" -name 'libleleka_cuda_driver-*.rlib' -print -quit)"
[[ -n "$rlib" ]]
cat > "$work/reject.rs" <<'RS'
use leleka_cuda_driver::{Driver,ProjectionSpec,ProjectionKind,DenseFormat};
fn main(){let d=Driver::load().unwrap();let c=d.device(0).unwrap().create_context(4096).unwrap();let mut w=c.allocate(34).unwrap();let x=c.allocate(128).unwrap();c.project_q8_1(&w,&x,&mut w,ProjectionSpec{kind:ProjectionKind::Dense(DenseFormat::Q8_0),rows:1,columns:32}).unwrap();}
RS
if rustc --edition=2024 --extern "leleka_cuda_driver=$rlib" -L "dependency=$work/target/debug/deps" "$work/reject.rs" -o "$work/reject" 2> "$work/reject.log"; then echo 'Common output alias escaped' >&2; exit 1; fi
grep -q 'cannot borrow.*w.*as mutable because it is also borrowed as immutable' "$work/reject.log"
echo 'Common output alias compile refusal: PASS'