Merge claude/experimental-resync: re-port kv_q4/kv_q8/kv_stream/qsa_attn to the 41cf05a0 Original, literal_port 8/8; the four programs refuse to open until their PTX is resealed on the server

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-03 02:28:33 +01:00
co-authored by Claude Sonnet 5.5
12 changed files with 635 additions and 86 deletions
+3 -4
View File
@@ -57,10 +57,9 @@ fast_path() {
debt cargo fmt -p leleka-model-format -p leleka-experimental-ref --check
cargo clippy --manifest-path "${repo_root}/Cargo.toml" --locked -p leleka-experimental-ref --all-targets --no-deps -- -D warnings
debt cargo clippy --manifest-path "${repo_root}/Cargo.toml" --locked -p leleka-model-format --all-targets --no-deps -- -D warnings
# literal_port is the drift guard between engine/strata/src/kernels/cuda and the checked-in experimental ports; it has failed since
# the 2026-10-25 upstream sync moved the kernels (docs/windows.md, docs/ci-audit.md): reported as debt until the ports are re-synced.
cargo test --manifest-path "${repo_root}/Cargo.toml" --locked -p leleka-experimental-ref -p leleka-model-format -- --skip _bodies_are_literal
debt cargo test --manifest-path "${repo_root}/Cargo.toml" --locked -p leleka-experimental-ref --test literal_port
# leleka-experimental-ref includes tests/literal_port.rs, the drift guard between engine/strata/src/kernels/cuda and the checked-in
# experimental ports (re-synced to the upstream 41cf05a0 kernels on 2026-11-03, docs/experiments/2026-10-14-experimental-modes-port.md).
cargo test --manifest-path "${repo_root}/Cargo.toml" --locked -p leleka-experimental-ref -p leleka-model-format
}
linux_typecheck() {
+26 -3
View File
@@ -10,10 +10,15 @@ the plan names (`rust_fields_to_fill`) with the SHA-256 of the .cu bytes and of
reseal_own.py --ptx-dir DIR ASSET_ID [ASSET_ID ...] # dry run: prints what would change
reseal_own.py --ptx-dir DIR --write ASSET_ID [ASSET_ID ...]
`--plan docs/cuda-seal-plan-additions-experimental.json` names another plan file (default: extra-seal-plan.json). The six
experimental programs (`experimental_{kv_q4,kv_q8,kv_stream,keyless,qsa_attn,cvec}`, group `experimental`) live there; when the
plan entry has `seal_sha256` / `seal_length` slots they are refreshed too (text-level, formatting untouched).
The sm_86 companions and the generated table are rebuilt afterwards with `scripts/gpu-bringup/sm86_assets.py build` (docs/sm86-assets.md).
"""
import argparse
import json
import re
import sys
from pathlib import Path
@@ -26,10 +31,12 @@ def main():
ap = argparse.ArgumentParser()
ap.add_argument("--ptx-dir", required=True, type=Path)
ap.add_argument("--write", action="store_true")
ap.add_argument("--plan", default="scripts/gpu-bringup/extra-seal-plan.json", help="repo-relative seal plan holding the assets (default: extra-seal-plan.json)")
ap.add_argument("ids", nargs="+")
args = ap.parse_args()
root = L.REPO
plan = json.loads((root / "scripts/gpu-bringup/extra-seal-plan.json").read_text())
plan_path = root / args.plan
plan = json.loads(plan_path.read_text(encoding="utf-8"))
by_id = {Path(a["cu"]).stem: a for a in plan["assets"]}
manifest = json.loads((args.ptx_dir / "build-manifest.json").read_text())
for asset_id in args.ids:
@@ -44,13 +51,29 @@ def main():
v = R.PinValues(len(raw), L.sha256_digest(raw), L.sha256_digest(cu))
for consumer, specs in a["rust_fields_to_fill"].items():
path = next(root.glob(f"crates/*/src/{consumer}"))
text = path.read_text(encoding="utf-8", newline="")
with open(path, encoding="utf-8", newline="") as fh: # (Path.read_text has no newline= before Python 3.13)
text = fh.read()
new = text
for spec in specs:
new = R.apply_field(new, spec, v)
print(f"{asset_id}: {path.relative_to(root)} {'patched' if new != text else 'unchanged'} (ptx {len(raw)} B sha {v.ptx_sha256.hex()[:16]}, cu sha {v.source_sha256.hex()[:16]})")
if args.write:
path.write_text(new, encoding="utf-8", newline="")
with open(path, "w", encoding="utf-8", newline="") as fh:
fh.write(new)
if "seal_sha256" in a and "seal_length" in a:
with open(plan_path, encoding="utf-8", newline="") as fh:
text = fh.read()
pat = re.compile(r'("ptx"\s*:\s*"' + re.escape(a["ptx"]) + r'"(?:(?!"cu"\s*:).)*?"seal_sha256"\s*:\s*)(null|"[0-9a-f]{64}")'
r'(\s*,\s*"seal_length"\s*:\s*)(null|\d+)', re.S)
ms = list(pat.finditer(text))
if len(ms) != 1:
sys.exit(f"{args.plan}: expected one seal_sha256/seal_length slot for {a['ptx']}, found {len(ms)}")
m = ms[0]
patched = text[: m.start(2)] + f'"{L.sha256_hex(raw)}"' + m.group(3) + str(len(raw)) + text[m.end(4):]
print(f"{asset_id}: {args.plan} seal_sha256/seal_length {'patched' if patched != text else 'unchanged'}")
if args.write:
with open(plan_path, "w", encoding="utf-8", newline="") as fh:
fh.write(patched)
if args.write:
(root / a["ptx"]).write_bytes(raw)
print(f"{asset_id}: wrote {a['ptx']}")