Sealed sources: scrub engine/strata from .cu/.cuh comments, move the source pins that cover them (STRA-407)

21 .cu/.cuh files change in comments only (proof: identical after comment stripping; where the file compiles without the removed headers, nvcc 13.2.86 gives the same PTX
modulo the content-hashed symbol names, which nvcc derives from the source text and which the committed PTX keeps as sealed). Every pin that covered such a file moves:
cu_pin sha256+bytes in the seal plans of mmq_original_prefill_misc, s_gemv_legacy, experimental_keyless, experimental_cvec (no repo tool writes cu_pin; computed with sha256),
experimental.rs PINS[3] and PINS[5] and closed_kernels.rs PINS[1] .source_sha256 (rustpins.apply_field, then rustfmt as seal_pins.py does). The four experimental sources
that were already pending a reseal stay pending. Seal-plan prose and -I flags follow the same wording as the gpu-bringup data.
This commit is contained in:
Pavlo Ratushnyi
2026-11-23 22:37:17 +01:00
parent da8c974f68
commit 5e963eada5
26 changed files with 69 additions and 69 deletions
@@ -1,5 +1,5 @@
// Original Strata fetch_blobs_kernel; arithmetic-free uint4 copy.
// engine/strata/src/kernels/cuda/verify_kernels.cu, pinned upstream provenance.
// Strata 41cf05a0, src/kernels/cuda/verify_kernels.cu, pinned upstream provenance.
#include <cuda_runtime.h>
#include <cstdint>
extern "C" __global__ void fetch_blobs_kernel(const unsigned long long* __restrict__ src, const int32_t* __restrict__ n,
@@ -1,6 +1,6 @@
{
"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.",
"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 Strata 41cf05a0, 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": [
{
"cu": "crates/cuda-driver/src/experimental_kv_q4.cu",
@@ -17,7 +17,7 @@
],
"policy": "EXPERIMENTAL, off by default (OptIn). 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",
"direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/kv_q4.cu",
"original": "Strata 41cf05a0, src/kernels/cuda/kv_q4.cu",
"rust_consumers": {
"experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
@@ -53,7 +53,7 @@
],
"policy": "EXPERIMENTAL, off by default (OptIn). INT8 append (K+V, K8V4 K half, V-only) + gather; Original kv_q8.cu precise",
"direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/kv_q8.cu",
"original": "Strata 41cf05a0, src/kernels/cuda/kv_q8.cu",
"rust_consumers": {
"experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
@@ -89,7 +89,7 @@
],
"policy": "EXPERIMENTAL, off by default (OptIn). CLOCK residency resolver, block copy, ring table, u4 copy; Original kv_stream.cu precise; integer only",
"direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/kv_stream.cu",
"original": "Strata 41cf05a0, src/kernels/cuda/kv_stream.cu",
"rust_consumers": {
"experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
@@ -113,8 +113,8 @@
{
"cu": "crates/cuda-driver/src/experimental_keyless.cu",
"cu_pin": {
"sha256": "77c50e5baff842e31f0d71624a5706f46ed74a56cdfc5e4211086d2ef08671c5",
"bytes": 1987
"sha256": "44304e967dc68e92233f6b78c25e6d80475ea4c0e94262cf928f7405cd553733",
"bytes": 1990
},
"ptx": "crates/cuda-driver/src/experimental_keyless.ptx",
"flags": [
@@ -125,7 +125,7 @@
],
"policy": "EXPERIMENTAL, off by default (OptIn). per-head query routing (fmaf-ordered 256x256); Original keyless.cu precise",
"direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/keyless.cu",
"original": "Strata 41cf05a0, src/kernels/cuda/keyless.cu",
"rust_consumers": {
"experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
@@ -161,7 +161,7 @@
],
"policy": "EXPERIMENTAL, off by default (OptIn). experimental attention modes 2/3/4 + merge; Original qsa_decode_attn.cu precise (expf/exp2f exact, not in the fast-math list)",
"direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/qsa_decode_attn.cu",
"original": "Strata 41cf05a0, src/kernels/cuda/qsa_decode_attn.cu",
"rust_consumers": {
"experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
@@ -185,8 +185,8 @@
{
"cu": "crates/cuda-driver/src/experimental_cvec.cu",
"cu_pin": {
"sha256": "d4fe221b11569db73247644bb79118b34d040b49c14897e0bac158dcd4ca356e",
"bytes": 4783
"sha256": "89038128664ea4688e20de69eb32f55dd17c3a51bb1d67ec7774cba97ec70686",
"bytes": 4786
},
"ptx": "crates/cuda-driver/src/experimental_cvec.ptx",
"flags": [
@@ -197,7 +197,7 @@
],
"policy": "EXPERIMENTAL, off by default (OptIn). control-vector apply; Original cvec.cu default flags (its own __expf in sigmoidf_ is explicit in the source)",
"direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/cvec.cu",
"original": "Strata 41cf05a0, src/kernels/cuda/cvec.cu",
"rust_consumers": {
"experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
@@ -1,7 +1,7 @@
{
"schema": 1,
"purpose": "Assets Root must seal for the literal Verifier window recorder (OriginalVerifyWindowOps). Everything not listed under new_sources is an already sealed asset that the window producers merely bind (SHA-256 pinned in the AssetSpec constants of crates/cuda-driver/src/original_verify_window_*.rs).",
"toolkit": "deploy/cuda-toolkit.lock.json (CUDA 13.0.88), built through scripts/build-original-verify-ptx.sh",
"toolkit": "deploy/cuda-toolkit.lock.json (CUDA 13.0.88), built with the precise nvcc flags (--fmad=true --ftz=false)",
"new_sources": [
{
"source": "crates/cuda-driver/src/original_verify_window_moe_experts.cu",
@@ -13,8 +13,8 @@
"-arch=sm_120",
"--fmad=true",
"--ftz=false",
"-Iengine/strata/include",
"-Iengine/strata/third_party/ggml",
"-Istrata-41cf05a0/include",
"-Istrata-41cf05a0/third_party/ggml",
"-Icrates/cuda-driver/src/third_party/llamacpp/ggml-cuda",
"-Icrates/cuda-driver/src/third_party/llamacpp/ggml-include",
"-Icrates/cuda-driver/src/third_party/llamacpp/ggml-src"
@@ -37,7 +37,7 @@
"window_moe_down_7",
"window_moe_down_8"
],
"derived_from": "engine/strata/src/kernels/cuda/iq_kernels.cu (native_gu_kernel, native_gu_multi_kernel, native_down_kernel, native_down_multi_kernel via native_expert_grouped / launch_gu / launch_down; textually includes crates/cuda-driver/src/mtp_original_full_head_iq.cu, the sealed copy of iq_kernels.cu; engine/strata/CMakeLists.txt gives iq_kernels.cu no per-source COMPILE_OPTIONS)",
"derived_from": "Strata 41cf05a0, src/kernels/cuda/iq_kernels.cu (native_gu_kernel, native_gu_multi_kernel, native_down_kernel, native_down_multi_kernel via native_expert_grouped / launch_gu / launch_down; textually includes crates/cuda-driver/src/mtp_original_full_head_iq.cu, the sealed copy of iq_kernels.cu; Strata 41cf05a0, CMakeLists.txt gives iq_kernels.cu no per-source COMPILE_OPTIONS)",
"notes": "NEW source: no sealed PTX instantiates the grouped gate/up and down templates for the target's formats. The rest of native_expert_grouped (swiglu_entries_kernel, quantize_q8_1_kernel) is sealed in mtp_original_full_head_iq.ptx under mangled names. The PTX will also carry the unused head_* / dequant entries of the included file. Update EXPERTS.sha in original_verify_window_moe.rs after sealing; the build script's required-exports check should list the exports above.",
"install": "Compile, append exactly ONE terminal NUL byte (like the other sealed MTP assets), write over the placeholder .ptx, then replace the all-zero `sha` of the matching AssetSpec by sha256 of the bytes BEFORE the NUL."
},
@@ -51,8 +51,8 @@
"-arch=sm_120",
"--fmad=true",
"--use_fast_math",
"-Iengine/strata/include",
"-Iengine/strata/third_party/ggml",
"-Istrata-41cf05a0/include",
"-Istrata-41cf05a0/third_party/ggml",
"-Icrates/cuda-driver/src/third_party/llamacpp/ggml-cuda",
"-Icrates/cuda-driver/src/third_party/llamacpp/ggml-include",
"-Icrates/cuda-driver/src/third_party/llamacpp/ggml-src"
@@ -60,8 +60,8 @@
"exports": [
"verify_window_qsa_gate"
],
"derived_from": "engine/strata/src/kernels/cuda/native_qsa.cu (kernel `gate`; CMakeLists.txt compiles native_qsa.cu with --use_fast_math)",
"nvcc_note": "--use_fast_math (as engine/strata/CMakeLists.txt compiles native_qsa.cu) implies --ftz=true --prec-div=false --prec-sqrt=false --fmad=true; --ftz=false is deliberately NOT passed.",
"derived_from": "Strata 41cf05a0, src/kernels/cuda/native_qsa.cu (kernel `gate`; CMakeLists.txt compiles native_qsa.cu with --use_fast_math)",
"nvcc_note": "--use_fast_math (as Strata 41cf05a0, CMakeLists.txt compiles native_qsa.cu) implies --ftz=true --prec-div=false --prec-sqrt=false --fmad=true; --ftz=false is deliberately NOT passed.",
"install": "Compile, append exactly ONE terminal NUL byte (like the other sealed MTP assets), write over the placeholder .ptx, then replace the all-zero `sha` of the matching AssetSpec by sha256 of the bytes BEFORE the NUL."
}
],
@@ -160,7 +160,7 @@
"native_qsa_indexer",
"native_qsa_score"
],
"note": "engine/strata/CMakeLists.txt compiles these Original sources with --use_fast_math. The sealed Rust copies below were built with the precise flags of scripts/build-original-verify-ptx.sh (--fmad=true --ftz=false). Some copies reproduce the fast-math operations with explicit intrinsics in the .cu (e.g. mtp_original_full_shared.cu: __fdividef/__expf); the others are a numerics risk for bit-exact parity with the Original window until a per-kernel golden comparison on the GPU (or a re-seal with --use_fast_math) proves otherwise.",
"note": "Strata 41cf05a0, CMakeLists.txt compiles these Original sources with --use_fast_math. The sealed Rust copies below were built with the precise flags (--fmad=true --ftz=false). Some copies reproduce the fast-math operations with explicit intrinsics in the .cu (e.g. mtp_original_full_shared.cu: __fdividef/__expf); the others are a numerics risk for bit-exact parity with the Original window until a per-kernel golden comparison on the GPU (or a re-seal with --use_fast_math) proves otherwise.",
"candidate_resealed_assets": [
{
"ptx": "mtp_original_full_head_native.ptx / mtp_original_tail.ptx / mtp_original_full_checks.ptx",
@@ -204,7 +204,7 @@
}
],
"audit": {
"method": "For each Original source in the fast-math list that the window launches, the fast-math-sensitive operations (/ , expf, sqrtf, powf, sinf, cosf, logf) were listed from engine/strata/src/kernels/cuda/*.cu and compared with the instruction mix of the sealed PTX. A precise nvcc compile emits div.rn/rcp.rn/sqrt.rn and the multi-instruction expf sequence (fma.rn + ex2.approx.ftz + mul); --use_fast_math emits div.full, rcp.approx.ftz, sqrt.approx.ftz, ex2.approx.ftz(x*log2e), sin/cos.approx.ftz and .ftz on the arithmetic. Only qsa_decode_postops.ptx carries .ftz on its arithmetic.",
"method": "For each Original source in the fast-math list that the window launches, the fast-math-sensitive operations (/ , expf, sqrtf, powf, sinf, cosf, logf) were listed from Strata 41cf05a0, src/kernels/cuda/*.cu and compared with the instruction mix of the sealed PTX. A precise nvcc compile emits div.rn/rcp.rn/sqrt.rn and the multi-instruction expf sequence (fma.rn + ex2.approx.ftz + mul); --use_fast_math emits div.full, rcp.approx.ftz, sqrt.approx.ftz, ex2.approx.ftz(x*log2e), sin/cos.approx.ftz and .ftz on the arithmetic. Only qsa_decode_postops.ptx carries .ftz on its arithmetic.",
"sealed_precise_but_original_fast_math": [
{
"ptx": "mtp_original_full_head_native.ptx",
@@ -257,7 +257,7 @@
"original_verify.ptx, mtp_original_full_fused_gr.ptx, mtp_original_kv.ptx, qsa_prompt_select.ptx, qsa_prompt_resolver.ptx, mtp_original_full_element.ptx, mtp_original_full_s2.ptx, mtp_original_full_head_iq.ptx, mtp_original_full_router_legacy.ptx (all precise in the Original)"
],
"not_in_verify_window": "native_flash_attn.cu and native_qsa_score.cu are launched only by the single-token layer.cpp path, never by verify.cpp (qsa_decode_attn_batch / qsa_block_scores are precise)",
"action": "Re-seal the six assets above from their existing .cu with --use_fast_math (scripts/build-original-verify-ptx.sh compiles every source with the precise flags) and update their SHA pins; none of those sources contains hand-written intrinsics that a fast-math build would double-apply. The same assets back the MTP path, so the MTP golden comparisons must be redone after the re-seal."
"action": "Re-seal the six assets above from their existing .cu with --use_fast_math (every source was sealed with the precise flags) and update their SHA pins; none of those sources contains hand-written intrinsics that a fast-math build would double-apply. The same assets back the MTP path, so the MTP golden comparisons must be redone after the re-seal."
},
"not_candidates_original_is_precise": [
{
@@ -1,6 +1,6 @@
{
"schema": 1,
"note": "Additions to CUDA-SEAL-PLAN.json (schema 1, see stra169 plan) for the .cu assets added on claude/port-forward-leaves. Same fields; seal_sha256/seal_length are filled by the sealing session after nvcc. None of these needs -I/work/include (they include only cuda_fp16.h/cuda_runtime.h/libc headers). Verify each compiled entry list with `cuobjdump -sass`/`grep .entry` against `entries` before pinning. Flags follow engine/strata/CMakeLists.txt: --use_fast_math only for files in the native_* fast-math list.",
"note": "Additions to CUDA-SEAL-PLAN.json (schema 1, see stra169 plan) for the .cu assets added on claude/port-forward-leaves. Same fields; seal_sha256/seal_length are filled by the sealing session after nvcc. None of these needs -I/work/include (they include only cuda_fp16.h/cuda_runtime.h/libc headers). Verify each compiled entry list with `cuobjdump -sass`/`grep .entry` against `entries` before pinning. Flags follow Strata 41cf05a0, CMakeLists.txt: --use_fast_math only for files in the native_* fast-math list.",
"assets": [
{
"cu": "crates/cuda-driver/src/qsa_prompt_attention_variants.cu",
@@ -81,8 +81,8 @@
{
"cu": "crates/cuda-driver/src/mmq_original_prefill_misc.cu",
"cu_pin": {
"sha256": "da4cc72e19ca1ad694f4be807d6c0c1337ecfd8ca553fe31dd4c5185ed24cf4a",
"bytes": 3072
"sha256": "c5b2242dd01a48168052e4dd42ed5ab37bf44bd1bcc47a9bccb8f4ab7460faad",
"bytes": 3075
},
"ptx": "crates/cuda-driver/src/mmq_original_prefill_misc.ptx",
"flags": [
@@ -154,8 +154,8 @@
{
"cu": "crates/cuda-driver/src/s_gemv_legacy.cu",
"cu_pin": {
"sha256": "0922bb96ca3b2f1110509adab242cf76fa1f910cde859d1e4e4150c607b51952",
"bytes": 51423
"sha256": "0476de35304abd5149fc3b123e2a81855d79b37d36e0f4022433732fe94090ca",
"bytes": 51401
},
"ptx": "crates/cuda-driver/src/s_gemv_legacy.ptx",
"flags": [
@@ -211,7 +211,7 @@
}
],
"flags_policy_audit": {
"audited": "2026-10-14 with scripts/cuda-stubs/literal_diff.py (SOURCES=1) over every crates/cuda-driver/src/*.cu, against engine/strata/CMakeLists.txt",
"audited": "2026-10-14 with a literal-diff check (SOURCES=1) over every crates/cuda-driver/src/*.cu, against Strata 41cf05a0, CMakeLists.txt",
"cmake_policy": {
"per_source_use_fast_math": [
"native_mmvq",
@@ -229,7 +229,7 @@
"native_qsa_indexer",
"native_qsa_score"
],
"cmake_lines": "engine/strata/CMakeLists.txt:340-352 (strata_kernels), :965 (strata_mmq)",
"cmake_lines": "Strata 41cf05a0, CMakeLists.txt:340-352 (strata_kernels), :965 (strata_mmq)",
"strata_mmq_extended_lambda_use_fast_math": [
"src/prefill/moe_mmq.cu",
"src/prefill/ggml_cuda_host.cu",
@@ -320,6 +320,6 @@
"mtp_original_full_fused_gr (fused_gr)",
"mtp_original_full_s2 / mtp_original_full_shared / mtp_original_full_verify / mtp_original_full_element / mtp_original_full_gr_write / mtp_original_full_head_iq / mtp_original_full_head_sampler / mtp_original_full_coupled / mtp_original_full_quant80"
],
"stale_toolkit_comments": "kar_decode_levels.cu, experimental_*.cu, mmq_original_group_*.cu, mmq_original_formats*.cu say nvcc 12.8.93; deploy/cuda-toolkit.lock.json and scripts/build-original-verify-ptx.sh pin 13.0.88"
"stale_toolkit_comments": "kar_decode_levels.cu, experimental_*.cu, mmq_original_group_*.cu, mmq_original_formats*.cu say nvcc 12.8.93; deploy/cuda-toolkit.lock.json pins 13.0.88"
}
}
+2 -2
View File
@@ -54,8 +54,8 @@ pub const PINS: [PtxPin; 3] = [
},
PtxPin {
source_sha256: [
9, 34, 187, 150, 202, 59, 47, 17, 16, 80, 154, 218, 178, 66, 207, 118, 250, 31, 145, 12, 222, 133, 157, 30,
78, 65, 80, 198, 7, 181, 25, 82,
4, 118, 222, 53, 48, 74, 189, 81, 73, 252, 59, 18, 62, 42, 129, 133, 93, 121, 179, 125, 54, 224, 244, 2,
36, 51, 115, 47, 233, 64, 144, 202,
],
ptx_sha256: [
58, 180, 209, 42, 94, 151, 196, 226, 244, 96, 44, 108, 135, 35, 114, 197, 192, 104, 93, 140, 241, 162, 2,
+4 -4
View File
@@ -136,8 +136,8 @@ pub const PINS: [PtxPin; 6] = [
},
PtxPin {
source_sha256: [
119, 197, 14, 91, 175, 248, 66, 227, 31, 13, 113, 98, 74, 87, 6, 244, 110, 215, 74, 86, 205, 252, 94, 66,
17, 8, 109, 46, 240, 134, 113, 197,
68, 48, 78, 150, 125, 198, 142, 146, 35, 63, 107, 120, 194, 94, 109, 128, 71, 94, 164, 192, 233, 66, 98,
207, 146, 143, 116, 5, 205, 85, 55, 51,
],
ptx_sha256: [
26, 184, 184, 21, 110, 140, 130, 65, 49, 192, 12, 236, 218, 23, 127, 229, 125, 116, 178, 134, 160, 43, 126,
@@ -156,8 +156,8 @@ pub const PINS: [PtxPin; 6] = [
},
PtxPin {
source_sha256: [
212, 254, 34, 27, 17, 86, 157, 183, 50, 71, 100, 75, 183, 145, 24, 179, 77, 4, 11, 73, 193, 72, 151, 224,
186, 193, 88, 220, 212, 202, 53, 110,
137, 3, 129, 40, 102, 78, 164, 104, 142, 32, 222, 105, 235, 50, 245, 93, 209, 124, 58, 81, 187, 29, 103,
236, 119, 116, 203, 169, 126, 199, 6, 134,
],
ptx_sha256: [
25, 58, 221, 92, 180, 72, 245, 225, 147, 242, 15, 242, 72, 202, 68, 89, 171, 185, 98, 180, 114, 102, 60, 0,
+1 -1
View File
@@ -6,7 +6,7 @@
// an explicit ExperimentalOptIn (experimental.rs). With the flag off and no pending write the kernel is a no-op;
// with a pending write it applies the fused hyper-connection read's own arithmetic.
//
// LITERAL PORT of engine/strata/src/kernels/cuda/cvec.cu: `cvec_kernel`'s BODY and `sigmoidf_` are
// LITERAL PORT of Strata 41cf05a0, src/kernels/cuda/cvec.cu: `cvec_kernel`'s BODY and `sigmoidf_` are
// byte-identical to the Original's (experimental_cvec.rs::literal_bodies_match_the_original). Edits:
// `__global__ cvec_kernel` became the `__device__ cvec_kernel_body` function called by the `extern "C" __global__`
// entry; the host tables (g_dev, cvec_upload, cvec_apply) are Rust. A null `bo`/`inj` is a 64-bit zero argument.
@@ -5,7 +5,7 @@
// model-quality gate (docs/keyless-runtime.md): this is an unqualified experiment, off by default, and the driver
// refuses the program without an explicit ExperimentalOptIn (experimental.rs).
//
// LITERAL PORT of engine/strata/src/kernels/cuda/keyless.cu: the kernel BODY is byte-identical to the Original's
// LITERAL PORT of Strata 41cf05a0, src/kernels/cuda/keyless.cu: the kernel BODY is byte-identical to the Original's
// (experimental_attn.rs::literal_bodies_match_the_original). Edits: `__global__ route_kernel` became the
// `__device__ route_kernel_body` function called by the `extern "C" __global__` entry; the host wrapper
// `keyless_route_query` (argument checks and launch geometry) is Rust.
+1 -1
View File
@@ -3,7 +3,7 @@
// 256-point Walsh-Hadamard transform they rely on. Off by default; the driver refuses to open this program
// without an explicit ExperimentalOptIn for a mode that needs it (experimental.rs).
//
// LITERAL PORT of engine/strata/src/kernels/cuda/kv_q4.cu (Original, PR #21). Every kernel BODY below is
// LITERAL PORT of Strata 41cf05a0, src/kernels/cuda/kv_q4.cu (Original, PR #21). Every kernel BODY below is
// byte-identical to the Original's (experimental_kv.rs::literal_bodies_match_the_original compares them).
// The only edits:
// 1. each `__global__` kernel became a `__device__ ..._body` function with the same parameters, called by
+2 -2
View File
@@ -8,7 +8,7 @@
// Both are lossy/unqualified and off by default; the driver refuses this program without an explicit
// ExperimentalOptIn (experimental.rs). The production INT8 path of the Rust runtime does not use this file.
//
// LITERAL PORT of engine/strata/src/kernels/cuda/kv_q8.cu. Kernel BODIES are byte-identical to the Original's
// LITERAL PORT of Strata 41cf05a0, src/kernels/cuda/kv_q8.cu. Kernel BODIES are byte-identical to the Original's
// (experimental_kv.rs::literal_bodies_match_the_original). Edits: each `__global__` kernel became a
// `__device__ ..._body` function with the same parameters called by an `extern "C" __global__` entry with a
// flat pointer/integer ABI (KvHostPools rebuilt from pointers; a null pointer argument is a 64-bit zero);
@@ -22,7 +22,7 @@
// `cur_stride` (the Original's S26 multi-token append); the body is copied verbatim and the entry instantiates the
// single-token form (MULTI = false, strides 0), the old behaviour bit for bit, with its ABI unchanged. The MULTI
// branch is therefore not instantiated here. The Original's 8-wide gather (kv_gather_q8_wide_kernel) exists only
// under STRATA_EXPERIMENTAL_SM60 and is not part of this sm_120 program (tests/literal_port.rs lists it as excluded).
// under STRATA_EXPERIMENTAL_SM60 and is not part of this sm_120 program.
// Not compiled after the re-sync (no nvcc on that host): the sealed PTX is the 2026-10-15 build of the previous source
// and experimental::PENDING_RESEAL makes the program refuse to open until the server reseals it.
// Sealed 2026-10-15 with nvcc 13.2.86 -ptx -O3 -arch=sm_120 -std=c++17, precise math (the Original builds kv_q8.cu with
@@ -5,7 +5,7 @@
// bitwise equal to resident attention), but it is unqualified in this port and off by default; the driver
// refuses this program without an explicit ExperimentalOptIn (experimental.rs).
//
// LITERAL PORT of engine/strata/src/kernels/cuda/kv_stream.cu (resolve_kernel, copy_kernel, reset_kernel,
// LITERAL PORT of Strata 41cf05a0, src/kernels/cuda/kv_stream.cu (resolve_kernel, copy_kernel, reset_kernel,
// ring_kernel, block_scan, Runs, RT). Bodies are byte-identical to the Original's
// (experimental_stream.rs::literal_bodies_match_the_original). Edits: `__global__` kernels became
// `__device__ ..._body` functions with the same parameters called by `extern "C" __global__` entries with a flat
@@ -7,7 +7,7 @@
// ExperimentalOptIn (experimental.rs). The fp16 and INT8 modes of the Original kernel are NOT instantiated here
// (INT8 is qsa_native_decode.cu; fp16 is not part of the Rust runtime).
//
// LITERAL PORT of engine/strata/src/kernels/cuda/qsa_decode_attn.cu: warp_sum, warp_max, load8_*, load8<>,
// LITERAL PORT of Strata 41cf05a0, src/kernels/cuda/qsa_decode_attn.cu: warp_sum, warp_max, load8_*, load8<>,
// attn_chunk_kernel<> and attn_merge_kernel BODIES are byte-identical to the Original's
// (experimental_attn.rs::literal_bodies_match_the_original), as are the constants and mrope_pos. Edits: the
// `__global__` kernels became `__device__ ..._body` functions with the same parameters, called by
@@ -24,7 +24,7 @@
// LANE_CELL, QUERY_SWIZZLE, REDUCE12>` (with reduce12_gfx906 / reduce12_head_of_lane), copied verbatim; the entries
// instantiate it with the three flags off, which is the previous kernel's arithmetic. The Original's alternate
// schedules and batch variants (attn_chunk_kernel_pre75 and its helpers, attn_merge_v2_kernel, the INT8 v3 kernel,
// the slot / row kernels) are not part of this program: tests/literal_port.rs lists each as excluded with its reason.
// the slot / row kernels) are not part of this program.
// Not compiled after the re-sync (no nvcc on that host): the sealed PTX is the 2026-10-15 build of the previous
// source and experimental::PENDING_RESEAL makes the program refuse to open until the server reseals it.
// Sealed 2026-10-15 with nvcc 13.2.86 -ptx -O3 -arch=sm_120 -std=c++17, precise math (the Original builds
@@ -3,7 +3,7 @@
// Literal Original prefill/moe_mmq.cu kernels that the Rust MMQ owners did not carry: copy1_kernel (the
// unaligned branch of gather_native), strata_q2_kernel (a Strata-pack Q2_0 expert blob -> GGUF Q2_0 blocks) and
// iota_kernel (the identity row map `ids_identity`, written by Prefill::run at the start of every prompt).
// Bodies are copied verbatim from engine/strata/src/prefill/moe_mmq.cu; only the export names change
// Bodies are copied verbatim from Strata 41cf05a0, src/prefill/moe_mmq.cu; only the export names change
// (leleka_original_mmq_*), the anonymous namespace is dropped. Original build flags for this file:
// --extended-lambda -use_fast_math (no arithmetic here, so precise/fast-math PTX is identical).
// Launch geometry (Original): 256 threads, ceil(n / 256) blocks, n = elements below.
@@ -3,7 +3,7 @@
// i.e. `fused_gdn_conv_l2` + `fused_gdn_ab` + `fused_gdn_step_norm` in place of the decomposed
// conv / L2 / alpha-beta / gate / step / out-norm launches.
//
// Origin: engine/strata/src/kernels/cuda/fused_gdn.cu (Strata upstream commit recorded in docs/upstream.md):
// Origin: Strata 41cf05a0, src/kernels/cuda/fused_gdn.cu (Strata upstream commit recorded in third_party/strata/UPSTREAM.md):
// gdn_conv_l2_kernel, gdn_ab_kernel, gdn_step_norm_kernel.
// The bodies below are the original statements unchanged. The ONLY edits:
// * each original `__global__` kernel became a `__device__ __forceinline__` body of identical parameters and
@@ -19,7 +19,7 @@
// nvcc -ptx -O3 -arch=sm_120 offline_gdn_fused_t1_kernel.cu -o offline_gdn_fused_t1.ptx
// The PTX, its length and sha256 are produced and pinned by the toolchain owner (see gdn_fused_t1.rs).
//
// Strata is MIT-licensed upstream code of its authors; see engine/strata for the provenance record.
// Strata is MIT-licensed upstream code of its authors; see third_party/strata/UPSTREAM.md for the provenance record.
#include <cuda_runtime.h>
@@ -1,6 +1,6 @@
// STRA-169 candidate source: the Strata PREFILL GDN kernels, transcribed verbatim.
//
// Origin: engine/strata/src/prefill/kernels.cu (Strata upstream commit recorded in docs/upstream.md):
// Origin: Strata 41cf05a0, src/prefill/kernels.cu (Strata upstream commit recorded in third_party/strata/UPSTREAM.md):
// gdn_gates_kernel, gdn_conv_kernel, gdn_conv_tiled_kernel, gdn_conv_hist_kernel, gdn_l2_kernel,
// gdn_rec_cols_pipe_kernel, gdn_out_norm_kernel, and the BF16/FP16 image tail of gr_mix_kernel.
// This is NOT the pinned native/decode T1 arithmetic of offline_gdn_kernel.cu (that one stays untouched and keeps
@@ -22,7 +22,7 @@
// nvcc -ptx -O3 -arch=sm_120 offline_gdn_prefill_kernel.cu -o offline_gdn_prefill.ptx
// The PTX, its length and sha256 are produced and pinned by the toolchain owner (see gdn_native_batch.rs).
//
// Strata is MIT-licensed upstream code of its authors; see engine/strata for the provenance record.
// Strata is MIT-licensed upstream code of its authors; see third_party/strata/UPSTREAM.md for the provenance record.
#include <cuda_fp16.h>
#include <cuda_runtime.h>
@@ -1,6 +1,6 @@
// STRA-169 candidate source: the Strata PREFILL MoE router / shared-expert / combine dispatches, verbatim.
//
// Origin: engine/strata/src/prefill/kernels.cu (Strata upstream commit recorded in docs/upstream.md):
// Origin: Strata 41cf05a0, src/prefill/kernels.cu (Strata upstream commit recorded in third_party/strata/UPSTREAM.md):
// route_kernel<16> (the 512-expert instantiation chosen by route()), swiglu_pair_kernel, moe_combine_kernel,
// and the BF16/FP16 image tail of gr_mix_kernel (bf()/bf_lo()/hf()).
// The decode/T1 router asset (moe_route_top10.cu, one token per launch, native_router.cu arithmetic) stays untouched
@@ -16,7 +16,7 @@
// nvcc -ptx -O3 -arch=sm_120 offline_moe_prefill_kernel.cu -o offline_moe_prefill.ptx
// The PTX, its length and sha256 are produced and pinned by the toolchain owner (see moe_prefill_batch.rs).
//
// Strata is MIT-licensed upstream code of its authors; see engine/strata for the provenance record.
// Strata is MIT-licensed upstream code of its authors; see third_party/strata/UPSTREAM.md for the provenance record.
#include <cuda_fp16.h>
#include <cuda_runtime.h>
@@ -1,6 +1,6 @@
// STRA-169 candidate source: native GGUF blocks -> FP16 dequantization of the Strata prompt path.
//
// Origin: engine/strata/src/kernels/cuda/dequant_bf16.cu (group32<TYPE>, dequant_kernel, the H16 output of
// Origin: Strata 41cf05a0, src/kernels/cuda/dequant_bf16.cu (group32<TYPE>, dequant_kernel, the H16 output of
// dequant_f16), itself transcribed from ggml/src/ggml-quants.c at the pinned llama.cpp (MIT License,
// Copyright (c) 2023-2026 The ggml authors): dequantize_row_q8_0/q4_K/q5_K/q6_K/iq4_nl/iq4_xs.
// Only the GGUF types the GDN projections (attn_qkv, attn_gate, ssm_out) can carry are instantiated:
@@ -1,5 +1,5 @@
// Adapted from the pinned native operation:
// engine/strata/src/kernels/cuda/native_bf16.cu
// Strata 41cf05a0, src/kernels/cuda/native_bf16.cu
// SHA-256 70b44795528fb73d636be5914d60f0adaa849a48cc38f309d327a2976c3ed3da
// and exact BF16 bit expansion in bf16_bits.hpp
// SHA-256 813b51f17c5c264d642f4d77b3d6e5f35e7ea7310ba87b18b3a2a5bc9185198f.
@@ -1,7 +1,7 @@
// src/original_verify_window_moe_experts.cu - the grouped native-expert gate/up and down kernels of the
// Verifier window (child of `original_verify`, producer family MoE / FFN).
//
// Original: engine/strata/src/kernels/cuda/iq_kernels.cu, `native_expert_grouped`:
// Original: Strata 41cf05a0, src/kernels/cuda/iq_kernels.cu, `native_expert_grouped`:
//
// launch_gu<T> -> native_gu_kernel<T> | native_gu_multi_kernel<T> (kSplit<T> selects the second)
// swiglu_entries_kernel, quantize_q8_1_kernel (sealed in mtp_original_full_head_iq.ptx)
@@ -18,8 +18,8 @@
// STRATA_D_FMTS). The split/non-split choice of `launch_gu` / `launch_down` is made at compile time per type,
// exactly as in the Original with STRATA_OLD_IQ_MMVQ unset (the default).
//
// Build: scripts/build-original-verify-ptx.sh flags (nvcc --ptx -std=c++17 -O3 -arch=sm_120 --fmad=true --ftz=false);
// engine/strata/CMakeLists.txt gives iq_kernels.cu no per-source options (it is not in the --use_fast_math list).
// Build: precise flags (nvcc --ptx -std=c++17 -O3 -arch=sm_120 --fmad=true --ftz=false);
// Strata 41cf05a0, CMakeLists.txt gives iq_kernels.cu no per-source options (it is not in the --use_fast_math list).
#include "mtp_original_full_head_iq.cu"
namespace strata::kernels {
+1 -1
View File
@@ -10,7 +10,7 @@
// The host launchers (argument checks, geometry, cudaDeviceSynchronize) are not carried: see s_gemv_legacy.rs.
// Original build flags: default (none of these files is in CMakeLists' fast-math list). STATUS: NOT COMPILED OR RUN
// (no nvcc here); executed on the host through oracle/shim (drivers/s_gemv_legacy.cpp).
// Original sources (Strata upstream tree as imported under engine/strata):
// Original sources (Strata upstream tree, 41cf05a0):
// s_gemv.cu sha256 46c946cff34b50f252a5d4a6b2f99e0d30b78a6ad741919417566ccb43017e40
// s2_gemv.cu sha256 4d21a4e14e166b02652719c095b25fa7f346c3d0b3dd1009e050e793b2167b9b
// s2_gemv_quads.cu sha256 3633ad7b7006fdfc96e7b1aa06733168e2292a5b700c49ece60e121c3db4280c
+2 -2
View File
@@ -1,7 +1,7 @@
// claude/decode-sm120-switches, switch ATTN_DAILY (upstream STRATA_ATTN_DAILY=1, one of the five bitwise switches that Strata 0.2.6 turns on by
// default on a compute capability 12.0 card, engine/strata/include/strata/core/sm120_series.hpp).
// default on a compute capability 12.0 card, Strata 41cf05a0, include/strata/core/sm120_series.hpp).
//
// Source: engine/strata/src/kernels/cuda/qsa_decode_attn.cu at the pinned upstream (docs/upstream.md):
// Source: Strata 41cf05a0, src/kernels/cuda/qsa_decode_attn.cu at the pinned upstream (third_party/strata/UPSTREAM.md):
// attn_chunk_kernel_pre75<KV_MODE = 1, NC = 2, DPP = false> (PR #540, the Daily's attn_chunk_kernel) -> leleka_qsa_decode_chunk_daily
// attn_merge_v2_kernel<kMergeU = 16> (the Daily's 3effa9d5) -> leleka_qsa_decode_merge_v2
// Same arithmetic, same operand order as the literal Original `attn_chunk_kernel<1>` / `attn_merge_kernel` of qsa_native_decode.cu that they
+2 -2
View File
@@ -1,5 +1,5 @@
// claude/ffn-down-sub16, switch DOWN_SUB16 (D1 of docs/experiments/ffn-phase-loss-design.md; upstream's default down kernel on a compute capability 12.0 card,
// engine/strata/src/kernels/cuda/iq_kernels.cu `native_down_multi_kernel<TD, SUB_DOWN = true>`, the `hb == 20` branches).
// Strata 41cf05a0, src/kernels/cuda/iq_kernels.cu `native_down_multi_kernel<TD, SUB_DOWN = true>`, the `hb == 20` branches).
//
// The window's grouped routed-expert down projection (`window_moe_down_<T>`: one 32-lane warp per output row, 8 rows a block, grid.y = one block row per
// possible group) is replaced for the two down formats the target uses, IQ4_NL (20) and Q2_0 (42), at n_ff 640 by upstream's sub-warp rows:
@@ -15,7 +15,7 @@
// probe tools/decode-sm120/sm120_probe.cpp `down` compares every output float of this kernel with `window_moe_down_<T>` byte for byte). The store is
// `s * sd` with sd = 1.0f (tail_off 0: no NVFP4 tail), which is exact.
//
// Source: engine/strata/src/kernels/cuda/iq_kernels.cu at the pinned upstream (docs/upstream.md), textually included (sm120_iq_prefix.cuh, see
// Source: Strata 41cf05a0, src/kernels/cuda/iq_kernels.cu at the pinned upstream (third_party/strata/UPSTREAM.md), textually included (sm120_iq_prefix.cuh, see
// sm120_gu_swiglu.cu): the traits, the two row dots and GRP_NC are upstream's. A `__global__` template cannot be called from another kernel, so the
// body is repeated below as a `__device__` template, and one extern "C" kernel per down format wraps it. Only n_ff == 640 (hb == 20) is covered; the
// planner keeps `window_moe_down_<T>` for any other layer.
@@ -22,7 +22,7 @@
// same text gives the same PTX shape (checked by a unit test that looks for the FMA chain of the sum of squares in the sealed PTX).
//
// Compile: nvcc -ptx -O3 -arch=sm_120 -std=c++17 --fmad=true --ftz=false (the recipe of chain_window.cu). Self-contained: the 112-byte FusedGrArgs
// layout the sealed chain kernels use is repeated here (the header in engine/strata/include has later fields and is 168 bytes).
// layout the sealed chain kernels use is repeated here (the header in Strata 41cf05a0 include/ has later fields and is 168 bytes).
#include <cuda_runtime.h>
#include <stdint.h>
#include <stddef.h>
+3 -3
View File
@@ -1,13 +1,13 @@
// claude/decode-sm120-switches, switch GU_SWIGLU (upstream STRATA_GU_SWIGLU=1, one of the five bitwise switches that Strata 0.2.6 turns on by default on a
// compute capability 12.0 card, engine/strata/include/strata/core/sm120_series.hpp; upstream commit 147-verify).
// compute capability 12.0 card, Strata 41cf05a0, include/strata/core/sm120_series.hpp; upstream commit 147-verify).
//
// The window's grouped routed-expert gate/up kernel (`window_moe_gu_<T>`, the old pin's native_gu_multi_kernel: one 32-lane warp per row), the entry-wise
// SwiGLU (`swiglu_entries_kernel`) and the q8_1 quantizer (`quantize_q8_1_kernel`) are replaced by ONE launch of upstream's `native_gu_swiglu_kernel<TG, STAGE>`:
// 16-lane sub-warp rows (`row_dot2_80_sub16`: a gate row and its up row at once, 100 % active lanes where the warp-per-row kernel idles half of them on its third
// pass), the SwiGLU product formed in the block and quantized there (`q8_1_store`), so the gate / up floats never round-trip through memory.
//
// Source: engine/strata/src/kernels/cuda/iq_kernels.cu at the pinned upstream (docs/upstream.md), textually included (sm120_iq_prefix.cuh: the file up to the dequant
// banner, generated by scripts/decode-sm120/make_iq_prefix.py; the whole file's host launchers would instantiate ~60 MB of PTX) so every trait, row dot, q8_1_store and the
// Source: Strata 41cf05a0, src/kernels/cuda/iq_kernels.cu at the pinned upstream (third_party/strata/UPSTREAM.md), textually included (sm120_iq_prefix.cuh: the file up to the dequant
// banner, copied unchanged; the whole file's host launchers would instantiate ~60 MB of PTX) so every trait, row dot, q8_1_store and the
// grid staging are upstream's. A `__global__` template cannot be called from another kernel, so the body of native_gu_swiglu_kernel is repeated below as a
// `__device__` template, line for line, and one extern "C" kernel per gate/up format wraps it. The staging default is upstream's on a 12.0 card
// (`launch_gu_swiglu`: stage the codebook for 16 / 17 / 22 / 29, not for IQ3_XXS / IQ3_S (STRATA_IQ_STAGE_TABLES off), none for 23 / 42).
+2 -2
View File
@@ -1,5 +1,5 @@
// GENERATED by scripts/decode-sm120/make_iq_prefix.py from engine/strata/src/kernels/cuda/iq_kernels.cu (the pinned upstream, docs/upstream.md): the file up to the dequant banner,
// unchanged. Do not edit; `make_iq_prefix.py --check` compares it with the engine tree. Opens `namespace strata::kernels { namespace {` and leaves both open.
// Copied from Strata 41cf05a0, src/kernels/cuda/iq_kernels.cu (the pinned upstream, third_party/strata/UPSTREAM.md): the file up to the dequant banner,
// unchanged. Do not edit; it is a verbatim copy of that range. Opens `namespace strata::kernels { namespace {` and leaves both open.
// src/kernels/cuda/iq_kernels.cu - see include/strata/kernels/iq_kernels.hpp.
//
// The dot products (vec_dot_*_q8_1), the dequantizers and the q8_1 quantizer are transcribed from llama.cpp
@@ -1,7 +1,7 @@
// verify window, FFN phase (docs/experiments/ffn-phase-loss-design.md, D3): LELEKA_SM120_WAIT_M_ROWS.
//
// The wait on flag M (the CPU leg's rows are in the mapped buffer) folded into the copy of those rows: upstream's
// `copy_rows_from_mapped_after` (engine/strata/src/kernels/cuda/elementwise.cu 240-262, verify.cpp 2189), one kernel
// `copy_rows_from_mapped_after` (Strata 41cf05a0, src/kernels/cuda/elementwise.cu 240-262, verify.cpp 2189), one kernel
// node fewer a layer. It replaces the pair
// verify_wait_flag_ge_kernel (original_verify.cu: 1 block of 1 thread, `while (*flag < v) nanosleep(100);
// __threadfence_system();`)