46 lines
3.0 KiB
Python
46 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Regenerates crates/cuda-driver/seal-plans/cuda-seal-plan-additions-experimental.json (sha256 + bytes of the six experimental .cu assets
|
|
and their Rust consumers). Run from the repository root after any edit to those files:
|
|
python3 crates/experimental-ref/oracle/gen_seal_additions.py
|
|
Flags follow engine/strata/CMakeLists.txt: none of the six Original TUs is in the --use_fast_math list and the
|
|
target sets only CUDA_STANDARD 17, so the build is precise, default -fmad."""
|
|
import hashlib, json
|
|
|
|
def sha(path):
|
|
data = open(path, "rb").read()
|
|
return {"sha256": hashlib.sha256(data).hexdigest(), "bytes": len(data)}
|
|
|
|
PROGRAMS = [
|
|
("kv_q4", "kv_q4.cu", "FWHT-256 + Q4_0 append (step/batched) + gather; Original kv_q4.cu precise (default flags, not in the fast-math list); K8V4's Q4_0 V half and rotated INT8's FWHT"),
|
|
("kv_q8", "kv_q8.cu", "INT8 append (K+V, K8V4 K half, V-only) + gather; Original kv_q8.cu precise"),
|
|
("kv_stream", "kv_stream.cu", "CLOCK residency resolver, block copy, ring table, u4 copy; Original kv_stream.cu precise; integer only"),
|
|
("keyless", "keyless.cu", "per-head query routing (fmaf-ordered 256x256); Original keyless.cu precise"),
|
|
("qsa_attn", "qsa_decode_attn.cu", "experimental attention modes 2/3/4 + merge; Original qsa_decode_attn.cu precise (expf/exp2f exact, not in the fast-math list)"),
|
|
("cvec", "cvec.cu", "control-vector apply; Original cvec.cu default flags (its own __expf in sigmoidf_ is explicit in the source)"),
|
|
]
|
|
src = "crates/cuda-driver/src/"
|
|
assets = []
|
|
for i, (name, original, policy) in enumerate(PROGRAMS):
|
|
assets.append({
|
|
"cu": f"{src}experimental_{name}.cu",
|
|
"cu_pin": sha(f"{src}experimental_{name}.cu"),
|
|
"ptx": f"{src}experimental_{name}.ptx",
|
|
"flags": ["-ptx", "-O3", "-arch=sm_120", "-std=c++17"],
|
|
"policy": "EXPERIMENTAL, off by default (OptIn). " + policy,
|
|
"direct_original_headers": [],
|
|
"original": f"engine/strata/src/kernels/cuda/{original}",
|
|
"rust_consumers": {"experimental.rs": sha(src + "experimental.rs"), "experimental_gpu.rs": sha(src + "experimental_gpu.rs")},
|
|
"rust_fields_to_fill": {"experimental.rs": [f"PINS[{i}].source_sha256", f"PINS[{i}].ptx_sha256"]},
|
|
"encoding": "concat_include_str",
|
|
"seal_sha256": None,
|
|
"seal_length": None,
|
|
})
|
|
doc = {
|
|
"schema": 1,
|
|
"note": "Additions for the experimental Strata modes. None of these six .cu files has been compiled; PINS in experimental.rs are all zero and admit_ptx refuses every asset until Root builds the PTX and freezes the digests. Flags follow engine/strata/CMakeLists.txt: none of the six Original TUs is in the --use_fast_math list (native_* only) and the strata_kernels target adds no other CUDA flag besides CUDA_STANDARD 17, so the build is precise (no --use_fast_math) with default -fmad contraction.",
|
|
"assets": assets,
|
|
}
|
|
with open("crates/cuda-driver/seal-plans/cuda-seal-plan-additions-experimental.json", "w") as f:
|
|
json.dump(doc, f, indent=2)
|
|
f.write("\n")
|