A q8_1 block stores d = amax / 127 and the sum of its 32 activations as fp16: one massive activation (amax > 8.3 M, or a sum past 65504) rounded to inf and the dot products then read inf * 0 = NaN (NonFiniteMmqOutput here, "!!!!" upstream). The quantizers now clamp both to the largest finite half and keep the codes inside int8 (strata/kernels/q8_1_finite.hpp); a NaN input still gives a NaN sum. Finite blocks are stored bit for bit as before. Sites: head_quant (mtp_original_full_head_native, native_head_native), mtp_original_quantize (mtp_original_tail, mtp_original_full_checks), quantize_q8_1_kernel (mtp_original_full_head_iq, native_head_iq: the routed experts' input and SwiGLU output) and the opt-in chain swiglu+quantize (chain_window). Not taken: the MMQ prompt quantizers (ggml quantize_mmq_q8_1, mtp_prefill_q8), which upstream did not clamp. The sealed PTX are patched entry by entry (scripts/q8): three were built with CUDA 13.0.88, which is not installed, and a recompile renames the hashed anonymous-namespace entries; only the quantizer entries change, every other byte is the sealed one. Pins, the seal plan digests and the sm_86 companions (sm86_assets.py build) follow. tools/q8-probe compares old and new PTX on the GPU. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
287 lines
15 KiB
JSON
287 lines
15 KiB
JSON
{
|
|
"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",
|
|
"new_sources": [
|
|
{
|
|
"source": "crates/cuda-driver/src/original_verify_window_moe_experts.cu",
|
|
"ptx": "crates/cuda-driver/src/original_verify_window_moe_experts.ptx",
|
|
"nvcc": [
|
|
"--ptx",
|
|
"-std=c++17",
|
|
"-O3",
|
|
"-arch=sm_120",
|
|
"--fmad=true",
|
|
"--ftz=false",
|
|
"-Iengine/strata/include",
|
|
"-Iengine/strata/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"
|
|
],
|
|
"exports": [
|
|
"window_moe_gu_16",
|
|
"window_moe_gu_17",
|
|
"window_moe_gu_18",
|
|
"window_moe_gu_21",
|
|
"window_moe_gu_22",
|
|
"window_moe_gu_23",
|
|
"window_moe_gu_29",
|
|
"window_moe_gu_42",
|
|
"window_moe_gu_12",
|
|
"window_moe_gu_13",
|
|
"window_moe_gu_8",
|
|
"window_moe_down_20",
|
|
"window_moe_down_23",
|
|
"window_moe_down_42",
|
|
"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)",
|
|
"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."
|
|
},
|
|
{
|
|
"source": "crates/cuda-driver/src/original_verify_window_qsa_gate.cu",
|
|
"ptx": "crates/cuda-driver/src/original_verify_window_qsa_gate.ptx",
|
|
"nvcc": [
|
|
"--ptx",
|
|
"-std=c++17",
|
|
"-O3",
|
|
"-arch=sm_120",
|
|
"--fmad=true",
|
|
"--use_fast_math",
|
|
"-Iengine/strata/include",
|
|
"-Iengine/strata/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"
|
|
],
|
|
"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.",
|
|
"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."
|
|
}
|
|
],
|
|
"sealed_assets_bound": [
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_attention.ptx",
|
|
"sha256": "3fb235ca405d24c3b8d0ec46611d9d640103b71a65859923194f02f06b482f6c"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_bf16.ptx",
|
|
"sha256": "a16dfcfc9a49ccab25d8030293d5826f8f75e2868fae1b6c4cef706b6dfc3d08"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_combine.ptx",
|
|
"sha256": "2253fe2d641350f4445a0a69c4a0fc22b85c2fffca7cbd536ffe5d2912f81fb7"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_element.ptx",
|
|
"sha256": "8fdfdf8ef616698c12301f7df4716fc022bf34b419099e4c972729920bd5f4a7"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_fused_gr.ptx",
|
|
"sha256": "ac5400a7972b3f242648c2de71ef4f178466d38b1392a83a9591b3b24e92c59b"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_gr_norm.ptx",
|
|
"sha256": "06d6177b482cb67413c6596a0291b4dab1850332164a9212aff67b9efdf21120"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_gr_post.ptx",
|
|
"sha256": "9b479c0f412ae00773815c9a6d89d7f4c3f7a9f0f691876de805eb38178d9790"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_head_iq.ptx",
|
|
"sha256": "e57452ccac772a8a8a77253bc6c964ebb7bc61fdb2e97527a9775f8ccf3c3b9f"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_head_native.ptx",
|
|
"sha256": "f8209e1c9fbf978bc57b60b0b5f6edcab1905e49a4ab3aa982604e3e680fa437"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_router.ptx",
|
|
"sha256": "be6e3c91e4f6831464f5993787f0bff969bc5d28395f24226b88676b3069a8cb"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_router_legacy.ptx",
|
|
"sha256": "a58412249757cc351eb8332e807e79f1b3da5865574d0fb7179ef558df70af24"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_s2.ptx",
|
|
"sha256": "fbb917d590ea80338a7bdf07b2ca6d458fa72763ba279e576bcc1eec8836fd55"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_full_shared.ptx",
|
|
"sha256": "b36f432692e43f7948a2538c22cab55ef67c625b8d4461c67ca2a27519b9e0f0"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/mtp_original_kv.ptx",
|
|
"sha256": "e0c1ff10d3d4bcf8fd3369713079b232e62cdb2c3a345faec49d1e66763f911f"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/ple_native_batch.ptx",
|
|
"sha256": "5fa5c930f40cb49d9e79a35e1911c68581f92c097750eff28c245e2870964a40"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/qsa_decode_postops.ptx",
|
|
"sha256": "fd76e6f84557d7f2a62ac56e16d5e4f78862e756ef9852b04d591999213a5119"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/qsa_prompt_postops.ptx",
|
|
"sha256": "486a73b06b3a34f298f57e92c20cc8394dc59d7bd84b5cccf8da53aa5081ac9f"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/qsa_prompt_resolver.ptx",
|
|
"sha256": "8d3ecbaecbf28445ba64485bdff3d91a21d87b85d5939a0152ef2f2414480e22"
|
|
},
|
|
{
|
|
"ptx": "crates/cuda-driver/src/qsa_prompt_select.ptx",
|
|
"sha256": "1e35514744216229b0cffb4f45d2f13f25cb95f377a30c1c012543dbf53a1c2d"
|
|
}
|
|
],
|
|
"numerics_risk_fast_math": {
|
|
"engine_fast_math_sources_cmake": [
|
|
"native_mmvq",
|
|
"native_bf16",
|
|
"native_gr_norm",
|
|
"native_moe",
|
|
"native_gdn",
|
|
"native_gr_postops",
|
|
"native_router",
|
|
"native_gdn_preprocess",
|
|
"native_qsa",
|
|
"native_rope",
|
|
"native_ple_postops",
|
|
"native_flash_attn",
|
|
"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.",
|
|
"candidate_resealed_assets": [
|
|
{
|
|
"ptx": "mtp_original_full_head_native.ptx / mtp_original_tail.ptx / mtp_original_full_checks.ptx",
|
|
"derived_from": "native_mmvq (quantize_q8_1 + MMVQ)"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_bf16.ptx",
|
|
"derived_from": "native_bf16"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_router.ptx",
|
|
"derived_from": "native_router"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_gr_norm.ptx / mtp_original_full_gr_post.ptx",
|
|
"derived_from": "native_gr_norm / native_gr_postops"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_combine.ptx",
|
|
"derived_from": "native_moe"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_qnorm.ptx / mtp_original_full_qsa_gate.ptx / qsa_native_gate.ptx",
|
|
"derived_from": "native_qsa"
|
|
},
|
|
{
|
|
"ptx": "qsa_decode_postops.ptx",
|
|
"derived_from": "native_qsa norm + native_rope"
|
|
},
|
|
{
|
|
"ptx": "original_verify_qsa.ptx / qsa_prompt_indexer.ptx",
|
|
"derived_from": "native_qsa_indexer"
|
|
},
|
|
{
|
|
"ptx": "ple_native_batch.ptx / ple_prompt_device.ptx",
|
|
"derived_from": "native_ple_postops"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_prefill_mmq.ptx / mtp_original_prefill_fixup.ptx / mtp_original_prefill_quant.ptx",
|
|
"derived_from": "ggml mmq instances + quantize.cu, built by the Original's strata_mmq target with -use_fast_math"
|
|
}
|
|
],
|
|
"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.",
|
|
"sealed_precise_but_original_fast_math": [
|
|
{
|
|
"ptx": "mtp_original_full_head_native.ptx",
|
|
"entry": "head_quant",
|
|
"original": "native_mmvq.cu native_quantize_q8_1_kernel",
|
|
"operations": "d = amax / 127.0f and q = roundf(xi / d): two div.rn.f32 where the Original emits div.full.f32 (a 1-2 ulp quotient change can flip roundf at a half-integer, i.e. one int8 code); every q8_1 activation of the window (GDN/QSA projections, shared expert, head) goes through it. The MMVQ dot kernels have no division (FTZ-only difference)."
|
|
},
|
|
{
|
|
"ptx": "original_verify_qsa.ptx",
|
|
"entry": "verify_qsa_append_analytic (+ commit re-append)",
|
|
"original": "native_qsa_indexer.cu append<false> (the default; STRATA_ROPE_TABLE=1 is opt-in)",
|
|
"operations": "powf(theta_scale, pair), cosf(theta), sinf(theta) (and logf for YaRN) are precise here and __powf/cos.approx/sin.approx in the Original; angles reach thousands of radians so the pooled index keys differ well beyond 1 ulp. Matters once the context exceeds the 2051-cell selection width."
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_router.ptx",
|
|
"entry": "mtp_full_route",
|
|
"original": "native_router.cu route",
|
|
"operations": "expf(values - max) (precise expf sequence vs ex2.approx(x*log2e)), 1.0f / warp_sum and 1.0f / selected_sum (rcp.rn vs div.full): the routed expert weights differ in the last bits (expert ids do not)."
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_gr_post.ptx",
|
|
"entry": "mtp_full_down_silu, mtp_full_pre_final, mtp_full_native_write",
|
|
"original": "native_gr_postops.cu",
|
|
"operations": "sigmoid 1.0f / (1.0f + expf(-x)) and silu x / (1.0f + expf(-x)): precise expf and division; used by final_write and the head mix."
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_gr_norm.ptx",
|
|
"entry": "mtp_full_gr_norm",
|
|
"original": "native_gr_norm.cu weighted_rms_norm",
|
|
"operations": "mean = partial / n_cols (div.rn vs div.full) feeding rsqrtf; used by the head mix."
|
|
},
|
|
{
|
|
"ptx": "ple_native_batch.ptx",
|
|
"entry": "native PLE post-ops",
|
|
"original": "native_ple_postops.cu",
|
|
"operations": "sqrtf, expf, 1.0f / (1.0f + expf(..)), sum / (1.0f + expf(..)) and partial / N: precise vs fast; only with a PLE block."
|
|
}
|
|
],
|
|
"ftz_only_difference": [
|
|
"mtp_original_full_bf16.ptx (native_bf16.cu)",
|
|
"mtp_original_full_combine.ptx (native_moe.cu)",
|
|
"the MMVQ kernels of mtp_original_full_head_native.ptx (native_mmvq.cu)",
|
|
"qsa_prompt_postops.ptx (q/gate split copy)"
|
|
],
|
|
"matches_original": [
|
|
"qsa_decode_postops.ptx (fast math, native_qsa norm / native_rope)",
|
|
"original_verify_window_qsa_gate.cu (to be sealed with --use_fast_math)",
|
|
"mtp_original_full_shared.ptx (Original shared_expert.cu spells __fdividef/__expf itself)",
|
|
"mtp_original_full_attention.ptx (qsa_decode_attn.cu: __expf explicit, precise division)",
|
|
"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."
|
|
},
|
|
"not_candidates_original_is_precise": [
|
|
{
|
|
"ptx": "mtp_original_full_attention.ptx",
|
|
"derived_from": "qsa_decode_attn.cu"
|
|
},
|
|
{
|
|
"ptx": "qsa_prompt_postops.ptx",
|
|
"derived_from": "prefill/kernels.cu"
|
|
},
|
|
{
|
|
"ptx": "qsa_prompt_select.ptx",
|
|
"derived_from": "qsa_select.cu (the Original verifier scores with qsa_select, not native_qsa_score)"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_router_legacy.ptx",
|
|
"derived_from": "router_top10.cu"
|
|
},
|
|
{
|
|
"ptx": "mtp_original_full_fused_gr.ptx",
|
|
"derived_from": "fused_gr.cu"
|
|
}
|
|
],
|
|
"correction": "The first version of this list named mtp_original_full_attention, qsa_prompt_postops, qsa_prompt_select, mtp_original_full_router_legacy and mtp_original_full_fused_gr; a function-level comparison against the Original shows those derive from sources that are NOT in the CMake fast-math list, and it missed the assets listed above."
|
|
}
|
|
}
|