diff --git a/architecture-baseline.json b/architecture-baseline.json index 5f14f753..f867d87b 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -32,7 +32,7 @@ "crates/cuda-driver/src/prefill_stage_gr_gpu.rs": 445, "crates/cuda-driver/src/qsa_resident_index_program/impl_qsapromptindexworkspace.rs": 415, "crates/cuda-driver/src/qwen_ffi.rs": 826, - "crates/cuda-driver/src/sm86_table.rs": 1719, + "crates/cuda-driver/src/sm86_table.rs": 934, "crates/cuda-driver/tests/mock_driver.rs": 435, "crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier_fn.rs": 455, "crates/deploy/src/app.rs": 1490, @@ -70,9 +70,7 @@ "crates/gptoss/tests/synthetic_model.rs": 922, "crates/igpu/src/lib.rs": 1386, "crates/igpu/src/shaders.rs": 440, - "crates/native-cpu-expert/examples/kernel_ab.rs": 3992, - "crates/native-cpu-expert/src/rust_codebooks.rs": 1905, - "crates/native-cpu-expert/src/rust_iq1_grid.rs": 2051, + "crates/native-cpu-expert/examples/kernel_ab/main.rs": 1635, "crates/openvino/src/lib.rs": 676, "crates/quant-core/src/iq2s_grid.rs": 1032, "crates/runtime-client/tests/grpc_backend.rs": 689, diff --git a/crates/cuda-driver/src/sm86_table.rs b/crates/cuda-driver/src/sm86_table.rs index 2b7adc3d..3583b5c1 100644 --- a/crates/cuda-driver/src/sm86_table.rs +++ b/crates/cuda-driver/src/sm86_table.rs @@ -12,1708 +12,923 @@ pub(crate) struct Companion { } /// Sorted by `key`. +#[rustfmt::skip] pub(crate) static COMPANIONS: &[Companion] = &[ Companion { name: "ple_bf16_pack.ptx", - key: [ - 0x01, 0x59, 0x28, 0xed, 0xe2, 0x02, 0x42, 0xc6, 0x31, 0x51, 0x30, 0x7b, 0xd5, 0x02, 0xbf, 0x98, 0xf4, 0xfb, - 0x58, 0x0b, 0xad, 0x2b, 0x7d, 0x34, 0x72, 0xee, 0xbb, 0xa1, 0x12, 0x95, 0x30, 0xb3, - ], + key: [0x01, 0x59, 0x28, 0xed, 0xe2, 0x02, 0x42, 0xc6, 0x31, 0x51, 0x30, 0x7b, 0xd5, 0x02, 0xbf, 0x98, 0xf4, 0xfb, 0x58, 0x0b, 0xad, 0x2b, 0x7d, 0x34, 0x72, 0xee, 0xbb, 0xa1, 0x12, 0x95, 0x30, 0xb3], len: 8276, - sha: [ - 0xb5, 0xe9, 0x9b, 0x53, 0x10, 0xcf, 0x1c, 0x92, 0x11, 0x67, 0x45, 0x06, 0x42, 0x6e, 0xe8, 0x99, 0x68, 0xd1, - 0x4a, 0xb7, 0x71, 0x80, 0x55, 0x3d, 0x94, 0xd5, 0xbd, 0xb8, 0x8e, 0x3c, 0x9c, 0x09, - ], + sha: [0xb5, 0xe9, 0x9b, 0x53, 0x10, 0xcf, 0x1c, 0x92, 0x11, 0x67, 0x45, 0x06, 0x42, 0x6e, 0xe8, 0x99, 0x68, 0xd1, 0x4a, 0xb7, 0x71, 0x80, 0x55, 0x3d, 0x94, 0xd5, 0xbd, 0xb8, 0x8e, 0x3c, 0x9c, 0x09], ptx: concat!(include_str!("../ptx-sm86/ple_bf16_pack.ptx"), "\0").as_bytes(), }, Companion { name: "offline_native_dequant_f16.ptx", - key: [ - 0x02, 0x0b, 0xc7, 0x97, 0xfc, 0x5a, 0x8f, 0x36, 0x23, 0x07, 0x54, 0x36, 0xb4, 0x4e, 0x02, 0x1a, 0x2e, 0x97, - 0xff, 0xba, 0xaa, 0xbf, 0x54, 0xd2, 0x73, 0xea, 0xce, 0xc1, 0x31, 0x32, 0xeb, 0x2a, - ], + key: [0x02, 0x0b, 0xc7, 0x97, 0xfc, 0x5a, 0x8f, 0x36, 0x23, 0x07, 0x54, 0x36, 0xb4, 0x4e, 0x02, 0x1a, 0x2e, 0x97, 0xff, 0xba, 0xaa, 0xbf, 0x54, 0xd2, 0x73, 0xea, 0xce, 0xc1, 0x31, 0x32, 0xeb, 0x2a], len: 58080, - sha: [ - 0x24, 0x31, 0xc2, 0x8a, 0x19, 0x52, 0x5c, 0x64, 0xb7, 0xf9, 0x75, 0x30, 0x6e, 0x01, 0x99, 0xce, 0x0f, 0x0d, - 0x68, 0xf5, 0x5d, 0x22, 0x39, 0xe4, 0xb4, 0x72, 0x80, 0x9f, 0x1e, 0x17, 0x36, 0x70, - ], + sha: [0x24, 0x31, 0xc2, 0x8a, 0x19, 0x52, 0x5c, 0x64, 0xb7, 0xf9, 0x75, 0x30, 0x6e, 0x01, 0x99, 0xce, 0x0f, 0x0d, 0x68, 0xf5, 0x5d, 0x22, 0x39, 0xe4, 0xb4, 0x72, 0x80, 0x9f, 0x1e, 0x17, 0x36, 0x70], ptx: concat!(include_str!("../ptx-sm86/offline_native_dequant_f16.ptx"), "\0").as_bytes(), }, Companion { name: "kar_ple_fixed.ptx", - key: [ - 0x03, 0xc9, 0xf6, 0x63, 0x49, 0x5b, 0xea, 0xf1, 0xdd, 0x42, 0x02, 0x5f, 0x14, 0x80, 0x9b, 0x7b, 0xfb, 0x8c, - 0xd7, 0xad, 0x4c, 0x7f, 0xb5, 0x5e, 0x17, 0x3a, 0x79, 0xb1, 0xa9, 0x72, 0x0c, 0x3b, - ], + key: [0x03, 0xc9, 0xf6, 0x63, 0x49, 0x5b, 0xea, 0xf1, 0xdd, 0x42, 0x02, 0x5f, 0x14, 0x80, 0x9b, 0x7b, 0xfb, 0x8c, 0xd7, 0xad, 0x4c, 0x7f, 0xb5, 0x5e, 0x17, 0x3a, 0x79, 0xb1, 0xa9, 0x72, 0x0c, 0x3b], len: 5210, - sha: [ - 0x76, 0xda, 0x12, 0x64, 0x39, 0xb0, 0x93, 0xf3, 0x9e, 0xda, 0x77, 0x14, 0x29, 0x9b, 0x6d, 0xf9, 0xc9, 0xa6, - 0x0f, 0xaf, 0x43, 0xcb, 0x75, 0x8f, 0x49, 0xf3, 0x12, 0x42, 0x75, 0xce, 0xcf, 0x56, - ], + sha: [0x76, 0xda, 0x12, 0x64, 0x39, 0xb0, 0x93, 0xf3, 0x9e, 0xda, 0x77, 0x14, 0x29, 0x9b, 0x6d, 0xf9, 0xc9, 0xa6, 0x0f, 0xaf, 0x43, 0xcb, 0x75, 0x8f, 0x49, 0xf3, 0x12, 0x42, 0x75, 0xce, 0xcf, 0x56], ptx: concat!(include_str!("../ptx-sm86/kar_ple_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "bf16_f32_mmvf.ptx", - key: [ - 0x04, 0x45, 0x43, 0xf6, 0x81, 0xbb, 0x23, 0xeb, 0x9c, 0xae, 0x60, 0x2b, 0x1a, 0x16, 0xaa, 0x7b, 0x23, 0x86, - 0xd6, 0xd5, 0xc3, 0xb1, 0x5c, 0xc4, 0x19, 0x87, 0x33, 0x8b, 0xd6, 0x13, 0xb1, 0xc3, - ], + key: [0x04, 0x45, 0x43, 0xf6, 0x81, 0xbb, 0x23, 0xeb, 0x9c, 0xae, 0x60, 0x2b, 0x1a, 0x16, 0xaa, 0x7b, 0x23, 0x86, 0xd6, 0xd5, 0xc3, 0xb1, 0x5c, 0xc4, 0x19, 0x87, 0x33, 0x8b, 0xd6, 0x13, 0xb1, 0xc3], len: 5875, - sha: [ - 0x54, 0xa3, 0x31, 0x46, 0x55, 0x8e, 0xf7, 0x6c, 0x81, 0x7f, 0xc8, 0xe5, 0x56, 0xf7, 0x09, 0x22, 0x8f, 0x90, - 0xe2, 0xcc, 0xd6, 0x56, 0x5f, 0x57, 0xc4, 0xf8, 0xec, 0x46, 0x46, 0xe6, 0xc4, 0x42, - ], + sha: [0x54, 0xa3, 0x31, 0x46, 0x55, 0x8e, 0xf7, 0x6c, 0x81, 0x7f, 0xc8, 0xe5, 0x56, 0xf7, 0x09, 0x22, 0x8f, 0x90, 0xe2, 0xcc, 0xd6, 0x56, 0x5f, 0x57, 0xc4, 0xf8, 0xec, 0x46, 0x46, 0xe6, 0xc4, 0x42], ptx: concat!(include_str!("../ptx-sm86/bf16_f32_mmvf.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_iq4_xs_nc4.ptx", - key: [ - 0x06, 0x11, 0xaa, 0x38, 0x6b, 0x2b, 0x36, 0x6e, 0x99, 0x42, 0xd5, 0x37, 0x17, 0x5b, 0xe5, 0xb1, 0xd9, 0x6e, - 0x9c, 0x33, 0xbe, 0x5e, 0x12, 0x36, 0xc8, 0xb4, 0x6a, 0x83, 0x18, 0xf6, 0xb6, 0xc1, - ], + key: [0x06, 0x11, 0xaa, 0x38, 0x6b, 0x2b, 0x36, 0x6e, 0x99, 0x42, 0xd5, 0x37, 0x17, 0x5b, 0xe5, 0xb1, 0xd9, 0x6e, 0x9c, 0x33, 0xbe, 0x5e, 0x12, 0x36, 0xc8, 0xb4, 0x6a, 0x83, 0x18, 0xf6, 0xb6, 0xc1], len: 74210, - sha: [ - 0x7c, 0xf9, 0x63, 0x32, 0x59, 0x2e, 0x39, 0x9b, 0x49, 0xe8, 0x4e, 0x53, 0x40, 0xff, 0xbb, 0xab, 0x26, 0xdb, - 0x49, 0x25, 0x9a, 0x9b, 0x5e, 0x03, 0x04, 0x79, 0x4c, 0x1c, 0x0f, 0x54, 0x79, 0x41, - ], + sha: [0x7c, 0xf9, 0x63, 0x32, 0x59, 0x2e, 0x39, 0x9b, 0x49, 0xe8, 0x4e, 0x53, 0x40, 0xff, 0xbb, 0xab, 0x26, 0xdb, 0x49, 0x25, 0x9a, 0x9b, 0x5e, 0x03, 0x04, 0x79, 0x4c, 0x1c, 0x0f, 0x54, 0x79, 0x41], ptx: concat!(include_str!("../ptx-sm86/moe_group_iq4_xs_nc4.ptx"), "\0").as_bytes(), }, Companion { name: "q8_1_quantize.ptx", - key: [ - 0x06, 0x40, 0x3c, 0x31, 0xe0, 0x94, 0x4b, 0x39, 0xc6, 0x8f, 0x3a, 0xf6, 0x37, 0xe3, 0x3d, 0xaa, 0x5f, 0x3d, - 0x4c, 0x07, 0x26, 0x8f, 0x6b, 0xce, 0x15, 0x0c, 0x89, 0x1b, 0x9c, 0xf2, 0x33, 0xb0, - ], + key: [0x06, 0x40, 0x3c, 0x31, 0xe0, 0x94, 0x4b, 0x39, 0xc6, 0x8f, 0x3a, 0xf6, 0x37, 0xe3, 0x3d, 0xaa, 0x5f, 0x3d, 0x4c, 0x07, 0x26, 0x8f, 0x6b, 0xce, 0x15, 0x0c, 0x89, 0x1b, 0x9c, 0xf2, 0x33, 0xb0], len: 7200, - sha: [ - 0xbb, 0x46, 0xb0, 0x53, 0xaf, 0x13, 0x94, 0xc4, 0x62, 0x17, 0x39, 0x3b, 0x4f, 0x7e, 0xff, 0xc1, 0xc9, 0x5f, - 0xc4, 0x8a, 0xa5, 0x54, 0x68, 0x2a, 0xfb, 0xa5, 0xea, 0xeb, 0x0c, 0xd9, 0xc0, 0x6a, - ], + sha: [0xbb, 0x46, 0xb0, 0x53, 0xaf, 0x13, 0x94, 0xc4, 0x62, 0x17, 0x39, 0x3b, 0x4f, 0x7e, 0xff, 0xc1, 0xc9, 0x5f, 0xc4, 0x8a, 0xa5, 0x54, 0x68, 0x2a, 0xfb, 0xa5, 0xea, 0xeb, 0x0c, 0xd9, 0xc0, 0x6a], ptx: concat!(include_str!("../ptx-sm86/q8_1_quantize.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_gr_norm.ptx", - key: [ - 0x06, 0xd6, 0x17, 0x7b, 0x48, 0x2c, 0xb6, 0x74, 0x13, 0xc6, 0x59, 0x6a, 0x02, 0x91, 0xb4, 0xda, 0xb1, 0x85, - 0x03, 0x32, 0x16, 0x4a, 0x92, 0x12, 0xaf, 0xf6, 0x7b, 0x9e, 0xfd, 0xf2, 0x11, 0x20, - ], + key: [0x06, 0xd6, 0x17, 0x7b, 0x48, 0x2c, 0xb6, 0x74, 0x13, 0xc6, 0x59, 0x6a, 0x02, 0x91, 0xb4, 0xda, 0xb1, 0x85, 0x03, 0x32, 0x16, 0x4a, 0x92, 0x12, 0xaf, 0xf6, 0x7b, 0x9e, 0xfd, 0xf2, 0x11, 0x20], len: 29069, - sha: [ - 0xaa, 0x51, 0x98, 0x13, 0x94, 0xa9, 0x4a, 0xe2, 0x22, 0xf4, 0x4c, 0x23, 0x9d, 0xff, 0x1e, 0xf2, 0x3c, 0xa7, - 0xab, 0xda, 0x2a, 0xb0, 0x8f, 0x17, 0x95, 0x43, 0xd6, 0x2e, 0x71, 0x19, 0xd2, 0x1a, - ], + sha: [0xaa, 0x51, 0x98, 0x13, 0x94, 0xa9, 0x4a, 0xe2, 0x22, 0xf4, 0x4c, 0x23, 0x9d, 0xff, 0x1e, 0xf2, 0x3c, 0xa7, 0xab, 0xda, 0x2a, 0xb0, 0x8f, 0x17, 0x95, 0x43, 0xd6, 0x2e, 0x71, 0x19, 0xd2, 0x1a], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_gr_norm.ptx"), "\0").as_bytes(), }, Companion { name: "offline_moe_prefill.ptx", - key: [ - 0x07, 0x5e, 0xf4, 0x38, 0xcd, 0xb6, 0x21, 0x15, 0x05, 0x46, 0xdb, 0xef, 0xf8, 0xf5, 0xe6, 0xfd, 0xc4, 0xaa, - 0xeb, 0xc2, 0xe7, 0xfa, 0x10, 0x99, 0xe6, 0xcc, 0x6e, 0xff, 0x3f, 0x5b, 0x6f, 0x34, - ], + key: [0x07, 0x5e, 0xf4, 0x38, 0xcd, 0xb6, 0x21, 0x15, 0x05, 0x46, 0xdb, 0xef, 0xf8, 0xf5, 0xe6, 0xfd, 0xc4, 0xaa, 0xeb, 0xc2, 0xe7, 0xfa, 0x10, 0x99, 0xe6, 0xcc, 0x6e, 0xff, 0x3f, 0x5b, 0x6f, 0x34], len: 71011, - sha: [ - 0xe1, 0x5e, 0x02, 0x23, 0xec, 0x1d, 0x55, 0x5a, 0x3b, 0x89, 0xd7, 0xcb, 0xe3, 0xa6, 0xe9, 0xa0, 0xfe, 0x45, - 0xb6, 0x5d, 0x39, 0x02, 0x90, 0x10, 0xd5, 0x19, 0xc7, 0x31, 0x32, 0x48, 0xcc, 0x7f, - ], + sha: [0xe1, 0x5e, 0x02, 0x23, 0xec, 0x1d, 0x55, 0x5a, 0x3b, 0x89, 0xd7, 0xcb, 0xe3, 0xa6, 0xe9, 0xa0, 0xfe, 0x45, 0xb6, 0x5d, 0x39, 0x02, 0x90, 0x10, 0xd5, 0x19, 0xc7, 0x31, 0x32, 0x48, 0xcc, 0x7f], ptx: concat!(include_str!("../ptx-sm86/offline_moe_prefill.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_down_iq4_nl.ptx", - key: [ - 0x0b, 0x7b, 0xa2, 0xb0, 0x0b, 0x91, 0xb6, 0x64, 0x50, 0x51, 0x82, 0xbe, 0xf3, 0x2c, 0xac, 0xad, 0x06, 0x3f, - 0x11, 0xee, 0x37, 0xed, 0x93, 0x13, 0x29, 0x64, 0x8d, 0x3e, 0xe4, 0xa0, 0x4d, 0x5a, - ], + key: [0x0b, 0x7b, 0xa2, 0xb0, 0x0b, 0x91, 0xb6, 0x64, 0x50, 0x51, 0x82, 0xbe, 0xf3, 0x2c, 0xac, 0xad, 0x06, 0x3f, 0x11, 0xee, 0x37, 0xed, 0x93, 0x13, 0x29, 0x64, 0x8d, 0x3e, 0xe4, 0xa0, 0x4d, 0x5a], len: 8620, - sha: [ - 0x7d, 0xcf, 0xdb, 0x60, 0x83, 0x16, 0xcb, 0x28, 0xf0, 0x77, 0x6a, 0x10, 0xf8, 0x40, 0xb1, 0x98, 0x81, 0x43, - 0x5c, 0x75, 0xb7, 0xf4, 0xf2, 0x2b, 0xa2, 0xc3, 0xfe, 0xf9, 0xe5, 0xbb, 0x89, 0xcb, - ], + sha: [0x7d, 0xcf, 0xdb, 0x60, 0x83, 0x16, 0xcb, 0x28, 0xf0, 0x77, 0x6a, 0x10, 0xf8, 0x40, 0xb1, 0x98, 0x81, 0x43, 0x5c, 0x75, 0xb7, 0xf4, 0xf2, 0x2b, 0xa2, 0xc3, 0xfe, 0xf9, 0xe5, 0xbb, 0x89, 0xcb], ptx: concat!(include_str!("../ptx-sm86/moe_group_down_iq4_nl.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_s2_fixed.ptx", - key: [ - 0x0b, 0xf7, 0xb8, 0x12, 0x8c, 0x2d, 0x59, 0x0e, 0x36, 0xc8, 0xc5, 0x55, 0x97, 0xb4, 0xd0, 0x2f, 0x3c, 0x50, - 0x7e, 0x12, 0x0f, 0x3d, 0x09, 0x1c, 0xb3, 0x54, 0xea, 0xee, 0x9e, 0x09, 0x74, 0xf7, - ], + key: [0x0b, 0xf7, 0xb8, 0x12, 0x8c, 0x2d, 0x59, 0x0e, 0x36, 0xc8, 0xc5, 0x55, 0x97, 0xb4, 0xd0, 0x2f, 0x3c, 0x50, 0x7e, 0x12, 0x0f, 0x3d, 0x09, 0x1c, 0xb3, 0x54, 0xea, 0xee, 0x9e, 0x09, 0x74, 0xf7], len: 103812, - sha: [ - 0x97, 0xef, 0x26, 0x18, 0x0d, 0x6c, 0xa0, 0xa6, 0xc3, 0xb4, 0xe2, 0x8c, 0x55, 0x5b, 0xf4, 0x94, 0x12, 0x17, - 0x5b, 0x7c, 0x65, 0x2d, 0x71, 0xa3, 0x1d, 0xc4, 0xee, 0x09, 0x7d, 0xc2, 0xc1, 0xb2, - ], + sha: [0x97, 0xef, 0x26, 0x18, 0x0d, 0x6c, 0xa0, 0xa6, 0xc3, 0xb4, 0xe2, 0x8c, 0x55, 0x5b, 0xf4, 0x94, 0x12, 0x17, 0x5b, 0x7c, 0x65, 0x2d, 0x71, 0xa3, 0x1d, 0xc4, 0xee, 0x09, 0x7d, 0xc2, 0xc1, 0xb2], ptx: concat!(include_str!("../ptx-sm86/mtp_s2_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "mmq-adaptive-selected.ptx", - key: [ - 0x0c, 0x7f, 0xa1, 0x08, 0x28, 0x02, 0x0b, 0x9e, 0xc8, 0x9b, 0x8b, 0x2f, 0xe5, 0x85, 0x50, 0x2c, 0x84, 0x89, - 0xbe, 0x92, 0xf1, 0xf8, 0x25, 0x18, 0x7d, 0x4c, 0x6b, 0x90, 0xf1, 0x06, 0x49, 0x48, - ], + key: [0x0c, 0x7f, 0xa1, 0x08, 0x28, 0x02, 0x0b, 0x9e, 0xc8, 0x9b, 0x8b, 0x2f, 0xe5, 0x85, 0x50, 0x2c, 0x84, 0x89, 0xbe, 0x92, 0xf1, 0xf8, 0x25, 0x18, 0x7d, 0x4c, 0x6b, 0x90, 0xf1, 0x06, 0x49, 0x48], len: 3249625, - sha: [ - 0x3f, 0x3c, 0xbc, 0x5f, 0x2d, 0x2d, 0xc8, 0x23, 0x83, 0xb1, 0x5a, 0x0d, 0xaf, 0xf0, 0x7f, 0xb6, 0x77, 0xcc, - 0x4e, 0x45, 0xfb, 0x35, 0x73, 0x7d, 0xdc, 0x61, 0x41, 0x2f, 0xff, 0x3f, 0x79, 0x2c, - ], + sha: [0x3f, 0x3c, 0xbc, 0x5f, 0x2d, 0x2d, 0xc8, 0x23, 0x83, 0xb1, 0x5a, 0x0d, 0xaf, 0xf0, 0x7f, 0xb6, 0x77, 0xcc, 0x4e, 0x45, 0xfb, 0x35, 0x73, 0x7d, 0xdc, 0x61, 0x41, 0x2f, 0xff, 0x3f, 0x79, 0x2c], ptx: concat!(include_str!("../ptx-sm86/mmq-adaptive-selected.ptx"), "\0").as_bytes(), }, Companion { name: "mapped_expert_copy.ptx", - key: [ - 0x10, 0x51, 0x98, 0x85, 0xee, 0x9d, 0xab, 0xb6, 0x00, 0x10, 0x15, 0x4e, 0x2f, 0x80, 0x9b, 0x39, 0x73, 0x61, - 0x86, 0xba, 0x1c, 0x0d, 0xac, 0x11, 0xa2, 0x40, 0x96, 0x5d, 0x05, 0x77, 0x62, 0x57, - ], + key: [0x10, 0x51, 0x98, 0x85, 0xee, 0x9d, 0xab, 0xb6, 0x00, 0x10, 0x15, 0x4e, 0x2f, 0x80, 0x9b, 0x39, 0x73, 0x61, 0x86, 0xba, 0x1c, 0x0d, 0xac, 0x11, 0xa2, 0x40, 0x96, 0x5d, 0x05, 0x77, 0x62, 0x57], len: 5620, - sha: [ - 0x11, 0xda, 0x70, 0xf0, 0x16, 0x18, 0xa2, 0xa6, 0xf9, 0xd6, 0x59, 0xa6, 0xda, 0x03, 0xbb, 0x90, 0x48, 0x0d, - 0x4c, 0xbd, 0x14, 0x1d, 0x3c, 0x36, 0x6c, 0xfe, 0x90, 0xc2, 0x65, 0x9d, 0x11, 0xb0, - ], + sha: [0x11, 0xda, 0x70, 0xf0, 0x16, 0x18, 0xa2, 0xa6, 0xf9, 0xd6, 0x59, 0xa6, 0xda, 0x03, 0xbb, 0x90, 0x48, 0x0d, 0x4c, 0xbd, 0x14, 0x1d, 0x3c, 0x36, 0x6c, 0xfe, 0x90, 0xc2, 0x65, 0x9d, 0x11, 0xb0], ptx: concat!(include_str!("../ptx-sm86/mapped_expert_copy.ptx"), "\0").as_bytes(), }, Companion { name: "original_verify_window_qsa_gate.ptx", - key: [ - 0x10, 0x80, 0x7c, 0x4c, 0x62, 0xd8, 0xbf, 0x4b, 0xe7, 0x5c, 0xfb, 0x1a, 0x50, 0x77, 0xfc, 0x3e, 0x00, 0xdc, - 0x8f, 0x40, 0xea, 0x66, 0x9b, 0x22, 0xdc, 0xff, 0x7b, 0x78, 0x53, 0xab, 0x79, 0x49, - ], + key: [0x10, 0x80, 0x7c, 0x4c, 0x62, 0xd8, 0xbf, 0x4b, 0xe7, 0x5c, 0xfb, 0x1a, 0x50, 0x77, 0xfc, 0x3e, 0x00, 0xdc, 0x8f, 0x40, 0xea, 0x66, 0x9b, 0x22, 0xdc, 0xff, 0x7b, 0x78, 0x53, 0xab, 0x79, 0x49], len: 2232, - sha: [ - 0x0c, 0x13, 0xa5, 0xf2, 0x95, 0x3f, 0x70, 0x7b, 0xb2, 0x87, 0xbc, 0x53, 0x25, 0x83, 0xf3, 0xfd, 0x69, 0xae, - 0x8e, 0x80, 0xa7, 0x6e, 0x61, 0xdc, 0x88, 0x27, 0xe1, 0x3f, 0x00, 0x6b, 0x48, 0x49, - ], + sha: [0x0c, 0x13, 0xa5, 0xf2, 0x95, 0x3f, 0x70, 0x7b, 0xb2, 0x87, 0xbc, 0x53, 0x25, 0x83, 0xf3, 0xfd, 0x69, 0xae, 0x8e, 0x80, 0xa7, 0x6e, 0x61, 0xdc, 0x88, 0x27, 0xe1, 0x3f, 0x00, 0x6b, 0x48, 0x49], ptx: concat!(include_str!("../ptx-sm86/original_verify_window_qsa_gate.ptx"), "\0").as_bytes(), }, Companion { name: "gr_native_batch.ptx", - key: [ - 0x10, 0xa3, 0xe8, 0x36, 0xb9, 0x02, 0xe9, 0xa3, 0x87, 0x05, 0x5e, 0x98, 0x0c, 0x3e, 0xd0, 0x45, 0xe9, 0x0b, - 0xdc, 0x25, 0x1e, 0xe1, 0xe6, 0xbe, 0x57, 0x66, 0x81, 0x61, 0x8f, 0x62, 0x1d, 0xb2, - ], + key: [0x10, 0xa3, 0xe8, 0x36, 0xb9, 0x02, 0xe9, 0xa3, 0x87, 0x05, 0x5e, 0x98, 0x0c, 0x3e, 0xd0, 0x45, 0xe9, 0x0b, 0xdc, 0x25, 0x1e, 0xe1, 0xe6, 0xbe, 0x57, 0x66, 0x81, 0x61, 0x8f, 0x62, 0x1d, 0xb2], len: 29664, - sha: [ - 0xda, 0xec, 0x53, 0x68, 0x4c, 0x0c, 0xc3, 0x08, 0x8d, 0x46, 0xe9, 0x24, 0x14, 0x2d, 0xd3, 0x61, 0x32, 0xa5, - 0x9f, 0xb7, 0x87, 0x16, 0x56, 0x94, 0xd1, 0x48, 0x27, 0xaf, 0xd3, 0x10, 0xd9, 0xc9, - ], + sha: [0xda, 0xec, 0x53, 0x68, 0x4c, 0x0c, 0xc3, 0x08, 0x8d, 0x46, 0xe9, 0x24, 0x14, 0x2d, 0xd3, 0x61, 0x32, 0xa5, 0x9f, 0xb7, 0x87, 0x16, 0x56, 0x94, 0xd1, 0x48, 0x27, 0xaf, 0xd3, 0x10, 0xd9, 0xc9], ptx: concat!(include_str!("../ptx-sm86/gr_native_batch.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_checks.ptx", - key: [ - 0x16, 0xcb, 0x9f, 0x01, 0xe5, 0x4b, 0x05, 0x33, 0x43, 0x99, 0x37, 0xdd, 0x09, 0xae, 0xa4, 0xcc, 0xf9, 0x8d, - 0xf7, 0x36, 0x76, 0xeb, 0x2b, 0x79, 0x62, 0x98, 0xac, 0x72, 0xe1, 0x27, 0xa5, 0x91, - ], + key: [0x16, 0xcb, 0x9f, 0x01, 0xe5, 0x4b, 0x05, 0x33, 0x43, 0x99, 0x37, 0xdd, 0x09, 0xae, 0xa4, 0xcc, 0xf9, 0x8d, 0xf7, 0x36, 0x76, 0xeb, 0x2b, 0x79, 0x62, 0x98, 0xac, 0x72, 0xe1, 0x27, 0xa5, 0x91], len: 115865, - sha: [ - 0x70, 0x7a, 0xd0, 0xce, 0x70, 0xa3, 0x2b, 0x33, 0x34, 0x8b, 0x26, 0x48, 0xfd, 0xfe, 0x44, 0xaa, 0xe0, 0xd1, - 0xfa, 0x1c, 0x43, 0x0a, 0x97, 0xe7, 0x39, 0x64, 0x2e, 0x4b, 0xc3, 0x38, 0x1e, 0x62, - ], + sha: [0x70, 0x7a, 0xd0, 0xce, 0x70, 0xa3, 0x2b, 0x33, 0x34, 0x8b, 0x26, 0x48, 0xfd, 0xfe, 0x44, 0xaa, 0xe0, 0xd1, 0xfa, 0x1c, 0x43, 0x0a, 0x97, 0xe7, 0x39, 0x64, 0x2e, 0x4b, 0xc3, 0x38, 0x1e, 0x62], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_checks.ptx"), "\0").as_bytes(), }, Companion { name: "iq4_nl_q8_1.ptx", - key: [ - 0x18, 0x9b, 0x02, 0xce, 0xe8, 0x18, 0x63, 0x79, 0xfb, 0x7b, 0x0b, 0xd0, 0x7a, 0x83, 0x1e, 0x1f, 0xb2, 0x76, - 0x4d, 0x29, 0xa9, 0x8a, 0x17, 0xfd, 0x2b, 0x51, 0x6c, 0x54, 0x59, 0xf9, 0xd4, 0xce, - ], + key: [0x18, 0x9b, 0x02, 0xce, 0xe8, 0x18, 0x63, 0x79, 0xfb, 0x7b, 0x0b, 0xd0, 0x7a, 0x83, 0x1e, 0x1f, 0xb2, 0x76, 0x4d, 0x29, 0xa9, 0x8a, 0x17, 0xfd, 0x2b, 0x51, 0x6c, 0x54, 0x59, 0xf9, 0xd4, 0xce], len: 38554, - sha: [ - 0xeb, 0x57, 0xbb, 0xff, 0x87, 0x55, 0x63, 0x75, 0xe2, 0xf9, 0x84, 0x95, 0x5b, 0x7d, 0x28, 0x9d, 0xf1, 0xfc, - 0xab, 0xf8, 0xca, 0x20, 0x84, 0x88, 0xfa, 0x73, 0xbb, 0x3d, 0xc2, 0xe8, 0x11, 0x76, - ], + sha: [0xeb, 0x57, 0xbb, 0xff, 0x87, 0x55, 0x63, 0x75, 0xe2, 0xf9, 0x84, 0x95, 0x5b, 0x7d, 0x28, 0x9d, 0xf1, 0xfc, 0xab, 0xf8, 0xca, 0x20, 0x84, 0x88, 0xfa, 0x73, 0xbb, 0x3d, 0xc2, 0xe8, 0x11, 0x76], ptx: concat!(include_str!("../ptx-sm86/iq4_nl_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "experimental_cvec.ptx", - key: [ - 0x19, 0x3a, 0xdd, 0x5c, 0xb4, 0x48, 0xf5, 0xe1, 0x93, 0xf2, 0x0f, 0xf2, 0x48, 0xca, 0x44, 0x59, 0xab, 0xb9, - 0x62, 0xb4, 0x72, 0x66, 0x3c, 0x00, 0xd1, 0x89, 0x41, 0x31, 0x3b, 0xfa, 0x3e, 0xbc, - ], + key: [0x19, 0x3a, 0xdd, 0x5c, 0xb4, 0x48, 0xf5, 0xe1, 0x93, 0xf2, 0x0f, 0xf2, 0x48, 0xca, 0x44, 0x59, 0xab, 0xb9, 0x62, 0xb4, 0x72, 0x66, 0x3c, 0x00, 0xd1, 0x89, 0x41, 0x31, 0x3b, 0xfa, 0x3e, 0xbc], len: 28943, - sha: [ - 0x09, 0x43, 0xc5, 0xc0, 0x4e, 0xf8, 0x63, 0x4b, 0x8e, 0xb6, 0x11, 0x33, 0x32, 0x9a, 0xd7, 0x30, 0xf6, 0xbc, - 0x39, 0xdc, 0x4e, 0x55, 0xce, 0x9a, 0xc6, 0x25, 0x87, 0x1f, 0xa1, 0x62, 0x58, 0x78, - ], + sha: [0x09, 0x43, 0xc5, 0xc0, 0x4e, 0xf8, 0x63, 0x4b, 0x8e, 0xb6, 0x11, 0x33, 0x32, 0x9a, 0xd7, 0x30, 0xf6, 0xbc, 0x39, 0xdc, 0x4e, 0x55, 0xce, 0x9a, 0xc6, 0x25, 0x87, 0x1f, 0xa1, 0x62, 0x58, 0x78], ptx: concat!(include_str!("../ptx-sm86/experimental_cvec.ptx"), "\0").as_bytes(), }, Companion { name: "experimental_keyless.ptx", - key: [ - 0x1a, 0xb8, 0xb8, 0x15, 0x6e, 0x8c, 0x82, 0x41, 0x31, 0xc0, 0x0c, 0xec, 0xda, 0x17, 0x7f, 0xe5, 0x7d, 0x74, - 0xb2, 0x86, 0xa0, 0x2b, 0x7e, 0x5a, 0xfd, 0xfa, 0x39, 0xac, 0xad, 0xaa, 0x33, 0xe6, - ], + key: [0x1a, 0xb8, 0xb8, 0x15, 0x6e, 0x8c, 0x82, 0x41, 0x31, 0xc0, 0x0c, 0xec, 0xda, 0x17, 0x7f, 0xe5, 0x7d, 0x74, 0xb2, 0x86, 0xa0, 0x2b, 0x7e, 0x5a, 0xfd, 0xfa, 0x39, 0xac, 0xad, 0xaa, 0x33, 0xe6], len: 3760, - sha: [ - 0x0a, 0x16, 0xc1, 0x19, 0x5e, 0x25, 0x74, 0x7c, 0xb0, 0x7b, 0x18, 0x34, 0xf7, 0xc4, 0x52, 0xb8, 0x91, 0x0c, - 0x27, 0xac, 0x2b, 0x7d, 0x30, 0xb9, 0xf6, 0x68, 0x7d, 0x28, 0xcc, 0x76, 0xb8, 0xb9, - ], + sha: [0x0a, 0x16, 0xc1, 0x19, 0x5e, 0x25, 0x74, 0x7c, 0xb0, 0x7b, 0x18, 0x34, 0xf7, 0xc4, 0x52, 0xb8, 0x91, 0x0c, 0x27, 0xac, 0x2b, 0x7d, 0x30, 0xb9, 0xf6, 0x68, 0x7d, 0x28, 0xcc, 0x76, 0xb8, 0xb9], ptx: concat!(include_str!("../ptx-sm86/experimental_keyless.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_attention.ptx", - key: [ - 0x1c, 0x89, 0xe6, 0xcb, 0xc8, 0xbb, 0x52, 0xb4, 0x64, 0x96, 0xa1, 0xca, 0xe3, 0x14, 0x3a, 0x8a, 0xd6, 0xcb, - 0x8e, 0x8d, 0xb7, 0x0f, 0x4e, 0x6d, 0x5a, 0x87, 0x4d, 0x59, 0xfd, 0xdd, 0x4a, 0x07, - ], + key: [0x1c, 0x89, 0xe6, 0xcb, 0xc8, 0xbb, 0x52, 0xb4, 0x64, 0x96, 0xa1, 0xca, 0xe3, 0x14, 0x3a, 0x8a, 0xd6, 0xcb, 0x8e, 0x8d, 0xb7, 0x0f, 0x4e, 0x6d, 0x5a, 0x87, 0x4d, 0x59, 0xfd, 0xdd, 0x4a, 0x07], len: 96184, - sha: [ - 0xf3, 0x2c, 0x26, 0xe3, 0xdf, 0x42, 0xa4, 0xa2, 0xda, 0x00, 0xf2, 0xa9, 0x79, 0x1e, 0x1a, 0xb8, 0x98, 0x41, - 0x61, 0xe8, 0x9e, 0x20, 0x3e, 0xdf, 0x88, 0x0a, 0xdc, 0xc8, 0x30, 0xe2, 0x43, 0x5c, - ], + sha: [0xf3, 0x2c, 0x26, 0xe3, 0xdf, 0x42, 0xa4, 0xa2, 0xda, 0x00, 0xf2, 0xa9, 0x79, 0x1e, 0x1a, 0xb8, 0x98, 0x41, 0x61, 0xe8, 0x9e, 0x20, 0x3e, 0xdf, 0x88, 0x0a, 0xdc, 0xc8, 0x30, 0xe2, 0x43, 0x5c], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_attention.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_select.ptx", - key: [ - 0x1e, 0x35, 0x51, 0x47, 0x44, 0x21, 0x62, 0x29, 0xb0, 0xcf, 0xfb, 0x4f, 0x45, 0xd2, 0xf1, 0x3f, 0x25, 0xcb, - 0x95, 0xf3, 0x77, 0xa3, 0x0c, 0x1c, 0x01, 0x25, 0x43, 0xdb, 0xf5, 0x3a, 0x1c, 0x2d, - ], + key: [0x1e, 0x35, 0x51, 0x47, 0x44, 0x21, 0x62, 0x29, 0xb0, 0xcf, 0xfb, 0x4f, 0x45, 0xd2, 0xf1, 0x3f, 0x25, 0xcb, 0x95, 0xf3, 0x77, 0xa3, 0x0c, 0x1c, 0x01, 0x25, 0x43, 0xdb, 0xf5, 0x3a, 0x1c, 0x2d], len: 97179, - sha: [ - 0x38, 0xef, 0x04, 0x0e, 0xff, 0x7b, 0x93, 0xe2, 0xaf, 0x2c, 0x15, 0x3f, 0xb1, 0xd9, 0x35, 0x24, 0xbd, 0xf1, - 0x65, 0x42, 0x8a, 0xa2, 0xf8, 0xcf, 0xbd, 0xa5, 0x08, 0x3e, 0xc4, 0x07, 0x1d, 0xf3, - ], + sha: [0x38, 0xef, 0x04, 0x0e, 0xff, 0x7b, 0x93, 0xe2, 0xaf, 0x2c, 0x15, 0x3f, 0xb1, 0xd9, 0x35, 0x24, 0xbd, 0xf1, 0x65, 0x42, 0x8a, 0xa2, 0xf8, 0xcf, 0xbd, 0xa5, 0x08, 0x3e, 0xc4, 0x07, 0x1d, 0xf3], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_select.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_iq2_s.ptx", - key: [ - 0x1e, 0x5c, 0x05, 0x7c, 0xfb, 0x36, 0xd3, 0x51, 0xcc, 0xb2, 0xba, 0x54, 0x6c, 0xf2, 0x95, 0xd1, 0x3b, 0xfa, - 0x00, 0x30, 0x65, 0xeb, 0x9b, 0x41, 0x5b, 0xf0, 0xc0, 0x11, 0x8b, 0xd4, 0x80, 0x4a, - ], + key: [0x1e, 0x5c, 0x05, 0x7c, 0xfb, 0x36, 0xd3, 0x51, 0xcc, 0xb2, 0xba, 0x54, 0x6c, 0xf2, 0x95, 0xd1, 0x3b, 0xfa, 0x00, 0x30, 0x65, 0xeb, 0x9b, 0x41, 0x5b, 0xf0, 0xc0, 0x11, 0x8b, 0xd4, 0x80, 0x4a], len: 42048, - sha: [ - 0xe8, 0xcb, 0x46, 0x20, 0xf1, 0xe2, 0xcf, 0x38, 0xd5, 0x6b, 0x87, 0x55, 0x33, 0xc3, 0x9e, 0x27, 0x95, 0x94, - 0x86, 0x2f, 0x77, 0x9e, 0x73, 0x1e, 0x50, 0x1d, 0xed, 0x50, 0xb2, 0xf8, 0xf5, 0x92, - ], + sha: [0xe8, 0xcb, 0x46, 0x20, 0xf1, 0xe2, 0xcf, 0x38, 0xd5, 0x6b, 0x87, 0x55, 0x33, 0xc3, 0x9e, 0x27, 0x95, 0x94, 0x86, 0x2f, 0x77, 0x9e, 0x73, 0x1e, 0x50, 0x1d, 0xed, 0x50, 0xb2, 0xf8, 0xf5, 0x92], ptx: concat!(include_str!("../ptx-sm86/moe_group_iq2_s.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_qsa_gate.ptx", - key: [ - 0x21, 0xf1, 0xa0, 0x14, 0xbf, 0xa0, 0x59, 0x74, 0x3a, 0x7c, 0x9d, 0x55, 0x3a, 0x46, 0x15, 0xf5, 0x48, 0x82, - 0x0b, 0xb4, 0xe7, 0xc4, 0x8f, 0x4e, 0xf1, 0xd7, 0x1f, 0x05, 0x07, 0x7b, 0x4b, 0x25, - ], + key: [0x21, 0xf1, 0xa0, 0x14, 0xbf, 0xa0, 0x59, 0x74, 0x3a, 0x7c, 0x9d, 0x55, 0x3a, 0x46, 0x15, 0xf5, 0x48, 0x82, 0x0b, 0xb4, 0xe7, 0xc4, 0x8f, 0x4e, 0xf1, 0xd7, 0x1f, 0x05, 0x07, 0x7b, 0x4b, 0x25], len: 26053, - sha: [ - 0xb4, 0x22, 0x8c, 0x01, 0x5b, 0xb0, 0xb0, 0x62, 0x6d, 0x31, 0x40, 0x62, 0x77, 0x20, 0x94, 0x39, 0x0a, 0xd3, - 0xba, 0xa6, 0x86, 0x64, 0xd7, 0x29, 0x9b, 0x2a, 0x17, 0x11, 0x80, 0xa4, 0x7c, 0x64, - ], + sha: [0xb4, 0x22, 0x8c, 0x01, 0x5b, 0xb0, 0xb0, 0x62, 0x6d, 0x31, 0x40, 0x62, 0x77, 0x20, 0x94, 0x39, 0x0a, 0xd3, 0xba, 0xa6, 0x86, 0x64, 0xd7, 0x29, 0x9b, 0x2a, 0x17, 0x11, 0x80, 0xa4, 0x7c, 0x64], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_qsa_gate.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_combine.ptx", - key: [ - 0x22, 0x53, 0xfe, 0x2d, 0x64, 0x13, 0x50, 0xf4, 0x44, 0x5a, 0x0a, 0x69, 0xc4, 0xa0, 0xfc, 0x22, 0xb8, 0x5c, - 0x2f, 0xff, 0xca, 0x7c, 0xbd, 0x53, 0x6f, 0xfe, 0x5d, 0x29, 0x12, 0xf8, 0x1f, 0xb7, - ], + key: [0x22, 0x53, 0xfe, 0x2d, 0x64, 0x13, 0x50, 0xf4, 0x44, 0x5a, 0x0a, 0x69, 0xc4, 0xa0, 0xfc, 0x22, 0xb8, 0x5c, 0x2f, 0xff, 0xca, 0x7c, 0xbd, 0x53, 0x6f, 0xfe, 0x5d, 0x29, 0x12, 0xf8, 0x1f, 0xb7], len: 12958, - sha: [ - 0x6e, 0x0f, 0xba, 0x41, 0xea, 0x8b, 0x0f, 0xe6, 0x0b, 0x1f, 0xc5, 0x1e, 0xb3, 0xe7, 0x0f, 0x5f, 0xc9, 0xb3, - 0x51, 0x63, 0xce, 0xff, 0x1d, 0xb4, 0x36, 0xd6, 0x2e, 0xf6, 0x7e, 0x9a, 0xbd, 0xfe, - ], + sha: [0x6e, 0x0f, 0xba, 0x41, 0xea, 0x8b, 0x0f, 0xe6, 0x0b, 0x1f, 0xc5, 0x1e, 0xb3, 0xe7, 0x0f, 0x5f, 0xc9, 0xb3, 0x51, 0x63, 0xce, 0xff, 0x1d, 0xb4, 0x36, 0xd6, 0x2e, 0xf6, 0x7e, 0x9a, 0xbd, 0xfe], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_combine.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_scalar_gr.ptx", - key: [ - 0x24, 0x01, 0x60, 0x6b, 0x7e, 0xb4, 0x4a, 0xf8, 0x2a, 0x8b, 0x57, 0x48, 0x48, 0x6c, 0x72, 0xae, 0xc9, 0xc4, - 0x7a, 0x4c, 0x7d, 0xb0, 0x6e, 0x5a, 0xbf, 0xd3, 0x7d, 0xb3, 0x75, 0x64, 0x88, 0x6d, - ], + key: [0x24, 0x01, 0x60, 0x6b, 0x7e, 0xb4, 0x4a, 0xf8, 0x2a, 0x8b, 0x57, 0x48, 0x48, 0x6c, 0x72, 0xae, 0xc9, 0xc4, 0x7a, 0x4c, 0x7d, 0xb0, 0x6e, 0x5a, 0xbf, 0xd3, 0x7d, 0xb3, 0x75, 0x64, 0x88, 0x6d], len: 387485, - sha: [ - 0x89, 0xf9, 0xe9, 0x1d, 0xc7, 0xe3, 0x28, 0xa6, 0x7a, 0xd8, 0x7e, 0x02, 0xde, 0xae, 0x1c, 0x7a, 0x25, 0x56, - 0xe7, 0x4d, 0x05, 0x98, 0x40, 0xd8, 0xe0, 0x94, 0x2d, 0x8e, 0x85, 0xe2, 0xe5, 0xcb, - ], + sha: [0x89, 0xf9, 0xe9, 0x1d, 0xc7, 0xe3, 0x28, 0xa6, 0x7a, 0xd8, 0x7e, 0x02, 0xde, 0xae, 0x1c, 0x7a, 0x25, 0x56, 0xe7, 0x4d, 0x05, 0x98, 0x40, 0xd8, 0xe0, 0x94, 0x2d, 0x8e, 0x85, 0xe2, 0xe5, 0xcb], ptx: concat!(include_str!("../ptx-sm86/mtp_original_scalar_gr.ptx"), "\0").as_bytes(), }, Companion { name: "original_verify_window_moe_experts.ptx", - key: [ - 0x24, 0xd2, 0x8c, 0xcd, 0x9c, 0x3a, 0x5b, 0xbe, 0xdb, 0xeb, 0x93, 0x3b, 0x4f, 0xeb, 0x37, 0x6f, 0x84, 0x0a, - 0x74, 0xe2, 0x1a, 0x44, 0x82, 0x17, 0x48, 0x8c, 0x06, 0xee, 0x23, 0x82, 0x11, 0x57, - ], + key: [0x24, 0xd2, 0x8c, 0xcd, 0x9c, 0x3a, 0x5b, 0xbe, 0xdb, 0xeb, 0x93, 0x3b, 0x4f, 0xeb, 0x37, 0x6f, 0x84, 0x0a, 0x74, 0xe2, 0x1a, 0x44, 0x82, 0x17, 0x48, 0x8c, 0x06, 0xee, 0x23, 0x82, 0x11, 0x57], len: 991906, - sha: [ - 0xf6, 0xbe, 0xc9, 0xbb, 0x67, 0xe4, 0x5a, 0xa8, 0x40, 0x4f, 0xaa, 0xfd, 0x44, 0xdc, 0x30, 0xb7, 0x90, 0xbf, - 0x29, 0x08, 0xf4, 0x5f, 0x0c, 0x7b, 0xb0, 0xef, 0x86, 0xa0, 0x4e, 0xad, 0x97, 0x23, - ], + sha: [0xf6, 0xbe, 0xc9, 0xbb, 0x67, 0xe4, 0x5a, 0xa8, 0x40, 0x4f, 0xaa, 0xfd, 0x44, 0xdc, 0x30, 0xb7, 0x90, 0xbf, 0x29, 0x08, 0xf4, 0x5f, 0x0c, 0x7b, 0xb0, 0xef, 0x86, 0xa0, 0x4e, 0xad, 0x97, 0x23], ptx: concat!(include_str!("../ptx-sm86/original_verify_window_moe_experts.ptx"), "\0").as_bytes(), }, Companion { name: "q4_k_q8_1.ptx", - key: [ - 0x29, 0x4f, 0x3a, 0xd5, 0xfd, 0xdd, 0xf7, 0x96, 0x94, 0x13, 0x46, 0xc9, 0x14, 0x4f, 0xc4, 0x9d, 0x4c, 0xff, - 0x54, 0x78, 0xa8, 0x8d, 0xaa, 0xd6, 0xb8, 0x94, 0x1f, 0xbd, 0x4b, 0xb2, 0x40, 0xcb, - ], + key: [0x29, 0x4f, 0x3a, 0xd5, 0xfd, 0xdd, 0xf7, 0x96, 0x94, 0x13, 0x46, 0xc9, 0x14, 0x4f, 0xc4, 0x9d, 0x4c, 0xff, 0x54, 0x78, 0xa8, 0x8d, 0xaa, 0xd6, 0xb8, 0x94, 0x1f, 0xbd, 0x4b, 0xb2, 0x40, 0xcb], len: 28282, - sha: [ - 0x7c, 0xb5, 0xfa, 0x63, 0x73, 0x59, 0x81, 0x41, 0x7d, 0x57, 0x45, 0x76, 0xcf, 0xd8, 0x7e, 0x86, 0x43, 0xcf, - 0xea, 0xd8, 0x1b, 0x84, 0x75, 0x44, 0xf9, 0xf1, 0x4c, 0x09, 0x70, 0x2b, 0x3b, 0x60, - ], + sha: [0x7c, 0xb5, 0xfa, 0x63, 0x73, 0x59, 0x81, 0x41, 0x7d, 0x57, 0x45, 0x76, 0xcf, 0xd8, 0x7e, 0x86, 0x43, 0xcf, 0xea, 0xd8, 0x1b, 0x84, 0x75, 0x44, 0xf9, 0xf1, 0x4c, 0x09, 0x70, 0x2b, 0x3b, 0x60], ptx: concat!(include_str!("../ptx-sm86/q4_k_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "mmq-original-formats.ptx", - key: [ - 0x29, 0xd9, 0x2d, 0xea, 0x14, 0x09, 0x95, 0x86, 0xc5, 0x7c, 0x97, 0x0a, 0x36, 0x46, 0xa7, 0x8e, 0x63, 0x1a, - 0x49, 0x9a, 0x71, 0x57, 0xd5, 0x6a, 0xa0, 0xe2, 0x0a, 0xc1, 0xe0, 0xb4, 0x01, 0x36, - ], + key: [0x29, 0xd9, 0x2d, 0xea, 0x14, 0x09, 0x95, 0x86, 0xc5, 0x7c, 0x97, 0x0a, 0x36, 0x46, 0xa7, 0x8e, 0x63, 0x1a, 0x49, 0x9a, 0x71, 0x57, 0xd5, 0x6a, 0xa0, 0xe2, 0x0a, 0xc1, 0xe0, 0xb4, 0x01, 0x36], len: 2072448, - sha: [ - 0xe0, 0x6d, 0xad, 0xbb, 0x57, 0xa9, 0xf0, 0xdc, 0x0b, 0x20, 0xd8, 0xb4, 0x7f, 0xdd, 0x62, 0xa4, 0xc8, 0x46, - 0x75, 0xcc, 0xd4, 0x17, 0x0d, 0x42, 0x48, 0x95, 0x6c, 0x09, 0xb4, 0xfb, 0xd2, 0x1e, - ], + sha: [0xe0, 0x6d, 0xad, 0xbb, 0x57, 0xa9, 0xf0, 0xdc, 0x0b, 0x20, 0xd8, 0xb4, 0x7f, 0xdd, 0x62, 0xa4, 0xc8, 0x46, 0x75, 0xcc, 0xd4, 0x17, 0x0d, 0x42, 0x48, 0x95, 0x6c, 0x09, 0xb4, 0xfb, 0xd2, 0x1e], ptx: concat!(include_str!("../ptx-sm86/mmq-original-formats.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_prefill_fixup.ptx", - key: [ - 0x29, 0xfd, 0x3f, 0x75, 0x98, 0x64, 0x39, 0x75, 0x7c, 0x3a, 0x6e, 0xb1, 0x7d, 0x93, 0xe3, 0xed, 0x12, 0x4c, - 0xc4, 0x18, 0x51, 0x97, 0xa2, 0xb4, 0x45, 0x84, 0x10, 0xd1, 0xe7, 0xf7, 0xec, 0x4b, - ], + key: [0x29, 0xfd, 0x3f, 0x75, 0x98, 0x64, 0x39, 0x75, 0x7c, 0x3a, 0x6e, 0xb1, 0x7d, 0x93, 0xe3, 0xed, 0x12, 0x4c, 0xc4, 0x18, 0x51, 0x97, 0xa2, 0xb4, 0x45, 0x84, 0x10, 0xd1, 0xe7, 0xf7, 0xec, 0x4b], len: 325813, - sha: [ - 0x43, 0xa2, 0xa5, 0x24, 0x43, 0xcf, 0x7a, 0x2e, 0x2e, 0xe6, 0x58, 0xf5, 0x93, 0xb0, 0xfe, 0xb3, 0x93, 0x3d, - 0xb7, 0x37, 0x93, 0x69, 0xef, 0x19, 0x15, 0xfe, 0x23, 0x99, 0x6a, 0xca, 0xda, 0x84, - ], + sha: [0x43, 0xa2, 0xa5, 0x24, 0x43, 0xcf, 0x7a, 0x2e, 0x2e, 0xe6, 0x58, 0xf5, 0x93, 0xb0, 0xfe, 0xb3, 0x93, 0x3d, 0xb7, 0x37, 0x93, 0x69, 0xef, 0x19, 0x15, 0xfe, 0x23, 0x99, 0x6a, 0xca, 0xda, 0x84], ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_fixup.ptx"), "\0").as_bytes(), }, Companion { name: "iq4_xs_q8_1.ptx", - key: [ - 0x2c, 0x85, 0x3b, 0xad, 0xe2, 0xbb, 0x62, 0xb6, 0x71, 0x67, 0xb7, 0xcb, 0xe0, 0x03, 0x24, 0x61, 0x6c, 0x72, - 0x87, 0xc6, 0x0a, 0xb5, 0xfb, 0x8a, 0x41, 0xd2, 0xb5, 0x69, 0x01, 0x97, 0xf1, 0xb4, - ], + key: [0x2c, 0x85, 0x3b, 0xad, 0xe2, 0xbb, 0x62, 0xb6, 0x71, 0x67, 0xb7, 0xcb, 0xe0, 0x03, 0x24, 0x61, 0x6c, 0x72, 0x87, 0xc6, 0x0a, 0xb5, 0xfb, 0x8a, 0x41, 0xd2, 0xb5, 0x69, 0x01, 0x97, 0xf1, 0xb4], len: 62854, - sha: [ - 0x49, 0xbf, 0x1b, 0x11, 0x6a, 0xd9, 0xa8, 0x42, 0x7d, 0x7b, 0x64, 0x01, 0xae, 0x41, 0x4a, 0x2b, 0xd7, 0x81, - 0x3c, 0x74, 0x4d, 0x96, 0x8a, 0x99, 0x26, 0xb9, 0xcc, 0x4a, 0x22, 0x3e, 0x96, 0xd6, - ], + sha: [0x49, 0xbf, 0x1b, 0x11, 0x6a, 0xd9, 0xa8, 0x42, 0x7d, 0x7b, 0x64, 0x01, 0xae, 0x41, 0x4a, 0x2b, 0xd7, 0x81, 0x3c, 0x74, 0x4d, 0x96, 0x8a, 0x99, 0x26, 0xb9, 0xcc, 0x4a, 0x22, 0x3e, 0x96, 0xd6], ptx: concat!(include_str!("../ptx-sm86/iq4_xs_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "mmq-fixup-selected.ptx", - key: [ - 0x32, 0xa0, 0xc8, 0xc5, 0x45, 0x8b, 0xce, 0x5f, 0x2e, 0x07, 0xc7, 0x95, 0x7e, 0x39, 0xaa, 0x97, 0xbe, 0xac, - 0x8d, 0x79, 0xbf, 0xad, 0x4a, 0x95, 0x4c, 0x91, 0xdc, 0xe3, 0x97, 0xa4, 0x79, 0x71, - ], + key: [0x32, 0xa0, 0xc8, 0xc5, 0x45, 0x8b, 0xce, 0x5f, 0x2e, 0x07, 0xc7, 0x95, 0x7e, 0x39, 0xaa, 0x97, 0xbe, 0xac, 0x8d, 0x79, 0xbf, 0xad, 0x4a, 0x95, 0x4c, 0x91, 0xdc, 0xe3, 0x97, 0xa4, 0x79, 0x71], len: 183342, - sha: [ - 0xbd, 0x2a, 0x21, 0xaa, 0x98, 0x59, 0xc3, 0x1d, 0x70, 0x97, 0x9d, 0x89, 0x7c, 0xe7, 0xb7, 0x9c, 0xd4, 0x48, - 0x3c, 0xde, 0xd8, 0x0a, 0x3b, 0x11, 0xbc, 0x24, 0x24, 0xdc, 0x13, 0xbc, 0x67, 0x0c, - ], + sha: [0xbd, 0x2a, 0x21, 0xaa, 0x98, 0x59, 0xc3, 0x1d, 0x70, 0x97, 0x9d, 0x89, 0x7c, 0xe7, 0xb7, 0x9c, 0xd4, 0x48, 0x3c, 0xde, 0xd8, 0x0a, 0x3b, 0x11, 0xbc, 0x24, 0x24, 0xdc, 0x13, 0xbc, 0x67, 0x0c], ptx: concat!(include_str!("../ptx-sm86/mmq-fixup-selected.ptx"), "\0").as_bytes(), }, Companion { name: "q8_0_q8_1.ptx", - key: [ - 0x34, 0x1a, 0xbb, 0xd0, 0x11, 0x39, 0x19, 0xd5, 0x73, 0x24, 0x1b, 0x1d, 0xc4, 0x78, 0x86, 0x51, 0x4e, 0xa7, - 0xaa, 0x1d, 0x4d, 0x3f, 0x1a, 0x86, 0x70, 0x24, 0xe7, 0x66, 0x4b, 0x50, 0x1a, 0x0a, - ], + key: [0x34, 0x1a, 0xbb, 0xd0, 0x11, 0x39, 0x19, 0xd5, 0x73, 0x24, 0x1b, 0x1d, 0xc4, 0x78, 0x86, 0x51, 0x4e, 0xa7, 0xaa, 0x1d, 0x4d, 0x3f, 0x1a, 0x86, 0x70, 0x24, 0xe7, 0x66, 0x4b, 0x50, 0x1a, 0x0a], len: 21418, - sha: [ - 0x5b, 0x7e, 0x7d, 0x2c, 0xd3, 0x17, 0xfd, 0x3b, 0x1a, 0x5b, 0xea, 0x40, 0x01, 0x32, 0xf0, 0x38, 0x6b, 0x06, - 0x9c, 0xa7, 0xdb, 0x60, 0x97, 0x45, 0x93, 0xe9, 0x02, 0x27, 0x66, 0xb3, 0x95, 0xb2, - ], + sha: [0x5b, 0x7e, 0x7d, 0x2c, 0xd3, 0x17, 0xfd, 0x3b, 0x1a, 0x5b, 0xea, 0x40, 0x01, 0x32, 0xf0, 0x38, 0x6b, 0x06, 0x9c, 0xa7, 0xdb, 0x60, 0x97, 0x45, 0x93, 0xe9, 0x02, 0x27, 0x66, 0xb3, 0x95, 0xb2], ptx: concat!(include_str!("../ptx-sm86/q8_0_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "gr_prompt_device.ptx", - key: [ - 0x39, 0xc4, 0xea, 0xcc, 0x21, 0x1f, 0xa4, 0x5f, 0xe3, 0x68, 0xee, 0x50, 0x2d, 0x3d, 0x3f, 0xf2, 0x12, 0x41, - 0xe6, 0xfe, 0x24, 0xd5, 0xd1, 0x21, 0x1c, 0x6e, 0x18, 0xef, 0x0d, 0x37, 0x28, 0x70, - ], + key: [0x39, 0xc4, 0xea, 0xcc, 0x21, 0x1f, 0xa4, 0x5f, 0xe3, 0x68, 0xee, 0x50, 0x2d, 0x3d, 0x3f, 0xf2, 0x12, 0x41, 0xe6, 0xfe, 0x24, 0xd5, 0xd1, 0x21, 0x1c, 0x6e, 0x18, 0xef, 0x0d, 0x37, 0x28, 0x70], len: 46298, - sha: [ - 0x1c, 0xcf, 0xf9, 0xa5, 0xce, 0x9f, 0x1a, 0xb7, 0x9c, 0xf8, 0xf5, 0xc8, 0x1d, 0xfd, 0x2a, 0x77, 0x5a, 0xd8, - 0x38, 0x11, 0x5c, 0x09, 0x41, 0x4e, 0x0e, 0x1c, 0xdb, 0x3f, 0x34, 0x7f, 0x35, 0x6b, - ], + sha: [0x1c, 0xcf, 0xf9, 0xa5, 0xce, 0x9f, 0x1a, 0xb7, 0x9c, 0xf8, 0xf5, 0xc8, 0x1d, 0xfd, 0x2a, 0x77, 0x5a, 0xd8, 0x38, 0x11, 0x5c, 0x09, 0x41, 0x4e, 0x0e, 0x1c, 0xdb, 0x3f, 0x34, 0x7f, 0x35, 0x6b], ptx: concat!(include_str!("../ptx-sm86/gr_prompt_device.ptx"), "\0").as_bytes(), }, Companion { name: "s_gemv_legacy.ptx", - key: [ - 0x3a, 0xb4, 0xd1, 0x2a, 0x5e, 0x97, 0xc4, 0xe2, 0xf4, 0x60, 0x2c, 0x6c, 0x87, 0x23, 0x72, 0xc5, 0xc0, 0x68, - 0x5d, 0x8c, 0xf1, 0xa2, 0x02, 0x60, 0xaf, 0x6e, 0x0f, 0x52, 0x05, 0xac, 0x76, 0xd5, - ], + key: [0x3a, 0xb4, 0xd1, 0x2a, 0x5e, 0x97, 0xc4, 0xe2, 0xf4, 0x60, 0x2c, 0x6c, 0x87, 0x23, 0x72, 0xc5, 0xc0, 0x68, 0x5d, 0x8c, 0xf1, 0xa2, 0x02, 0x60, 0xaf, 0x6e, 0x0f, 0x52, 0x05, 0xac, 0x76, 0xd5], len: 303521, - sha: [ - 0x97, 0x47, 0xc1, 0xbe, 0x0d, 0xb5, 0x20, 0x66, 0xf1, 0xef, 0xe8, 0xef, 0xa9, 0xad, 0xdf, 0x14, 0x23, 0xc5, - 0xfd, 0x12, 0xe3, 0x17, 0x47, 0x99, 0xdf, 0x85, 0x3b, 0x0f, 0x71, 0x55, 0x76, 0x55, - ], + sha: [0x97, 0x47, 0xc1, 0xbe, 0x0d, 0xb5, 0x20, 0x66, 0xf1, 0xef, 0xe8, 0xef, 0xa9, 0xad, 0xdf, 0x14, 0x23, 0xc5, 0xfd, 0x12, 0xe3, 0x17, 0x47, 0x99, 0xdf, 0x85, 0x3b, 0x0f, 0x71, 0x55, 0x76, 0x55], ptx: concat!(include_str!("../ptx-sm86/s_gemv_legacy.ptx"), "\0").as_bytes(), }, Companion { name: "iq3_native_integer_mma.ptx", - key: [ - 0x3b, 0xfb, 0x20, 0xc5, 0x31, 0xd0, 0xd5, 0x74, 0xcd, 0xd0, 0x12, 0xda, 0x9f, 0xd0, 0xca, 0xe0, 0x63, 0xf6, - 0x16, 0xd1, 0xa0, 0x70, 0xe0, 0x20, 0x17, 0x99, 0xab, 0x11, 0xd7, 0x36, 0x8e, 0x63, - ], + key: [0x3b, 0xfb, 0x20, 0xc5, 0x31, 0xd0, 0xd5, 0x74, 0xcd, 0xd0, 0x12, 0xda, 0x9f, 0xd0, 0xca, 0xe0, 0x63, 0xf6, 0x16, 0xd1, 0xa0, 0x70, 0xe0, 0x20, 0x17, 0x99, 0xab, 0x11, 0xd7, 0x36, 0x8e, 0x63], len: 17927, - sha: [ - 0x71, 0x0e, 0xda, 0x43, 0xa5, 0x42, 0x8c, 0x1f, 0xbe, 0xcc, 0xc6, 0x76, 0x82, 0x08, 0x93, 0x98, 0x0e, 0xa3, - 0xcf, 0x1d, 0xf1, 0x22, 0x47, 0x17, 0xea, 0x95, 0x19, 0xb2, 0xe1, 0x39, 0xe3, 0x76, - ], + sha: [0x71, 0x0e, 0xda, 0x43, 0xa5, 0x42, 0x8c, 0x1f, 0xbe, 0xcc, 0xc6, 0x76, 0x82, 0x08, 0x93, 0x98, 0x0e, 0xa3, 0xcf, 0x1d, 0xf1, 0x22, 0x47, 0x17, 0xea, 0x95, 0x19, 0xb2, 0xe1, 0x39, 0xe3, 0x76], ptx: concat!(include_str!("../ptx-sm86/iq3_native_integer_mma.ptx"), "\0").as_bytes(), }, Companion { name: "mmq_original_prefill_misc.ptx", - key: [ - 0x3e, 0x57, 0x32, 0x6d, 0x0d, 0xd6, 0xae, 0xc8, 0x14, 0x7e, 0x6c, 0xf8, 0x37, 0xce, 0xca, 0x9d, 0x77, 0x9b, - 0xa0, 0x6e, 0xa6, 0x7b, 0xf4, 0x31, 0x1b, 0x3c, 0xe0, 0xba, 0xa6, 0xd0, 0x4d, 0x69, - ], + key: [0x3e, 0x57, 0x32, 0x6d, 0x0d, 0xd6, 0xae, 0xc8, 0x14, 0x7e, 0x6c, 0xf8, 0x37, 0xce, 0xca, 0x9d, 0x77, 0x9b, 0xa0, 0x6e, 0xa6, 0x7b, 0xf4, 0x31, 0x1b, 0x3c, 0xe0, 0xba, 0xa6, 0xd0, 0x4d, 0x69], len: 5267, - sha: [ - 0x7f, 0xb7, 0x4e, 0x54, 0xb7, 0xaf, 0x58, 0xdd, 0x65, 0x0d, 0x17, 0xaa, 0xa4, 0x0c, 0xa2, 0x31, 0x57, 0xd7, - 0xb9, 0x88, 0x6b, 0xba, 0xf7, 0x0f, 0x8b, 0x71, 0x09, 0xc5, 0xa7, 0xa9, 0x74, 0xf2, - ], + sha: [0x7f, 0xb7, 0x4e, 0x54, 0xb7, 0xaf, 0x58, 0xdd, 0x65, 0x0d, 0x17, 0xaa, 0xa4, 0x0c, 0xa2, 0x31, 0x57, 0xd7, 0xb9, 0x88, 0x6b, 0xba, 0xf7, 0x0f, 0x8b, 0x71, 0x09, 0xc5, 0xa7, 0xa9, 0x74, 0xf2], ptx: concat!(include_str!("../ptx-sm86/mmq_original_prefill_misc.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_prefill_mmq.ptx", - key: [ - 0x3e, 0x67, 0x46, 0x7d, 0x41, 0x2d, 0xbf, 0x18, 0x12, 0x00, 0xd3, 0xca, 0x10, 0xf2, 0xb6, 0x69, 0x95, 0xaf, - 0xe3, 0x16, 0xcb, 0xe4, 0x02, 0x60, 0xde, 0xa2, 0x1d, 0x97, 0x31, 0x8b, 0x61, 0xe1, - ], + key: [0x3e, 0x67, 0x46, 0x7d, 0x41, 0x2d, 0xbf, 0x18, 0x12, 0x00, 0xd3, 0xca, 0x10, 0xf2, 0xb6, 0x69, 0x95, 0xaf, 0xe3, 0x16, 0xcb, 0xe4, 0x02, 0x60, 0xde, 0xa2, 0x1d, 0x97, 0x31, 0x8b, 0x61, 0xe1], len: 1850087, - sha: [ - 0x2f, 0xde, 0xe9, 0xf3, 0xc3, 0x06, 0x7e, 0x27, 0x64, 0x30, 0xc6, 0xb6, 0x15, 0x45, 0xb1, 0xf8, 0x59, 0x22, - 0x60, 0xd4, 0x62, 0x64, 0x98, 0x89, 0xa8, 0xc9, 0x3b, 0xaa, 0xdf, 0x46, 0x92, 0xaa, - ], + sha: [0x2f, 0xde, 0xe9, 0xf3, 0xc3, 0x06, 0x7e, 0x27, 0x64, 0x30, 0xc6, 0xb6, 0x15, 0x45, 0xb1, 0xf8, 0x59, 0x22, 0x60, 0xd4, 0x62, 0x64, 0x98, 0x89, 0xa8, 0xc9, 0x3b, 0xaa, 0xdf, 0x46, 0x92, 0xaa], ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_mmq.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_attention.ptx", - key: [ - 0x3f, 0xb2, 0x35, 0xca, 0x40, 0x5d, 0x24, 0xc3, 0xb8, 0xd0, 0xec, 0x46, 0x61, 0x1d, 0x9d, 0x64, 0x01, 0x03, - 0xb7, 0x1a, 0x65, 0x85, 0x99, 0x23, 0x19, 0x4f, 0x02, 0xf0, 0x6b, 0x48, 0x2f, 0x6c, - ], + key: [0x3f, 0xb2, 0x35, 0xca, 0x40, 0x5d, 0x24, 0xc3, 0xb8, 0xd0, 0xec, 0x46, 0x61, 0x1d, 0x9d, 0x64, 0x01, 0x03, 0xb7, 0x1a, 0x65, 0x85, 0x99, 0x23, 0x19, 0x4f, 0x02, 0xf0, 0x6b, 0x48, 0x2f, 0x6c], len: 54452, - sha: [ - 0xdc, 0x1a, 0xcb, 0x71, 0x2c, 0x99, 0x3b, 0x09, 0xaa, 0x87, 0x86, 0x72, 0x13, 0xd5, 0x23, 0xd8, 0x6d, 0x34, - 0x2c, 0x91, 0xe7, 0x33, 0xf2, 0xdb, 0x80, 0x49, 0x7b, 0x85, 0xdc, 0xdd, 0x0b, 0x41, - ], + sha: [0xdc, 0x1a, 0xcb, 0x71, 0x2c, 0x99, 0x3b, 0x09, 0xaa, 0x87, 0x86, 0x72, 0x13, 0xd5, 0x23, 0xd8, 0x6d, 0x34, 0x2c, 0x91, 0xe7, 0x33, 0xf2, 0xdb, 0x80, 0x49, 0x7b, 0x85, 0xdc, 0xdd, 0x0b, 0x41], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_attention.ptx"), "\0").as_bytes(), }, Companion { name: "ple_prompt_device.ptx", - key: [ - 0x41, 0x2e, 0xd1, 0xdc, 0xcd, 0x1f, 0xc6, 0x2c, 0x5c, 0xf6, 0xc7, 0x50, 0xad, 0x8d, 0x2f, 0x45, 0x20, 0x5f, - 0x6d, 0x19, 0xfa, 0xfc, 0x00, 0x23, 0xd6, 0x4a, 0x33, 0xd3, 0x12, 0x95, 0x09, 0x34, - ], + key: [0x41, 0x2e, 0xd1, 0xdc, 0xcd, 0x1f, 0xc6, 0x2c, 0x5c, 0xf6, 0xc7, 0x50, 0xad, 0x8d, 0x2f, 0x45, 0x20, 0x5f, 0x6d, 0x19, 0xfa, 0xfc, 0x00, 0x23, 0xd6, 0x4a, 0x33, 0xd3, 0x12, 0x95, 0x09, 0x34], len: 19418, - sha: [ - 0xdb, 0x53, 0x73, 0x24, 0x8a, 0x30, 0x34, 0xea, 0x29, 0xc1, 0xd3, 0x65, 0xae, 0x26, 0x78, 0x5e, 0x4c, 0x46, - 0x6f, 0x3d, 0xdc, 0x9b, 0x26, 0x48, 0x43, 0xca, 0x58, 0xaf, 0x47, 0xc9, 0xc2, 0x03, - ], + sha: [0xdb, 0x53, 0x73, 0x24, 0x8a, 0x30, 0x34, 0xea, 0x29, 0xc1, 0xd3, 0x65, 0xae, 0x26, 0x78, 0x5e, 0x4c, 0x46, 0x6f, 0x3d, 0xdc, 0x9b, 0x26, 0x48, 0x43, 0xca, 0x58, 0xaf, 0x47, 0xc9, 0xc2, 0x03], ptx: concat!(include_str!("../ptx-sm86/ple_prompt_device.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_s2_full_fixed.ptx", - key: [ - 0x43, 0x81, 0x4a, 0x9c, 0x17, 0x9a, 0xba, 0xba, 0x8f, 0xe0, 0xa8, 0x0b, 0x88, 0xa3, 0x15, 0xbc, 0x94, 0xc4, - 0x38, 0xf3, 0x9b, 0x38, 0x42, 0xf4, 0xe4, 0x30, 0x1e, 0x96, 0xa0, 0x32, 0xf7, 0x8d, - ], + key: [0x43, 0x81, 0x4a, 0x9c, 0x17, 0x9a, 0xba, 0xba, 0x8f, 0xe0, 0xa8, 0x0b, 0x88, 0xa3, 0x15, 0xbc, 0x94, 0xc4, 0x38, 0xf3, 0x9b, 0x38, 0x42, 0xf4, 0xe4, 0x30, 0x1e, 0x96, 0xa0, 0x32, 0xf7, 0x8d], len: 142044, - sha: [ - 0x48, 0x41, 0xdf, 0x97, 0x8e, 0x70, 0x2a, 0xd9, 0x1a, 0xdf, 0xd6, 0xb1, 0x7f, 0xd3, 0x1e, 0x53, 0xa4, 0x12, - 0x04, 0xf8, 0x0c, 0xbc, 0xa0, 0xdf, 0x2b, 0x6f, 0xad, 0xef, 0xf3, 0x5a, 0x3b, 0x78, - ], + sha: [0x48, 0x41, 0xdf, 0x97, 0x8e, 0x70, 0x2a, 0xd9, 0x1a, 0xdf, 0xd6, 0xb1, 0x7f, 0xd3, 0x1e, 0x53, 0xa4, 0x12, 0x04, 0xf8, 0x0c, 0xbc, 0xa0, 0xdf, 0x2b, 0x6f, 0xad, 0xef, 0xf3, 0x5a, 0x3b, 0x78], ptx: concat!(include_str!("../ptx-sm86/mtp_s2_full_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "experimental_kv_q8.ptx", - key: [ - 0x43, 0xc3, 0x08, 0x96, 0x08, 0x30, 0x83, 0x3e, 0x29, 0x32, 0x99, 0x07, 0xe2, 0x7b, 0xe5, 0x20, 0x3e, 0xf3, - 0xbc, 0x89, 0xcc, 0x7d, 0x0a, 0x91, 0x76, 0x27, 0x0d, 0xc1, 0x87, 0x32, 0xd6, 0x00, - ], + key: [0x43, 0xc3, 0x08, 0x96, 0x08, 0x30, 0x83, 0x3e, 0x29, 0x32, 0x99, 0x07, 0xe2, 0x7b, 0xe5, 0x20, 0x3e, 0xf3, 0xbc, 0x89, 0xcc, 0x7d, 0x0a, 0x91, 0x76, 0x27, 0x0d, 0xc1, 0x87, 0x32, 0xd6, 0x00], len: 32973, - sha: [ - 0x4b, 0xe6, 0xeb, 0xa3, 0xae, 0x08, 0xf2, 0x12, 0xeb, 0x89, 0x60, 0x7c, 0xea, 0x56, 0x63, 0x8c, 0x10, 0xfa, - 0x12, 0xee, 0x40, 0x98, 0x5b, 0xeb, 0xee, 0x99, 0x75, 0x44, 0xae, 0xd7, 0xad, 0xc7, - ], + sha: [0x4b, 0xe6, 0xeb, 0xa3, 0xae, 0x08, 0xf2, 0x12, 0xeb, 0x89, 0x60, 0x7c, 0xea, 0x56, 0x63, 0x8c, 0x10, 0xfa, 0x12, 0xee, 0x40, 0x98, 0x5b, 0xeb, 0xee, 0x99, 0x75, 0x44, 0xae, 0xd7, 0xad, 0xc7], ptx: concat!(include_str!("../ptx-sm86/experimental_kv_q8.ptx"), "\0").as_bytes(), }, Companion { name: "q6_k_q8_1.ptx", - key: [ - 0x45, 0x40, 0xf6, 0x7f, 0x72, 0xe3, 0xb3, 0x5b, 0xf2, 0x1c, 0xfb, 0xde, 0x0b, 0xfd, 0xf7, 0x85, 0x1e, 0xbe, - 0x90, 0xe4, 0x15, 0x40, 0x5c, 0x0c, 0x16, 0x16, 0x6d, 0x09, 0x33, 0xd5, 0x47, 0x97, - ], + key: [0x45, 0x40, 0xf6, 0x7f, 0x72, 0xe3, 0xb3, 0x5b, 0xf2, 0x1c, 0xfb, 0xde, 0x0b, 0xfd, 0xf7, 0x85, 0x1e, 0xbe, 0x90, 0xe4, 0x15, 0x40, 0x5c, 0x0c, 0x16, 0x16, 0x6d, 0x09, 0x33, 0xd5, 0x47, 0x97], len: 26986, - sha: [ - 0x56, 0xb6, 0x06, 0xf4, 0x0b, 0x9a, 0xdd, 0xb9, 0x14, 0xed, 0x01, 0x83, 0x5e, 0x77, 0x87, 0x44, 0x22, 0xca, - 0x26, 0xc5, 0xff, 0x32, 0x09, 0x94, 0x3d, 0x1d, 0xe1, 0x22, 0xfc, 0x79, 0x69, 0x58, - ], + sha: [0x56, 0xb6, 0x06, 0xf4, 0x0b, 0x9a, 0xdd, 0xb9, 0x14, 0xed, 0x01, 0x83, 0x5e, 0x77, 0x87, 0x44, 0x22, 0xca, 0x26, 0xc5, 0xff, 0x32, 0x09, 0x94, 0x3d, 0x1d, 0xe1, 0x22, 0xfc, 0x79, 0x69, 0x58], ptx: concat!(include_str!("../ptx-sm86/q6_k_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "moe_route_top10.ptx", - key: [ - 0x48, 0x04, 0xcc, 0xad, 0xee, 0x77, 0xaa, 0xbd, 0xa8, 0x80, 0xfb, 0xc0, 0xa5, 0xb3, 0x4f, 0x10, 0xe8, 0x58, - 0x51, 0xc1, 0x69, 0xea, 0xa8, 0x96, 0xf3, 0x31, 0x4b, 0xed, 0x64, 0x78, 0xe2, 0x25, - ], + key: [0x48, 0x04, 0xcc, 0xad, 0xee, 0x77, 0xaa, 0xbd, 0xa8, 0x80, 0xfb, 0xc0, 0xa5, 0xb3, 0x4f, 0x10, 0xe8, 0x58, 0x51, 0xc1, 0x69, 0xea, 0xa8, 0x96, 0xf3, 0x31, 0x4b, 0xed, 0x64, 0x78, 0xe2, 0x25], len: 61900, - sha: [ - 0xe3, 0x29, 0x7c, 0x8c, 0x54, 0x4c, 0xe8, 0x40, 0x15, 0xb5, 0xba, 0x73, 0x45, 0x57, 0xd5, 0x1e, 0xd7, 0x77, - 0xed, 0x40, 0x46, 0xf7, 0x4f, 0x09, 0x33, 0x1b, 0x63, 0x56, 0x9e, 0x01, 0xb5, 0x83, - ], + sha: [0xe3, 0x29, 0x7c, 0x8c, 0x54, 0x4c, 0xe8, 0x40, 0x15, 0xb5, 0xba, 0x73, 0x45, 0x57, 0xd5, 0x1e, 0xd7, 0x77, 0xed, 0x40, 0x46, 0xf7, 0x4f, 0x09, 0x33, 0x1b, 0x63, 0x56, 0x9e, 0x01, 0xb5, 0x83], ptx: concat!(include_str!("../ptx-sm86/moe_route_top10.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_postops.ptx", - key: [ - 0x48, 0x6a, 0x73, 0xb0, 0x6b, 0x3a, 0x34, 0xf2, 0x98, 0xf5, 0x7e, 0x92, 0xc2, 0x0c, 0xc8, 0x39, 0x4d, 0xc5, - 0x9d, 0x7b, 0xd8, 0x4b, 0x5c, 0xcc, 0xf8, 0xda, 0x53, 0xaa, 0x50, 0x81, 0xac, 0x9f, - ], + key: [0x48, 0x6a, 0x73, 0xb0, 0x6b, 0x3a, 0x34, 0xf2, 0x98, 0xf5, 0x7e, 0x92, 0xc2, 0x0c, 0xc8, 0x39, 0x4d, 0xc5, 0x9d, 0x7b, 0xd8, 0x4b, 0x5c, 0xcc, 0xf8, 0xda, 0x53, 0xaa, 0x50, 0x81, 0xac, 0x9f], len: 21830, - sha: [ - 0x34, 0x00, 0x50, 0x40, 0x42, 0xb6, 0x9f, 0x98, 0x8b, 0x9a, 0x13, 0x3c, 0x2a, 0xea, 0xf8, 0x67, 0x69, 0xc7, - 0xf3, 0x99, 0xfa, 0xaf, 0x94, 0xc6, 0x38, 0x7e, 0xbc, 0x6b, 0x46, 0xd3, 0x5d, 0xa9, - ], + sha: [0x34, 0x00, 0x50, 0x40, 0x42, 0xb6, 0x9f, 0x98, 0x8b, 0x9a, 0x13, 0x3c, 0x2a, 0xea, 0xf8, 0x67, 0x69, 0xc7, 0xf3, 0x99, 0xfa, 0xaf, 0x94, 0xc6, 0x38, 0x7e, 0xbc, 0x6b, 0x46, 0xd3, 0x5d, 0xa9], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_postops.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_selected_kv.ptx", - key: [ - 0x4f, 0x2a, 0xd2, 0x04, 0x10, 0x9b, 0xdd, 0x97, 0x4a, 0x7c, 0x96, 0x5d, 0x08, 0xd9, 0x06, 0x4a, 0xf5, 0x27, - 0x56, 0xb1, 0xf6, 0xfc, 0x15, 0x02, 0x7f, 0x47, 0x7d, 0xe2, 0xfd, 0x88, 0x3f, 0x92, - ], + key: [0x4f, 0x2a, 0xd2, 0x04, 0x10, 0x9b, 0xdd, 0x97, 0x4a, 0x7c, 0x96, 0x5d, 0x08, 0xd9, 0x06, 0x4a, 0xf5, 0x27, 0x56, 0xb1, 0xf6, 0xfc, 0x15, 0x02, 0x7f, 0x47, 0x7d, 0xe2, 0xfd, 0x88, 0x3f, 0x92], len: 3842, - sha: [ - 0x74, 0x02, 0x25, 0x5f, 0xdb, 0xe1, 0x21, 0xe0, 0x36, 0xaf, 0x74, 0x20, 0x3d, 0xb6, 0x0f, 0x61, 0xd9, 0xe2, - 0xe4, 0xe1, 0x08, 0xbf, 0xbe, 0xdf, 0x17, 0xc4, 0xc3, 0x9f, 0xc0, 0x4e, 0xbf, 0x62, - ], + sha: [0x74, 0x02, 0x25, 0x5f, 0xdb, 0xe1, 0x21, 0xe0, 0x36, 0xaf, 0x74, 0x20, 0x3d, 0xb6, 0x0f, 0x61, 0xd9, 0xe2, 0xe4, 0xe1, 0x08, 0xbf, 0xbe, 0xdf, 0x17, 0xc4, 0xc3, 0x9f, 0xc0, 0x4e, 0xbf, 0x62], ptx: concat!(include_str!("../ptx-sm86/qsa_selected_kv.ptx"), "\0").as_bytes(), }, Companion { name: "experimental_kv_stream.ptx", - key: [ - 0x4f, 0x71, 0xe7, 0x20, 0xe0, 0xca, 0x95, 0x0d, 0x32, 0x1b, 0xa3, 0xcb, 0xb2, 0x00, 0x82, 0xca, 0x47, 0x3e, - 0x98, 0x39, 0xb7, 0x6d, 0x08, 0x89, 0x8e, 0x95, 0xb6, 0x62, 0x3b, 0xff, 0xfe, 0x50, - ], + key: [0x4f, 0x71, 0xe7, 0x20, 0xe0, 0xca, 0x95, 0x0d, 0x32, 0x1b, 0xa3, 0xcb, 0xb2, 0x00, 0x82, 0xca, 0x47, 0x3e, 0x98, 0x39, 0xb7, 0x6d, 0x08, 0x89, 0x8e, 0x95, 0xb6, 0x62, 0x3b, 0xff, 0xfe, 0x50], len: 34329, - sha: [ - 0x9f, 0x99, 0x20, 0x44, 0x70, 0x2d, 0x0c, 0xa2, 0xf8, 0xcc, 0x0b, 0xfd, 0xfd, 0xb7, 0x55, 0x47, 0x59, 0x9f, - 0x91, 0x26, 0x15, 0xff, 0xdb, 0x7c, 0xdb, 0x56, 0xcc, 0x06, 0x3c, 0xe8, 0xd6, 0xcf, - ], + sha: [0x9f, 0x99, 0x20, 0x44, 0x70, 0x2d, 0x0c, 0xa2, 0xf8, 0xcc, 0x0b, 0xfd, 0xfd, 0xb7, 0x55, 0x47, 0x59, 0x9f, 0x91, 0x26, 0x15, 0xff, 0xdb, 0x7c, 0xdb, 0x56, 0xcc, 0x06, 0x3c, 0xe8, 0xd6, 0xcf], ptx: concat!(include_str!("../ptx-sm86/experimental_kv_stream.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_coupled.ptx", - key: [ - 0x55, 0x47, 0x41, 0x61, 0x1c, 0xc0, 0x3e, 0x2c, 0x35, 0xb7, 0xab, 0x1d, 0xfc, 0xa9, 0xc6, 0xd6, 0xc0, 0x1b, - 0x37, 0xc1, 0x7d, 0xd4, 0x91, 0x00, 0x0c, 0xcf, 0x0a, 0x23, 0xc3, 0xbb, 0xcb, 0xf9, - ], + key: [0x55, 0x47, 0x41, 0x61, 0x1c, 0xc0, 0x3e, 0x2c, 0x35, 0xb7, 0xab, 0x1d, 0xfc, 0xa9, 0xc6, 0xd6, 0xc0, 0x1b, 0x37, 0xc1, 0x7d, 0xd4, 0x91, 0x00, 0x0c, 0xcf, 0x0a, 0x23, 0xc3, 0xbb, 0xcb, 0xf9], len: 482063, - sha: [ - 0xee, 0x6c, 0x57, 0x9d, 0x55, 0x15, 0x6e, 0x90, 0x3a, 0xf6, 0xc1, 0x8e, 0x6a, 0x47, 0x32, 0x95, 0x5f, 0xc1, - 0x26, 0xd4, 0x8a, 0x02, 0x86, 0x04, 0xdb, 0x99, 0xa4, 0xcc, 0x2f, 0xcf, 0x4d, 0x80, - ], + sha: [0xee, 0x6c, 0x57, 0x9d, 0x55, 0x15, 0x6e, 0x90, 0x3a, 0xf6, 0xc1, 0x8e, 0x6a, 0x47, 0x32, 0x95, 0x5f, 0xc1, 0x26, 0xd4, 0x8a, 0x02, 0x86, 0x04, 0xdb, 0x99, 0xa4, 0xcc, 0x2f, 0xcf, 0x4d, 0x80], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_coupled.ptx"), "\0").as_bytes(), }, Companion { name: "experimental_qsa_attn.ptx", - key: [ - 0x56, 0x23, 0xa5, 0xae, 0x9b, 0x2e, 0xbd, 0x2f, 0xa0, 0x10, 0xc3, 0x34, 0x36, 0x7f, 0xfc, 0x54, 0x87, 0x9a, - 0xc6, 0xdf, 0x76, 0xae, 0xf0, 0x83, 0x81, 0xdb, 0xd3, 0x2b, 0x0f, 0x7e, 0xf3, 0x11, - ], + key: [0x56, 0x23, 0xa5, 0xae, 0x9b, 0x2e, 0xbd, 0x2f, 0xa0, 0x10, 0xc3, 0x34, 0x36, 0x7f, 0xfc, 0x54, 0x87, 0x9a, 0xc6, 0xdf, 0x76, 0xae, 0xf0, 0x83, 0x81, 0xdb, 0xd3, 0x2b, 0x0f, 0x7e, 0xf3, 0x11], len: 128247, - sha: [ - 0x2d, 0xe6, 0x09, 0xa4, 0xbf, 0x6e, 0xb8, 0x80, 0xbe, 0x59, 0x4d, 0x47, 0xc0, 0x7f, 0xe4, 0x0a, 0x78, 0xd2, - 0x5d, 0x70, 0xc7, 0x4e, 0xcd, 0xa7, 0x95, 0x82, 0xbd, 0x61, 0x21, 0x74, 0x99, 0xe2, - ], + sha: [0x2d, 0xe6, 0x09, 0xa4, 0xbf, 0x6e, 0xb8, 0x80, 0xbe, 0x59, 0x4d, 0x47, 0xc0, 0x7f, 0xe4, 0x0a, 0x78, 0xd2, 0x5d, 0x70, 0xc7, 0x4e, 0xcd, 0xa7, 0x95, 0x82, 0xbd, 0x61, 0x21, 0x74, 0x99, 0xe2], ptx: concat!(include_str!("../ptx-sm86/experimental_qsa_attn.ptx"), "\0").as_bytes(), }, Companion { name: "device_poison.ptx", - key: [ - 0x58, 0x7b, 0x09, 0x7a, 0x20, 0x1a, 0x67, 0x30, 0xe8, 0xfe, 0x55, 0x43, 0x29, 0x19, 0x87, 0xbb, 0xf8, 0x07, - 0xda, 0x72, 0xda, 0x12, 0xb8, 0xe0, 0xa1, 0x69, 0xf9, 0xe5, 0xe8, 0xf6, 0xa6, 0x58, - ], + key: [0x58, 0x7b, 0x09, 0x7a, 0x20, 0x1a, 0x67, 0x30, 0xe8, 0xfe, 0x55, 0x43, 0x29, 0x19, 0x87, 0xbb, 0xf8, 0x07, 0xda, 0x72, 0xda, 0x12, 0xb8, 0xe0, 0xa1, 0x69, 0xf9, 0xe5, 0xe8, 0xf6, 0xa6, 0x58], len: 870, - sha: [ - 0xab, 0x97, 0x01, 0x5f, 0xd4, 0x7e, 0x02, 0xe2, 0xbf, 0xde, 0x42, 0x49, 0x25, 0x62, 0xa5, 0x52, 0xef, 0x78, - 0xb6, 0x0b, 0x99, 0xf0, 0xf1, 0xf3, 0xbb, 0x43, 0x5a, 0x3c, 0x0c, 0x82, 0x59, 0xa9, - ], + sha: [0xab, 0x97, 0x01, 0x5f, 0xd4, 0x7e, 0x02, 0xe2, 0xbf, 0xde, 0x42, 0x49, 0x25, 0x62, 0xa5, 0x52, 0xef, 0x78, 0xb6, 0x0b, 0x99, 0xf0, 0xf1, 0xf3, 0xbb, 0x43, 0x5a, 0x3c, 0x0c, 0x82, 0x59, 0xa9], ptx: concat!(include_str!("../ptx-sm86/device_poison.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_iq3_s.ptx", - key: [ - 0x58, 0xd0, 0x68, 0xff, 0x3a, 0xcc, 0x42, 0x11, 0x61, 0x4f, 0x70, 0xab, 0x04, 0x70, 0x3a, 0x40, 0x85, 0x8e, - 0x14, 0x8f, 0x9a, 0xef, 0x85, 0x03, 0xed, 0x66, 0xf7, 0x64, 0x0a, 0xe2, 0xe2, 0xaa, - ], + key: [0x58, 0xd0, 0x68, 0xff, 0x3a, 0xcc, 0x42, 0x11, 0x61, 0x4f, 0x70, 0xab, 0x04, 0x70, 0x3a, 0x40, 0x85, 0x8e, 0x14, 0x8f, 0x9a, 0xef, 0x85, 0x03, 0xed, 0x66, 0xf7, 0x64, 0x0a, 0xe2, 0xe2, 0xaa], len: 25114, - sha: [ - 0x36, 0xc2, 0xf6, 0x8c, 0x0d, 0x3a, 0x3c, 0x52, 0x47, 0x87, 0xec, 0xf0, 0x3a, 0x1f, 0x33, 0xe2, 0xda, 0x93, - 0x0a, 0x49, 0x17, 0x41, 0x9e, 0xa5, 0x89, 0x3c, 0xca, 0xa2, 0x8c, 0x33, 0xa8, 0x8c, - ], + sha: [0x36, 0xc2, 0xf6, 0x8c, 0x0d, 0x3a, 0x3c, 0x52, 0x47, 0x87, 0xec, 0xf0, 0x3a, 0x1f, 0x33, 0xe2, 0xda, 0x93, 0x0a, 0x49, 0x17, 0x41, 0x9e, 0xa5, 0x89, 0x3c, 0xca, 0xa2, 0x8c, 0x33, 0xa8, 0x8c], ptx: concat!(include_str!("../ptx-sm86/moe_group_iq3_s.ptx"), "\0").as_bytes(), }, Companion { name: "original_sampler.ptx", - key: [ - 0x59, 0x1a, 0xa3, 0xdd, 0xa5, 0x2f, 0x41, 0xf0, 0xd1, 0x95, 0x41, 0x6c, 0xf0, 0x93, 0x96, 0x25, 0x68, 0xd2, - 0xf8, 0x3d, 0x6f, 0x76, 0x2a, 0x96, 0x78, 0xbe, 0x61, 0x94, 0x6c, 0xec, 0xb7, 0x5b, - ], + key: [0x59, 0x1a, 0xa3, 0xdd, 0xa5, 0x2f, 0x41, 0xf0, 0xd1, 0x95, 0x41, 0x6c, 0xf0, 0x93, 0x96, 0x25, 0x68, 0xd2, 0xf8, 0x3d, 0x6f, 0x76, 0x2a, 0x96, 0x78, 0xbe, 0x61, 0x94, 0x6c, 0xec, 0xb7, 0x5b], len: 475837, - sha: [ - 0x3c, 0xf7, 0xa3, 0x0f, 0x81, 0x6f, 0x9f, 0x27, 0xa2, 0x2f, 0xf8, 0x21, 0x11, 0x7e, 0x9b, 0xff, 0x7c, 0xbc, - 0xc3, 0x19, 0x69, 0xac, 0x25, 0x5d, 0x32, 0xb4, 0x0d, 0xdd, 0x4d, 0xda, 0xdc, 0x40, - ], + sha: [0x3c, 0xf7, 0xa3, 0x0f, 0x81, 0x6f, 0x9f, 0x27, 0xa2, 0x2f, 0xf8, 0x21, 0x11, 0x7e, 0x9b, 0xff, 0x7c, 0xbc, 0xc3, 0x19, 0x69, 0xac, 0x25, 0x5d, 0x32, 0xb4, 0x0d, 0xdd, 0x4d, 0xda, 0xdc, 0x40], ptx: concat!(include_str!("../ptx-sm86/original_sampler.ptx"), "\0").as_bytes(), }, Companion { name: "mmq-selected.ptx", - key: [ - 0x5a, 0x56, 0xd8, 0xeb, 0x66, 0xf1, 0xf9, 0x8e, 0x3c, 0xb3, 0xab, 0x75, 0x18, 0x1e, 0x0f, 0x26, 0x3e, 0x4d, - 0x51, 0xc4, 0xe7, 0x1e, 0x27, 0xab, 0x2b, 0xc9, 0x9a, 0x1a, 0x3b, 0x7c, 0x01, 0xcb, - ], + key: [0x5a, 0x56, 0xd8, 0xeb, 0x66, 0xf1, 0xf9, 0x8e, 0x3c, 0xb3, 0xab, 0x75, 0x18, 0x1e, 0x0f, 0x26, 0x3e, 0x4d, 0x51, 0xc4, 0xe7, 0x1e, 0x27, 0xab, 0x2b, 0xc9, 0x9a, 0x1a, 0x3b, 0x7c, 0x01, 0xcb], len: 955352, - sha: [ - 0xc1, 0x5b, 0x58, 0x0a, 0x9f, 0xdc, 0x85, 0x67, 0x39, 0xfc, 0xa0, 0xa5, 0x68, 0x57, 0xfc, 0x7e, 0x7e, 0xc0, - 0x1b, 0x4f, 0x1c, 0x99, 0x3f, 0xfb, 0x2e, 0xde, 0x04, 0x66, 0x01, 0x04, 0x86, 0x28, - ], + sha: [0xc1, 0x5b, 0x58, 0x0a, 0x9f, 0xdc, 0x85, 0x67, 0x39, 0xfc, 0xa0, 0xa5, 0x68, 0x57, 0xfc, 0x7e, 0x7e, 0xc0, 0x1b, 0x4f, 0x1c, 0x99, 0x3f, 0xfb, 0x2e, 0xde, 0x04, 0x66, 0x01, 0x04, 0x86, 0x28], ptx: concat!(include_str!("../ptx-sm86/mmq-selected.ptx"), "\0").as_bytes(), }, Companion { name: "offline_gdn_prefill.ptx", - key: [ - 0x5c, 0xc3, 0xa0, 0x28, 0x5d, 0xb9, 0x83, 0xce, 0xbe, 0x9e, 0x35, 0xfa, 0xc2, 0xd5, 0x3e, 0x57, 0x32, 0x68, - 0xaf, 0x81, 0x7f, 0x13, 0x1b, 0x23, 0x40, 0xbd, 0x00, 0x3a, 0xe3, 0xe1, 0x64, 0xce, - ], + key: [0x5c, 0xc3, 0xa0, 0x28, 0x5d, 0xb9, 0x83, 0xce, 0xbe, 0x9e, 0x35, 0xfa, 0xc2, 0xd5, 0x3e, 0x57, 0x32, 0x68, 0xaf, 0x81, 0x7f, 0x13, 0x1b, 0x23, 0x40, 0xbd, 0x00, 0x3a, 0xe3, 0xe1, 0x64, 0xce], len: 52304, - sha: [ - 0x12, 0x71, 0xac, 0x05, 0x6e, 0xa0, 0x13, 0x2b, 0xda, 0x7d, 0x11, 0x57, 0x0a, 0x29, 0x6d, 0x00, 0x81, 0x1d, - 0x82, 0xe3, 0x90, 0x1d, 0x6c, 0x5d, 0x77, 0x14, 0x77, 0xf8, 0xd9, 0x60, 0x6c, 0x37, - ], + sha: [0x12, 0x71, 0xac, 0x05, 0x6e, 0xa0, 0x13, 0x2b, 0xda, 0x7d, 0x11, 0x57, 0x0a, 0x29, 0x6d, 0x00, 0x81, 0x1d, 0x82, 0xe3, 0x90, 0x1d, 0x6c, 0x5d, 0x77, 0x14, 0x77, 0xf8, 0xd9, 0x60, 0x6c, 0x37], ptx: concat!(include_str!("../ptx-sm86/offline_gdn_prefill.ptx"), "\0").as_bytes(), }, Companion { name: "ple_native_batch.ptx", - key: [ - 0x5f, 0xa5, 0xc9, 0x30, 0xf4, 0x0c, 0xb4, 0x9d, 0x9e, 0x79, 0xa3, 0x5e, 0x19, 0x11, 0xc6, 0x85, 0x81, 0xf9, - 0x2c, 0x09, 0x77, 0x50, 0xef, 0xf2, 0x8c, 0x24, 0x5e, 0x28, 0x70, 0x96, 0x4a, 0x40, - ], + key: [0x5f, 0xa5, 0xc9, 0x30, 0xf4, 0x0c, 0xb4, 0x9d, 0x9e, 0x79, 0xa3, 0x5e, 0x19, 0x11, 0xc6, 0x85, 0x81, 0xf9, 0x2c, 0x09, 0x77, 0x50, 0xef, 0xf2, 0x8c, 0x24, 0x5e, 0x28, 0x70, 0x96, 0x4a, 0x40], len: 19699, - sha: [ - 0xf9, 0xa3, 0x97, 0x01, 0xe2, 0xcc, 0xf0, 0xf6, 0xf7, 0x2d, 0x5e, 0xce, 0x56, 0x6b, 0x78, 0x09, 0x33, 0xea, - 0xdd, 0xe6, 0x89, 0xe7, 0xff, 0x50, 0x2a, 0xcf, 0x87, 0xdb, 0x63, 0xf5, 0xd8, 0x5f, - ], + sha: [0xf9, 0xa3, 0x97, 0x01, 0xe2, 0xcc, 0xf0, 0xf6, 0xf7, 0x2d, 0x5e, 0xce, 0x56, 0x6b, 0x78, 0x09, 0x33, 0xea, 0xdd, 0xe6, 0x89, 0xe7, 0xff, 0x50, 0x2a, 0xcf, 0x87, 0xdb, 0x63, 0xf5, 0xd8, 0x5f], ptx: concat!(include_str!("../ptx-sm86/ple_native_batch.ptx"), "\0").as_bytes(), }, Companion { name: "ple_value_full_fixed.ptx", - key: [ - 0x61, 0x80, 0xf3, 0xde, 0xbc, 0x74, 0x34, 0x9d, 0x62, 0xe2, 0x9c, 0x17, 0xe0, 0x75, 0x17, 0xac, 0x6c, 0x15, - 0x1e, 0x71, 0xea, 0xe6, 0x72, 0x97, 0x85, 0x66, 0x49, 0x58, 0x84, 0x23, 0x25, 0xd0, - ], + key: [0x61, 0x80, 0xf3, 0xde, 0xbc, 0x74, 0x34, 0x9d, 0x62, 0xe2, 0x9c, 0x17, 0xe0, 0x75, 0x17, 0xac, 0x6c, 0x15, 0x1e, 0x71, 0xea, 0xe6, 0x72, 0x97, 0x85, 0x66, 0x49, 0x58, 0x84, 0x23, 0x25, 0xd0], len: 5199, - sha: [ - 0xbf, 0xcd, 0x7c, 0x88, 0x44, 0x62, 0xc1, 0xe1, 0xe2, 0x8e, 0x3f, 0x73, 0xc7, 0x25, 0x0f, 0xbb, 0xa5, 0x1b, - 0xc0, 0xc9, 0x5f, 0x03, 0x7d, 0xba, 0x18, 0x4f, 0x32, 0x24, 0x75, 0x8f, 0xaa, 0x33, - ], + sha: [0xbf, 0xcd, 0x7c, 0x88, 0x44, 0x62, 0xc1, 0xe1, 0xe2, 0x8e, 0x3f, 0x73, 0xc7, 0x25, 0x0f, 0xbb, 0xa5, 0x1b, 0xc0, 0xc9, 0x5f, 0x03, 0x7d, 0xba, 0x18, 0x4f, 0x32, 0x24, 0x75, 0x8f, 0xaa, 0x33], ptx: concat!(include_str!("../ptx-sm86/ple_value_full_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "q5_k_q8_1.ptx", - key: [ - 0x65, 0xcd, 0x98, 0x13, 0x8e, 0x2a, 0xd9, 0xd1, 0xc2, 0x71, 0x1f, 0xf7, 0xfc, 0x27, 0x28, 0x0f, 0x07, 0xf1, - 0xa2, 0x24, 0xfc, 0xdd, 0x2a, 0xbe, 0xea, 0x9b, 0xed, 0xf9, 0xd9, 0xd3, 0xff, 0xfc, - ], + key: [0x65, 0xcd, 0x98, 0x13, 0x8e, 0x2a, 0xd9, 0xd1, 0xc2, 0x71, 0x1f, 0xf7, 0xfc, 0x27, 0x28, 0x0f, 0x07, 0xf1, 0xa2, 0x24, 0xfc, 0xdd, 0x2a, 0xbe, 0xea, 0x9b, 0xed, 0xf9, 0xd9, 0xd3, 0xff, 0xfc], len: 33608, - sha: [ - 0x24, 0x64, 0xea, 0x04, 0x0f, 0xfa, 0x4d, 0xa2, 0x03, 0xe7, 0xde, 0xe9, 0x14, 0x5a, 0x1e, 0xa9, 0x88, 0xdb, - 0x90, 0x2d, 0xff, 0xe7, 0xa1, 0x6d, 0x4f, 0x2c, 0xf1, 0x77, 0xcd, 0x7d, 0x32, 0xd6, - ], + sha: [0x24, 0x64, 0xea, 0x04, 0x0f, 0xfa, 0x4d, 0xa2, 0x03, 0xe7, 0xde, 0xe9, 0x14, 0x5a, 0x1e, 0xa9, 0x88, 0xdb, 0x90, 0x2d, 0xff, 0xe7, 0xa1, 0x6d, 0x4f, 0x2c, 0xf1, 0x77, 0xcd, 0x7d, 0x32, 0xd6], ptx: concat!(include_str!("../ptx-sm86/q5_k_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "native_head_iq.ptx", - key: [ - 0x66, 0xd3, 0xe6, 0x22, 0xee, 0x4f, 0xb8, 0xb6, 0x71, 0x92, 0x8a, 0x73, 0xda, 0xe7, 0x03, 0x85, 0xe4, 0x41, - 0x5d, 0xb4, 0x7a, 0xd5, 0x34, 0x2d, 0x5e, 0xb0, 0xd2, 0x50, 0x7b, 0xea, 0xb5, 0xe4, - ], + key: [0x66, 0xd3, 0xe6, 0x22, 0xee, 0x4f, 0xb8, 0xb6, 0x71, 0x92, 0x8a, 0x73, 0xda, 0xe7, 0x03, 0x85, 0xe4, 0x41, 0x5d, 0xb4, 0x7a, 0xd5, 0x34, 0x2d, 0x5e, 0xb0, 0xd2, 0x50, 0x7b, 0xea, 0xb5, 0xe4], len: 753628, - sha: [ - 0x90, 0xda, 0x63, 0x69, 0xf0, 0x50, 0x9e, 0x6c, 0xa6, 0x41, 0xb0, 0xa4, 0x7d, 0xce, 0x03, 0x81, 0xe8, 0x8c, - 0x27, 0xf0, 0x0e, 0xb4, 0x18, 0x19, 0x82, 0xd9, 0x42, 0x22, 0x16, 0x97, 0x2a, 0x2c, - ], + sha: [0x90, 0xda, 0x63, 0x69, 0xf0, 0x50, 0x9e, 0x6c, 0xa6, 0x41, 0xb0, 0xa4, 0x7d, 0xce, 0x03, 0x81, 0xe8, 0x8c, 0x27, 0xf0, 0x0e, 0xb4, 0x18, 0x19, 0x82, 0xd9, 0x42, 0x22, 0x16, 0x97, 0x2a, 0x2c], ptx: concat!(include_str!("../ptx-sm86/native_head_iq.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_device_gate.ptx", - key: [ - 0x69, 0xf0, 0x3b, 0xe1, 0x7d, 0xb1, 0x7a, 0xba, 0x2f, 0x82, 0x8c, 0xf4, 0x37, 0x91, 0x0a, 0x4d, 0xb6, 0x63, - 0x23, 0x97, 0x3d, 0xaa, 0x8b, 0x1a, 0x45, 0x9c, 0x24, 0x18, 0xf9, 0x11, 0x45, 0xd4, - ], + key: [0x69, 0xf0, 0x3b, 0xe1, 0x7d, 0xb1, 0x7a, 0xba, 0x2f, 0x82, 0x8c, 0xf4, 0x37, 0x91, 0x0a, 0x4d, 0xb6, 0x63, 0x23, 0x97, 0x3d, 0xaa, 0x8b, 0x1a, 0x45, 0x9c, 0x24, 0x18, 0xf9, 0x11, 0x45, 0xd4], len: 2382, - sha: [ - 0x3b, 0xca, 0x8a, 0x59, 0x4f, 0x37, 0xdd, 0x80, 0xff, 0x12, 0xbd, 0x9b, 0x2c, 0x45, 0x4b, 0x76, 0x68, 0xf2, - 0x26, 0x57, 0x1a, 0x2f, 0x2c, 0x5d, 0x33, 0x89, 0xd7, 0xa5, 0xa9, 0x81, 0xba, 0xa7, - ], + sha: [0x3b, 0xca, 0x8a, 0x59, 0x4f, 0x37, 0xdd, 0x80, 0xff, 0x12, 0xbd, 0x9b, 0x2c, 0x45, 0x4b, 0x76, 0x68, 0xf2, 0x26, 0x57, 0x1a, 0x2f, 0x2c, 0x5d, 0x33, 0x89, 0xd7, 0xa5, 0xa9, 0x81, 0xba, 0xa7], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_device_gate.ptx"), "\0").as_bytes(), }, Companion { name: "q6_batch_preview.ptx", - key: [ - 0x6a, 0x4d, 0x43, 0xe4, 0x1a, 0x45, 0xd9, 0x9f, 0xbb, 0xaa, 0xe3, 0x91, 0x70, 0x38, 0xe2, 0x81, 0xf1, 0x1d, - 0x04, 0x37, 0x0e, 0x02, 0x59, 0xea, 0x70, 0x26, 0x81, 0x14, 0x42, 0x96, 0xde, 0x79, - ], + key: [0x6a, 0x4d, 0x43, 0xe4, 0x1a, 0x45, 0xd9, 0x9f, 0xbb, 0xaa, 0xe3, 0x91, 0x70, 0x38, 0xe2, 0x81, 0xf1, 0x1d, 0x04, 0x37, 0x0e, 0x02, 0x59, 0xea, 0x70, 0x26, 0x81, 0x14, 0x42, 0x96, 0xde, 0x79], len: 28112, - sha: [ - 0xf5, 0x4e, 0xea, 0xa6, 0xeb, 0x53, 0xa4, 0xd5, 0x02, 0x34, 0x4f, 0x90, 0x8f, 0x97, 0x65, 0xaa, 0xdf, 0x44, - 0x53, 0x77, 0xd4, 0x3a, 0x70, 0x53, 0x23, 0x59, 0xfe, 0xe2, 0x33, 0xa0, 0x06, 0x73, - ], + sha: [0xf5, 0x4e, 0xea, 0xa6, 0xeb, 0x53, 0xa4, 0xd5, 0x02, 0x34, 0x4f, 0x90, 0x8f, 0x97, 0x65, 0xaa, 0xdf, 0x44, 0x53, 0x77, 0xd4, 0x3a, 0x70, 0x53, 0x23, 0x59, 0xfe, 0xe2, 0x33, 0xa0, 0x06, 0x73], ptx: concat!(include_str!("../ptx-sm86/q6_batch_preview.ptx"), "\0").as_bytes(), }, Companion { name: "prefill_stage.ptx", - key: [ - 0x6f, 0x8f, 0xb3, 0xbb, 0xd1, 0x11, 0x71, 0xc9, 0x39, 0x02, 0x97, 0xd5, 0xd2, 0xc9, 0xcb, 0x90, 0x76, 0xd4, - 0xb6, 0x51, 0xf2, 0xa7, 0x04, 0x2b, 0xf1, 0x6f, 0x4c, 0xaf, 0x89, 0xa5, 0xb3, 0x84, - ], + key: [0x6f, 0x8f, 0xb3, 0xbb, 0xd1, 0x11, 0x71, 0xc9, 0x39, 0x02, 0x97, 0xd5, 0xd2, 0xc9, 0xcb, 0x90, 0x76, 0xd4, 0xb6, 0x51, 0xf2, 0xa7, 0x04, 0x2b, 0xf1, 0x6f, 0x4c, 0xaf, 0x89, 0xa5, 0xb3, 0x84], len: 161928, - sha: [ - 0xd8, 0x1a, 0x87, 0x43, 0x7b, 0x72, 0x6b, 0xcf, 0x1a, 0x9d, 0xf0, 0xca, 0x6d, 0x5e, 0xbe, 0xdf, 0x5c, 0x06, - 0xda, 0xce, 0xe6, 0x88, 0xbd, 0xc8, 0xfe, 0x91, 0x78, 0x91, 0xcc, 0x0c, 0xda, 0x4b, - ], + sha: [0xd8, 0x1a, 0x87, 0x43, 0x7b, 0x72, 0x6b, 0xcf, 0x1a, 0x9d, 0xf0, 0xca, 0x6d, 0x5e, 0xbe, 0xdf, 0x5c, 0x06, 0xda, 0xce, 0xe6, 0x88, 0xbd, 0xc8, 0xfe, 0x91, 0x78, 0x91, 0xcc, 0x0c, 0xda, 0x4b], ptx: concat!(include_str!("../ptx-sm86/prefill_stage.ptx"), "\0").as_bytes(), }, Companion { name: "original_verify_window_pcie_fast.ptx", - key: [ - 0x74, 0x07, 0x85, 0x9f, 0x8d, 0x88, 0x81, 0x66, 0x3f, 0x3a, 0x64, 0x6e, 0xbe, 0x28, 0x8c, 0x31, 0x13, 0x8c, - 0xce, 0x32, 0x27, 0xc1, 0xc5, 0xd9, 0xe2, 0xe5, 0x92, 0x64, 0x8e, 0xd7, 0x7a, 0xea, - ], + key: [0x74, 0x07, 0x85, 0x9f, 0x8d, 0x88, 0x81, 0x66, 0x3f, 0x3a, 0x64, 0x6e, 0xbe, 0x28, 0x8c, 0x31, 0x13, 0x8c, 0xce, 0x32, 0x27, 0xc1, 0xc5, 0xd9, 0xe2, 0xe5, 0x92, 0x64, 0x8e, 0xd7, 0x7a, 0xea], len: 71051, - sha: [ - 0x23, 0x48, 0x1b, 0x50, 0xaf, 0x2c, 0x50, 0x1b, 0x04, 0xed, 0xc1, 0xe9, 0xd4, 0xa3, 0x85, 0x35, 0xcf, 0x83, - 0x88, 0x46, 0xaa, 0x57, 0xd4, 0x4f, 0x0b, 0xcf, 0x2c, 0x2d, 0xc7, 0xf3, 0xd1, 0xa3, - ], + sha: [0x23, 0x48, 0x1b, 0x50, 0xaf, 0x2c, 0x50, 0x1b, 0x04, 0xed, 0xc1, 0xe9, 0xd4, 0xa3, 0x85, 0x35, 0xcf, 0x83, 0x88, 0x46, 0xaa, 0x57, 0xd4, 0x4f, 0x0b, 0xcf, 0x2c, 0x2d, 0xc7, 0xf3, 0xd1, 0xa3], ptx: concat!(include_str!("../ptx-sm86/original_verify_window_pcie_fast.ptx"), "\0").as_bytes(), }, Companion { name: "experimental_kv_q4.ptx", - key: [ - 0x74, 0x66, 0x5b, 0x01, 0x6f, 0xde, 0x9d, 0xc4, 0xf5, 0x0a, 0x36, 0xe6, 0x2c, 0xbf, 0x2e, 0x57, 0x8c, 0x73, - 0x5e, 0x48, 0xe3, 0xbe, 0x51, 0xb7, 0x07, 0x34, 0xe9, 0xe5, 0x39, 0x42, 0xcd, 0xe7, - ], + key: [0x74, 0x66, 0x5b, 0x01, 0x6f, 0xde, 0x9d, 0xc4, 0xf5, 0x0a, 0x36, 0xe6, 0x2c, 0xbf, 0x2e, 0x57, 0x8c, 0x73, 0x5e, 0x48, 0xe3, 0xbe, 0x51, 0xb7, 0x07, 0x34, 0xe9, 0xe5, 0x39, 0x42, 0xcd, 0xe7], len: 36319, - sha: [ - 0x36, 0x1d, 0xb3, 0xe8, 0x47, 0x1e, 0x42, 0x77, 0x8a, 0x4b, 0x7d, 0x45, 0x9a, 0xf7, 0x28, 0x9a, 0xa8, 0xe8, - 0x01, 0x7b, 0xb3, 0xa7, 0x45, 0x5e, 0x6a, 0xa2, 0xe0, 0x49, 0xb2, 0x2a, 0xd0, 0x93, - ], + sha: [0x36, 0x1d, 0xb3, 0xe8, 0x47, 0x1e, 0x42, 0x77, 0x8a, 0x4b, 0x7d, 0x45, 0x9a, 0xf7, 0x28, 0x9a, 0xa8, 0xe8, 0x01, 0x7b, 0xb3, 0xa7, 0x45, 0x5e, 0x6a, 0xa2, 0xe0, 0x49, 0xb2, 0x2a, 0xd0, 0x93], ptx: concat!(include_str!("../ptx-sm86/experimental_kv_q4.ptx"), "\0").as_bytes(), }, Companion { name: "qwen_qsa_attention_native.ptx", - key: [ - 0x77, 0x72, 0xe4, 0xe7, 0x5d, 0x78, 0xa9, 0x91, 0x01, 0x44, 0xca, 0x10, 0x85, 0x51, 0x80, 0x0f, 0xd4, 0x29, - 0x69, 0x55, 0x78, 0x15, 0x40, 0xaf, 0xb6, 0x5f, 0x53, 0xd6, 0x12, 0xd7, 0xe1, 0xf3, - ], + key: [0x77, 0x72, 0xe4, 0xe7, 0x5d, 0x78, 0xa9, 0x91, 0x01, 0x44, 0xca, 0x10, 0x85, 0x51, 0x80, 0x0f, 0xd4, 0x29, 0x69, 0x55, 0x78, 0x15, 0x40, 0xaf, 0xb6, 0x5f, 0x53, 0xd6, 0x12, 0xd7, 0xe1, 0xf3], len: 3139, - sha: [ - 0xda, 0xb3, 0xfd, 0x1c, 0xe3, 0xde, 0x7e, 0xfc, 0x94, 0x1e, 0xcb, 0x26, 0x84, 0x33, 0x6d, 0xea, 0x26, 0xe3, - 0x61, 0xd6, 0xc5, 0x0a, 0xbd, 0x45, 0xdc, 0xf2, 0x0f, 0x2e, 0x1e, 0x8f, 0x86, 0xdd, - ], + sha: [0xda, 0xb3, 0xfd, 0x1c, 0xe3, 0xde, 0x7e, 0xfc, 0x94, 0x1e, 0xcb, 0x26, 0x84, 0x33, 0x6d, 0xea, 0x26, 0xe3, 0x61, 0xd6, 0xc5, 0x0a, 0xbd, 0x45, 0xdc, 0xf2, 0x0f, 0x2e, 0x1e, 0x8f, 0x86, 0xdd], ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_attention_native.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_iq3_xxs.ptx", - key: [ - 0x78, 0x82, 0x05, 0x48, 0x65, 0xe5, 0x55, 0x01, 0x0d, 0x4d, 0x60, 0xfc, 0x21, 0xf1, 0xae, 0xbb, 0x97, 0xb1, - 0x0d, 0xc0, 0x6a, 0xf1, 0xaf, 0xe3, 0xd0, 0x9f, 0xce, 0x21, 0x96, 0xac, 0x37, 0x67, - ], + key: [0x78, 0x82, 0x05, 0x48, 0x65, 0xe5, 0x55, 0x01, 0x0d, 0x4d, 0x60, 0xfc, 0x21, 0xf1, 0xae, 0xbb, 0x97, 0xb1, 0x0d, 0xc0, 0x6a, 0xf1, 0xaf, 0xe3, 0xd0, 0x9f, 0xce, 0x21, 0x96, 0xac, 0x37, 0x67], len: 16161, - sha: [ - 0xd7, 0x67, 0xad, 0x5a, 0x01, 0x05, 0x0a, 0x8e, 0xc6, 0x8b, 0x73, 0xc3, 0xb5, 0x30, 0x05, 0x09, 0x40, 0x2a, - 0x5f, 0x25, 0x14, 0xd6, 0x72, 0xf1, 0x93, 0x01, 0x71, 0xa5, 0xef, 0x98, 0x65, 0xbc, - ], + sha: [0xd7, 0x67, 0xad, 0x5a, 0x01, 0x05, 0x0a, 0x8e, 0xc6, 0x8b, 0x73, 0xc3, 0xb5, 0x30, 0x05, 0x09, 0x40, 0x2a, 0x5f, 0x25, 0x14, 0xd6, 0x72, 0xf1, 0x93, 0x01, 0x71, 0xa5, 0xef, 0x98, 0x65, 0xbc], ptx: concat!(include_str!("../ptx-sm86/moe_group_iq3_xxs.ptx"), "\0").as_bytes(), }, Companion { name: "head_greedy.ptx", - key: [ - 0x78, 0x9f, 0xb7, 0xfc, 0xd5, 0x56, 0x4d, 0xea, 0xac, 0x9e, 0xbd, 0x24, 0x79, 0x7d, 0x3a, 0x15, 0xcd, 0xbb, - 0x7c, 0x45, 0xf3, 0x97, 0xa7, 0x72, 0x05, 0x7a, 0x6c, 0x5e, 0xd3, 0xf5, 0x2e, 0xb1, - ], + key: [0x78, 0x9f, 0xb7, 0xfc, 0xd5, 0x56, 0x4d, 0xea, 0xac, 0x9e, 0xbd, 0x24, 0x79, 0x7d, 0x3a, 0x15, 0xcd, 0xbb, 0x7c, 0x45, 0xf3, 0x97, 0xa7, 0x72, 0x05, 0x7a, 0x6c, 0x5e, 0xd3, 0xf5, 0x2e, 0xb1], len: 4291, - sha: [ - 0x00, 0xa5, 0xe1, 0x17, 0x6c, 0xc8, 0x95, 0x28, 0x19, 0x41, 0x5f, 0x62, 0x2b, 0x88, 0x6e, 0xea, 0xc3, 0xd6, - 0x7b, 0x1f, 0x2b, 0xd5, 0xa4, 0xf9, 0xc7, 0x2e, 0xde, 0x97, 0x85, 0xdf, 0xd8, 0x6e, - ], + sha: [0x00, 0xa5, 0xe1, 0x17, 0x6c, 0xc8, 0x95, 0x28, 0x19, 0x41, 0x5f, 0x62, 0x2b, 0x88, 0x6e, 0xea, 0xc3, 0xd6, 0x7b, 0x1f, 0x2b, 0xd5, 0xa4, 0xf9, 0xc7, 0x2e, 0xde, 0x97, 0x85, 0xdf, 0xd8, 0x6e], ptx: concat!(include_str!("../ptx-sm86/head_greedy.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_gr_fixed.ptx", - key: [ - 0x7a, 0xba, 0x70, 0x01, 0x45, 0xb1, 0x9a, 0x09, 0x1d, 0x1c, 0xa2, 0x77, 0x44, 0x62, 0x01, 0xff, 0x47, 0x69, - 0xba, 0xa3, 0x66, 0xe7, 0xd5, 0xa0, 0x29, 0x4a, 0x91, 0xe7, 0x6b, 0xa6, 0x09, 0xd4, - ], + key: [0x7a, 0xba, 0x70, 0x01, 0x45, 0xb1, 0x9a, 0x09, 0x1d, 0x1c, 0xa2, 0x77, 0x44, 0x62, 0x01, 0xff, 0x47, 0x69, 0xba, 0xa3, 0x66, 0xe7, 0xd5, 0xa0, 0x29, 0x4a, 0x91, 0xe7, 0x6b, 0xa6, 0x09, 0xd4], len: 103348, - sha: [ - 0xcf, 0xa8, 0x85, 0xcd, 0x69, 0xf9, 0x51, 0xd3, 0x61, 0x67, 0x31, 0x9a, 0xb0, 0x5b, 0x5a, 0x6b, 0xbd, 0xce, - 0x95, 0x98, 0xc9, 0x13, 0x3c, 0xd4, 0x30, 0x0d, 0x18, 0xa1, 0x92, 0x8f, 0x24, 0xdd, - ], + sha: [0xcf, 0xa8, 0x85, 0xcd, 0x69, 0xf9, 0x51, 0xd3, 0x61, 0x67, 0x31, 0x9a, 0xb0, 0x5b, 0x5a, 0x6b, 0xbd, 0xce, 0x95, 0x98, 0xc9, 0x13, 0x3c, 0xd4, 0x30, 0x0d, 0x18, 0xa1, 0x92, 0x8f, 0x24, 0xdd], ptx: concat!(include_str!("../ptx-sm86/mtp_gr_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "gdn_fixed.ptx", - key: [ - 0x7b, 0x2f, 0x20, 0x3c, 0xe1, 0xb1, 0xb4, 0xc7, 0xe6, 0x3b, 0xb5, 0x6a, 0x1f, 0x7c, 0x35, 0x1a, 0x21, 0x3e, - 0x1f, 0x5d, 0xf9, 0x71, 0x1a, 0xd2, 0xd8, 0xdb, 0x30, 0x47, 0xae, 0xad, 0x9e, 0x25, - ], + key: [0x7b, 0x2f, 0x20, 0x3c, 0xe1, 0xb1, 0xb4, 0xc7, 0xe6, 0x3b, 0xb5, 0x6a, 0x1f, 0x7c, 0x35, 0x1a, 0x21, 0x3e, 0x1f, 0x5d, 0xf9, 0x71, 0x1a, 0xd2, 0xd8, 0xdb, 0x30, 0x47, 0xae, 0xad, 0x9e, 0x25], len: 35268, - sha: [ - 0x09, 0x82, 0x29, 0x8e, 0xa9, 0xf8, 0xe4, 0xbf, 0xa7, 0x0e, 0xef, 0xb1, 0xde, 0xe0, 0xa4, 0x30, 0x73, 0x74, - 0x38, 0x9b, 0x3d, 0x60, 0x4d, 0xf5, 0xea, 0x50, 0x7f, 0x35, 0xb5, 0x2f, 0xe4, 0x10, - ], + sha: [0x09, 0x82, 0x29, 0x8e, 0xa9, 0xf8, 0xe4, 0xbf, 0xa7, 0x0e, 0xef, 0xb1, 0xde, 0xe0, 0xa4, 0x30, 0x73, 0x74, 0x38, 0x9b, 0x3d, 0x60, 0x4d, 0xf5, 0xea, 0x50, 0x7f, 0x35, 0xb5, 0x2f, 0xe4, 0x10], ptx: concat!(include_str!("../ptx-sm86/gdn_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "offline_gdn_fused_t1.ptx", - key: [ - 0x7b, 0xd0, 0x09, 0x09, 0x27, 0x3c, 0x41, 0x06, 0x55, 0xc3, 0xe1, 0x78, 0x1e, 0x58, 0xd2, 0x1a, 0xe1, 0x54, - 0x18, 0x1f, 0xbd, 0x74, 0xc6, 0xb2, 0x11, 0x55, 0x74, 0x8c, 0x97, 0x03, 0x5d, 0xd3, - ], + key: [0x7b, 0xd0, 0x09, 0x09, 0x27, 0x3c, 0x41, 0x06, 0x55, 0xc3, 0xe1, 0x78, 0x1e, 0x58, 0xd2, 0x1a, 0xe1, 0x54, 0x18, 0x1f, 0xbd, 0x74, 0xc6, 0xb2, 0x11, 0x55, 0x74, 0x8c, 0x97, 0x03, 0x5d, 0xd3], len: 51663, - sha: [ - 0x5d, 0x2d, 0xa8, 0x20, 0xdb, 0xc9, 0x31, 0x38, 0xe6, 0xa7, 0xce, 0x85, 0x92, 0xc7, 0x1e, 0xc3, 0xd6, 0xa2, - 0xb1, 0x0d, 0x57, 0xd1, 0x89, 0xa2, 0xab, 0x50, 0x7d, 0xce, 0x5b, 0x20, 0xd0, 0x1c, - ], + sha: [0x5d, 0x2d, 0xa8, 0x20, 0xdb, 0xc9, 0x31, 0x38, 0xe6, 0xa7, 0xce, 0x85, 0x92, 0xc7, 0x1e, 0xc3, 0xd6, 0xa2, 0xb1, 0x0d, 0x57, 0xd1, 0x89, 0xa2, 0xab, 0x50, 0x7d, 0xce, 0x5b, 0x20, 0xd0, 0x1c], ptx: concat!(include_str!("../ptx-sm86/offline_gdn_fused_t1.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_native_decode.ptx", - key: [ - 0x7c, 0x98, 0xe8, 0xf0, 0x08, 0x92, 0x14, 0x23, 0xe3, 0x05, 0x9f, 0x81, 0xf9, 0xf4, 0xe3, 0x17, 0xeb, 0x40, - 0x7d, 0x15, 0xd6, 0xb9, 0x81, 0x5a, 0xe6, 0xda, 0xd7, 0x92, 0x08, 0x83, 0xb0, 0xda, - ], + key: [0x7c, 0x98, 0xe8, 0xf0, 0x08, 0x92, 0x14, 0x23, 0xe3, 0x05, 0x9f, 0x81, 0xf9, 0xf4, 0xe3, 0x17, 0xeb, 0x40, 0x7d, 0x15, 0xd6, 0xb9, 0x81, 0x5a, 0xe6, 0xda, 0xd7, 0x92, 0x08, 0x83, 0xb0, 0xda], len: 55720, - sha: [ - 0xde, 0x1e, 0x3c, 0x7a, 0xe0, 0x3c, 0x7e, 0x7f, 0x57, 0x47, 0x2e, 0xbd, 0xe7, 0x58, 0x1f, 0xf0, 0x51, 0x62, - 0xb5, 0x45, 0xb1, 0x00, 0x27, 0xf9, 0x6b, 0x2b, 0x36, 0xc4, 0x10, 0xd1, 0xa3, 0x65, - ], + sha: [0xde, 0x1e, 0x3c, 0x7a, 0xe0, 0x3c, 0x7e, 0x7f, 0x57, 0x47, 0x2e, 0xbd, 0xe7, 0x58, 0x1f, 0xf0, 0x51, 0x62, 0xb5, 0x45, 0xb1, 0x00, 0x27, 0xf9, 0x6b, 0x2b, 0x36, 0xc4, 0x10, 0xd1, 0xa3, 0x65], ptx: concat!(include_str!("../ptx-sm86/qsa_native_decode.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_prefill_embedding.ptx", - key: [ - 0x7e, 0x49, 0xc0, 0x3b, 0x93, 0x3c, 0xdf, 0x6a, 0x4a, 0x79, 0x37, 0x6f, 0xfa, 0x97, 0xf0, 0x61, 0x88, 0x7a, - 0x54, 0x92, 0x46, 0x77, 0x43, 0xd0, 0x8e, 0x28, 0x5a, 0x13, 0x95, 0x58, 0x0f, 0xc8, - ], + key: [0x7e, 0x49, 0xc0, 0x3b, 0x93, 0x3c, 0xdf, 0x6a, 0x4a, 0x79, 0x37, 0x6f, 0xfa, 0x97, 0xf0, 0x61, 0x88, 0x7a, 0x54, 0x92, 0x46, 0x77, 0x43, 0xd0, 0x8e, 0x28, 0x5a, 0x13, 0x95, 0x58, 0x0f, 0xc8], len: 847405, - sha: [ - 0x2c, 0xe1, 0xd3, 0xe9, 0xaa, 0x97, 0x2f, 0x1f, 0xd0, 0xc1, 0x34, 0x27, 0x21, 0x66, 0xd2, 0x72, 0x22, 0xe9, - 0x3b, 0xae, 0x18, 0xda, 0x19, 0xfc, 0x11, 0x97, 0x41, 0x6f, 0x26, 0x4a, 0xe5, 0x54, - ], + sha: [0x2c, 0xe1, 0xd3, 0xe9, 0xaa, 0x97, 0x2f, 0x1f, 0xd0, 0xc1, 0x34, 0x27, 0x21, 0x66, 0xd2, 0x72, 0x22, 0xe9, 0x3b, 0xae, 0x18, 0xda, 0x19, 0xfc, 0x11, 0x97, 0x41, 0x6f, 0x26, 0x4a, 0xe5, 0x54], ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_embedding.ptx"), "\0").as_bytes(), }, Companion { name: "native_head_native.ptx", - key: [ - 0x81, 0xa3, 0x99, 0x0c, 0x14, 0x3e, 0x45, 0x1d, 0xac, 0x79, 0x48, 0x62, 0xcf, 0x73, 0x3f, 0x5f, 0x41, 0x21, - 0xf5, 0x2a, 0xa0, 0x70, 0x50, 0xc5, 0x6e, 0x06, 0x1c, 0x17, 0x63, 0xd1, 0x47, 0x9a, - ], + key: [0x81, 0xa3, 0x99, 0x0c, 0x14, 0x3e, 0x45, 0x1d, 0xac, 0x79, 0x48, 0x62, 0xcf, 0x73, 0x3f, 0x5f, 0x41, 0x21, 0xf5, 0x2a, 0xa0, 0x70, 0x50, 0xc5, 0x6e, 0x06, 0x1c, 0x17, 0x63, 0xd1, 0x47, 0x9a], len: 7398533, - sha: [ - 0xe5, 0x44, 0x90, 0xc3, 0x6e, 0x5c, 0xd5, 0xbf, 0x1f, 0x3c, 0x77, 0xc1, 0xaa, 0xf0, 0xdb, 0x21, 0x1c, 0x06, - 0x0d, 0x53, 0xfa, 0x93, 0x0a, 0x7a, 0xd0, 0xd4, 0xe9, 0xa5, 0x1c, 0xb9, 0x33, 0x89, - ], + sha: [0xe5, 0x44, 0x90, 0xc3, 0x6e, 0x5c, 0xd5, 0xbf, 0x1f, 0x3c, 0x77, 0xc1, 0xaa, 0xf0, 0xdb, 0x21, 0x1c, 0x06, 0x0d, 0x53, 0xfa, 0x93, 0x0a, 0x7a, 0xd0, 0xd4, 0xe9, 0xa5, 0x1c, 0xb9, 0x33, 0x89], ptx: concat!(include_str!("../ptx-sm86/native_head_native.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_session_native_rope.ptx", - key: [ - 0x85, 0xb7, 0xef, 0x7c, 0xa5, 0x94, 0x3d, 0xbd, 0x71, 0x07, 0x10, 0x6b, 0x30, 0x29, 0xd5, 0x02, 0x7b, 0x46, - 0x44, 0x14, 0x8d, 0x70, 0x05, 0xa4, 0x7d, 0xef, 0x7f, 0xa9, 0x01, 0xa3, 0xd7, 0x0a, - ], + key: [0x85, 0xb7, 0xef, 0x7c, 0xa5, 0x94, 0x3d, 0xbd, 0x71, 0x07, 0x10, 0x6b, 0x30, 0x29, 0xd5, 0x02, 0x7b, 0x46, 0x44, 0x14, 0x8d, 0x70, 0x05, 0xa4, 0x7d, 0xef, 0x7f, 0xa9, 0x01, 0xa3, 0xd7, 0x0a], len: 10518, - sha: [ - 0x8e, 0x24, 0xc9, 0xe8, 0x0e, 0xe3, 0x11, 0xc7, 0x82, 0x77, 0x00, 0x77, 0x70, 0x3c, 0x7c, 0x11, 0x2a, 0x16, - 0x3b, 0xb1, 0x12, 0x3c, 0x95, 0xb8, 0xc3, 0x12, 0x38, 0x0d, 0xf7, 0x14, 0x03, 0x25, - ], + sha: [0x8e, 0x24, 0xc9, 0xe8, 0x0e, 0xe3, 0x11, 0xc7, 0x82, 0x77, 0x00, 0x77, 0x70, 0x3c, 0x7c, 0x11, 0x2a, 0x16, 0x3b, 0xb1, 0x12, 0x3c, 0x95, 0xb8, 0xc3, 0x12, 0x38, 0x0d, 0xf7, 0x14, 0x03, 0x25], ptx: concat!(include_str!("../ptx-sm86/mtp_original_session_native_rope.ptx"), "\0").as_bytes(), }, Companion { name: "native_head_sampler.ptx", - key: [ - 0x86, 0x3d, 0xb1, 0x3d, 0xc6, 0x50, 0x23, 0x20, 0x6e, 0xb1, 0xa4, 0x5f, 0x29, 0xd4, 0xb9, 0x90, 0xa6, 0x59, - 0x57, 0xba, 0x15, 0xd7, 0x83, 0xc2, 0x32, 0x9b, 0xbd, 0x88, 0xec, 0x61, 0x33, 0x3f, - ], + key: [0x86, 0x3d, 0xb1, 0x3d, 0xc6, 0x50, 0x23, 0x20, 0x6e, 0xb1, 0xa4, 0x5f, 0x29, 0xd4, 0xb9, 0x90, 0xa6, 0x59, 0x57, 0xba, 0x15, 0xd7, 0x83, 0xc2, 0x32, 0x9b, 0xbd, 0x88, 0xec, 0x61, 0x33, 0x3f], len: 497973, - sha: [ - 0xe8, 0x64, 0x39, 0x00, 0x9f, 0x42, 0xe6, 0xbf, 0x64, 0xbf, 0xfa, 0xe8, 0x1c, 0xdc, 0x7e, 0xef, 0x69, 0x3f, - 0xac, 0x9c, 0x09, 0x32, 0x80, 0x3f, 0xf0, 0x20, 0x8f, 0x85, 0x07, 0x1a, 0x86, 0x49, - ], + sha: [0xe8, 0x64, 0x39, 0x00, 0x9f, 0x42, 0xe6, 0xbf, 0x64, 0xbf, 0xfa, 0xe8, 0x1c, 0xdc, 0x7e, 0xef, 0x69, 0x3f, 0xac, 0x9c, 0x09, 0x32, 0x80, 0x3f, 0xf0, 0x20, 0x8f, 0x85, 0x07, 0x1a, 0x86, 0x49], ptx: concat!(include_str!("../ptx-sm86/native_head_sampler.ptx"), "\0").as_bytes(), }, Companion { name: "mmq_resident_helpers.ptx", - key: [ - 0x87, 0x0c, 0x6b, 0xc8, 0xa6, 0xec, 0x32, 0x0a, 0x05, 0x9c, 0x50, 0xbe, 0x9d, 0x5c, 0x96, 0x2f, 0xed, 0xec, - 0x86, 0x63, 0x4d, 0x98, 0x8f, 0xc0, 0xe6, 0xb9, 0xd7, 0xed, 0xea, 0x11, 0x8d, 0x89, - ], + key: [0x87, 0x0c, 0x6b, 0xc8, 0xa6, 0xec, 0x32, 0x0a, 0x05, 0x9c, 0x50, 0xbe, 0x9d, 0x5c, 0x96, 0x2f, 0xed, 0xec, 0x86, 0x63, 0x4d, 0x98, 0x8f, 0xc0, 0xe6, 0xb9, 0xd7, 0xed, 0xea, 0x11, 0x8d, 0x89], len: 4045, - sha: [ - 0x66, 0x8f, 0x35, 0x95, 0xce, 0x0d, 0xc7, 0x12, 0x77, 0x2b, 0x80, 0xbd, 0xa3, 0xb8, 0x5b, 0x5f, 0x05, 0xdd, - 0x89, 0x23, 0x2a, 0x0a, 0x15, 0x00, 0x46, 0xff, 0x1f, 0xc4, 0xb1, 0x37, 0x90, 0x94, - ], + sha: [0x66, 0x8f, 0x35, 0x95, 0xce, 0x0d, 0xc7, 0x12, 0x77, 0x2b, 0x80, 0xbd, 0xa3, 0xb8, 0x5b, 0x5f, 0x05, 0xdd, 0x89, 0x23, 0x2a, 0x0a, 0x15, 0x00, 0x46, 0xff, 0x1f, 0xc4, 0xb1, 0x37, 0x90, 0x94], ptx: concat!(include_str!("../ptx-sm86/mmq_resident_helpers.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_kv.ptx", - key: [ - 0x87, 0xfd, 0x96, 0x69, 0xca, 0x28, 0x05, 0xe3, 0xaf, 0x3f, 0x97, 0x26, 0xb9, 0xd6, 0x92, 0x66, 0xda, 0xea, - 0xc4, 0x17, 0x25, 0x31, 0x6a, 0x38, 0x23, 0x63, 0xc9, 0x56, 0xfd, 0x51, 0x04, 0x65, - ], + key: [0x87, 0xfd, 0x96, 0x69, 0xca, 0x28, 0x05, 0xe3, 0xaf, 0x3f, 0x97, 0x26, 0xb9, 0xd6, 0x92, 0x66, 0xda, 0xea, 0xc4, 0x17, 0x25, 0x31, 0x6a, 0x38, 0x23, 0x63, 0xc9, 0x56, 0xfd, 0x51, 0x04, 0x65], len: 12143, - sha: [ - 0xad, 0xce, 0x0f, 0xc9, 0xb8, 0x5a, 0x2f, 0x60, 0x52, 0xcc, 0xd1, 0x13, 0x55, 0xf9, 0x11, 0x8b, 0x88, 0x63, - 0x4e, 0x52, 0x31, 0x46, 0xe9, 0xfa, 0x8e, 0x1f, 0x86, 0xf0, 0xe8, 0xdb, 0x5b, 0x6c, - ], + sha: [0xad, 0xce, 0x0f, 0xc9, 0xb8, 0x5a, 0x2f, 0x60, 0x52, 0xcc, 0xd1, 0x13, 0x55, 0xf9, 0x11, 0x8b, 0x88, 0x63, 0x4e, 0x52, 0x31, 0x46, 0xe9, 0xfa, 0x8e, 0x1f, 0x86, 0xf0, 0xe8, 0xdb, 0x5b, 0x6c], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_kv.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_gr_write.ptx", - key: [ - 0x88, 0x1e, 0x38, 0xf0, 0xc9, 0x78, 0x6c, 0xed, 0x23, 0x8b, 0x7a, 0x00, 0x14, 0x8a, 0x2e, 0x16, 0xac, 0xff, - 0x92, 0x7f, 0x7b, 0x8d, 0xe6, 0x6a, 0x1d, 0xd5, 0x83, 0xab, 0xf8, 0x1c, 0xf5, 0xb1, - ], + key: [0x88, 0x1e, 0x38, 0xf0, 0xc9, 0x78, 0x6c, 0xed, 0x23, 0x8b, 0x7a, 0x00, 0x14, 0x8a, 0x2e, 0x16, 0xac, 0xff, 0x92, 0x7f, 0x7b, 0x8d, 0xe6, 0x6a, 0x1d, 0xd5, 0x83, 0xab, 0xf8, 0x1c, 0xf5, 0xb1], len: 133910, - sha: [ - 0x3b, 0xb1, 0x46, 0x0d, 0xe3, 0x5d, 0xa4, 0x42, 0x21, 0x7f, 0xf0, 0x35, 0x38, 0x7c, 0xaf, 0xc5, 0x33, 0x3a, - 0x7d, 0x6b, 0x6c, 0x31, 0x16, 0xc5, 0x8a, 0xb3, 0x0a, 0xce, 0xd9, 0x62, 0x0c, 0xd1, - ], + sha: [0x3b, 0xb1, 0x46, 0x0d, 0xe3, 0x5d, 0xa4, 0x42, 0x21, 0x7f, 0xf0, 0x35, 0x38, 0x7c, 0xaf, 0xc5, 0x33, 0x3a, 0x7d, 0x6b, 0x6c, 0x31, 0x16, 0xc5, 0x8a, 0xb3, 0x0a, 0xce, 0xd9, 0x62, 0x0c, 0xd1], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_gr_write.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_indexer.ptx", - key: [ - 0x89, 0x15, 0x70, 0x0d, 0xd8, 0x1c, 0x99, 0x08, 0x3d, 0xe3, 0xcf, 0xf4, 0xed, 0x5d, 0x1a, 0x8b, 0x9a, 0x0c, - 0x5d, 0xb1, 0x8c, 0x4d, 0x6d, 0xef, 0x9d, 0x49, 0xb3, 0xbb, 0xc8, 0xf2, 0x82, 0x30, - ], + key: [0x89, 0x15, 0x70, 0x0d, 0xd8, 0x1c, 0x99, 0x08, 0x3d, 0xe3, 0xcf, 0xf4, 0xed, 0x5d, 0x1a, 0x8b, 0x9a, 0x0c, 0x5d, 0xb1, 0x8c, 0x4d, 0x6d, 0xef, 0x9d, 0x49, 0xb3, 0xbb, 0xc8, 0xf2, 0x82, 0x30], len: 30560, - sha: [ - 0x51, 0x62, 0x2e, 0x4f, 0x08, 0xa7, 0xe1, 0xfb, 0x52, 0x0f, 0xac, 0x0d, 0x0d, 0x8d, 0x2c, 0x3b, 0x61, 0xdc, - 0xa1, 0x22, 0x70, 0x51, 0xaa, 0x14, 0xf6, 0xf7, 0x7d, 0xfc, 0x0a, 0xdf, 0x57, 0xad, - ], + sha: [0x51, 0x62, 0x2e, 0x4f, 0x08, 0xa7, 0xe1, 0xfb, 0x52, 0x0f, 0xac, 0x0d, 0x0d, 0x8d, 0x2c, 0x3b, 0x61, 0xdc, 0xa1, 0x22, 0x70, 0x51, 0xaa, 0x14, 0xf6, 0xf7, 0x7d, 0xfc, 0x0a, 0xdf, 0x57, 0xad], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_indexer.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_resolver.ptx", - key: [ - 0x8d, 0x3e, 0xcb, 0xae, 0xcb, 0xf2, 0x84, 0x45, 0xba, 0x64, 0x48, 0x5b, 0xdf, 0xf3, 0xd9, 0x1a, 0x21, 0xd8, - 0x7b, 0x85, 0xd5, 0x93, 0x9a, 0x01, 0x52, 0xef, 0x2f, 0x24, 0x14, 0x48, 0x0e, 0x22, - ], + key: [0x8d, 0x3e, 0xcb, 0xae, 0xcb, 0xf2, 0x84, 0x45, 0xba, 0x64, 0x48, 0x5b, 0xdf, 0xf3, 0xd9, 0x1a, 0x21, 0xd8, 0x7b, 0x85, 0xd5, 0x93, 0x9a, 0x01, 0x52, 0xef, 0x2f, 0x24, 0x14, 0x48, 0x0e, 0x22], len: 23915, - sha: [ - 0x32, 0xd9, 0x6c, 0xa6, 0xa7, 0x2f, 0x40, 0xed, 0xa2, 0x1d, 0x51, 0xd9, 0xf4, 0xd4, 0xd3, 0x77, 0xc3, 0x73, - 0xc6, 0x37, 0x83, 0xcc, 0x42, 0x29, 0x10, 0x88, 0x3b, 0xb8, 0xd8, 0xd8, 0xb0, 0x8d, - ], + sha: [0x32, 0xd9, 0x6c, 0xa6, 0xa7, 0x2f, 0x40, 0xed, 0xa2, 0x1d, 0x51, 0xd9, 0xf4, 0xd4, 0xd3, 0x77, 0xc3, 0x73, 0xc6, 0x37, 0x83, 0xcc, 0x42, 0x29, 0x10, 0x88, 0x3b, 0xb8, 0xd8, 0xd8, 0xb0, 0x8d], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_resolver.ptx"), "\0").as_bytes(), }, Companion { name: "q2_0_q8_1.ptx", - key: [ - 0x8e, 0x81, 0xdb, 0xba, 0xa7, 0x6d, 0x85, 0x16, 0x47, 0x63, 0x39, 0xc1, 0x68, 0xf1, 0xd9, 0xc1, 0x72, 0x34, - 0x1a, 0x78, 0xcc, 0xec, 0xda, 0x08, 0x71, 0x4a, 0x13, 0xa5, 0x68, 0x7e, 0x3b, 0x6e, - ], + key: [0x8e, 0x81, 0xdb, 0xba, 0xa7, 0x6d, 0x85, 0x16, 0x47, 0x63, 0x39, 0xc1, 0x68, 0xf1, 0xd9, 0xc1, 0x72, 0x34, 0x1a, 0x78, 0xcc, 0xec, 0xda, 0x08, 0x71, 0x4a, 0x13, 0xa5, 0x68, 0x7e, 0x3b, 0x6e], len: 18542, - sha: [ - 0x8a, 0x25, 0x1c, 0x65, 0x02, 0x31, 0xac, 0x07, 0xa0, 0xce, 0xa8, 0xdd, 0xa2, 0x12, 0xbb, 0x84, 0xd1, 0xcf, - 0x5c, 0xa3, 0x72, 0xf6, 0x30, 0xce, 0x03, 0x23, 0x81, 0xe0, 0x18, 0xce, 0x59, 0xf5, - ], + sha: [0x8a, 0x25, 0x1c, 0x65, 0x02, 0x31, 0xac, 0x07, 0xa0, 0xce, 0xa8, 0xdd, 0xa2, 0x12, 0xbb, 0x84, 0xd1, 0xcf, 0x5c, 0xa3, 0x72, 0xf6, 0x30, 0xce, 0x03, 0x23, 0x81, 0xe0, 0x18, 0xce, 0x59, 0xf5], ptx: concat!(include_str!("../ptx-sm86/q2_0_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_element.ptx", - key: [ - 0x8f, 0xdf, 0xdf, 0x8e, 0xf6, 0x16, 0x69, 0x8c, 0x12, 0x30, 0x1f, 0x7d, 0xf4, 0x71, 0x6f, 0xc0, 0x22, 0xbf, - 0x34, 0xb4, 0x19, 0x09, 0x9e, 0x4c, 0x97, 0x27, 0x29, 0x92, 0x0b, 0xd5, 0xf4, 0xa7, - ], + key: [0x8f, 0xdf, 0xdf, 0x8e, 0xf6, 0x16, 0x69, 0x8c, 0x12, 0x30, 0x1f, 0x7d, 0xf4, 0x71, 0x6f, 0xc0, 0x22, 0xbf, 0x34, 0xb4, 0x19, 0x09, 0x9e, 0x4c, 0x97, 0x27, 0x29, 0x92, 0x0b, 0xd5, 0xf4, 0xa7], len: 54956, - sha: [ - 0xe3, 0xd7, 0x50, 0x63, 0x73, 0xa9, 0x30, 0x1c, 0x4d, 0x0e, 0xbd, 0x40, 0x13, 0x17, 0x2c, 0xce, 0x60, 0x91, - 0xfc, 0xd5, 0x87, 0xb2, 0xad, 0xc3, 0x54, 0x1b, 0x6a, 0x55, 0xb9, 0xd5, 0xf1, 0xfd, - ], + sha: [0xe3, 0xd7, 0x50, 0x63, 0x73, 0xa9, 0x30, 0x1c, 0x4d, 0x0e, 0xbd, 0x40, 0x13, 0x17, 0x2c, 0xce, 0x60, 0x91, 0xfc, 0xd5, 0x87, 0xb2, 0xad, 0xc3, 0x54, 0x1b, 0x6a, 0x55, 0xb9, 0xd5, 0xf1, 0xfd], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_element.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_prompt_attention_variants.ptx", - key: [ - 0x90, 0x41, 0xe2, 0x50, 0xf6, 0xff, 0xca, 0x2f, 0x84, 0x9c, 0x20, 0x60, 0x5a, 0x3f, 0x75, 0x8c, 0x54, 0xf7, - 0x85, 0x6e, 0x7c, 0xd0, 0x15, 0xc8, 0xa1, 0xda, 0x66, 0x25, 0x04, 0x8d, 0x6a, 0xac, - ], + key: [0x90, 0x41, 0xe2, 0x50, 0xf6, 0xff, 0xca, 0x2f, 0x84, 0x9c, 0x20, 0x60, 0x5a, 0x3f, 0x75, 0x8c, 0x54, 0xf7, 0x85, 0x6e, 0x7c, 0xd0, 0x15, 0xc8, 0xa1, 0xda, 0x66, 0x25, 0x04, 0x8d, 0x6a, 0xac], len: 216290, - sha: [ - 0xa3, 0xe4, 0xd6, 0x97, 0x57, 0x88, 0xd1, 0x26, 0x72, 0xe3, 0x85, 0x5e, 0x5e, 0x9f, 0x16, 0x56, 0x0d, 0x3d, - 0x82, 0x63, 0xb7, 0x52, 0x16, 0xaa, 0xf0, 0x89, 0x5c, 0x57, 0x98, 0x70, 0xbb, 0x7d, - ], + sha: [0xa3, 0xe4, 0xd6, 0x97, 0x57, 0x88, 0xd1, 0x26, 0x72, 0xe3, 0x85, 0x5e, 0x5e, 0x9f, 0x16, 0x56, 0x0d, 0x3d, 0x82, 0x63, 0xb7, 0x52, 0x16, 0xaa, 0xf0, 0x89, 0x5c, 0x57, 0x98, 0x70, 0xbb, 0x7d], ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_attention_variants.ptx"), "\0").as_bytes(), }, Companion { name: "qwen_qsa_attention.ptx", - key: [ - 0x91, 0x21, 0x9c, 0xfb, 0xc1, 0xa7, 0x7c, 0x4b, 0xb6, 0x66, 0x61, 0x06, 0x0a, 0xc9, 0x39, 0xa5, 0x0d, 0xc4, - 0xc4, 0xd7, 0xd4, 0xdb, 0x8d, 0x50, 0xbc, 0x59, 0xfb, 0xcd, 0x16, 0x75, 0x62, 0xb2, - ], + key: [0x91, 0x21, 0x9c, 0xfb, 0xc1, 0xa7, 0x7c, 0x4b, 0xb6, 0x66, 0x61, 0x06, 0x0a, 0xc9, 0x39, 0xa5, 0x0d, 0xc4, 0xc4, 0xd7, 0xd4, 0xdb, 0x8d, 0x50, 0xbc, 0x59, 0xfb, 0xcd, 0x16, 0x75, 0x62, 0xb2], len: 26737, - sha: [ - 0xc1, 0x11, 0xc6, 0x12, 0x6a, 0x3a, 0x67, 0x5e, 0xc8, 0x87, 0x20, 0x88, 0x1d, 0x46, 0x99, 0xa6, 0xe7, 0x21, - 0x84, 0xd2, 0xf4, 0x55, 0x87, 0x9a, 0xe0, 0x85, 0x5c, 0x56, 0xb8, 0x48, 0xbe, 0xa1, - ], + sha: [0xc1, 0x11, 0xc6, 0x12, 0x6a, 0x3a, 0x67, 0x5e, 0xc8, 0x87, 0x20, 0x88, 0x1d, 0x46, 0x99, 0xa6, 0xe7, 0x21, 0x84, 0xd2, 0xf4, 0x55, 0x87, 0x9a, 0xe0, 0x85, 0x5c, 0x56, 0xb8, 0x48, 0xbe, 0xa1], ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_attention.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_down_q2_0.ptx", - key: [ - 0x94, 0x7d, 0x08, 0xc4, 0x10, 0x9a, 0x19, 0x7a, 0xa1, 0xfa, 0xfc, 0xa4, 0xe8, 0xc9, 0x82, 0x3c, 0x91, 0xa8, - 0xbd, 0xa0, 0x34, 0xb1, 0x62, 0x79, 0x2c, 0x83, 0x9a, 0x67, 0x97, 0x55, 0x19, 0xda, - ], + key: [0x94, 0x7d, 0x08, 0xc4, 0x10, 0x9a, 0x19, 0x7a, 0xa1, 0xfa, 0xfc, 0xa4, 0xe8, 0xc9, 0x82, 0x3c, 0x91, 0xa8, 0xbd, 0xa0, 0x34, 0xb1, 0x62, 0x79, 0x2c, 0x83, 0x9a, 0x67, 0x97, 0x55, 0x19, 0xda], len: 13458, - sha: [ - 0xfc, 0x1a, 0xfa, 0x0b, 0x72, 0x43, 0x38, 0xd9, 0x31, 0x48, 0x1f, 0x41, 0x61, 0x6b, 0x8d, 0x25, 0x1f, 0x15, - 0x0d, 0x06, 0x5d, 0x91, 0x15, 0x1a, 0x77, 0x12, 0xf9, 0xa9, 0x41, 0xce, 0x25, 0x4f, - ], + sha: [0xfc, 0x1a, 0xfa, 0x0b, 0x72, 0x43, 0x38, 0xd9, 0x31, 0x48, 0x1f, 0x41, 0x61, 0x6b, 0x8d, 0x25, 0x1f, 0x15, 0x0d, 0x06, 0x5d, 0x91, 0x15, 0x1a, 0x77, 0x12, 0xf9, 0xa9, 0x41, 0xce, 0x25, 0x4f], ptx: concat!(include_str!("../ptx-sm86/moe_group_down_q2_0.ptx"), "\0").as_bytes(), }, Companion { name: "iq3_s_q8_1.ptx", - key: [ - 0x94, 0xf7, 0x98, 0xc0, 0x08, 0x13, 0xc2, 0xfb, 0x86, 0x0b, 0x4b, 0xf7, 0x7b, 0xe9, 0x22, 0x57, 0x67, 0xd4, - 0x08, 0x95, 0x5e, 0x34, 0x21, 0x33, 0x0a, 0xc3, 0x4a, 0x4e, 0xbd, 0x43, 0x97, 0x8f, - ], + key: [0x94, 0xf7, 0x98, 0xc0, 0x08, 0x13, 0xc2, 0xfb, 0x86, 0x0b, 0x4b, 0xf7, 0x7b, 0xe9, 0x22, 0x57, 0x67, 0xd4, 0x08, 0x95, 0x5e, 0x34, 0x21, 0x33, 0x0a, 0xc3, 0x4a, 0x4e, 0xbd, 0x43, 0x97, 0x8f], len: 24712, - sha: [ - 0xb1, 0x98, 0x60, 0x07, 0x0e, 0x69, 0xdc, 0xcd, 0x5e, 0x98, 0xd1, 0xe6, 0xbc, 0x7c, 0xdd, 0xcd, 0xa2, 0x92, - 0x8e, 0xfb, 0xd3, 0xf0, 0xbd, 0x21, 0x56, 0x8f, 0xd1, 0xae, 0x7d, 0x4a, 0xe9, 0x27, - ], + sha: [0xb1, 0x98, 0x60, 0x07, 0x0e, 0x69, 0xdc, 0xcd, 0x5e, 0x98, 0xd1, 0xe6, 0xbc, 0x7c, 0xdd, 0xcd, 0xa2, 0x92, 0x8e, 0xfb, 0xd3, 0xf0, 0xbd, 0x21, 0x56, 0x8f, 0xd1, 0xae, 0x7d, 0x4a, 0xe9, 0x27], ptx: concat!(include_str!("../ptx-sm86/iq3_s_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_gr_post.ptx", - key: [ - 0x9b, 0x47, 0x9c, 0x0f, 0x41, 0x2a, 0xe0, 0x07, 0x73, 0x81, 0x5c, 0x9a, 0x6d, 0x89, 0xd7, 0xf4, 0xc3, 0xf7, - 0xa9, 0xf0, 0xf6, 0x91, 0x87, 0x6d, 0xe8, 0x05, 0xeb, 0x38, 0x17, 0x8d, 0x97, 0x90, - ], + key: [0x9b, 0x47, 0x9c, 0x0f, 0x41, 0x2a, 0xe0, 0x07, 0x73, 0x81, 0x5c, 0x9a, 0x6d, 0x89, 0xd7, 0xf4, 0xc3, 0xf7, 0xa9, 0xf0, 0xf6, 0x91, 0x87, 0x6d, 0xe8, 0x05, 0xeb, 0x38, 0x17, 0x8d, 0x97, 0x90], len: 35821, - sha: [ - 0x77, 0x93, 0x32, 0x2e, 0x19, 0x00, 0x2f, 0xe8, 0x19, 0x97, 0xbc, 0xab, 0x03, 0xb9, 0xf4, 0xce, 0xd6, 0xce, - 0x07, 0x62, 0xde, 0x88, 0x6b, 0xed, 0xe9, 0xbb, 0x11, 0xa9, 0xd3, 0x80, 0xf6, 0x4c, - ], + sha: [0x77, 0x93, 0x32, 0x2e, 0x19, 0x00, 0x2f, 0xe8, 0x19, 0x97, 0xbc, 0xab, 0x03, 0xb9, 0xf4, 0xce, 0xd6, 0xce, 0x07, 0x62, 0xde, 0x88, 0x6b, 0xed, 0xe9, 0xbb, 0x11, 0xa9, 0xd3, 0x80, 0xf6, 0x4c], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_gr_post.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_native_batch.ptx", - key: [ - 0x9b, 0xa6, 0x85, 0x23, 0xb6, 0x7a, 0x0e, 0x3b, 0x80, 0xfc, 0x16, 0x7b, 0x97, 0x30, 0x19, 0x63, 0xcf, 0x15, - 0x98, 0x12, 0xcd, 0x15, 0x7f, 0x03, 0xc5, 0xa0, 0x2b, 0x69, 0xfd, 0xa2, 0x2f, 0xc7, - ], + key: [0x9b, 0xa6, 0x85, 0x23, 0xb6, 0x7a, 0x0e, 0x3b, 0x80, 0xfc, 0x16, 0x7b, 0x97, 0x30, 0x19, 0x63, 0xcf, 0x15, 0x98, 0x12, 0xcd, 0x15, 0x7f, 0x03, 0xc5, 0xa0, 0x2b, 0x69, 0xfd, 0xa2, 0x2f, 0xc7], len: 4566, - sha: [ - 0xcb, 0xf1, 0x3c, 0x31, 0x7b, 0x78, 0x84, 0x54, 0x28, 0xc9, 0x86, 0xe9, 0xa9, 0xbf, 0xc0, 0x47, 0x53, 0x30, - 0x29, 0x55, 0x51, 0x3a, 0x4a, 0xfd, 0x11, 0xf1, 0x39, 0xf2, 0x62, 0x22, 0xb6, 0xff, - ], + sha: [0xcb, 0xf1, 0x3c, 0x31, 0x7b, 0x78, 0x84, 0x54, 0x28, 0xc9, 0x86, 0xe9, 0xa9, 0xbf, 0xc0, 0x47, 0x53, 0x30, 0x29, 0x55, 0x51, 0x3a, 0x4a, 0xfd, 0x11, 0xf1, 0x39, 0xf2, 0x62, 0x22, 0xb6, 0xff], ptx: concat!(include_str!("../ptx-sm86/qsa_native_batch.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_session_legacy_rope.ptx", - key: [ - 0x9b, 0xba, 0x3b, 0x35, 0x85, 0x0c, 0xe3, 0x86, 0x9e, 0x32, 0xc5, 0x6c, 0x9d, 0xe6, 0x6a, 0x06, 0x52, 0x69, - 0x11, 0x88, 0xf4, 0xc7, 0xff, 0x1d, 0xc4, 0xb1, 0xee, 0x9b, 0x2f, 0x9d, 0x0d, 0x9f, - ], + key: [0x9b, 0xba, 0x3b, 0x35, 0x85, 0x0c, 0xe3, 0x86, 0x9e, 0x32, 0xc5, 0x6c, 0x9d, 0xe6, 0x6a, 0x06, 0x52, 0x69, 0x11, 0x88, 0xf4, 0xc7, 0xff, 0x1d, 0xc4, 0xb1, 0xee, 0x9b, 0x2f, 0x9d, 0x0d, 0x9f], len: 12202, - sha: [ - 0x25, 0x7e, 0x32, 0x1a, 0xbe, 0xa3, 0x30, 0x92, 0x6b, 0x29, 0x9a, 0x6a, 0x03, 0x03, 0x0d, 0x4c, 0xd2, 0xdf, - 0x98, 0xe1, 0xf9, 0x7f, 0xfe, 0x07, 0x2d, 0xc1, 0x83, 0xc1, 0x1c, 0x5b, 0x9d, 0xe7, - ], + sha: [0x25, 0x7e, 0x32, 0x1a, 0xbe, 0xa3, 0x30, 0x92, 0x6b, 0x29, 0x9a, 0x6a, 0x03, 0x03, 0x0d, 0x4c, 0xd2, 0xdf, 0x98, 0xe1, 0xf9, 0x7f, 0xfe, 0x07, 0x2d, 0xc1, 0x83, 0xc1, 0x1c, 0x5b, 0x9d, 0xe7], ptx: concat!(include_str!("../ptx-sm86/mtp_original_session_legacy_rope.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_qnorm.ptx", - key: [ - 0xa0, 0xbc, 0xfe, 0xbd, 0x6b, 0xf4, 0x77, 0xcd, 0x3a, 0xd1, 0x36, 0x07, 0xe2, 0xf0, 0x1f, 0x3c, 0x0a, 0x9e, - 0x4c, 0x70, 0x22, 0x87, 0x21, 0x36, 0x20, 0xd9, 0x1c, 0x89, 0xb9, 0x29, 0x8e, 0xb1, - ], + key: [0xa0, 0xbc, 0xfe, 0xbd, 0x6b, 0xf4, 0x77, 0xcd, 0x3a, 0xd1, 0x36, 0x07, 0xe2, 0xf0, 0x1f, 0x3c, 0x0a, 0x9e, 0x4c, 0x70, 0x22, 0x87, 0x21, 0x36, 0x20, 0xd9, 0x1c, 0x89, 0xb9, 0x29, 0x8e, 0xb1], len: 36079, - sha: [ - 0x0f, 0x71, 0xc4, 0x60, 0xd4, 0x0a, 0x3e, 0xfb, 0xc4, 0x68, 0xba, 0xc3, 0x4b, 0xb9, 0x3f, 0x62, 0xa7, 0x17, - 0x37, 0xd7, 0x28, 0x31, 0x92, 0x17, 0x5c, 0xff, 0x7e, 0x13, 0x32, 0x38, 0x20, 0x7f, - ], + sha: [0x0f, 0x71, 0xc4, 0x60, 0xd4, 0x0a, 0x3e, 0xfb, 0xc4, 0x68, 0xba, 0xc3, 0x4b, 0xb9, 0x3f, 0x62, 0xa7, 0x17, 0x37, 0xd7, 0x28, 0x31, 0x92, 0x17, 0x5c, 0xff, 0x7e, 0x13, 0x32, 0x38, 0x20, 0x7f], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_qnorm.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_bf16.ptx", - key: [ - 0xa1, 0x6d, 0xfc, 0xfc, 0x9a, 0x49, 0xcc, 0xab, 0x25, 0xd8, 0x03, 0x02, 0x93, 0xd5, 0x82, 0x6f, 0x8f, 0x75, - 0xe2, 0x86, 0x8f, 0xae, 0x1b, 0x6c, 0x4c, 0xef, 0x70, 0x6b, 0x6d, 0xfc, 0x3d, 0x08, - ], + key: [0xa1, 0x6d, 0xfc, 0xfc, 0x9a, 0x49, 0xcc, 0xab, 0x25, 0xd8, 0x03, 0x02, 0x93, 0xd5, 0x82, 0x6f, 0x8f, 0x75, 0xe2, 0x86, 0x8f, 0xae, 0x1b, 0x6c, 0x4c, 0xef, 0x70, 0x6b, 0x6d, 0xfc, 0x3d, 0x08], len: 461120, - sha: [ - 0x07, 0xf4, 0xde, 0x80, 0xcb, 0xb0, 0xdc, 0x7d, 0xc2, 0xb7, 0x5f, 0x75, 0x6e, 0x24, 0x1b, 0x30, 0x89, 0xd3, - 0xcd, 0x97, 0xc7, 0x33, 0x6a, 0xe5, 0xf6, 0xbe, 0x0f, 0xa6, 0x42, 0x78, 0x3d, 0x81, - ], + sha: [0x07, 0xf4, 0xde, 0x80, 0xcb, 0xb0, 0xdc, 0x7d, 0xc2, 0xb7, 0x5f, 0x75, 0x6e, 0x24, 0x1b, 0x30, 0x89, 0xd3, 0xcd, 0x97, 0xc7, 0x33, 0x6a, 0xe5, 0xf6, 0xbe, 0x0f, 0xa6, 0x42, 0x78, 0x3d, 0x81], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_bf16.ptx"), "\0").as_bytes(), }, Companion { name: "iq2_s_q8_1.ptx", - key: [ - 0xa3, 0x1e, 0x65, 0x3d, 0xa8, 0xc2, 0x22, 0xe1, 0x67, 0x1c, 0xf2, 0x5e, 0xd1, 0x90, 0x17, 0xee, 0xb0, 0xb3, - 0xef, 0x4d, 0x89, 0x0c, 0x01, 0x42, 0xb1, 0x81, 0xf3, 0xd5, 0xbc, 0xfc, 0xfb, 0x2c, - ], + key: [0xa3, 0x1e, 0x65, 0x3d, 0xa8, 0xc2, 0x22, 0xe1, 0x67, 0x1c, 0xf2, 0x5e, 0xd1, 0x90, 0x17, 0xee, 0xb0, 0xb3, 0xef, 0x4d, 0x89, 0x0c, 0x01, 0x42, 0xb1, 0x81, 0xf3, 0xd5, 0xbc, 0xfc, 0xfb, 0x2c], len: 46912, - sha: [ - 0xc6, 0xca, 0xe7, 0xc0, 0x39, 0x61, 0x79, 0x04, 0x0b, 0x0c, 0x88, 0xf3, 0xce, 0xbd, 0x24, 0x70, 0xdf, 0x92, - 0x69, 0xad, 0x5d, 0xc6, 0x6e, 0x9e, 0x22, 0x7f, 0x60, 0x0d, 0x1e, 0x79, 0xed, 0x9b, - ], + sha: [0xc6, 0xca, 0xe7, 0xc0, 0x39, 0x61, 0x79, 0x04, 0x0b, 0x0c, 0x88, 0xf3, 0xce, 0xbd, 0x24, 0x70, 0xdf, 0x92, 0x69, 0xad, 0x5d, 0xc6, 0x6e, 0x9e, 0x22, 0x7f, 0x60, 0x0d, 0x1e, 0x79, 0xed, 0x9b], ptx: concat!(include_str!("../ptx-sm86/iq2_s_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "chain_window.ptx", - key: [ - 0xa3, 0xab, 0xdc, 0x41, 0x86, 0xb6, 0x6d, 0x51, 0xa8, 0x0c, 0x8e, 0xf5, 0x2f, 0x63, 0x6f, 0x18, 0x93, 0xa2, - 0x13, 0x6b, 0x88, 0x7c, 0xd6, 0x54, 0x87, 0x86, 0xfe, 0xa2, 0x79, 0xef, 0x71, 0xba, - ], + key: [0xa3, 0xab, 0xdc, 0x41, 0x86, 0xb6, 0x6d, 0x51, 0xa8, 0x0c, 0x8e, 0xf5, 0x2f, 0x63, 0x6f, 0x18, 0x93, 0xa2, 0x13, 0x6b, 0x88, 0x7c, 0xd6, 0x54, 0x87, 0x86, 0xfe, 0xa2, 0x79, 0xef, 0x71, 0xba], len: 2336938, - sha: [ - 0x36, 0x1e, 0x11, 0x00, 0xad, 0x58, 0xb9, 0xa2, 0x1b, 0xe3, 0xd9, 0x58, 0xef, 0x55, 0x59, 0xe7, 0x0b, 0x72, - 0xf2, 0xd0, 0x4e, 0x15, 0xdb, 0x5e, 0x9d, 0xbc, 0x14, 0xd1, 0x21, 0xe0, 0xee, 0x43, - ], + sha: [0x36, 0x1e, 0x11, 0x00, 0xad, 0x58, 0xb9, 0xa2, 0x1b, 0xe3, 0xd9, 0x58, 0xef, 0x55, 0x59, 0xe7, 0x0b, 0x72, 0xf2, 0xd0, 0x4e, 0x15, 0xdb, 0x5e, 0x9d, 0xbc, 0x14, 0xd1, 0x21, 0xe0, 0xee, 0x43], ptx: concat!(include_str!("../ptx-sm86/chain_window.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_router_legacy.ptx", - key: [ - 0xa5, 0x84, 0x12, 0x24, 0x97, 0x57, 0xcc, 0x35, 0x1e, 0xb8, 0x33, 0x2e, 0x80, 0x7e, 0x79, 0xf1, 0xb3, 0xda, - 0x58, 0x65, 0x57, 0x4d, 0x0f, 0xb7, 0x17, 0x9e, 0xf5, 0x58, 0xdf, 0x70, 0xaf, 0x24, - ], + key: [0xa5, 0x84, 0x12, 0x24, 0x97, 0x57, 0xcc, 0x35, 0x1e, 0xb8, 0x33, 0x2e, 0x80, 0x7e, 0x79, 0xf1, 0xb3, 0xda, 0x58, 0x65, 0x57, 0x4d, 0x0f, 0xb7, 0x17, 0x9e, 0xf5, 0x58, 0xdf, 0x70, 0xaf, 0x24], len: 159038, - sha: [ - 0xa9, 0x2b, 0xf0, 0xc3, 0xfc, 0x4c, 0xc5, 0x31, 0x2c, 0x14, 0xa5, 0x52, 0xf7, 0x24, 0x4d, 0x4a, 0x7e, 0x10, - 0x26, 0xbb, 0x79, 0x32, 0xb0, 0x56, 0x1d, 0x73, 0x57, 0xd8, 0xec, 0x41, 0x72, 0x7f, - ], + sha: [0xa9, 0x2b, 0xf0, 0xc3, 0xfc, 0x4c, 0xc5, 0x31, 0x2c, 0x14, 0xa5, 0x52, 0xf7, 0x24, 0x4d, 0x4a, 0x7e, 0x10, 0x26, 0xbb, 0x79, 0x32, 0xb0, 0x56, 0x1d, 0x73, 0x57, 0xd8, 0xec, 0x41, 0x72, 0x7f], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_router_legacy.ptx"), "\0").as_bytes(), }, Companion { name: "mmq-original-formats-fixup.ptx", - key: [ - 0xa6, 0x6a, 0x85, 0x6c, 0xe4, 0x97, 0x82, 0x20, 0xbb, 0xb0, 0x12, 0x57, 0xf3, 0x34, 0xe4, 0x48, 0x46, 0xce, - 0xb3, 0x4d, 0x5d, 0xc3, 0x06, 0xdf, 0xbe, 0xba, 0x95, 0x65, 0x7e, 0x05, 0x0b, 0xf3, - ], + key: [0xa6, 0x6a, 0x85, 0x6c, 0xe4, 0x97, 0x82, 0x20, 0xbb, 0xb0, 0x12, 0x57, 0xf3, 0x34, 0xe4, 0x48, 0x46, 0xce, 0xb3, 0x4d, 0x5d, 0xc3, 0x06, 0xdf, 0xbe, 0xba, 0x95, 0x65, 0x7e, 0x05, 0x0b, 0xf3], len: 309892, - sha: [ - 0xd2, 0x16, 0x69, 0x31, 0xf0, 0x54, 0x52, 0xde, 0x65, 0xed, 0x06, 0xd1, 0xb0, 0x60, 0xa9, 0x4c, 0x27, 0xa8, - 0x68, 0x8e, 0xf5, 0x9b, 0x5f, 0xfc, 0x96, 0x08, 0x69, 0x64, 0x7a, 0x44, 0x84, 0x8b, - ], + sha: [0xd2, 0x16, 0x69, 0x31, 0xf0, 0x54, 0x52, 0xde, 0x65, 0xed, 0x06, 0xd1, 0xb0, 0x60, 0xa9, 0x4c, 0x27, 0xa8, 0x68, 0x8e, 0xf5, 0x9b, 0x5f, 0xfc, 0x96, 0x08, 0x69, 0x64, 0x7a, 0x44, 0x84, 0x8b], ptx: concat!(include_str!("../ptx-sm86/mmq-original-formats-fixup.ptx"), "\0").as_bytes(), }, Companion { name: "mmq_original_group_fixup.ptx", - key: [ - 0xa8, 0xc7, 0x51, 0x91, 0xba, 0x8e, 0xf7, 0xa4, 0x57, 0x20, 0x82, 0x48, 0x50, 0xd6, 0x4c, 0xf4, 0x43, 0x45, - 0x9b, 0x30, 0xbc, 0x53, 0x79, 0xab, 0x80, 0x7e, 0xb8, 0x3e, 0x26, 0x14, 0x88, 0x3f, - ], + key: [0xa8, 0xc7, 0x51, 0x91, 0xba, 0x8e, 0xf7, 0xa4, 0x57, 0x20, 0x82, 0x48, 0x50, 0xd6, 0x4c, 0xf4, 0x43, 0x45, 0x9b, 0x30, 0xbc, 0x53, 0x79, 0xab, 0x80, 0x7e, 0xb8, 0x3e, 0x26, 0x14, 0x88, 0x3f], len: 1455508, - sha: [ - 0x18, 0xc9, 0x1c, 0x0f, 0x77, 0x48, 0x36, 0xd9, 0xcd, 0xc6, 0xee, 0x49, 0x8f, 0x3f, 0x3d, 0x66, 0x2b, 0x40, - 0x07, 0x77, 0x39, 0x95, 0x29, 0xa4, 0x38, 0xf7, 0xae, 0x27, 0x67, 0x10, 0xf2, 0x04, - ], + sha: [0x18, 0xc9, 0x1c, 0x0f, 0x77, 0x48, 0x36, 0xd9, 0xcd, 0xc6, 0xee, 0x49, 0x8f, 0x3f, 0x3d, 0x66, 0x2b, 0x40, 0x07, 0x77, 0x39, 0x95, 0x29, 0xa4, 0x38, 0xf7, 0xae, 0x27, 0x67, 0x10, 0xf2, 0x04], ptx: concat!(include_str!("../ptx-sm86/mmq_original_group_fixup.ptx"), "\0").as_bytes(), }, Companion { name: "mmq_original_group_swiglu.ptx", - key: [ - 0xa9, 0x13, 0x99, 0x36, 0x00, 0x87, 0x8c, 0xed, 0xd1, 0x28, 0xbe, 0xe0, 0xf7, 0x76, 0x89, 0x51, 0x19, 0xe5, - 0x56, 0xe3, 0x3f, 0x2a, 0xd7, 0x0d, 0xad, 0xf0, 0x8e, 0x9e, 0x1a, 0x7e, 0xb9, 0xbd, - ], + key: [0xa9, 0x13, 0x99, 0x36, 0x00, 0x87, 0x8c, 0xed, 0xd1, 0x28, 0xbe, 0xe0, 0xf7, 0x76, 0x89, 0x51, 0x19, 0xe5, 0x56, 0xe3, 0x3f, 0x2a, 0xd7, 0x0d, 0xad, 0xf0, 0x8e, 0x9e, 0x1a, 0x7e, 0xb9, 0xbd], len: 6090, - sha: [ - 0x7a, 0x34, 0x2b, 0xa9, 0x78, 0x1d, 0x0f, 0xdb, 0x63, 0x66, 0xc1, 0xb5, 0xbf, 0xd0, 0x65, 0xaa, 0x40, 0x05, - 0xfd, 0x3f, 0x3d, 0x19, 0x5d, 0xaf, 0x0f, 0x2f, 0x0f, 0x64, 0x7d, 0x71, 0xe9, 0xec, - ], + sha: [0x7a, 0x34, 0x2b, 0xa9, 0x78, 0x1d, 0x0f, 0xdb, 0x63, 0x66, 0xc1, 0xb5, 0xbf, 0xd0, 0x65, 0xaa, 0x40, 0x05, 0xfd, 0x3f, 0x3d, 0x19, 0x5d, 0xaf, 0x0f, 0x2f, 0x0f, 0x64, 0x7d, 0x71, 0xe9, 0xec], ptx: concat!(include_str!("../ptx-sm86/mmq_original_group_swiglu.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_fused_gr.ptx", - key: [ - 0xac, 0x54, 0x00, 0xa7, 0x97, 0x2b, 0x3f, 0x24, 0x26, 0x48, 0xc2, 0xde, 0x71, 0xef, 0x4f, 0x17, 0x84, 0x66, - 0xd3, 0x8b, 0x13, 0x92, 0xa8, 0x3a, 0x95, 0x91, 0xb3, 0xb2, 0x4e, 0x92, 0xc5, 0x9b, - ], + key: [0xac, 0x54, 0x00, 0xa7, 0x97, 0x2b, 0x3f, 0x24, 0x26, 0x48, 0xc2, 0xde, 0x71, 0xef, 0x4f, 0x17, 0x84, 0x66, 0xd3, 0x8b, 0x13, 0x92, 0xa8, 0x3a, 0x95, 0x91, 0xb3, 0xb2, 0x4e, 0x92, 0xc5, 0x9b], len: 422848, - sha: [ - 0xe4, 0xc8, 0xcc, 0xbb, 0xfb, 0x68, 0x26, 0x7c, 0xa0, 0xba, 0xc4, 0xfd, 0xbd, 0x91, 0x04, 0x22, 0xa3, 0x16, - 0x87, 0x0b, 0x0f, 0x79, 0x9c, 0x48, 0x52, 0x9c, 0x8a, 0x9d, 0xb9, 0xea, 0xa8, 0xe6, - ], + sha: [0xe4, 0xc8, 0xcc, 0xbb, 0xfb, 0x68, 0x26, 0x7c, 0xa0, 0xba, 0xc4, 0xfd, 0xbd, 0x91, 0x04, 0x22, 0xa3, 0x16, 0x87, 0x0b, 0x0f, 0x79, 0x9c, 0x48, 0x52, 0x9c, 0x8a, 0x9d, 0xb9, 0xea, 0xa8, 0xe6], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_fused_gr.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_fixed.ptx", - key: [ - 0xad, 0xa8, 0x7a, 0x1b, 0xd6, 0xff, 0x2f, 0x60, 0x13, 0xd2, 0xbd, 0x64, 0x1a, 0x37, 0x86, 0xeb, 0x46, 0xb9, - 0xc9, 0xfc, 0xf3, 0x58, 0x6c, 0x66, 0x60, 0x9c, 0x8e, 0xee, 0xa4, 0xb1, 0x07, 0xe8, - ], + key: [0xad, 0xa8, 0x7a, 0x1b, 0xd6, 0xff, 0x2f, 0x60, 0x13, 0xd2, 0xbd, 0x64, 0x1a, 0x37, 0x86, 0xeb, 0x46, 0xb9, 0xc9, 0xfc, 0xf3, 0x58, 0x6c, 0x66, 0x60, 0x9c, 0x8e, 0xee, 0xa4, 0xb1, 0x07, 0xe8], len: 15190, - sha: [ - 0x62, 0xd0, 0x43, 0x0e, 0x9e, 0xaf, 0x35, 0xd2, 0x1b, 0x95, 0xad, 0xc8, 0x18, 0xd5, 0x7b, 0xb8, 0x5e, 0xaf, - 0x0a, 0x74, 0x66, 0x06, 0x87, 0x0d, 0xd5, 0xf1, 0xf2, 0xed, 0x25, 0xc1, 0xf7, 0x27, - ], + sha: [0x62, 0xd0, 0x43, 0x0e, 0x9e, 0xaf, 0x35, 0xd2, 0x1b, 0x95, 0xad, 0xc8, 0x18, 0xd5, 0x7b, 0xb8, 0x5e, 0xaf, 0x0a, 0x74, 0x66, 0x06, 0x87, 0x0d, 0xd5, 0xf1, 0xf2, 0xed, 0x25, 0xc1, 0xf7, 0x27], ptx: concat!(include_str!("../ptx-sm86/mtp_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_head_sampler.ptx", - key: [ - 0xb0, 0x48, 0xca, 0x90, 0xf9, 0x7e, 0x6e, 0x6f, 0x2c, 0x0d, 0x93, 0xe5, 0xc1, 0x24, 0xe5, 0xd4, 0xad, 0xbc, - 0x7b, 0x34, 0x09, 0x74, 0xe4, 0x5a, 0x4f, 0x98, 0xdc, 0x15, 0xd0, 0xb1, 0xbc, 0x59, - ], + key: [0xb0, 0x48, 0xca, 0x90, 0xf9, 0x7e, 0x6e, 0x6f, 0x2c, 0x0d, 0x93, 0xe5, 0xc1, 0x24, 0xe5, 0xd4, 0xad, 0xbc, 0x7b, 0x34, 0x09, 0x74, 0xe4, 0x5a, 0x4f, 0x98, 0xdc, 0x15, 0xd0, 0xb1, 0xbc, 0x59], len: 504479, - sha: [ - 0xa2, 0x45, 0xc8, 0x5c, 0x87, 0xbd, 0xf2, 0x03, 0x13, 0xbf, 0xf4, 0x22, 0x07, 0xbb, 0xd6, 0xfb, 0xa6, 0xda, - 0x14, 0x8a, 0xd3, 0xa0, 0x89, 0x4d, 0x6a, 0x5e, 0xbf, 0xa3, 0x39, 0x8e, 0xca, 0xc7, - ], + sha: [0xa2, 0x45, 0xc8, 0x5c, 0x87, 0xbd, 0xf2, 0x03, 0x13, 0xbf, 0xf4, 0x22, 0x07, 0xbb, 0xd6, 0xfb, 0xa6, 0xda, 0x14, 0x8a, 0xd3, 0xa0, 0x89, 0x4d, 0x6a, 0x5e, 0xbf, 0xa3, 0x39, 0x8e, 0xca, 0xc7], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_head_sampler.ptx"), "\0").as_bytes(), }, Companion { name: "ple_fixed.ptx", - key: [ - 0xb1, 0x4c, 0x64, 0x24, 0xb3, 0x4a, 0x4f, 0xba, 0xc6, 0x8a, 0xe3, 0x33, 0xad, 0xf9, 0x77, 0xe1, 0xa3, 0xff, - 0x93, 0xe5, 0x0a, 0xe9, 0x97, 0x52, 0x8b, 0xb9, 0xa2, 0x33, 0xdf, 0xe7, 0x04, 0x86, - ], + key: [0xb1, 0x4c, 0x64, 0x24, 0xb3, 0x4a, 0x4f, 0xba, 0xc6, 0x8a, 0xe3, 0x33, 0xad, 0xf9, 0x77, 0xe1, 0xa3, 0xff, 0x93, 0xe5, 0x0a, 0xe9, 0x97, 0x52, 0x8b, 0xb9, 0xa2, 0x33, 0xdf, 0xe7, 0x04, 0x86], len: 30868, - sha: [ - 0x32, 0xbc, 0x7b, 0xc0, 0xcb, 0x88, 0x9b, 0x30, 0xaf, 0xc2, 0x02, 0x88, 0x51, 0x8b, 0x90, 0xa4, 0x13, 0x7a, - 0x05, 0xb0, 0x5d, 0xaf, 0x3d, 0x4f, 0xee, 0xde, 0xcc, 0x02, 0xe5, 0x66, 0xce, 0x0a, - ], + sha: [0x32, 0xbc, 0x7b, 0xc0, 0xcb, 0x88, 0x9b, 0x30, 0xaf, 0xc2, 0x02, 0x88, 0x51, 0x8b, 0x90, 0xa4, 0x13, 0x7a, 0x05, 0xb0, 0x5d, 0xaf, 0x3d, 0x4f, 0xee, 0xde, 0xcc, 0x02, 0xe5, 0x66, 0xce, 0x0a], ptx: concat!(include_str!("../ptx-sm86/ple_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_shared.ptx", - key: [ - 0xb3, 0x6f, 0x43, 0x26, 0x92, 0xe4, 0x3f, 0x79, 0x48, 0xa2, 0x53, 0x8c, 0x22, 0xca, 0xb5, 0x5e, 0xf6, 0x7c, - 0x62, 0x5b, 0x8d, 0x44, 0x61, 0xc6, 0x7c, 0xa2, 0xa2, 0x75, 0x19, 0xb9, 0xe0, 0xf0, - ], + key: [0xb3, 0x6f, 0x43, 0x26, 0x92, 0xe4, 0x3f, 0x79, 0x48, 0xa2, 0x53, 0x8c, 0x22, 0xca, 0xb5, 0x5e, 0xf6, 0x7c, 0x62, 0x5b, 0x8d, 0x44, 0x61, 0xc6, 0x7c, 0xa2, 0xa2, 0x75, 0x19, 0xb9, 0xe0, 0xf0], len: 45827, - sha: [ - 0xe9, 0x22, 0x49, 0x6b, 0x44, 0xdd, 0xb0, 0xde, 0x69, 0x00, 0xb5, 0xbe, 0xec, 0x4b, 0x35, 0x09, 0xf2, 0xfa, - 0x7e, 0x2a, 0x17, 0x2c, 0x3f, 0xe1, 0x76, 0xc1, 0x6e, 0xdd, 0x10, 0x18, 0x52, 0x90, - ], + sha: [0xe9, 0x22, 0x49, 0x6b, 0x44, 0xdd, 0xb0, 0xde, 0x69, 0x00, 0xb5, 0xbe, 0xec, 0x4b, 0x35, 0x09, 0xf2, 0xfa, 0x7e, 0x2a, 0x17, 0x2c, 0x3f, 0xe1, 0x76, 0xc1, 0x6e, 0xdd, 0x10, 0x18, 0x52, 0x90], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_shared.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_scalar_norm.ptx", - key: [ - 0xbb, 0x78, 0x4f, 0xd8, 0xa5, 0x74, 0xeb, 0x38, 0xcc, 0x3f, 0xdb, 0x92, 0x64, 0xb6, 0x9b, 0x72, 0xcd, 0xf3, - 0x40, 0x78, 0x85, 0x91, 0x88, 0x5c, 0x9b, 0x7f, 0x96, 0xa0, 0x5a, 0x6a, 0x81, 0x07, - ], + key: [0xbb, 0x78, 0x4f, 0xd8, 0xa5, 0x74, 0xeb, 0x38, 0xcc, 0x3f, 0xdb, 0x92, 0x64, 0xb6, 0x9b, 0x72, 0xcd, 0xf3, 0x40, 0x78, 0x85, 0x91, 0x88, 0x5c, 0x9b, 0x7f, 0x96, 0xa0, 0x5a, 0x6a, 0x81, 0x07], len: 16691, - sha: [ - 0x56, 0xab, 0x10, 0x69, 0x20, 0x71, 0x2b, 0x92, 0x7c, 0xe8, 0x94, 0xb7, 0x22, 0x7d, 0x7c, 0xb4, 0x7c, 0x7a, - 0xda, 0x9f, 0x07, 0x90, 0xc3, 0x65, 0x08, 0xf5, 0xc9, 0x8f, 0x74, 0x0d, 0x7c, 0xdc, - ], + sha: [0x56, 0xab, 0x10, 0x69, 0x20, 0x71, 0x2b, 0x92, 0x7c, 0xe8, 0x94, 0xb7, 0x22, 0x7d, 0x7c, 0xb4, 0x7c, 0x7a, 0xda, 0x9f, 0x07, 0x90, 0xc3, 0x65, 0x08, 0xf5, 0xc9, 0x8f, 0x74, 0x0d, 0x7c, 0xdc], ptx: concat!(include_str!("../ptx-sm86/mtp_original_scalar_norm.ptx"), "\0").as_bytes(), }, Companion { name: "native_flash_attn.ptx", - key: [ - 0xbe, 0x35, 0x3e, 0x61, 0x9a, 0x15, 0xa5, 0x66, 0xe5, 0x7b, 0xae, 0x12, 0xa0, 0xbf, 0x30, 0xcc, 0x17, 0x12, - 0xa2, 0x81, 0xbc, 0xe6, 0x92, 0x8f, 0x3b, 0xb7, 0x6c, 0x14, 0xe5, 0x11, 0x4b, 0xba, - ], + key: [0xbe, 0x35, 0x3e, 0x61, 0x9a, 0x15, 0xa5, 0x66, 0xe5, 0x7b, 0xae, 0x12, 0xa0, 0xbf, 0x30, 0xcc, 0x17, 0x12, 0xa2, 0x81, 0xbc, 0xe6, 0x92, 0x8f, 0x3b, 0xb7, 0x6c, 0x14, 0xe5, 0x11, 0x4b, 0xba], len: 208590, - sha: [ - 0x6e, 0xaf, 0xd5, 0x7d, 0x2f, 0xcf, 0x68, 0x71, 0xb8, 0x22, 0x4f, 0xe9, 0x48, 0x52, 0x59, 0xd1, 0xec, 0x75, - 0x0f, 0xb1, 0x76, 0xa2, 0x68, 0x96, 0x6b, 0x1d, 0xe4, 0x3f, 0xfa, 0x75, 0x62, 0x97, - ], + sha: [0x6e, 0xaf, 0xd5, 0x7d, 0x2f, 0xcf, 0x68, 0x71, 0xb8, 0x22, 0x4f, 0xe9, 0x48, 0x52, 0x59, 0xd1, 0xec, 0x75, 0x0f, 0xb1, 0x76, 0xa2, 0x68, 0x96, 0x6b, 0x1d, 0xe4, 0x3f, 0xfa, 0x75, 0x62, 0x97], ptx: concat!(include_str!("../ptx-sm86/native_flash_attn.ptx"), "\0").as_bytes(), }, Companion { name: "quantize-d4-selected.ptx", - key: [ - 0xbe, 0x3b, 0x9f, 0x55, 0xff, 0x60, 0x69, 0xde, 0x50, 0x52, 0xc8, 0x3e, 0xf2, 0x2d, 0xa8, 0xfe, 0x88, 0xcd, - 0x65, 0xe3, 0xe4, 0xfb, 0x1b, 0x13, 0xa7, 0xf9, 0x3d, 0xd1, 0x4f, 0x69, 0x9c, 0x1b, - ], + key: [0xbe, 0x3b, 0x9f, 0x55, 0xff, 0x60, 0x69, 0xde, 0x50, 0x52, 0xc8, 0x3e, 0xf2, 0x2d, 0xa8, 0xfe, 0x88, 0xcd, 0x65, 0xe3, 0xe4, 0xfb, 0x1b, 0x13, 0xa7, 0xf9, 0x3d, 0xd1, 0x4f, 0x69, 0x9c, 0x1b], len: 102215, - sha: [ - 0x15, 0xe3, 0xb0, 0xb1, 0x95, 0x03, 0x41, 0x3b, 0x7f, 0x7d, 0x97, 0x21, 0xaf, 0x05, 0x11, 0xbb, 0x5a, 0xb9, - 0xf5, 0xe5, 0x9a, 0x7c, 0xf9, 0x16, 0x77, 0xa3, 0x13, 0xc2, 0x79, 0xc6, 0xa6, 0x9a, - ], + sha: [0x15, 0xe3, 0xb0, 0xb1, 0x95, 0x03, 0x41, 0x3b, 0x7f, 0x7d, 0x97, 0x21, 0xaf, 0x05, 0x11, 0xbb, 0x5a, 0xb9, 0xf5, 0xe5, 0x9a, 0x7c, 0xf9, 0x16, 0x77, 0xa3, 0x13, 0xc2, 0x79, 0xc6, 0xa6, 0x9a], ptx: concat!(include_str!("../ptx-sm86/quantize-d4-selected.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_router.ptx", - key: [ - 0xbe, 0x6e, 0x3c, 0x91, 0xe4, 0xf6, 0x83, 0x14, 0x64, 0xf5, 0x99, 0x37, 0x87, 0xf0, 0xbf, 0xf9, 0x69, 0xbc, - 0x5d, 0x28, 0x39, 0x5f, 0x24, 0x22, 0x6b, 0x88, 0x67, 0x6b, 0x30, 0x69, 0xa8, 0xcb, - ], + key: [0xbe, 0x6e, 0x3c, 0x91, 0xe4, 0xf6, 0x83, 0x14, 0x64, 0xf5, 0x99, 0x37, 0x87, 0xf0, 0xbf, 0xf9, 0x69, 0xbc, 0x5d, 0x28, 0x39, 0x5f, 0x24, 0x22, 0x6b, 0x88, 0x67, 0x6b, 0x30, 0x69, 0xa8, 0xcb], len: 107477, - sha: [ - 0x17, 0xa9, 0x4f, 0xd3, 0xc2, 0xa1, 0xe2, 0x8c, 0x56, 0xbd, 0x85, 0x10, 0xba, 0xd4, 0xb1, 0xda, 0xa3, 0xdb, - 0x39, 0xec, 0x01, 0x36, 0xdb, 0xc0, 0x33, 0x4a, 0x00, 0xfa, 0xad, 0xaf, 0x0c, 0x47, - ], + sha: [0x17, 0xa9, 0x4f, 0xd3, 0xc2, 0xa1, 0xe2, 0x8c, 0x56, 0xbd, 0x85, 0x10, 0xba, 0xd4, 0xb1, 0xda, 0xa3, 0xdb, 0x39, 0xec, 0x01, 0x36, 0xdb, 0xc0, 0x33, 0x4a, 0x00, 0xfa, 0xad, 0xaf, 0x0c, 0x47], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_router.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_iq3_s_nc4.ptx", - key: [ - 0xbe, 0x6e, 0xe9, 0x07, 0xc0, 0xb3, 0x70, 0xcb, 0x99, 0x89, 0x4a, 0x03, 0x41, 0x94, 0x66, 0xf1, 0xaa, 0x46, - 0x5b, 0xa9, 0xb8, 0xe2, 0xe8, 0xcf, 0x60, 0x38, 0x87, 0xf5, 0x34, 0x45, 0x0d, 0x0c, - ], + key: [0xbe, 0x6e, 0xe9, 0x07, 0xc0, 0xb3, 0x70, 0xcb, 0x99, 0x89, 0x4a, 0x03, 0x41, 0x94, 0x66, 0xf1, 0xaa, 0x46, 0x5b, 0xa9, 0xb8, 0xe2, 0xe8, 0xcf, 0x60, 0x38, 0x87, 0xf5, 0x34, 0x45, 0x0d, 0x0c], len: 36382, - sha: [ - 0x23, 0xb7, 0x02, 0xaa, 0xf1, 0x27, 0x8d, 0xd3, 0xd4, 0x36, 0x14, 0x2b, 0x9c, 0x27, 0x32, 0x19, 0x21, 0xf3, - 0x6d, 0xda, 0x76, 0x06, 0xd1, 0xf7, 0x56, 0x97, 0x3e, 0x5d, 0xfc, 0xbd, 0x45, 0x37, - ], + sha: [0x23, 0xb7, 0x02, 0xaa, 0xf1, 0x27, 0x8d, 0xd3, 0xd4, 0x36, 0x14, 0x2b, 0x9c, 0x27, 0x32, 0x19, 0x21, 0xf3, 0x6d, 0xda, 0x76, 0x06, 0xd1, 0xf7, 0x56, 0x97, 0x3e, 0x5d, 0xfc, 0xbd, 0x45, 0x37], ptx: concat!(include_str!("../ptx-sm86/moe_group_iq3_s_nc4.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_verify.ptx", - key: [ - 0xbe, 0xbb, 0xef, 0xc6, 0x5c, 0x2c, 0xc2, 0x1c, 0x54, 0x84, 0x71, 0xf6, 0x90, 0xce, 0x02, 0xc6, 0x73, 0x41, - 0x8e, 0x8a, 0xc0, 0x66, 0xd4, 0x9f, 0x94, 0x8d, 0x0e, 0x6e, 0x35, 0xcf, 0xa2, 0x03, - ], + key: [0xbe, 0xbb, 0xef, 0xc6, 0x5c, 0x2c, 0xc2, 0x1c, 0x54, 0x84, 0x71, 0xf6, 0x90, 0xce, 0x02, 0xc6, 0x73, 0x41, 0x8e, 0x8a, 0xc0, 0x66, 0xd4, 0x9f, 0x94, 0x8d, 0x0e, 0x6e, 0x35, 0xcf, 0xa2, 0x03], len: 179130, - sha: [ - 0x8e, 0x19, 0x61, 0xf3, 0x6f, 0x40, 0x9d, 0xea, 0x38, 0x60, 0x66, 0x6b, 0xc8, 0xd7, 0x67, 0x95, 0x1c, 0x50, - 0xbb, 0xac, 0x96, 0x36, 0x6a, 0x9e, 0xc5, 0xd9, 0x9d, 0x87, 0xbe, 0xc4, 0xe9, 0x30, - ], + sha: [0x8e, 0x19, 0x61, 0xf3, 0x6f, 0x40, 0x9d, 0xea, 0x38, 0x60, 0x66, 0x6b, 0xc8, 0xd7, 0x67, 0x95, 0x1c, 0x50, 0xbb, 0xac, 0x96, 0x36, 0x6a, 0x9e, 0xc5, 0xd9, 0x9d, 0x87, 0xbe, 0xc4, 0xe9, 0x30], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_verify.ptx"), "\0").as_bytes(), }, Companion { name: "gr_batch_preview.ptx", - key: [ - 0xc8, 0x56, 0xb6, 0xf5, 0x2d, 0x41, 0xd7, 0xe8, 0xf8, 0x8d, 0x7c, 0x63, 0xed, 0x68, 0x3b, 0x94, 0x73, 0x10, - 0x08, 0x87, 0x10, 0xf6, 0x62, 0xbc, 0xad, 0x0a, 0xfc, 0xed, 0x3e, 0xf6, 0x5c, 0xac, - ], + key: [0xc8, 0x56, 0xb6, 0xf5, 0x2d, 0x41, 0xd7, 0xe8, 0xf8, 0x8d, 0x7c, 0x63, 0xed, 0x68, 0x3b, 0x94, 0x73, 0x10, 0x08, 0x87, 0x10, 0xf6, 0x62, 0xbc, 0xad, 0x0a, 0xfc, 0xed, 0x3e, 0xf6, 0x5c, 0xac], len: 24666, - sha: [ - 0x8b, 0x51, 0xd3, 0x67, 0x3b, 0xce, 0x01, 0x8b, 0x58, 0x7e, 0xa8, 0x1c, 0x5a, 0xb2, 0xe9, 0xd7, 0xdd, 0x4d, - 0x75, 0xd0, 0x01, 0x4f, 0x6c, 0xfd, 0x4f, 0x7c, 0xf5, 0xfc, 0x17, 0xcd, 0x4c, 0xb3, - ], + sha: [0x8b, 0x51, 0xd3, 0x67, 0x3b, 0xce, 0x01, 0x8b, 0x58, 0x7e, 0xa8, 0x1c, 0x5a, 0xb2, 0xe9, 0xd7, 0xdd, 0x4d, 0x75, 0xd0, 0x01, 0x4f, 0x6c, 0xfd, 0x4f, 0x7c, 0xf5, 0xfc, 0x17, 0xcd, 0x4c, 0xb3], ptx: concat!(include_str!("../ptx-sm86/gr_batch_preview.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_iq4_xs.ptx", - key: [ - 0xc8, 0x88, 0x0e, 0xf0, 0x8d, 0xcc, 0x6b, 0xfa, 0x4a, 0xcc, 0xc9, 0x89, 0x87, 0xc4, 0x5c, 0x64, 0x1e, 0x47, - 0x2c, 0x52, 0x06, 0xad, 0x9d, 0x38, 0x9f, 0x5e, 0x94, 0x38, 0x5c, 0xd8, 0xc9, 0x84, - ], + key: [0xc8, 0x88, 0x0e, 0xf0, 0x8d, 0xcc, 0x6b, 0xfa, 0x4a, 0xcc, 0xc9, 0x89, 0x87, 0xc4, 0x5c, 0x64, 0x1e, 0x47, 0x2c, 0x52, 0x06, 0xad, 0x9d, 0x38, 0x9f, 0x5e, 0x94, 0x38, 0x5c, 0xd8, 0xc9, 0x84], len: 63256, - sha: [ - 0x72, 0x2e, 0xff, 0xee, 0x93, 0x55, 0xd3, 0xe1, 0x39, 0x73, 0xd8, 0xec, 0x9e, 0x77, 0xde, 0x98, 0xfe, 0xc0, - 0xfd, 0x4a, 0x97, 0xea, 0xfe, 0xbb, 0x55, 0x0c, 0xf9, 0xdd, 0xfd, 0x55, 0xc0, 0x2b, - ], + sha: [0x72, 0x2e, 0xff, 0xee, 0x93, 0x55, 0xd3, 0xe1, 0x39, 0x73, 0xd8, 0xec, 0x9e, 0x77, 0xde, 0x98, 0xfe, 0xc0, 0xfd, 0x4a, 0x97, 0xea, 0xfe, 0xbb, 0x55, 0x0c, 0xf9, 0xdd, 0xfd, 0x55, 0xc0, 0x2b], ptx: concat!(include_str!("../ptx-sm86/moe_group_iq4_xs.ptx"), "\0").as_bytes(), }, Companion { name: "original_verify_window_pcie.ptx", - key: [ - 0xcb, 0xeb, 0x32, 0x3f, 0x76, 0x47, 0x68, 0x2f, 0xee, 0x9e, 0xd3, 0xf1, 0x2f, 0xb7, 0xb7, 0xa5, 0xb3, 0xeb, - 0x19, 0x2f, 0x21, 0x66, 0xc6, 0xec, 0x96, 0xb8, 0x1d, 0x55, 0xc3, 0xba, 0xb9, 0xd1, - ], + key: [0xcb, 0xeb, 0x32, 0x3f, 0x76, 0x47, 0x68, 0x2f, 0xee, 0x9e, 0xd3, 0xf1, 0x2f, 0xb7, 0xb7, 0xa5, 0xb3, 0xeb, 0x19, 0x2f, 0x21, 0x66, 0xc6, 0xec, 0x96, 0xb8, 0x1d, 0x55, 0xc3, 0xba, 0xb9, 0xd1], len: 7687, - sha: [ - 0x98, 0x5b, 0xbf, 0xc8, 0x77, 0x91, 0xbd, 0x96, 0xa2, 0xcf, 0x61, 0x32, 0xce, 0x7e, 0x49, 0x9b, 0x90, 0xeb, - 0xfe, 0x7a, 0x31, 0x0e, 0xe1, 0xc5, 0x78, 0x1c, 0x49, 0xaf, 0xd1, 0x96, 0x4f, 0x67, - ], + sha: [0x98, 0x5b, 0xbf, 0xc8, 0x77, 0x91, 0xbd, 0x96, 0xa2, 0xcf, 0x61, 0x32, 0xce, 0x7e, 0x49, 0x9b, 0x90, 0xeb, 0xfe, 0x7a, 0x31, 0x0e, 0xe1, 0xc5, 0x78, 0x1c, 0x49, 0xaf, 0xd1, 0x96, 0x4f, 0x67], ptx: concat!(include_str!("../ptx-sm86/original_verify_window_pcie.ptx"), "\0").as_bytes(), }, Companion { name: "original_verify.ptx", - key: [ - 0xd0, 0xda, 0xda, 0x67, 0x15, 0xfb, 0x80, 0x8b, 0xb3, 0x28, 0x82, 0x91, 0xfd, 0x4a, 0x5c, 0x29, 0xe7, 0x8f, - 0xd7, 0xfa, 0x6e, 0x70, 0xf2, 0xb9, 0x4d, 0x22, 0x0f, 0x86, 0x0b, 0xb4, 0x33, 0x53, - ], + key: [0xd0, 0xda, 0xda, 0x67, 0x15, 0xfb, 0x80, 0x8b, 0xb3, 0x28, 0x82, 0x91, 0xfd, 0x4a, 0x5c, 0x29, 0xe7, 0x8f, 0xd7, 0xfa, 0x6e, 0x70, 0xf2, 0xb9, 0x4d, 0x22, 0x0f, 0x86, 0x0b, 0xb4, 0x33, 0x53], len: 154200, - sha: [ - 0xba, 0x92, 0xfe, 0x4e, 0x9b, 0x5a, 0xe0, 0x48, 0x86, 0x4a, 0x1c, 0xcb, 0xa8, 0x64, 0x50, 0x22, 0x4a, 0x07, - 0x83, 0x67, 0x2c, 0x0c, 0x2b, 0x99, 0xe4, 0xec, 0x32, 0x02, 0xe1, 0x66, 0x03, 0x55, - ], + sha: [0xba, 0x92, 0xfe, 0x4e, 0x9b, 0x5a, 0xe0, 0x48, 0x86, 0x4a, 0x1c, 0xcb, 0xa8, 0x64, 0x50, 0x22, 0x4a, 0x07, 0x83, 0x67, 0x2c, 0x0c, 0x2b, 0x99, 0xe4, 0xec, 0x32, 0x02, 0xe1, 0x66, 0x03, 0x55], ptx: concat!(include_str!("../ptx-sm86/original_verify.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_quant80.ptx", - key: [ - 0xd1, 0xae, 0x17, 0xce, 0xcc, 0x24, 0xe2, 0x4e, 0x0e, 0x1f, 0xc9, 0x5a, 0x73, 0x52, 0x79, 0x89, 0x71, 0x9b, - 0x94, 0x5d, 0xfe, 0xed, 0x68, 0x9e, 0x80, 0x67, 0xa5, 0x8f, 0x10, 0x18, 0x11, 0x90, - ], + key: [0xd1, 0xae, 0x17, 0xce, 0xcc, 0x24, 0xe2, 0x4e, 0x0e, 0x1f, 0xc9, 0x5a, 0x73, 0x52, 0x79, 0x89, 0x71, 0x9b, 0x94, 0x5d, 0xfe, 0xed, 0x68, 0x9e, 0x80, 0x67, 0xa5, 0x8f, 0x10, 0x18, 0x11, 0x90], len: 96194, - sha: [ - 0x33, 0x98, 0x0b, 0x2a, 0xd2, 0x18, 0xeb, 0x46, 0xb6, 0x4c, 0x3f, 0xf0, 0xf2, 0xe7, 0x3e, 0xba, 0x2d, 0xde, - 0x43, 0xed, 0xa7, 0xbf, 0x12, 0x8c, 0x62, 0xc4, 0x08, 0xad, 0xe0, 0x2b, 0xbd, 0x83, - ], + sha: [0x33, 0x98, 0x0b, 0x2a, 0xd2, 0x18, 0xeb, 0x46, 0xb6, 0x4c, 0x3f, 0xf0, 0xf2, 0xe7, 0x3e, 0xba, 0x2d, 0xde, 0x43, 0xed, 0xa7, 0xbf, 0x12, 0x8c, 0x62, 0xc4, 0x08, 0xad, 0xe0, 0x2b, 0xbd, 0x83], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_quant80.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_prefill_quant.ptx", - key: [ - 0xd5, 0xa6, 0x7b, 0x91, 0xe2, 0xbd, 0x30, 0x8b, 0x6c, 0x5b, 0x3c, 0xf3, 0x80, 0xf4, 0xb1, 0x40, 0x00, 0x43, - 0x28, 0xbd, 0x26, 0x4c, 0x98, 0x83, 0x70, 0xb7, 0x14, 0x37, 0xf9, 0x6b, 0x86, 0x4c, - ], + key: [0xd5, 0xa6, 0x7b, 0x91, 0xe2, 0xbd, 0x30, 0x8b, 0x6c, 0x5b, 0x3c, 0xf3, 0x80, 0xf4, 0xb1, 0x40, 0x00, 0x43, 0x28, 0xbd, 0x26, 0x4c, 0x98, 0x83, 0x70, 0xb7, 0x14, 0x37, 0xf9, 0x6b, 0x86, 0x4c], len: 217573, - sha: [ - 0xcb, 0xa7, 0x20, 0xbb, 0x6b, 0xfb, 0x98, 0x41, 0xfa, 0xc5, 0x71, 0x6f, 0x84, 0x88, 0x6c, 0x94, 0x7f, 0x36, - 0xf4, 0xf0, 0x21, 0x0d, 0xe9, 0x10, 0xd3, 0x99, 0x5c, 0x1d, 0x8e, 0x62, 0x0d, 0xd7, - ], + sha: [0xcb, 0xa7, 0x20, 0xbb, 0x6b, 0xfb, 0x98, 0x41, 0xfa, 0xc5, 0x71, 0x6f, 0x84, 0x88, 0x6c, 0x94, 0x7f, 0x36, 0xf4, 0xf0, 0x21, 0x0d, 0xe9, 0x10, 0xd3, 0x99, 0x5c, 0x1d, 0x8e, 0x62, 0x0d, 0xd7], ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_quant.ptx"), "\0").as_bytes(), }, Companion { name: "qwen_qsa_native.ptx", - key: [ - 0xd6, 0x04, 0x89, 0xfb, 0x70, 0xce, 0x43, 0x70, 0x04, 0x7b, 0xf5, 0x4f, 0xae, 0x8d, 0xd4, 0x6d, 0xfb, 0x53, - 0xbb, 0x73, 0xb1, 0x61, 0x8c, 0x58, 0x94, 0x29, 0x32, 0xa7, 0x89, 0xd0, 0x64, 0xc5, - ], + key: [0xd6, 0x04, 0x89, 0xfb, 0x70, 0xce, 0x43, 0x70, 0x04, 0x7b, 0xf5, 0x4f, 0xae, 0x8d, 0xd4, 0x6d, 0xfb, 0x53, 0xbb, 0x73, 0xb1, 0x61, 0x8c, 0x58, 0x94, 0x29, 0x32, 0xa7, 0x89, 0xd0, 0x64, 0xc5], len: 31598, - sha: [ - 0x91, 0x8c, 0x74, 0x1a, 0xb3, 0xde, 0x0c, 0x8e, 0x3a, 0x4d, 0xb0, 0xf4, 0x54, 0xbc, 0xfc, 0x73, 0x9b, 0x9b, - 0xad, 0xcd, 0x58, 0xdd, 0x04, 0x7c, 0xc5, 0xfd, 0x87, 0x2e, 0x99, 0xc0, 0x1e, 0xf0, - ], + sha: [0x91, 0x8c, 0x74, 0x1a, 0xb3, 0xde, 0x0c, 0x8e, 0x3a, 0x4d, 0xb0, 0xf4, 0x54, 0xbc, 0xfc, 0x73, 0x9b, 0x9b, 0xad, 0xcd, 0x58, 0xdd, 0x04, 0x7c, 0xc5, 0xfd, 0x87, 0x2e, 0x99, 0xc0, 0x1e, 0xf0], ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_native.ptx"), "\0").as_bytes(), }, Companion { name: "gr_fixed.ptx", - key: [ - 0xde, 0xaa, 0x95, 0xe6, 0x1d, 0x25, 0xff, 0x87, 0xfd, 0x53, 0x1b, 0x62, 0xd5, 0xc2, 0x93, 0x09, 0xb6, 0x9a, - 0x37, 0x71, 0x18, 0x20, 0x4e, 0xef, 0xae, 0xe3, 0x10, 0xaf, 0x4e, 0xcf, 0xfa, 0x8b, - ], + key: [0xde, 0xaa, 0x95, 0xe6, 0x1d, 0x25, 0xff, 0x87, 0xfd, 0x53, 0x1b, 0x62, 0xd5, 0xc2, 0x93, 0x09, 0xb6, 0x9a, 0x37, 0x71, 0x18, 0x20, 0x4e, 0xef, 0xae, 0xe3, 0x10, 0xaf, 0x4e, 0xcf, 0xfa, 0x8b], len: 22704, - sha: [ - 0x89, 0x18, 0x62, 0xf3, 0xd1, 0x04, 0x0d, 0x14, 0xbf, 0xd3, 0x8f, 0xf0, 0x0e, 0x19, 0xea, 0x42, 0xf4, 0xc6, - 0x30, 0xdd, 0xcc, 0xfd, 0xa1, 0x69, 0x9f, 0xf5, 0xc6, 0x8f, 0xa1, 0x26, 0xd9, 0x66, - ], + sha: [0x89, 0x18, 0x62, 0xf3, 0xd1, 0x04, 0x0d, 0x14, 0xbf, 0xd3, 0x8f, 0xf0, 0x0e, 0x19, 0xea, 0x42, 0xf4, 0xc6, 0x30, 0xdd, 0xcc, 0xfd, 0xa1, 0x69, 0x9f, 0xf5, 0xc6, 0x8f, 0xa1, 0x26, 0xd9, 0x66], ptx: concat!(include_str!("../ptx-sm86/gr_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "qwen_qsa_select.ptx", - key: [ - 0xe0, 0x94, 0xe1, 0x0f, 0x84, 0xcc, 0xa6, 0x12, 0xca, 0x28, 0x59, 0x6a, 0xa3, 0x94, 0xee, 0x99, 0x9e, 0x33, - 0xfe, 0x7b, 0xc8, 0x4b, 0x35, 0x9b, 0xfa, 0xb6, 0xda, 0x07, 0x30, 0xd4, 0xa5, 0x19, - ], + key: [0xe0, 0x94, 0xe1, 0x0f, 0x84, 0xcc, 0xa6, 0x12, 0xca, 0x28, 0x59, 0x6a, 0xa3, 0x94, 0xee, 0x99, 0x9e, 0x33, 0xfe, 0x7b, 0xc8, 0x4b, 0x35, 0x9b, 0xfa, 0xb6, 0xda, 0x07, 0x30, 0xd4, 0xa5, 0x19], len: 41468, - sha: [ - 0xe8, 0xad, 0xf4, 0x5c, 0x34, 0x90, 0x8f, 0xa7, 0xf1, 0x58, 0x3d, 0x1d, 0xa0, 0xc5, 0x83, 0x04, 0xfa, 0x02, - 0x29, 0xbc, 0x2e, 0x37, 0x43, 0xc2, 0xaa, 0x30, 0x58, 0xf9, 0xe2, 0x6f, 0xf2, 0x7b, - ], + sha: [0xe8, 0xad, 0xf4, 0x5c, 0x34, 0x90, 0x8f, 0xa7, 0xf1, 0x58, 0x3d, 0x1d, 0xa0, 0xc5, 0x83, 0x04, 0xfa, 0x02, 0x29, 0xbc, 0x2e, 0x37, 0x43, 0xc2, 0xaa, 0x30, 0x58, 0xf9, 0xe2, 0x6f, 0xf2, 0x7b], ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_select.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_kv.ptx", - key: [ - 0xe0, 0xc1, 0xff, 0x10, 0xd3, 0xd4, 0xbc, 0xf8, 0xfd, 0x33, 0x69, 0x71, 0x30, 0x79, 0xb2, 0x32, 0xe6, 0x2c, - 0xdb, 0x2c, 0x3a, 0x34, 0x5f, 0xae, 0xc4, 0x9d, 0x1e, 0x66, 0x76, 0x3f, 0x91, 0x1f, - ], + key: [0xe0, 0xc1, 0xff, 0x10, 0xd3, 0xd4, 0xbc, 0xf8, 0xfd, 0x33, 0x69, 0x71, 0x30, 0x79, 0xb2, 0x32, 0xe6, 0x2c, 0xdb, 0x2c, 0x3a, 0x34, 0x5f, 0xae, 0xc4, 0x9d, 0x1e, 0x66, 0x76, 0x3f, 0x91, 0x1f], len: 16734, - sha: [ - 0xb9, 0x61, 0xa6, 0xbc, 0xaf, 0x30, 0x9b, 0xca, 0x67, 0xab, 0xf6, 0xc3, 0x7b, 0x8e, 0x30, 0x3b, 0x16, 0x5f, - 0xcd, 0x8f, 0x51, 0xc6, 0x8f, 0x63, 0x11, 0xc5, 0xa0, 0xe1, 0x3f, 0x86, 0x1f, 0x8b, - ], + sha: [0xb9, 0x61, 0xa6, 0xbc, 0xaf, 0x30, 0x9b, 0xca, 0x67, 0xab, 0xf6, 0xc3, 0x7b, 0x8e, 0x30, 0x3b, 0x16, 0x5f, 0xcd, 0x8f, 0x51, 0xc6, 0x8f, 0x63, 0x11, 0xc5, 0xa0, 0xe1, 0x3f, 0x86, 0x1f, 0x8b], ptx: concat!(include_str!("../ptx-sm86/mtp_original_kv.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_attention_fixed.ptx", - key: [ - 0xe1, 0x1a, 0xc4, 0xde, 0x66, 0xc9, 0x9c, 0x31, 0xec, 0x95, 0x37, 0x27, 0xbd, 0xac, 0x91, 0xca, 0xc9, 0x7d, - 0x58, 0xd8, 0x2a, 0x3d, 0xcb, 0xe0, 0x6e, 0xf4, 0xc6, 0xe8, 0xdc, 0x2a, 0x4c, 0x66, - ], + key: [0xe1, 0x1a, 0xc4, 0xde, 0x66, 0xc9, 0x9c, 0x31, 0xec, 0x95, 0x37, 0x27, 0xbd, 0xac, 0x91, 0xca, 0xc9, 0x7d, 0x58, 0xd8, 0x2a, 0x3d, 0xcb, 0xe0, 0x6e, 0xf4, 0xc6, 0xe8, 0xdc, 0x2a, 0x4c, 0x66], len: 75847, - sha: [ - 0xa0, 0x5c, 0xff, 0x97, 0xbd, 0x7e, 0x4e, 0x0a, 0xc9, 0x24, 0xad, 0xb9, 0xf0, 0x1f, 0x7b, 0x6c, 0xa8, 0xe9, - 0x67, 0x11, 0x3f, 0x84, 0xa1, 0x68, 0x7e, 0x09, 0x76, 0xb5, 0x64, 0x13, 0xa8, 0x37, - ], + sha: [0xa0, 0x5c, 0xff, 0x97, 0xbd, 0x7e, 0x4e, 0x0a, 0xc9, 0x24, 0xad, 0xb9, 0xf0, 0x1f, 0x7b, 0x6c, 0xa8, 0xe9, 0x67, 0x11, 0x3f, 0x84, 0xa1, 0x68, 0x7e, 0x09, 0x76, 0xb5, 0x64, 0x13, 0xa8, 0x37], ptx: concat!(include_str!("../ptx-sm86/mtp_attention_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_head_iq.ptx", - key: [ - 0xe5, 0x74, 0x52, 0xcc, 0xac, 0x77, 0x2a, 0x8a, 0x8a, 0x77, 0x25, 0x3b, 0xc6, 0xc9, 0x64, 0xeb, 0xb7, 0xbc, - 0x61, 0xfd, 0xb2, 0xe9, 0x75, 0x27, 0xa9, 0x77, 0x5f, 0x8c, 0xcf, 0x3c, 0x3b, 0x9f, - ], + key: [0xe5, 0x74, 0x52, 0xcc, 0xac, 0x77, 0x2a, 0x8a, 0x8a, 0x77, 0x25, 0x3b, 0xc6, 0xc9, 0x64, 0xeb, 0xb7, 0xbc, 0x61, 0xfd, 0xb2, 0xe9, 0x75, 0x27, 0xa9, 0x77, 0x5f, 0x8c, 0xcf, 0x3c, 0x3b, 0x9f], len: 792488, - sha: [ - 0xea, 0x98, 0x3e, 0x2b, 0x8f, 0xce, 0xae, 0xbb, 0xa0, 0xad, 0xdb, 0x29, 0x62, 0x84, 0xa1, 0xf2, 0xfa, 0x54, - 0x6e, 0x26, 0x04, 0xfe, 0x8d, 0x6a, 0x10, 0x17, 0x02, 0x9a, 0xaf, 0x7e, 0x18, 0xae, - ], + sha: [0xea, 0x98, 0x3e, 0x2b, 0x8f, 0xce, 0xae, 0xbb, 0xa0, 0xad, 0xdb, 0x29, 0x62, 0x84, 0xa1, 0xf2, 0xfa, 0x54, 0x6e, 0x26, 0x04, 0xfe, 0x8d, 0x6a, 0x10, 0x17, 0x02, 0x9a, 0xaf, 0x7e, 0x18, 0xae], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_head_iq.ptx"), "\0").as_bytes(), }, Companion { name: "mmq-adaptive-fixup.ptx", - key: [ - 0xe8, 0x14, 0xd7, 0x50, 0x21, 0xa7, 0x3c, 0x38, 0x31, 0x02, 0x3d, 0x29, 0x81, 0x84, 0x72, 0x23, 0x2d, 0xb4, - 0x47, 0x29, 0x21, 0x3d, 0xf1, 0x0d, 0x60, 0xc4, 0x78, 0x63, 0xaa, 0x47, 0x72, 0x78, - ], + key: [0xe8, 0x14, 0xd7, 0x50, 0x21, 0xa7, 0x3c, 0x38, 0x31, 0x02, 0x3d, 0x29, 0x81, 0x84, 0x72, 0x23, 0x2d, 0xb4, 0x47, 0x29, 0x21, 0x3d, 0xf1, 0x0d, 0x60, 0xc4, 0x78, 0x63, 0xaa, 0x47, 0x72, 0x78], len: 445570, - sha: [ - 0xa5, 0x0b, 0x8a, 0x99, 0x40, 0x09, 0xa3, 0xc6, 0x0e, 0xd8, 0x29, 0xaa, 0x45, 0xf7, 0xb1, 0x71, 0x23, 0x40, - 0x12, 0x95, 0xbd, 0xaa, 0x4e, 0x03, 0xe8, 0x71, 0xb4, 0x39, 0x3c, 0x2a, 0xf9, 0x1c, - ], + sha: [0xa5, 0x0b, 0x8a, 0x99, 0x40, 0x09, 0xa3, 0xc6, 0x0e, 0xd8, 0x29, 0xaa, 0x45, 0xf7, 0xb1, 0x71, 0x23, 0x40, 0x12, 0x95, 0xbd, 0xaa, 0x4e, 0x03, 0xe8, 0x71, 0xb4, 0x39, 0x3c, 0x2a, 0xf9, 0x1c], ptx: concat!(include_str!("../ptx-sm86/mmq-adaptive-fixup.ptx"), "\0").as_bytes(), }, Companion { name: "mmq_original_group_mul.ptx", - key: [ - 0xea, 0x0d, 0xb7, 0x85, 0x05, 0x28, 0x9e, 0x8e, 0x74, 0x3a, 0x55, 0x2e, 0xf2, 0x3d, 0xed, 0x98, 0xd6, 0x68, - 0xa4, 0x89, 0xc6, 0x79, 0xa0, 0xe4, 0x48, 0x93, 0xb0, 0x00, 0x44, 0x5b, 0x48, 0xc7, - ], + key: [0xea, 0x0d, 0xb7, 0x85, 0x05, 0x28, 0x9e, 0x8e, 0x74, 0x3a, 0x55, 0x2e, 0xf2, 0x3d, 0xed, 0x98, 0xd6, 0x68, 0xa4, 0x89, 0xc6, 0x79, 0xa0, 0xe4, 0x48, 0x93, 0xb0, 0x00, 0x44, 0x5b, 0x48, 0xc7], len: 13083403, - sha: [ - 0x8a, 0x80, 0x90, 0xb4, 0x00, 0xf4, 0x08, 0x8f, 0x3d, 0x45, 0x0a, 0x70, 0xca, 0x0f, 0x83, 0x60, 0x8f, 0xfe, - 0x44, 0x73, 0xf4, 0x49, 0xd7, 0x9c, 0x69, 0xf8, 0x8c, 0x7c, 0x12, 0x2a, 0x26, 0x4a, - ], + sha: [0x8a, 0x80, 0x90, 0xb4, 0x00, 0xf4, 0x08, 0x8f, 0x3d, 0x45, 0x0a, 0x70, 0xca, 0x0f, 0x83, 0x60, 0x8f, 0xfe, 0x44, 0x73, 0xf4, 0x49, 0xd7, 0x9c, 0x69, 0xf8, 0x8c, 0x7c, 0x12, 0x2a, 0x26, 0x4a], ptx: concat!(include_str!("../ptx-sm86/mmq_original_group_mul.ptx"), "\0").as_bytes(), }, Companion { name: "mmq_native_resident_d4.ptx", - key: [ - 0xea, 0x33, 0xd3, 0xd1, 0xdb, 0xc3, 0xc6, 0x39, 0x81, 0x55, 0xef, 0xa1, 0x92, 0xb5, 0xbb, 0x4d, 0x5a, 0x25, - 0xf7, 0x3f, 0x6e, 0x8a, 0xf6, 0x5f, 0x2d, 0xdc, 0x1b, 0x91, 0x95, 0xbb, 0x3e, 0xeb, - ], + key: [0xea, 0x33, 0xd3, 0xd1, 0xdb, 0xc3, 0xc6, 0x39, 0x81, 0x55, 0xef, 0xa1, 0x92, 0xb5, 0xbb, 0x4d, 0x5a, 0x25, 0xf7, 0x3f, 0x6e, 0x8a, 0xf6, 0x5f, 0x2d, 0xdc, 0x1b, 0x91, 0x95, 0xbb, 0x3e, 0xeb], len: 5199, - sha: [ - 0x95, 0x4e, 0x26, 0x5c, 0x1d, 0x6a, 0x60, 0x53, 0x6c, 0x93, 0x6d, 0x3e, 0x01, 0x24, 0x02, 0x13, 0xc5, 0x0d, - 0xf2, 0xae, 0xc8, 0x8c, 0x5f, 0x42, 0x88, 0xa5, 0xd5, 0xf6, 0xe3, 0xb7, 0xc1, 0x14, - ], + sha: [0x95, 0x4e, 0x26, 0x5c, 0x1d, 0x6a, 0x60, 0x53, 0x6c, 0x93, 0x6d, 0x3e, 0x01, 0x24, 0x02, 0x13, 0xc5, 0x0d, 0xf2, 0xae, 0xc8, 0x8c, 0x5f, 0x42, 0x88, 0xa5, 0xd5, 0xf6, 0xe3, 0xb7, 0xc1, 0x14], ptx: concat!(include_str!("../ptx-sm86/mmq_native_resident_d4.ptx"), "\0").as_bytes(), }, Companion { name: "moe_fixed.ptx", - key: [ - 0xeb, 0x25, 0xf4, 0x5f, 0x2b, 0xf1, 0xcd, 0x3b, 0xe5, 0x7e, 0x0b, 0x5f, 0x32, 0x6a, 0x63, 0xf6, 0x66, 0x05, - 0x9a, 0x58, 0x70, 0x6d, 0x7a, 0x2b, 0xd4, 0x70, 0x52, 0x6c, 0x22, 0xc0, 0xf6, 0x7a, - ], + key: [0xeb, 0x25, 0xf4, 0x5f, 0x2b, 0xf1, 0xcd, 0x3b, 0xe5, 0x7e, 0x0b, 0x5f, 0x32, 0x6a, 0x63, 0xf6, 0x66, 0x05, 0x9a, 0x58, 0x70, 0x6d, 0x7a, 0x2b, 0xd4, 0x70, 0x52, 0x6c, 0x22, 0xc0, 0xf6, 0x7a], len: 24983, - sha: [ - 0x67, 0x25, 0x8f, 0xde, 0x60, 0xe2, 0xe5, 0xd0, 0xe5, 0x0b, 0xe8, 0xcb, 0xd6, 0x3b, 0x0d, 0xe4, 0x2e, 0x33, - 0xf7, 0x22, 0xb1, 0x61, 0x40, 0xe1, 0xb0, 0x71, 0x85, 0x7b, 0x47, 0xaa, 0xa8, 0xbe, - ], + sha: [0x67, 0x25, 0x8f, 0xde, 0x60, 0xe2, 0xe5, 0xd0, 0xe5, 0x0b, 0xe8, 0xcb, 0xd6, 0x3b, 0x0d, 0xe4, 0x2e, 0x33, 0xf7, 0x22, 0xb1, 0x61, 0x40, 0xe1, 0xb0, 0x71, 0x85, 0x7b, 0x47, 0xaa, 0xa8, 0xbe], ptx: concat!(include_str!("../ptx-sm86/moe_fixed.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_late.ptx", - key: [ - 0xeb, 0xc8, 0xbc, 0x0a, 0xac, 0x1b, 0xd4, 0xa7, 0x45, 0x40, 0xed, 0x24, 0x6c, 0x00, 0x96, 0x0d, 0x10, 0x15, - 0x96, 0x30, 0x20, 0x11, 0x33, 0xe6, 0xd2, 0x1f, 0x30, 0x6e, 0xfe, 0xb1, 0xba, 0x2f, - ], + key: [0xeb, 0xc8, 0xbc, 0x0a, 0xac, 0x1b, 0xd4, 0xa7, 0x45, 0x40, 0xed, 0x24, 0x6c, 0x00, 0x96, 0x0d, 0x10, 0x15, 0x96, 0x30, 0x20, 0x11, 0x33, 0xe6, 0xd2, 0x1f, 0x30, 0x6e, 0xfe, 0xb1, 0xba, 0x2f], len: 213285, - sha: [ - 0x11, 0x8d, 0x23, 0x00, 0xe6, 0x7d, 0x15, 0x42, 0x0b, 0x7e, 0xbd, 0xb4, 0xee, 0x82, 0x3d, 0x91, 0xbe, 0x58, - 0x55, 0x62, 0x07, 0x23, 0x85, 0x3f, 0xe9, 0xda, 0x8d, 0xef, 0x8a, 0xe5, 0xe9, 0x8b, - ], + sha: [0x11, 0x8d, 0x23, 0x00, 0xe6, 0x7d, 0x15, 0x42, 0x0b, 0x7e, 0xbd, 0xb4, 0xee, 0x82, 0x3d, 0x91, 0xbe, 0x58, 0x55, 0x62, 0x07, 0x23, 0x85, 0x3f, 0xe9, 0xda, 0x8d, 0xef, 0x8a, 0xe5, 0xe9, 0x8b], ptx: concat!(include_str!("../ptx-sm86/qsa_late.ptx"), "\0").as_bytes(), }, Companion { name: "kar_decode_levels.ptx", - key: [ - 0xec, 0x69, 0x77, 0x87, 0xe0, 0x00, 0x53, 0x10, 0x00, 0x5e, 0xb1, 0x69, 0xa7, 0x58, 0x31, 0x5e, 0xb5, 0x50, - 0x3a, 0xc7, 0x67, 0x1a, 0x38, 0x49, 0x5e, 0xea, 0xea, 0xf4, 0xfb, 0x2a, 0x8e, 0xc9, - ], + key: [0xec, 0x69, 0x77, 0x87, 0xe0, 0x00, 0x53, 0x10, 0x00, 0x5e, 0xb1, 0x69, 0xa7, 0x58, 0x31, 0x5e, 0xb5, 0x50, 0x3a, 0xc7, 0x67, 0x1a, 0x38, 0x49, 0x5e, 0xea, 0xea, 0xf4, 0xfb, 0x2a, 0x8e, 0xc9], len: 18428, - sha: [ - 0xb9, 0x41, 0xaf, 0xb1, 0x17, 0xd7, 0x7a, 0x57, 0x32, 0xc1, 0x66, 0x6a, 0x25, 0x29, 0x1a, 0xb9, 0xbf, 0xd6, - 0x17, 0x25, 0x28, 0xbd, 0x6b, 0x52, 0x7c, 0x37, 0x39, 0x7f, 0x24, 0xfd, 0x77, 0xc4, - ], + sha: [0xb9, 0x41, 0xaf, 0xb1, 0x17, 0xd7, 0x7a, 0x57, 0x32, 0xc1, 0x66, 0x6a, 0x25, 0x29, 0x1a, 0xb9, 0xbf, 0xd6, 0x17, 0x25, 0x28, 0xbd, 0x6b, 0x52, 0x7c, 0x37, 0x39, 0x7f, 0x24, 0xfd, 0x77, 0xc4], ptx: concat!(include_str!("../ptx-sm86/kar_decode_levels.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_prefill.ptx", - key: [ - 0xf0, 0xa0, 0x67, 0x3d, 0x72, 0xe2, 0xaf, 0x9b, 0xaa, 0x48, 0x14, 0x64, 0xbd, 0x2f, 0x07, 0x04, 0x2a, 0x66, - 0x98, 0xd4, 0x64, 0x13, 0xfe, 0x6a, 0x85, 0x4c, 0xc8, 0x30, 0x1d, 0xba, 0x67, 0x5a, - ], + key: [0xf0, 0xa0, 0x67, 0x3d, 0x72, 0xe2, 0xaf, 0x9b, 0xaa, 0x48, 0x14, 0x64, 0xbd, 0x2f, 0x07, 0x04, 0x2a, 0x66, 0x98, 0xd4, 0x64, 0x13, 0xfe, 0x6a, 0x85, 0x4c, 0xc8, 0x30, 0x1d, 0xba, 0x67, 0x5a], len: 68280, - sha: [ - 0xc3, 0xba, 0x39, 0xe3, 0xc2, 0xbe, 0x4e, 0xfb, 0x0a, 0xca, 0x00, 0x19, 0xe2, 0xaa, 0xe7, 0x47, 0xff, 0x00, - 0x1d, 0x13, 0x63, 0x10, 0x16, 0xe5, 0xcc, 0x9f, 0xef, 0x86, 0x7e, 0x9a, 0xc1, 0xaf, - ], + sha: [0xc3, 0xba, 0x39, 0xe3, 0xc2, 0xbe, 0x4e, 0xfb, 0x0a, 0xca, 0x00, 0x19, 0xe2, 0xaa, 0xe7, 0x47, 0xff, 0x00, 0x1d, 0x13, 0x63, 0x10, 0x16, 0xe5, 0xcc, 0x9f, 0xef, 0x86, 0x7e, 0x9a, 0xc1, 0xaf], ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill.ptx"), "\0").as_bytes(), }, Companion { name: "original_verify_qsa.ptx", - key: [ - 0xf5, 0x7b, 0x41, 0x82, 0xe2, 0x19, 0x2b, 0xe7, 0xf5, 0xd3, 0x19, 0xe7, 0xa5, 0xe0, 0x2f, 0xaa, 0x5f, 0xc2, - 0x45, 0xc0, 0x61, 0x42, 0x6c, 0xd2, 0xbf, 0xc1, 0x39, 0xcf, 0x45, 0x3a, 0xdc, 0x05, - ], + key: [0xf5, 0x7b, 0x41, 0x82, 0xe2, 0x19, 0x2b, 0xe7, 0xf5, 0xd3, 0x19, 0xe7, 0xa5, 0xe0, 0x2f, 0xaa, 0x5f, 0xc2, 0x45, 0xc0, 0x61, 0x42, 0x6c, 0xd2, 0xbf, 0xc1, 0x39, 0xcf, 0x45, 0x3a, 0xdc, 0x05], len: 19585, - sha: [ - 0x22, 0xd6, 0x9a, 0x56, 0xf3, 0x88, 0xc1, 0xb3, 0x83, 0xc7, 0xb1, 0x25, 0xeb, 0x11, 0xcb, 0x36, 0xb5, 0xb0, - 0xe8, 0x02, 0x6e, 0x95, 0x7b, 0x87, 0xad, 0x06, 0xce, 0x07, 0xc8, 0x02, 0x52, 0x40, - ], + sha: [0x22, 0xd6, 0x9a, 0x56, 0xf3, 0x88, 0xc1, 0xb3, 0x83, 0xc7, 0xb1, 0x25, 0xeb, 0x11, 0xcb, 0x36, 0xb5, 0xb0, 0xe8, 0x02, 0x6e, 0x95, 0x7b, 0x87, 0xad, 0x06, 0xce, 0x07, 0xc8, 0x02, 0x52, 0x40], ptx: concat!(include_str!("../ptx-sm86/original_verify_qsa.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_head_native.ptx", - key: [ - 0xf8, 0x20, 0x9e, 0x1c, 0x9f, 0xbf, 0x97, 0x8b, 0xc5, 0x7b, 0x60, 0xb0, 0xb5, 0xf6, 0xed, 0xca, 0xb1, 0x90, - 0x5e, 0x49, 0xa4, 0xab, 0x3a, 0xa9, 0x82, 0x60, 0x4e, 0x3e, 0x68, 0x0f, 0xa4, 0x37, - ], + key: [0xf8, 0x20, 0x9e, 0x1c, 0x9f, 0xbf, 0x97, 0x8b, 0xc5, 0x7b, 0x60, 0xb0, 0xb5, 0xf6, 0xed, 0xca, 0xb1, 0x90, 0x5e, 0x49, 0xa4, 0xab, 0x3a, 0xa9, 0x82, 0x60, 0x4e, 0x3e, 0x68, 0x0f, 0xa4, 0x37], len: 7459176, - sha: [ - 0x6b, 0x0a, 0x23, 0x33, 0x72, 0xb7, 0x51, 0x3f, 0x8c, 0x6e, 0xef, 0xd7, 0xaa, 0x7e, 0x66, 0x34, 0x99, 0xb7, - 0xe2, 0x38, 0x6c, 0xd8, 0x7c, 0x82, 0x73, 0xde, 0x22, 0xd7, 0x26, 0xa9, 0x84, 0xe5, - ], + sha: [0x6b, 0x0a, 0x23, 0x33, 0x72, 0xb7, 0x51, 0x3f, 0x8c, 0x6e, 0xef, 0xd7, 0xaa, 0x7e, 0x66, 0x34, 0x99, 0xb7, 0xe2, 0x38, 0x6c, 0xd8, 0x7c, 0x82, 0x73, 0xde, 0x22, 0xd7, 0x26, 0xa9, 0x84, 0xe5], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_head_native.ptx"), "\0").as_bytes(), }, Companion { name: "iq3_xxs_q8_1.ptx", - key: [ - 0xf9, 0xc1, 0x08, 0x14, 0xf3, 0x7b, 0x75, 0xba, 0xbc, 0xae, 0xe1, 0x02, 0x8b, 0x4a, 0x13, 0x75, 0xe5, 0x30, - 0x22, 0x0f, 0x86, 0x3a, 0xb3, 0x80, 0x1b, 0xeb, 0x8f, 0xcb, 0x5a, 0x19, 0x73, 0x3f, - ], + key: [0xf9, 0xc1, 0x08, 0x14, 0xf3, 0x7b, 0x75, 0xba, 0xbc, 0xae, 0xe1, 0x02, 0x8b, 0x4a, 0x13, 0x75, 0xe5, 0x30, 0x22, 0x0f, 0x86, 0x3a, 0xb3, 0x80, 0x1b, 0xeb, 0x8f, 0xcb, 0x5a, 0x19, 0x73, 0x3f], len: 15564, - sha: [ - 0x94, 0x65, 0x5f, 0x22, 0x89, 0x15, 0xdd, 0x3d, 0x0a, 0xe5, 0xdc, 0x3a, 0xde, 0xde, 0xf8, 0xfc, 0xeb, 0x06, - 0x98, 0x20, 0xae, 0x17, 0xe1, 0x5d, 0xb9, 0x49, 0x44, 0x42, 0x79, 0x48, 0xaf, 0xda, - ], + sha: [0x94, 0x65, 0x5f, 0x22, 0x89, 0x15, 0xdd, 0x3d, 0x0a, 0xe5, 0xdc, 0x3a, 0xde, 0xde, 0xf8, 0xfc, 0xeb, 0x06, 0x98, 0x20, 0xae, 0x17, 0xe1, 0x5d, 0xb9, 0x49, 0x44, 0x42, 0x79, 0x48, 0xaf, 0xda], ptx: concat!(include_str!("../ptx-sm86/iq3_xxs_q8_1.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_native_gate.ptx", - key: [ - 0xf9, 0xf7, 0x78, 0x15, 0x44, 0xa4, 0xa0, 0xb0, 0xb2, 0xf0, 0x73, 0x3f, 0xe0, 0x0f, 0x36, 0xb8, 0x19, 0x49, - 0x54, 0x33, 0x3b, 0x9b, 0xca, 0x99, 0x95, 0x91, 0x40, 0x45, 0xd8, 0x6b, 0xaf, 0x1e, - ], + key: [0xf9, 0xf7, 0x78, 0x15, 0x44, 0xa4, 0xa0, 0xb0, 0xb2, 0xf0, 0x73, 0x3f, 0xe0, 0x0f, 0x36, 0xb8, 0x19, 0x49, 0x54, 0x33, 0x3b, 0x9b, 0xca, 0x99, 0x95, 0x91, 0x40, 0x45, 0xd8, 0x6b, 0xaf, 0x1e], len: 1356, - sha: [ - 0x20, 0x00, 0x36, 0x45, 0x64, 0x34, 0x00, 0x9b, 0x96, 0x1c, 0x37, 0x1d, 0xa8, 0xa1, 0x44, 0x0d, 0xb1, 0x5a, - 0x7b, 0xe9, 0x53, 0x19, 0xa8, 0xc8, 0x15, 0xe1, 0xbf, 0xe8, 0x00, 0x95, 0xf2, 0x1c, - ], + sha: [0x20, 0x00, 0x36, 0x45, 0x64, 0x34, 0x00, 0x9b, 0x96, 0x1c, 0x37, 0x1d, 0xa8, 0xa1, 0x44, 0x0d, 0xb1, 0x5a, 0x7b, 0xe9, 0x53, 0x19, 0xa8, 0xc8, 0x15, 0xe1, 0xbf, 0xe8, 0x00, 0x95, 0xf2, 0x1c], ptx: concat!(include_str!("../ptx-sm86/qsa_native_gate.ptx"), "\0").as_bytes(), }, Companion { name: "mtp_original_full_s2.ptx", - key: [ - 0xfb, 0xb9, 0x17, 0xd5, 0x90, 0xea, 0x80, 0x33, 0x8a, 0x7b, 0xdf, 0x07, 0xb2, 0xca, 0x6d, 0x45, 0x8f, 0xa7, - 0x27, 0x63, 0xba, 0x27, 0x9e, 0x57, 0x6b, 0xcc, 0x1e, 0xec, 0x88, 0x36, 0xfd, 0x55, - ], + key: [0xfb, 0xb9, 0x17, 0xd5, 0x90, 0xea, 0x80, 0x33, 0x8a, 0x7b, 0xdf, 0x07, 0xb2, 0xca, 0x6d, 0x45, 0x8f, 0xa7, 0x27, 0x63, 0xba, 0x27, 0x9e, 0x57, 0x6b, 0xcc, 0x1e, 0xec, 0x88, 0x36, 0xfd, 0x55], len: 408620, - sha: [ - 0x84, 0xfc, 0xa0, 0x77, 0x1f, 0xef, 0x37, 0x13, 0x49, 0xc7, 0x2a, 0xdd, 0xaf, 0x76, 0x73, 0x8a, 0xe9, 0xb7, - 0x55, 0x39, 0x89, 0xb5, 0xab, 0xf6, 0x60, 0x0a, 0x22, 0x35, 0x93, 0x95, 0xae, 0x83, - ], + sha: [0x84, 0xfc, 0xa0, 0x77, 0x1f, 0xef, 0x37, 0x13, 0x49, 0xc7, 0x2a, 0xdd, 0xaf, 0x76, 0x73, 0x8a, 0xe9, 0xb7, 0x55, 0x39, 0x89, 0xb5, 0xab, 0xf6, 0x60, 0x0a, 0x22, 0x35, 0x93, 0x95, 0xae, 0x83], ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_s2.ptx"), "\0").as_bytes(), }, Companion { name: "qsa_decode_postops.ptx", - key: [ - 0xfd, 0x76, 0xe6, 0xf8, 0x45, 0x57, 0xd7, 0xf2, 0xa6, 0x2a, 0xc5, 0x6e, 0x16, 0xd5, 0xe4, 0xf7, 0x88, 0x62, - 0xe7, 0x56, 0xef, 0x98, 0x52, 0xb0, 0x4d, 0x59, 0x19, 0x99, 0x21, 0x3a, 0x51, 0x19, - ], + key: [0xfd, 0x76, 0xe6, 0xf8, 0x45, 0x57, 0xd7, 0xf2, 0xa6, 0x2a, 0xc5, 0x6e, 0x16, 0xd5, 0xe4, 0xf7, 0x88, 0x62, 0xe7, 0x56, 0xef, 0x98, 0x52, 0xb0, 0x4d, 0x59, 0x19, 0x99, 0x21, 0x3a, 0x51, 0x19], len: 12390, - sha: [ - 0x5f, 0xf2, 0x93, 0x19, 0x01, 0x09, 0x9c, 0x2c, 0xfd, 0xb6, 0x03, 0x94, 0x56, 0x52, 0x2a, 0x1e, 0x1c, 0x26, - 0xae, 0x32, 0xb6, 0x1f, 0xdf, 0x69, 0xfb, 0xee, 0xd9, 0xc2, 0xca, 0x02, 0xdd, 0x1e, - ], + sha: [0x5f, 0xf2, 0x93, 0x19, 0x01, 0x09, 0x9c, 0x2c, 0xfd, 0xb6, 0x03, 0x94, 0x56, 0x52, 0x2a, 0x1e, 0x1c, 0x26, 0xae, 0x32, 0xb6, 0x1f, 0xdf, 0x69, 0xfb, 0xee, 0xd9, 0xc2, 0xca, 0x02, 0xdd, 0x1e], ptx: concat!(include_str!("../ptx-sm86/qsa_decode_postops.ptx"), "\0").as_bytes(), }, Companion { name: "moe_group_swiglu.ptx", - key: [ - 0xfe, 0x6f, 0xba, 0x86, 0x65, 0x4b, 0x64, 0x65, 0x1f, 0xee, 0xe8, 0x43, 0x91, 0xba, 0x77, 0xb2, 0xb0, 0xab, - 0xff, 0x8b, 0x06, 0x23, 0xcd, 0xad, 0x41, 0x69, 0x76, 0x95, 0x44, 0x39, 0x7a, 0xea, - ], + key: [0xfe, 0x6f, 0xba, 0x86, 0x65, 0x4b, 0x64, 0x65, 0x1f, 0xee, 0xe8, 0x43, 0x91, 0xba, 0x77, 0xb2, 0xb0, 0xab, 0xff, 0x8b, 0x06, 0x23, 0xcd, 0xad, 0x41, 0x69, 0x76, 0x95, 0x44, 0x39, 0x7a, 0xea], len: 4684, - sha: [ - 0xbe, 0x94, 0x9a, 0x3e, 0xf8, 0xc4, 0x3c, 0x2f, 0xa1, 0x1a, 0x73, 0x63, 0x7d, 0x2d, 0x2b, 0x9c, 0x8d, 0x83, - 0xdf, 0x56, 0xc2, 0x78, 0x49, 0x21, 0xeb, 0x7b, 0xc2, 0xb4, 0xf0, 0xb5, 0x72, 0x26, - ], + sha: [0xbe, 0x94, 0x9a, 0x3e, 0xf8, 0xc4, 0x3c, 0x2f, 0xa1, 0x1a, 0x73, 0x63, 0x7d, 0x2d, 0x2b, 0x9c, 0x8d, 0x83, 0xdf, 0x56, 0xc2, 0x78, 0x49, 0x21, 0xeb, 0x7b, 0xc2, 0xb4, 0xf0, 0xb5, 0x72, 0x26], ptx: concat!(include_str!("../ptx-sm86/moe_group_swiglu.ptx"), "\0").as_bytes(), }, ]; diff --git a/crates/native-cpu-expert/examples/kernel_ab.rs b/crates/native-cpu-expert/examples/kernel_ab.rs deleted file mode 100644 index 544826e8..00000000 --- a/crates/native-cpu-expert/examples/kernel_ab.rs +++ /dev/null @@ -1,3992 +0,0 @@ -#![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -// This file is its own lint gate: `cargo clippy -- -D warnings` also lints the other workspace crates, which carry warnings of their own. -#![deny(warnings, clippy::all)] -//! Rust half of the CPU kernel A/B, part 1 (STRA-289, S0.8b): the KAB1 reader, the comparison against the C++ reference outputs and -//! the COMPONENT_KERNEL record writer. The C++ driver (`tools/kernel-ab`, STRA-248) writes a run directory `D`; this example only -//! reads it. C++ and Rust meet through files: no FFI, no unsafe, public API of the crate only, no module in the production library. -//! -//! kernel_ab verify D the reader rule: manifest, every sha256 and length, header-derived sizes, finite -//! FP16 block headers and activations; any mismatch refuses the WHOLE directory -//! kernel_ab compare D [--out R] [--pin CPU] [--machine-role NAME] [--trees avx512,avx2] -//! verify D, run our trees in fresh processes (`run-tree`), compare with the C++ -//! `.out` files (bitwise on the f32 bit patterns, or the tolerance the manifest case -//! declares with its basis), write `R/case-.rust-.out` and one -//! COMPONENT_KERNEL record per case and tree to `R/records/` -//! kernel_ab run-tree D --tree T --out R [--pin CPU] [--case ID] -//! internal: one fresh process, one tree (T = avx512 | avx2), all cases or only ID -//! -//! Timing is not in `verify` / `compare`. The records written by `compare` carry the fields the schema requires for timing with the -//! explicit NOT_MEASURED marker (see `NOT_MEASURED`), never a measurement. Timing is the second half (STRA-318, S0.8b2): -//! -//! kernel_ab time --run-dir D --case ID --slices N --pin CPU --out F.json [--slice-ms 60] [--regime both|resident|streamed] -//! [--llc-bytes B] -//! the Rust twin of `kab time` (tools/kernel-ab, STRA-317): ONE fresh process times ONE -//! case in the resident and the streamed regime on the pinned CPU and writes the KAB1-time -//! JSON (writer "rust"); no statistics -//! kernel_ab alternate --run-dir D --case ID --rounds N --batch K --pin CPU --schedule FILE [--seed S] [--out R] [--slices N] -//! [--slice-ms MS] [--llc-bytes B] [--machine-role NAME] [--kab PATH] -//! the alternation runner (ARCHITECT 395f0394 sec 1.3): std::process::Command only. Per -//! round it starts FRESH processes for the cells {cpp, rust} x {avx512, avx2} (each twice, -//! a and b, for the A/A pairs) in the order of a seeded schedule file written before the -//! first run, and writes COMPONENT_KERNEL round records. It computes NO statistics: no -//! class, no interval, no A/A verdict (those are S0.10b, STRA-313). -//! -//! cargo run --release -p leleka-native-cpu-expert --example kernel_ab -- compare D -//! cargo test -p leleka-native-cpu-expert --example kernel_ab - -use leleka_native_cpu_expert::{ - BorrowedExpert, BorrowedGroup, DirectCpuPool, DownFormat, GateUpFormat, PreparedJob, cpu_kernel_report, - rust_topology, -}; -use sha2::{Digest, Sha256}; -use std::cell::Cell; -use std::collections::{BTreeMap, BTreeSet}; -use std::ffi::OsString; -use std::fs::{self, File}; -use std::io::{Read, Write}; -use std::path::{Path, PathBuf}; -use std::process::{Command, ExitCode}; -use std::sync::OnceLock; -use std::time::{Instant, SystemTime, UNIX_EPOCH}; - -const IN_MAGIC: u32 = 0x4942_414B; -const OUT_MAGIC: u32 = 0x4F42_414B; -const IN_HEADER: usize = 64; -const OUT_HEADER: usize = 20; -const H: usize = 2560; -const FF: usize = 640; -const MAX_ROWS: usize = 8; -/// Largest legitimate file of the format is about 2.7 MB; anything above this is refused before any buffer is taken. -const MAX_FILE_BYTES: u64 = 16 << 20; -const MAX_MANIFEST_BYTES: u64 = 8 << 20; -const MAX_CASES: usize = 1024; -const TOLERANCE_METRIC: &str = "max_abs_error_over_max_abs_reference"; -/// Marker of every schema-required timing field this part does not measure (STRA-318 fills them): a text marker where the schema takes -/// text, the smallest positive double (`5e-324`) where it takes a positive number, 1 where it takes a positive count. -const NOT_MEASURED: &str = "NOT_MEASURED (filled by STRA-318, the alternation runner)"; -const TREES: [&str; 2] = ["avx512", "avx2"]; - -thread_local! { static BUFFERS: Cell = const { Cell::new(0) }; } - -// ------------------------------------------------------------------------------------------------ formats - -/// (ggml id, format, block elements, block bytes, name) as `lib.rs kind()/block()`. -const GATE_UP: [(i32, GateUpFormat, usize, usize, &str); 7] = [ - (18, GateUpFormat::Iq3Xxs, 256, 98, "IQ3_XXS"), - (21, GateUpFormat::Iq3S, 256, 110, "IQ3_S"), - (22, GateUpFormat::Iq2S, 256, 82, "IQ2_S"), - (23, GateUpFormat::Iq4Xs, 256, 136, "IQ4_XS"), - (42, GateUpFormat::Q2_0, 64, 18, "Q2_0"), - (16, GateUpFormat::Iq2Xxs, 256, 66, "IQ2_XXS"), - (17, GateUpFormat::Iq2Xs, 256, 74, "IQ2_XS"), -]; -const DOWN: [(i32, DownFormat, usize, usize, &str); 2] = - [(20, DownFormat::Iq4Nl, 32, 18, "IQ4_NL"), (42, DownFormat::Q2_0, 64, 18, "Q2_0")]; - -fn gate_up_row(id: i32) -> Option<&'static (i32, GateUpFormat, usize, usize, &'static str)> { - GATE_UP.iter().find(|r| r.0 == id) -} -fn down_row(id: i32) -> Option<&'static (i32, DownFormat, usize, usize, &'static str)> { - DOWN.iter().find(|r| r.0 == id) -} - -// ------------------------------------------------------------------------------------------------ errors - -/// A refusal of the whole directory: names the file and says why. `incomplete` is the missing-manifest case. -#[derive(Debug)] -struct Refusal { - file: String, - reason: String, - incomplete: bool, -} -impl Refusal { - fn new(file: &str, reason: impl Into) -> Self { - Self { file: file.to_owned(), reason: reason.into(), incomplete: false } - } -} -impl std::fmt::Display for Refusal { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - if self.incomplete { - write!(f, "incomplete directory: {}: {}", self.file, self.reason) - } else { - write!(f, "REFUSED {}: {}", self.file, self.reason) - } - } -} - -// ------------------------------------------------------------------------------------------------ helpers - -fn sha_hex(bytes: &[u8]) -> String { - let digest = Sha256::digest(bytes); - digest.iter().map(|b| format!("{b:02x}")).collect() -} - -/// The only place a buffer is taken from a length that came from a file; every caller validates the length first. -fn take_buffer(len: usize) -> Result, String> { - BUFFERS.with(|c| c.set(c.get() + 1)); - let mut v = Vec::new(); - v.try_reserve_exact(len).map_err(|_| format!("a buffer of {len} bytes was refused"))?; - v.resize(len, 0); - Ok(v) -} - -/// Little-endian words of a byte slice (a trailing partial word is ignored; callers pass exact multiples). -fn words_le(bytes: &[u8]) -> Vec { - bytes.as_chunks::<4>().0.iter().map(|c| u32::from_le_bytes(*c)).collect() -} - -fn le32(b: &[u8], at: usize) -> u32 { - u32::from_le_bytes([b[at], b[at + 1], b[at + 2], b[at + 3]]) -} - -fn civil_from_days(z: i64) -> (i64, u32, u32) { - let z = z + 719_468; - let era = z.div_euclid(146_097); - let doe = z.rem_euclid(146_097); - let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; - let y = yoe + era * 400; - let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); - let mp = (5 * doy + 2) / 153; - let d = (doy - (153 * mp + 2) / 5 + 1) as u32; - let m = if mp < 10 { mp + 3 } else { mp - 9 } as u32; - (if m <= 2 { y + 1 } else { y }, m, d) -} - -fn utc_of(secs: u64) -> String { - let (y, m, d) = civil_from_days((secs / 86_400) as i64); - let s = secs % 86_400; - format!("{y:04}-{m:02}-{d:02}T{:02}:{:02}:{:02}Z", s / 3600, s % 3600 / 60, s % 60) -} - -fn now_utc() -> String { - utc_of(SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |d| d.as_secs())) -} - -fn is_utc(s: &str) -> bool { - let b = s.as_bytes(); - b.len() == 20 - && b.iter().enumerate().all(|(i, c)| match i { - 4 | 7 => *c == b'-', - 10 => *c == b'T', - 13 | 16 => *c == b':', - 19 => *c == b'Z', - _ => c.is_ascii_digit(), - }) -} - -fn is_hex(s: &str, min: usize, max: usize) -> bool { - (min..=max).contains(&s.len()) && s.bytes().all(|c| c.is_ascii_digit() || (b'a'..=b'f').contains(&c)) -} - -fn valid_id(id: &str) -> bool { - !id.is_empty() && id.len() <= 64 && id.bytes().all(|c| c.is_ascii_alphanumeric() || c == b'-' || c == b'_') -} - -// ------------------------------------------------------------------------------------------------ JSON (read) - -#[derive(Debug, Clone, PartialEq)] -enum Json { - Null, - Bool(bool), - Num(String), - Str(String), - Arr(Vec), - Obj(Vec<(String, Json)>), -} - -struct Parser<'a> { - b: &'a [u8], - at: usize, -} - -impl Parser<'_> { - fn ws(&mut self) { - while self.at < self.b.len() && matches!(self.b[self.at], b' ' | b'\t' | b'\n' | b'\r') { - self.at += 1; - } - } - fn err(&self, what: &str) -> Result { - Err(format!("JSON error at byte {}: {what}", self.at)) - } - fn lit(&mut self, word: &str, v: Json) -> Result { - if self.b[self.at..].starts_with(word.as_bytes()) { - self.at += word.len(); - Ok(v) - } else { - self.err("unknown literal") - } - } - fn hex4(&mut self) -> Result { - if self.at + 4 > self.b.len() { - return self.err("short \\u escape"); - } - let s = std::str::from_utf8(&self.b[self.at..self.at + 4]).map_err(|_| "bad \\u escape".to_owned())?; - let v = u32::from_str_radix(s, 16).map_err(|_| "bad \\u escape".to_owned())?; - self.at += 4; - Ok(v) - } - fn string(&mut self) -> Result { - self.at += 1; - let mut out: Vec = Vec::new(); - loop { - let Some(&c) = self.b.get(self.at) else { return self.err("unterminated string") }; - self.at += 1; - match c { - b'"' => return String::from_utf8(out).map_err(|_| "string is not UTF-8".to_owned()), - b'\\' => { - let Some(&e) = self.b.get(self.at) else { return self.err("unterminated escape") }; - self.at += 1; - let ch = match e { - b'"' => '"', - b'\\' => '\\', - b'/' => '/', - b'b' => '\u{8}', - b'f' => '\u{c}', - b'n' => '\n', - b'r' => '\r', - b't' => '\t', - b'u' => { - let hi = self.hex4()?; - let cp = if (0xD800..0xDC00).contains(&hi) { - if !self.b[self.at..].starts_with(b"\\u") { - return self.err("lone surrogate"); - } - self.at += 2; - let lo = self.hex4()?; - if !(0xDC00..0xE000).contains(&lo) { - return self.err("lone surrogate"); - } - 0x10000 + ((hi - 0xD800) << 10) + (lo - 0xDC00) - } else { - hi - }; - match char::from_u32(cp) { - Some(c) => c, - None => return self.err("lone surrogate"), - } - } - _ => return self.err("unknown escape"), - }; - let mut buf = [0u8; 4]; - out.extend_from_slice(ch.encode_utf8(&mut buf).as_bytes()); - } - 0..=0x1f => return self.err("control character in string"), - _ => out.push(c), - } - } - } - fn number(&mut self) -> Result { - let start = self.at; - while self.at < self.b.len() && matches!(self.b[self.at], b'-' | b'+' | b'.' | b'e' | b'E' | b'0'..=b'9') { - self.at += 1; - } - let text = std::str::from_utf8(&self.b[start..self.at]).map_err(|_| "bad number".to_owned())?; - if text.parse::().is_err() { - return self.err("bad number"); - } - Ok(Json::Num(text.to_owned())) - } - fn value(&mut self, depth: usize) -> Result { - if depth > 32 { - return self.err("nesting deeper than 32"); - } - self.ws(); - match self.b.get(self.at) { - None => self.err("unexpected end"), - Some(b'{') => { - self.at += 1; - let mut items: Vec<(String, Json)> = Vec::new(); - self.ws(); - if self.b.get(self.at) == Some(&b'}') { - self.at += 1; - return Ok(Json::Obj(items)); - } - loop { - self.ws(); - if self.b.get(self.at) != Some(&b'"') { - return self.err("object key expected"); - } - let key = self.string()?; - if items.iter().any(|(k, _)| *k == key) { - return self.err(&format!("duplicate key {key:?}")); - } - self.ws(); - if self.b.get(self.at) != Some(&b':') { - return self.err("':' expected"); - } - self.at += 1; - let v = self.value(depth + 1)?; - items.push((key, v)); - self.ws(); - match self.b.get(self.at) { - Some(b',') => self.at += 1, - Some(b'}') => { - self.at += 1; - return Ok(Json::Obj(items)); - } - _ => return self.err("',' or '}' expected"), - } - } - } - Some(b'[') => { - self.at += 1; - let mut items = Vec::new(); - self.ws(); - if self.b.get(self.at) == Some(&b']') { - self.at += 1; - return Ok(Json::Arr(items)); - } - loop { - items.push(self.value(depth + 1)?); - self.ws(); - match self.b.get(self.at) { - Some(b',') => self.at += 1, - Some(b']') => { - self.at += 1; - return Ok(Json::Arr(items)); - } - _ => return self.err("',' or ']' expected"), - } - } - } - Some(b'"') => Ok(Json::Str(self.string()?)), - Some(b't') => self.lit("true", Json::Bool(true)), - Some(b'f') => self.lit("false", Json::Bool(false)), - Some(b'n') => self.lit("null", Json::Null), - Some(b'-' | b'0'..=b'9') => self.number(), - Some(_) => self.err("unexpected character"), - } - } -} - -fn parse_json(bytes: &[u8]) -> Result { - let mut p = Parser { b: bytes, at: 0 }; - let v = p.value(0)?; - p.ws(); - if p.at != bytes.len() { - return p.err("trailing data"); - } - Ok(v) -} - -impl Json { - fn get(&self, key: &str) -> Option<&Json> { - match self { - Json::Obj(items) => items.iter().find(|(k, _)| k == key).map(|(_, v)| v), - _ => None, - } - } - fn req(&self, key: &str) -> Result<&Json, String> { - self.get(key).ok_or_else(|| format!("missing key {key:?}")) - } - fn str(&self, key: &str) -> Result<&str, String> { - match self.req(key)? { - Json::Str(s) => Ok(s), - _ => Err(format!("key {key:?} is not a string")), - } - } - fn uint(&self, key: &str) -> Result { - match self.req(key)? { - Json::Num(n) => n.parse::().map_err(|_| format!("key {key:?} is not an unsigned integer")), - _ => Err(format!("key {key:?} is not a number")), - } - } - fn float(&self, key: &str) -> Result { - match self.req(key)? { - Json::Num(n) => n - .parse::() - .ok() - .filter(|v| v.is_finite()) - .ok_or_else(|| format!("key {key:?} is not a finite number")), - _ => Err(format!("key {key:?} is not a number")), - } - } - /// A number, or None for a JSON null (the C++ writer prints null for a value it could not measure). - fn float_or_null(&self, key: &str) -> Result, String> { - match self.req(key)? { - Json::Null => Ok(None), - _ => self.float(key).map(Some), - } - } - fn flag(&self, key: &str) -> Result { - match self.req(key)? { - Json::Bool(b) => Ok(*b), - _ => Err(format!("key {key:?} is not a boolean")), - } - } - fn array(&self, key: &str) -> Result<&[Json], String> { - match self.req(key)? { - Json::Arr(a) => Ok(a), - _ => Err(format!("key {key:?} is not an array")), - } - } -} - -// ------------------------------------------------------------------------------------------------ KAB1 headers - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -struct InHeader { - gu: i32, - down: i32, - rows: usize, - gate: usize, - up: usize, - down_bytes: usize, -} - -impl InHeader { - fn input_at(&self) -> usize { - IN_HEADER + self.gate + self.up + self.down_bytes - } -} - -/// Pure: decides from 64 header bytes and the file length, allocates nothing. -fn validate_in_header(h: &[u8; IN_HEADER], file_len: u64) -> Result { - if le32(h, 0) != IN_MAGIC { - return Err(format!("wrong magic 0x{:08x}, expected 0x{IN_MAGIC:08x}", le32(h, 0))); - } - if le32(h, 4) != 1 { - return Err(format!("unsupported version {}, expected 1", le32(h, 4))); - } - let (gu, down) = (le32(h, 8) as i32, le32(h, 12) as i32); - let Some(&(_, _, gq, gb, _)) = gate_up_row(gu) else { - return Err(format!("gate/up type {gu} is not in the KAB1 list")); - }; - let Some(&(_, _, dq, db, _)) = down_row(down) else { - return Err(format!("down type {down} is not in the KAB1 list")); - }; - let rows = le32(h, 16) as usize; - if !(1..=MAX_ROWS).contains(&rows) { - return Err(format!("rows {rows} outside 1..={MAX_ROWS}")); - } - if le32(h, 20) as usize != H || le32(h, 24) as usize != FF { - return Err(format!("n_embd {} / n_ff {} differ from {H} / {FF}", le32(h, 20), le32(h, 24))); - } - let gsize = (H / gq * gb * FF) as u64; - let dsize = (FF / dq * db * H) as u64; - let (g, u, d) = (le32(h, 28) as u64, le32(h, 32) as u64, le32(h, 36) as u64); - if g != gsize || u != gsize || d != dsize { - return Err(format!( - "byte counts gate/up/down {g}/{u}/{d} differ from the format-derived {gsize}/{gsize}/{dsize}" - )); - } - if h[40..].iter().any(|b| *b != 0) { - return Err("header padding is not zero".to_owned()); - } - let total = IN_HEADER as u64 + g + u + d + (rows * H * 4) as u64; - if total != file_len { - return Err(format!("file length {file_len} differs from the header-derived {total}")); - } - Ok(InHeader { gu, down, rows, gate: g as usize, up: u as usize, down_bytes: d as usize }) -} - -/// Pure: 20 bytes and the file length. -fn validate_out_header(h: &[u8; OUT_HEADER], file_len: u64, rows: usize, tree: &str) -> Result<(), String> { - if le32(h, 0) != OUT_MAGIC { - return Err(format!("wrong magic 0x{:08x}, expected 0x{OUT_MAGIC:08x}", le32(h, 0))); - } - if le32(h, 4) != 1 { - return Err(format!("unsupported version {}, expected 1", le32(h, 4))); - } - if le32(h, 8) as usize != rows || le32(h, 12) as usize != H { - return Err(format!("rows {} / n_embd {} differ from the case ({rows} / {H})", le32(h, 8), le32(h, 12))); - } - let tree_id = TREES.iter().position(|t| *t == tree).map_or(u32::MAX, |i| i as u32); - if le32(h, 16) != tree_id { - return Err(format!("tree id {} differs from the file name's tree {tree} ({tree_id})", le32(h, 16))); - } - let total = (OUT_HEADER + rows * H * 4) as u64; - if total != file_len { - return Err(format!("file length {file_len} differs from the header-derived {total}")); - } - Ok(()) -} - -fn fp16_finite(bytes: &[u8], block: usize) -> Option { - (0..bytes.len()).step_by(block).find(|&at| u16::from_le_bytes([bytes[at], bytes[at + 1]]) & 0x7c00 == 0x7c00) -} - -// ------------------------------------------------------------------------------------------------ manifest - -#[derive(Debug, Clone, PartialEq)] -struct Tolerance { - value: f64, - basis: String, - basis_written_utc: String, -} - -#[derive(Debug, Clone)] -struct OutRef { - tree: &'static str, - name: String, - sha256: String, - bytes: u64, -} - -#[derive(Debug, Clone)] -struct CaseEntry { - id: String, - gu: i32, - down: i32, - rows: usize, - in_name: String, - in_sha256: String, - in_bytes: u64, - outs: Vec, - tolerance: Option, -} - -#[derive(Debug, Clone)] -struct Provenance { - run_id: String, - engine_strata_pin: String, - compiler_id: String, - compiler_version: String, - target_triple: String, - reference_flags: String, - avx512_ok: Option, -} - -#[derive(Debug)] -struct Verified { - dir: PathBuf, - manifest_sha256: String, - provenance: Provenance, - cases: Vec, - file_count: usize, -} - -type FileTable = Vec<(String, String, u64)>; - -fn parse_manifest(m: &Json) -> Result<(Provenance, Vec, FileTable), String> { - if m.str("format")? != "KAB1" || m.uint("version")? != 1 { - return Err("format is not KAB1 version 1".to_owned()); - } - let p = m.req("provenance")?; - let flags = p.req("flags")?; - let commit = p.str("engine_strata_pin")?; - if !is_hex(commit, 7, 40) { - return Err("provenance.engine_strata_pin is not a commit hash".to_owned()); - } - let built = p.str("built_at_utc")?; - if !is_utc(built) { - return Err("provenance.built_at_utc is not a UTC timestamp".to_owned()); - } - let avx512_ok = match p.get("avx512_ok") { - Some(Json::Bool(b)) => Some(*b), - _ => None, - }; - let provenance = Provenance { - run_id: m.str("run_id")?.to_owned(), - engine_strata_pin: commit.to_owned(), - compiler_id: p.str("compiler_id")?.to_owned(), - compiler_version: p.str("compiler_version")?.to_owned(), - target_triple: p.str("target_triple")?.to_owned(), - reference_flags: format!( - "strata_cxx_flags: {}; ggml_cpu_arch_flags: {}", - flags.str("strata_cxx_flags")?, - flags.str("ggml_cpu_arch_flags")? - ), - avx512_ok, - }; - let Json::Arr(cases_json) = m.req("cases")? else { return Err("cases is not an array".to_owned()) }; - if cases_json.is_empty() || cases_json.len() > MAX_CASES { - return Err(format!("{} cases (1..={MAX_CASES} allowed)", cases_json.len())); - } - let mut cases = Vec::new(); - for c in cases_json { - let id = c.str("id")?.to_owned(); - if !valid_id(&id) { - return Err(format!("case id {id:?} is not a plain identifier")); - } - let rows = c.uint("rows")? as usize; - let in_name = format!("case-{id}.in"); - if c.str("in")? != in_name { - return Err(format!("case {id}: file name {:?} is not {in_name}", c.str("in")?)); - } - let mut outs = Vec::new(); - for tree in TREES { - let key = format!("out_cpp_{tree}"); - let name = format!("case-{id}.cpp-{tree}.out"); - if c.str(&key)? != name { - return Err(format!("case {id}: file name {:?} is not {name}", c.str(&key)?)); - } - outs.push(OutRef { - tree, - name, - sha256: c.str(&format!("{key}_sha256"))?.to_owned(), - bytes: c.uint(&format!("{key}_bytes"))?, - }); - } - let tolerance = match (c.str("equality")?, c.req("tolerance")?) { - ("bitwise", Json::Null) => None, - ("tolerance", t @ Json::Obj(_)) => { - if t.str("metric")? != TOLERANCE_METRIC { - return Err(format!( - "case {id}: tolerance metric {:?} is not {TOLERANCE_METRIC}", - t.str("metric")? - )); - } - let value = match t.req("value")? { - Json::Num(n) => n.parse::().ok().filter(|v| v.is_finite() && *v > 0.0), - _ => None, - } - .ok_or_else(|| format!("case {id}: tolerance.value is not a positive number"))?; - let basis = t.str("basis")?.to_owned(); - let written = t.str("basis_written_utc")?.to_owned(); - if basis.trim().is_empty() || !is_utc(&written) { - return Err(format!("case {id}: tolerance needs a non-empty basis and a UTC basis_written_utc")); - } - if written.as_str() > built { - return Err(format!( - "case {id}: the tolerance basis was written {written}, after the reference run {built}" - )); - } - Some(Tolerance { value, basis, basis_written_utc: written }) - } - (other, _) => { - return Err(format!( - "case {id}: equality {other:?} and tolerance disagree (bitwise needs null, tolerance an object)" - )); - } - }; - let in_sha256 = c.str("in_sha256")?.to_owned(); - let gu = c.uint("gu_type")? as i32; - let down = c.uint("down_type")? as i32; - cases.push(CaseEntry { - id, - gu, - down, - rows, - in_name, - in_sha256, - in_bytes: c.uint("in_bytes")?, - outs, - tolerance, - }); - } - let Json::Obj(files_json) = m.req("files")? else { return Err("files is not an object".to_owned()) }; - let mut files = Vec::new(); - for (name, v) in files_json { - let sha = v.str("sha256")?; - if !is_hex(sha, 64, 64) { - return Err(format!("files.{name}.sha256 is not a sha256")); - } - files.push((name.clone(), sha.to_owned(), v.uint("bytes")?)); - } - let mut seen = BTreeSet::new(); - for c in &cases { - if !seen.insert(c.id.clone()) { - return Err(format!("case id {} appears twice", c.id)); - } - for sha in std::iter::once(&c.in_sha256).chain(c.outs.iter().map(|o| &o.sha256)) { - if !is_hex(sha, 64, 64) { - return Err(format!("case {}: a sha256 is not 64 lowercase hex digits", c.id)); - } - } - } - Ok((provenance, cases, files)) -} - -fn case_files(c: &CaseEntry) -> Vec<(&str, &str, u64)> { - let mut v = vec![(c.in_name.as_str(), c.in_sha256.as_str(), c.in_bytes)]; - v.extend(c.outs.iter().map(|o| (o.name.as_str(), o.sha256.as_str(), o.bytes))); - v -} - -// ------------------------------------------------------------------------------------------------ file readers - -#[derive(Debug)] -struct CaseIn { - header: InHeader, - blob: Vec, -} -impl CaseIn { - fn gate(&self) -> &[u8] { - &self.blob[IN_HEADER..IN_HEADER + self.header.gate] - } - fn up(&self) -> &[u8] { - let s = IN_HEADER + self.header.gate; - &self.blob[s..s + self.header.up] - } - fn down(&self) -> &[u8] { - let s = IN_HEADER + self.header.gate + self.header.up; - &self.blob[s..s + self.header.down_bytes] - } - fn input(&self) -> Vec { - words_le(&self.blob[self.header.input_at()..]).into_iter().map(f32::from_bits).collect() - } -} - -/// Reads one case input: length against the manifest and the limit, header decision, THEN the buffer, then sha256, FP16 headers and -/// finite activations. Any failure names the file. -fn read_case_in(dir: &Path, c: &CaseEntry) -> Result { - let name = c.in_name.as_str(); - let r = |reason: String| Refusal::new(name, reason); - let mut f = File::open(dir.join(name)).map_err(|e| r(format!("cannot open: {e}")))?; - let len = f.metadata().map_err(|e| r(format!("cannot stat: {e}")))?.len(); - if len != c.in_bytes { - return Err(r(format!("length {len} differs from the manifest's {}", c.in_bytes))); - } - if len > MAX_FILE_BYTES || len < IN_HEADER as u64 { - return Err(r(format!("length {len} outside {IN_HEADER}..={MAX_FILE_BYTES}"))); - } - let mut hdr = [0u8; IN_HEADER]; - f.read_exact(&mut hdr).map_err(|e| r(format!("cannot read the header: {e}")))?; - let header = validate_in_header(&hdr, len).map_err(r)?; - if header.gu != c.gu || header.down != c.down || header.rows != c.rows { - return Err(r("the header's types / rows differ from the manifest case".to_owned())); - } - let mut blob = take_buffer(len as usize).map_err(r)?; - blob[..IN_HEADER].copy_from_slice(&hdr); - f.read_exact(&mut blob[IN_HEADER..]).map_err(|e| r(format!("cannot read the body: {e}")))?; - if sha_hex(&blob) != c.in_sha256 { - return Err(r("sha256 differs from the manifest".to_owned())); - } - let case = CaseIn { header, blob }; - let (gb, db) = (gate_up_row(header.gu).map_or(1, |x| x.3), down_row(header.down).map_or(1, |x| x.3)); - for (role, bytes, block) in [("gate", case.gate(), gb), ("up", case.up(), gb), ("down", case.down(), db)] { - if let Some(at) = fp16_finite(bytes, block) { - return Err(r(format!("non-finite FP16 block header in {role} at byte {at}"))); - } - } - if words_le(&case.blob[header.input_at()..]).into_iter().any(|w| !f32::from_bits(w).is_finite()) { - return Err(r("non-finite activation".to_owned())); - } - Ok(case) -} - -/// Reads an `.out` file as f32 bit patterns. `expect` is the manifest's (sha256, bytes) for a C++ file; ours has none. -fn read_out( - path: &Path, - name: &str, - rows: usize, - tree: &str, - expect: Option<(&str, u64)>, -) -> Result, Refusal> { - let r = |reason: String| Refusal::new(name, reason); - let mut f = File::open(path).map_err(|e| r(format!("cannot open: {e}")))?; - let len = f.metadata().map_err(|e| r(format!("cannot stat: {e}")))?.len(); - if let Some((_, bytes)) = expect - && len != bytes - { - return Err(r(format!("length {len} differs from the manifest's {bytes}"))); - } - if len > MAX_FILE_BYTES || len < OUT_HEADER as u64 { - return Err(r(format!("length {len} outside {OUT_HEADER}..={MAX_FILE_BYTES}"))); - } - let mut hdr = [0u8; OUT_HEADER]; - f.read_exact(&mut hdr).map_err(|e| r(format!("cannot read the header: {e}")))?; - validate_out_header(&hdr, len, rows, tree).map_err(r)?; - let mut blob = take_buffer(len as usize).map_err(r)?; - blob[..OUT_HEADER].copy_from_slice(&hdr); - f.read_exact(&mut blob[OUT_HEADER..]).map_err(|e| r(format!("cannot read the body: {e}")))?; - if let Some((sha, _)) = expect - && sha_hex(&blob) != sha - { - return Err(r("sha256 differs from the manifest".to_owned())); - } - let bits = words_le(&blob[OUT_HEADER..]); - if bits.iter().any(|b| !f32::from_bits(*b).is_finite()) { - return Err(r("non-finite value".to_owned())); - } - Ok(bits) -} - -/// Reads and parses `manifest.json` (size cap first). Returns its bytes (the caller hashes them), the provenance, the cases and the flat -/// files table. A missing manifest is the `incomplete` refusal. -fn read_manifest(dir: &Path) -> Result<(Vec, Provenance, Vec, FileTable), Refusal> { - let mpath = dir.join("manifest.json"); - let mname = "manifest.json"; - if !mpath.is_file() { - let mut r = Refusal::new(mname, "no manifest.json (the writer publishes it last)"); - r.incomplete = true; - return Err(r); - } - let r = |reason: String| Refusal::new(mname, reason); - let mut f = File::open(&mpath).map_err(|e| r(format!("cannot open: {e}")))?; - let mlen = f.metadata().map_err(|e| r(format!("cannot stat: {e}")))?.len(); - if mlen > MAX_MANIFEST_BYTES { - return Err(r(format!("length {mlen} above the limit {MAX_MANIFEST_BYTES}"))); - } - let mut mbytes = take_buffer(mlen as usize).map_err(r)?; - f.read_exact(&mut mbytes).map_err(|e| r(format!("cannot read: {e}")))?; - let manifest = parse_json(&mbytes).map_err(r)?; - let (provenance, cases, files) = parse_manifest(&manifest).map_err(r)?; - Ok((mbytes, provenance, cases, files)) -} - -/// The reader rule. Everything in the directory is checked before anything is used; any problem refuses the whole directory. -fn verify_dir(dir: &Path) -> Result { - let mname = "manifest.json"; - let r = |reason: String| Refusal::new(mname, reason); - let (mbytes, provenance, cases, files) = read_manifest(dir)?; - // the flat files table and the case entries must describe exactly the same files - let mut expected: Vec<(&str, &str, u64)> = cases.iter().flat_map(case_files).collect(); - expected.sort_unstable(); - let mut table: Vec<(&str, &str, u64)> = files.iter().map(|(n, s, b)| (n.as_str(), s.as_str(), *b)).collect(); - table.sort_unstable(); - if expected != table { - return Err(r("the flat files table and the case entries disagree".to_owned())); - } - let names: BTreeSet<&str> = expected.iter().map(|e| e.0).collect(); - let listing = fs::read_dir(dir).map_err(|e| r(format!("cannot list the directory: {e}")))?; - for entry in listing { - let entry = entry.map_err(|e| r(format!("cannot list the directory: {e}")))?; - let n = entry.file_name().to_string_lossy().into_owned(); - if n != mname && !names.contains(n.as_str()) { - return Err(Refusal::new(&n, "file is not in the manifest")); - } - } - let file_count = names.len() + 1; - for c in &cases { - read_case_in(dir, c)?; - for o in &c.outs { - read_out(&dir.join(&o.name), &o.name, c.rows, o.tree, Some((&o.sha256, o.bytes)))?; - } - } - Ok(Verified { dir: dir.to_owned(), manifest_sha256: sha_hex(&mbytes), provenance, cases, file_count }) -} - -// ------------------------------------------------------------------------------------------------ compare - -#[derive(Debug, PartialEq)] -struct Outcome { - compared: usize, - mismatches: usize, - differing_bits: usize, - max_abs_error: f64, - first_mismatch: Option<(usize, u32, u32)>, -} -impl Outcome { - fn equal(&self) -> bool { - self.mismatches == 0 - } -} - -/// Bitwise on the f32 bit patterns (so -0 and +0 differ) when `tol` is None; otherwise `|ours - ref| <= value * max|ref|` per value -/// (the one metric the reader knows, `TOLERANCE_METRIC`). -fn compare_bits(ours: &[u32], reference: &[u32], tol: Option<&Tolerance>) -> Outcome { - let scale = reference.iter().map(|b| f64::from(f32::from_bits(*b)).abs()).fold(0.0, f64::max); - let mut o = Outcome { - compared: reference.len(), - mismatches: 0, - differing_bits: 0, - max_abs_error: 0.0, - first_mismatch: None, - }; - for (i, (a, b)) in ours.iter().zip(reference).enumerate() { - let err = (f64::from(f32::from_bits(*a)) - f64::from(f32::from_bits(*b))).abs(); - if a != b { - o.differing_bits += 1; - } - if err.is_finite() { - o.max_abs_error = o.max_abs_error.max(err); - } - let bad = match tol { - None => a != b, - Some(t) => err.partial_cmp(&(t.value * scale)).is_none_or(|o| o == std::cmp::Ordering::Greater), - }; - if bad { - o.mismatches += 1; - o.first_mismatch.get_or_insert((i, *a, *b)); - } - } - if ours.len() != reference.len() { - o.mismatches += ours.len().abs_diff(reference.len()); - } - o -} - -// ------------------------------------------------------------------------------------------------ record (hand-written JSON) - -fn jstr(s: &str) -> String { - let mut o = String::with_capacity(s.len() + 2); - o.push('"'); - for c in s.chars() { - match c { - '"' => o.push_str("\\\""), - '\\' => o.push_str("\\\\"), - '\n' => o.push_str("\\n"), - '\r' => o.push_str("\\r"), - '\t' => o.push_str("\\t"), - c if (c as u32) < 0x20 => o.push_str(&format!("\\u{:04x}", c as u32)), - c => o.push(c), - } - } - o.push('"'); - o -} - -struct RecordInput<'a> { - record_id: String, - created_utc: String, - run_started_utc: String, - machine_role: String, - cpu_model: String, - os: String, - ours_compiler: String, - ours_version: String, - ours_triple: String, - ours_flags: String, - tree: &'a str, - verified: &'a Verified, - case: &'a CaseEntry, - pin_cpu: usize, - sibling_idle: bool, - outcome: &'a Outcome, -} - -fn record_json(r: &RecordInput) -> String { - let p = &r.verified.provenance; - let c = r.case; - let mode = if c.tolerance.is_some() { "tolerance" } else { "bitwise" }; - let tolerance = c.tolerance.as_ref().map_or(String::new(), |t| { - format!( - ",\n \"tolerance\": {{\"value\": {:e}, \"basis\": {}, \"basis_written_utc\": {}}}", - t.value, - jstr(&format!("{} [metric: {TOLERANCE_METRIC}]", t.basis)), - jstr(&t.basis_written_utc) - ) - }); - let tiny = format!("{:e}", f64::from_bits(1)); - let (gu, down) = (gate_up_row(c.gu).map_or("?", |x| x.4), down_row(c.down).map_or("?", |x| x.4)); - format!( - "{{\n \"schema_version\": \"1\",\n \"level\": \"COMPONENT_KERNEL\",\n \"record_id\": {rid},\n \"created_utc\": {created},\n \"run_started_utc\": {started},\n \"machine\": {{\"machine_role\": {role}, \"cpu_model\": {cpu}, \"gpu_name\": \"none\", \"os\": {os}}},\n \"kernel\": {kernel},\n \"toolchain\": {{\n \"ours\": {{\"compiler\": {oc}, \"version\": {ov}, \"target_triple\": {ot}, \"flags\": {of}}},\n \"reference\": {{\"compiler\": {rc}, \"version\": {rv}, \"target_triple\": {rt}, \"flags\": {rf}}}\n }},\n \"case_id\": {cid},\n \"input_sha256\": {insha},\n \"kab1_manifest_sha256\": {msha},\n \"tree\": {{\"ours\": {tree}, \"reference\": {tree}}},\n \"regime\": \"resident\",\n \"pin\": {{\"logical_cpu\": {pin}, \"sibling_idle\": {sib}}},\n \"strata_upstream_commit\": {commit},\n \"clock_calibration\": {{\"method\": {nm}, \"ghz_before\": {tiny}, \"ghz_after\": {tiny}, \"max_drift_fraction\": 0, \"slices_total\": 1, \"slices_dropped\": 0}},\n \"rows\": [\n {{\"row_type\": {rowtype}, \"unit\": \"ns\", \"rounds\": 1, \"ours\": {{\"median\": {tiny}, \"p05\": {tiny}, \"p95\": {tiny}}}, \"reference\": {{\"median\": {tiny}, \"p05\": {tiny}, \"p95\": {tiny}}}}}\n ],\n \"aa_noise_floor\": {{\"ours_vs_ours\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"reference_vs_reference\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"floor_fraction\": 0}},\n \"equality\": {{\n \"mode\": \"{mode}\",\n \"verdict\": \"{verdict}\",\n \"compared_values\": {compared},\n \"mismatches\": {mism}{tolerance}\n }}\n}}\n", - rid = jstr(&r.record_id), - created = jstr(&r.created_utc), - started = jstr(&r.run_started_utc), - role = jstr(&r.machine_role), - cpu = jstr(&r.cpu_model), - os = jstr(&r.os), - kernel = jstr(&format!( - "routed-expert-gate-up-down {gu}+{down} rows={} (equality only; timing {NOT_MEASURED})", - c.rows - )), - oc = jstr(&r.ours_compiler), - ov = jstr(&r.ours_version), - ot = jstr(&r.ours_triple), - of = jstr(&r.ours_flags), - rc = jstr(&p.compiler_id), - rv = jstr(&p.compiler_version), - rt = jstr(&p.target_triple), - rf = jstr(&p.reference_flags), - cid = jstr(&c.id), - insha = jstr(&c.in_sha256), - msha = jstr(&r.verified.manifest_sha256), - tree = jstr(r.tree), - pin = r.pin_cpu, - sib = r.sibling_idle, - commit = jstr(&p.engine_strata_pin), - nm = jstr(NOT_MEASURED), - rowtype = jstr(&format!("{gu}+{down} r{} {NOT_MEASURED}", c.rows)), - verdict = if r.outcome.equal() { "EQUAL" } else { "NOT_EQUAL" }, - compared = r.outcome.compared, - mism = r.outcome.mismatches, - ) -} - -// ------------------------------------------------------------------------------------------------ run-tree (one fresh process) - -fn write_out(path: &Path, rows: usize, tree: &str, values: &[f32]) -> Result<(), String> { - let tree_id = TREES.iter().position(|t| *t == tree).ok_or("unknown tree")? as u32; - let mut b = Vec::with_capacity(OUT_HEADER + values.len() * 4); - for w in [OUT_MAGIC, 1, rows as u32, H as u32, tree_id] { - b.extend_from_slice(&w.to_le_bytes()); - } - for v in values { - b.extend_from_slice(&v.to_bits().to_le_bytes()); - } - File::create(path).and_then(|mut f| f.write_all(&b)).map_err(|e| format!("{}: {e}", path.display())) -} - -/// Our kernels on one verified case through the public API: PreparedJob only for the input validation it performs, then one -/// `compute_group` over borrowed bytes (one expert, `rows` tokens, pairs `(t, 0)`, stride 1). -fn compute_case(pool: &mut DirectCpuPool, case: &CaseIn) -> Result, String> { - let (gu, down) = - (gate_up_row(case.header.gu).ok_or("gate/up type")?.1, down_row(case.header.down).ok_or("down type")?.1); - let input = case.input(); - PreparedJob::new( - gu, - down, - case.gate().into(), - case.up().into(), - case.down().into(), - input.clone().into(), - case.header.rows, - ) - .map_err(|e| format!("PreparedJob refused the input: {e:?}"))?; - let pairs: Vec<(usize, usize)> = (0..case.header.rows).map(|t| (t, 0)).collect(); - let expert = BorrowedExpert { gate: case.gate(), up: case.up(), down: case.down(), pairs: &pairs }; - let experts = [expert]; - let group = BorrowedGroup { tokens: &input, experts: &experts, stride: 1 }; - let mut out = vec![0.0f32; case.header.rows * H]; - pool.compute_group(gu, down, &group, &mut out).map_err(|e| format!("compute_group failed: {e:?}"))?; - Ok(out) -} - -fn family_of(report: &[String]) -> Option<&'static str> { - report - .iter() - .find(|l| l.starts_with("cpu: process kernel family ")) - .map(|l| if l.starts_with("cpu: process kernel family AVX-512") { "avx512" } else { "avx2" }) -} - -fn cmd_run_tree(dir: &Path, tree: &str, out: &Path, pin: usize, only_case: Option<&str>) -> Result { - let verified = verify_dir(dir).map_err(|e| e.to_string())?; - let previous = rust_topology::pin_current_thread(pin as i32); - if previous < 0 { - eprintln!("kernel_ab: the pin to CPU {pin} was refused; running unpinned"); - } - let report = cpu_kernel_report(); - for line in &report { - println!("REPORT {line}"); - } - let family = family_of(&report).ok_or("no process kernel family line in cpu_kernel_report")?; - if family != tree { - eprintln!("kernel_ab: this process runs the {family} family, not {tree}"); - return Ok(ExitCode::from(3)); - } - fs::create_dir_all(out).map_err(|e| format!("{}: {e}", out.display()))?; - let mut pool = DirectCpuPool::new(1).map_err(|e| format!("DirectCpuPool::new(1) failed: {e:?}"))?; - let mut done = 0usize; - for c in verified.cases.iter().filter(|c| only_case.is_none_or(|id| c.id == id)) { - let case = read_case_in(&verified.dir, c).map_err(|e| e.to_string())?; - let values = compute_case(&mut pool, &case).map_err(|e| format!("case {}: {e}", c.id))?; - write_out(&out.join(format!("case-{}.rust-{tree}.out", c.id)), c.rows, tree, &values)?; - done += 1; - } - if done == 0 { - return Err(format!("case {} is not in the manifest", only_case.unwrap_or("?"))); - } - println!("RUN-TREE {tree} cases={done}"); - Ok(ExitCode::SUCCESS) -} - -// ------------------------------------------------------------------------------------------------ compare driver - -/// Linux: is the SMT sibling of `cpu` idle (below 5 percent busy over 200 ms)? No sibling counts as idle. Elsewhere: false (unknown). -fn sibling_idle(cpu: usize) -> bool { - if !cfg!(target_os = "linux") { - return false; - } - let Ok(list) = fs::read_to_string(format!("/sys/devices/system/cpu/cpu{cpu}/topology/thread_siblings_list")) else { - return false; - }; - let mut siblings = Vec::new(); - for part in list.trim().split(',') { - let (a, b) = part.split_once('-').unwrap_or((part, part)); - let (Ok(a), Ok(b)) = (a.trim().parse::(), b.trim().parse::()) else { return false }; - siblings.extend((a..=b).filter(|s| *s != cpu)); - } - if siblings.is_empty() { - return true; - } - let sample = |cpu: usize| -> Option<(u64, u64)> { - let stat = fs::read_to_string("/proc/stat").ok()?; - let line = stat.lines().find(|l| l.starts_with(&format!("cpu{cpu} ")))?; - let f: Vec = line.split_whitespace().skip(1).filter_map(|x| x.parse().ok()).collect(); - let idle = f.get(3)? + f.get(4).copied().unwrap_or(0); - Some((f.iter().sum(), idle)) - }; - let before: Vec<_> = siblings.iter().map(|s| sample(*s)).collect(); - std::thread::sleep(std::time::Duration::from_millis(200)); - siblings.iter().zip(before).all(|(s, b)| match (b, sample(*s)) { - (Some(b), Some(a)) => { - let total = a.0.saturating_sub(b.0); - let idle = a.1.saturating_sub(b.1); - total > 0 && (total - idle.min(total)) * 20 < total - } - _ => false, - }) -} - -fn rustc_info() -> (String, String) { - // $RUSTC, then `rustc` on the PATH, then the rustup shim of the user (a non-login shell has no cargo bin directory on its PATH) - let home = std::env::var("HOME").or_else(|_| std::env::var("USERPROFILE")).unwrap_or_default(); - let shim = format!("{home}/.cargo/bin/{}", if cfg!(windows) { "rustc.exe" } else { "rustc" }); - let candidates = [std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_owned()), "rustc".to_owned(), shim]; - let triple = if cfg!(windows) { "x86_64-pc-windows-msvc" } else { "x86_64-unknown-linux-gnu" }; - let version = candidates - .iter() - .find_map(|rustc| { - Command::new(rustc) - .arg("--version") - .output() - .ok() - .filter(|o| o.status.success()) - .and_then(|o| String::from_utf8(o.stdout).ok()) - }) - .map_or_else(|| "unknown (rustc not runnable at record time)".to_owned(), |s| s.trim().to_owned()); - (version, triple.to_owned()) -} - -fn host_os() -> String { - if cfg!(target_os = "linux") - && let Ok(text) = fs::read_to_string("/etc/os-release") - && let Some(l) = text.lines().find(|l| l.starts_with("PRETTY_NAME=")) - { - return l["PRETTY_NAME=".len()..].trim_matches('"').to_owned(); - } - std::env::consts::OS.to_owned() -} - -fn cpu_model_of(report: &[String]) -> String { - report - .iter() - .find(|l| l.starts_with("cpu: logical ")) - .and_then(|l| l.split_once("): ").map(|x| x.1)) - .and_then(|rest| rest.split(';').next()) - .map_or_else(|| "unknown model".to_owned(), |s| s.trim().to_owned()) -} - -struct Options { - out: Option, - pin: usize, - machine_role: Option, - trees: Vec, - tree: Option, - case: Option, -} - -fn parse_options(args: &[String]) -> Result { - let mut o = Options { - out: None, - pin: 0, - machine_role: None, - trees: TREES.iter().map(|t| (*t).to_owned()).collect(), - tree: None, - case: None, - }; - let mut it = args.iter(); - while let Some(a) = it.next() { - let mut value = |what: &str| it.next().cloned().ok_or_else(|| format!("{what} needs a value")); - match a.as_str() { - "--out" => o.out = Some(PathBuf::from(value("--out")?)), - "--pin" => o.pin = value("--pin")?.parse().map_err(|_| "--pin takes a logical CPU number".to_owned())?, - "--machine-role" => o.machine_role = Some(value("--machine-role")?), - "--trees" => o.trees = value("--trees")?.split(',').map(str::to_owned).collect(), - "--tree" => o.tree = Some(value("--tree")?), - "--case" => o.case = Some(value("--case")?), - other => return Err(format!("unknown option {other}")), - } - } - if let Some(bad) = o.trees.iter().find(|t| !TREES.contains(&t.as_str())) { - return Err(format!("unknown tree {bad} (avx512 | avx2)")); - } - Ok(o) -} - -fn cmd_compare(dir: &Path, opts: &Options) -> Result { - let started = now_utc(); - let verified = match verify_dir(dir) { - Ok(v) => v, - Err(e) => { - println!("{e}"); - return Ok(ExitCode::from(if e.incomplete { 2 } else { 1 })); - } - }; - println!( - "KAB1 directory verified: {} files, {} cases, manifest sha256 {}", - verified.file_count, - verified.cases.len(), - verified.manifest_sha256 - ); - let out = opts.out.clone().unwrap_or_else(|| { - let name = dir.file_name().map_or_else(|| "kab1".to_owned(), |n| n.to_string_lossy().into_owned()); - dir.parent().unwrap_or(Path::new(".")).join(format!("{name}.rust")) - }); - if out.starts_with(dir) || dir.starts_with(&out) { - return Err("--out must not contain or lie inside the KAB1 directory".to_owned()); - } - if out.exists() && fs::read_dir(&out).map_err(|e| format!("{}: {e}", out.display()))?.next().is_some() { - return Err(format!("{} exists and is not empty (nothing is overwritten or deleted)", out.display())); - } - let records = out.join("records"); - fs::create_dir_all(&records).map_err(|e| format!("{}: {e}", records.display()))?; - let exe = std::env::current_exe().map_err(|e| format!("current_exe: {e}"))?; - let parent_env: Vec<(OsString, OsString)> = std::env::vars_os().collect(); - let machine_role = opts - .machine_role - .clone() - .or_else(|| std::env::var("HOSTNAME").ok()) - .or_else(|| std::env::var("COMPUTERNAME").ok()) - .unwrap_or_else(|| "unknown".to_owned()); - let (rustc_version, triple) = rustc_info(); - let flags = format!( - "cargo profile {}; RUSTFLAGS={:?}; target-cpu default", - if cfg!(debug_assertions) { "dev" } else { "release" }, - std::env::var("RUSTFLAGS").unwrap_or_default() - ); - let mut all_equal = true; - let mut cells = 0usize; - for tree in &opts.trees { - let sibling = sibling_idle(opts.pin); - let probe = Proc { - imp: Impl::Rust, - tree: TREES.iter().find(|t| **t == tree.as_str()).copied().unwrap_or("avx2"), - rep: 'a', - }; - let mut cmd = scrubbed_command(&exe, &parent_env, &cell_env(&probe)); - cmd.arg("run-tree").arg(dir).args(["--tree", tree, "--out"]).arg(&out).args(["--pin", &opts.pin.to_string()]); - let res = cmd.output().map_err(|e| format!("cannot start the {tree} process: {e}"))?; - let stdout = String::from_utf8_lossy(&res.stdout).into_owned(); - let report: Vec = stdout.lines().filter_map(|l| l.strip_prefix("REPORT ")).map(str::to_owned).collect(); - match res.status.code() { - Some(0) => {} - Some(3) if tree == "avx512" && verified.provenance.avx512_ok == Some(false) => { - println!( - "tree avx512: SKIPPED, this host has no AVX-512 (manifest avx512_ok=false; the reference trees are identical by construction)" - ); - continue; - } - code => { - eprint!("{}", String::from_utf8_lossy(&res.stderr)); - println!("tree {tree}: the Rust process failed (exit {code:?})"); - return Ok(ExitCode::from(1)); - } - } - println!( - "tree {tree}: {}", - report.iter().find(|l| l.starts_with("cpu: process kernel family")).map_or("", String::as_str) - ); - let tree_name: &str = TREES.iter().find(|t| **t == tree.as_str()).copied().unwrap_or("avx2"); - for c in &verified.cases { - let ours_name = format!("case-{}.rust-{tree}.out", c.id); - let ours = read_out(&out.join(&ours_name), &ours_name, c.rows, tree, None).map_err(|e| e.to_string())?; - let o = c.outs.iter().find(|o| o.tree == tree_name).ok_or("missing reference out")?; - let reference = read_out(&verified.dir.join(&o.name), &o.name, c.rows, tree, Some((&o.sha256, o.bytes))) - .map_err(|e| e.to_string())?; - let outcome = compare_bits(&ours, &reference, c.tolerance.as_ref()); - let label = match (&c.tolerance, outcome.equal()) { - (None, true) => "bitwise EQUAL".to_owned(), - (None, false) => "bitwise NOT EQUAL".to_owned(), - (Some(t), eq) => format!( - "{} within tolerance {:e} (metric {TOLERANCE_METRIC}; basis: {})", - if eq { "EQUAL" } else { "NOT EQUAL" }, - t.value, - t.basis - ), - }; - let detail = match outcome.first_mismatch { - Some((i, a, b)) => format!( - "; {} of {} values differ, first at {i}: ours {a:#010x} reference {b:#010x}, max abs error {:e}", - outcome.mismatches, outcome.compared, outcome.max_abs_error - ), - None => format!("; {} values", outcome.compared), - }; - println!("case {} [{tree}] {label}{detail}", c.id); - all_equal &= outcome.equal(); - cells += 1; - let record = record_json(&RecordInput { - record_id: format!( - "kab1-{}-{}-{tree}-{}", - verified.provenance.run_id, - c.id, - started.replace([':', '-'], "") - ), - created_utc: now_utc(), - run_started_utc: started.clone(), - machine_role: machine_role.clone(), - cpu_model: cpu_model_of(&report), - os: host_os(), - ours_compiler: "rustc".to_owned(), - ours_version: rustc_version.clone(), - ours_triple: triple.clone(), - ours_flags: flags.clone(), - tree: tree_name, - verified: &verified, - case: c, - pin_cpu: opts.pin, - sibling_idle: sibling, - outcome: &outcome, - }); - let path = records.join(format!("case-{}.{tree}.record.json", c.id)); - fs::write(&path, record).map_err(|e| format!("{}: {e}", path.display()))?; - } - } - println!( - "compared {cells} cells; records in {}; {}", - records.display(), - if all_equal { "ALL EQUAL" } else { "NOT ALL EQUAL" } - ); - Ok(if all_equal && cells > 0 { ExitCode::SUCCESS } else { ExitCode::from(1) }) -} - -// ------------------------------------------------------------------------------------------------ flags (time, alternate) - -struct Flags(Vec<(String, String)>); - -impl Flags { - fn parse(args: &[String], known: &[&str]) -> Result { - let mut items: Vec<(String, String)> = Vec::new(); - let mut it = args.iter(); - while let Some(a) = it.next() { - let name = a.strip_prefix("--").ok_or_else(|| format!("unexpected argument {a}"))?; - if !known.contains(&name) { - return Err(format!("unknown option {a}")); - } - if items.iter().any(|(k, _)| k == name) { - return Err(format!("option {a} given twice")); - } - let v = it.next().ok_or_else(|| format!("{a} needs a value"))?; - items.push((name.to_owned(), v.clone())); - } - Ok(Self(items)) - } - fn get(&self, k: &str) -> Option<&str> { - self.0.iter().find(|(n, _)| n == k).map(|(_, v)| v.as_str()) - } - fn req(&self, k: &str) -> Result<&str, String> { - self.get(k).ok_or_else(|| format!("--{k} is required")) - } - fn number(&self, k: &str) -> Result, String> { - self.get(k).map(|v| v.parse::().map_err(|_| format!("--{k} {v:?} is not a valid number"))).transpose() - } -} - -// ------------------------------------------------------------------------------------------------ clocks and host facts - -/// The 60 ms slice of `tq_cpu_parity.cpp:461` (`slice_ms = quick ? 40 : 60`), the same value `kab time` uses. -const DEFAULT_SLICE_MS: f64 = 60.0; -/// `tq_cpu_parity.cpp:303`: a slice whose calibrated clock moved by more than this fraction is dropped. Copied, not chosen here. -const CLOCK_MOVED_FRACTION: f64 = 0.05; -/// An SMT sibling busier than this fraction is not idle (the 5 percent rule of `sibling_idle`). -const SIBLING_BUSY_LIMIT: f64 = 0.05; -const ALIGN: usize = 4096; -/// Cycles of one step of the calibration chain `x = (x * k) ^ (x >> 17)`: a 64-bit multiply (3 cycles on Intel Skylake to Golden Cove -/// and AMD Zen 1 to 5) then an xor (1 cycle); the shift runs beside the multiply. -const CHAIN_STEP_CYCLES: f64 = 4.0; -const CLOCK_METHOD: &str = "chain of dependent steps x = (x * k) ^ (x >> 17), 4 cycles per step (3 multiply + 1 xor), 1000000 iterations of 4 steps, ghz = 4 * 4e6 / (elapsed ns); before and after every slice"; - -fn mono_ns() -> u64 { - static ORIGIN: OnceLock = OnceLock::new(); - ORIGIN.get_or_init(Instant::now).elapsed().as_nanos() as u64 -} - -/// The core clock in GHz from a chain of dependent steps (safe code: the C++ chain of dependent adds needs inline assembly). A plain -/// chain of multiplies by an opaque constant is folded by LLVM (measured: 175 GHz), so every step also xors in a shifted copy of the -/// running value, which no reassociation can remove. -fn core_ghz() -> f64 { - let k = std::hint::black_box(0x9E37_79B9_7F4A_7C15u64 | 1); - let mut x = std::hint::black_box(1u64); - let n = 1_000_000u64; - let t0 = mono_ns(); - for _ in 0..n { - x = x.wrapping_mul(k) ^ (x >> 17); - x = x.wrapping_mul(k) ^ (x >> 17); - x = x.wrapping_mul(k) ^ (x >> 17); - x = x.wrapping_mul(k) ^ (x >> 17); - } - let dt = mono_ns().saturating_sub(t0).max(1); - std::hint::black_box(x); - CHAIN_STEP_CYCLES * 4.0 * n as f64 / dt as f64 -} - -fn median_of(v: &[f64]) -> f64 { - if v.is_empty() { - return 0.0; - } - let mut s = v.to_vec(); - s.sort_by(f64::total_cmp); - s[s.len() / 2] -} - -/// Nearest-rank percentile of raw slice values (a description of the slices, not an inference). -fn percentile_of(v: &[f64], p: f64) -> f64 { - if v.is_empty() { - return 0.0; - } - let mut s = v.to_vec(); - s.sort_by(f64::total_cmp); - s[((s.len() - 1) as f64 * p).round() as usize] -} - -fn jnum(v: f64, decimals: usize) -> String { - if v.is_finite() { format!("{v:.decimals$}") } else { "null".to_owned() } -} - -fn read_text(path: &str) -> String { - fs::read_to_string(path).map(|s| s.trim().to_owned()).unwrap_or_default() -} - -fn parse_cpu_list(s: &str) -> Vec { - let mut v = Vec::new(); - for part in s.trim().split(',').filter(|p| !p.is_empty()) { - let (a, b) = part.split_once('-').unwrap_or((part, part)); - if let (Ok(a), Ok(b)) = (a.trim().parse::(), b.trim().parse::()) { - v.extend(a..=b); - } - } - v -} - -fn parse_size(s: &str) -> u64 { - let digits: String = s.chars().take_while(char::is_ascii_digit).collect(); - let n = digits.parse::().unwrap_or(0); - match s[digits.len()..].chars().next() { - Some('K' | 'k') => n << 10, - Some('M' | 'm') => n << 20, - Some('G' | 'g') => n << 30, - _ => n, - } -} - -struct Llc { - level: u32, - bytes: u64, - source: String, -} - -/// Linux: the highest-level data or unified cache of `cpu` from sysfs. Elsewhere: None (the caller passes `--llc-bytes`). -fn llc_of_cpu(cpu: usize) -> Option { - let mut best: Option = None; - for i in 0..16 { - let d = format!("/sys/devices/system/cpu/cpu{cpu}/cache/index{i}"); - let (level, kind, size) = - (read_text(&format!("{d}/level")), read_text(&format!("{d}/type")), read_text(&format!("{d}/size"))); - if level.is_empty() || size.is_empty() || kind == "Instruction" { - continue; - } - let level_n = level.parse::().unwrap_or(0); - if best.as_ref().is_none_or(|b| level_n >= b.level) { - best = Some(Llc { level: level_n, bytes: parse_size(&size), source: format!("{d}/size = {size}") }); - } - } - best.filter(|l| l.bytes > 0) -} - -/// (busy, total) jiffies of one logical CPU from /proc/stat (Linux). -fn proc_stat_cpu(cpu: usize) -> Option<(u64, u64)> { - let stat = fs::read_to_string("/proc/stat").ok()?; - let line = stat.lines().find(|l| l.starts_with(&format!("cpu{cpu} ")))?; - let f: Vec = line.split_whitespace().skip(1).filter_map(|x| x.parse().ok()).collect(); - let total: u64 = f.iter().take(8).sum(); - Some((total - f.get(3)? - f.get(4).copied().unwrap_or(0), total)) -} - -fn busy_fraction(before: Option<(u64, u64)>, after: Option<(u64, u64)>) -> Option { - let (b, a) = (before?, after?); - (a.1 > b.1).then(|| (a.0.saturating_sub(b.0)) as f64 / (a.1 - b.1) as f64) -} - -/// Linux: the logical CPU the calling thread last ran on (field 39 of /proc/thread-self/stat). Elsewhere: None. -fn current_cpu() -> Option { - if !cfg!(target_os = "linux") { - return None; - } - let s = fs::read_to_string("/proc/thread-self/stat").ok()?; - let rest = &s[s.rfind(')')? + 1..]; - rest.split_whitespace().nth(36)?.parse().ok() -} - -/// Linux: every thread of this process with the CPU it last ran on (the pool's worker is one of them). -fn observed_threads() -> Vec<(String, Option)> { - let mut v = Vec::new(); - if let Ok(dir) = fs::read_dir("/proc/self/task") { - for e in dir.flatten() { - let p = e.path(); - let name = read_text(&format!("{}/comm", p.display())); - let cpu = fs::read_to_string(p.join("stat")) - .ok() - .and_then(|s| s.get(s.rfind(')')? + 1..)?.split_whitespace().nth(36)?.parse().ok()); - v.push((name, cpu)); - } - } - v.sort(); - v -} - -fn is_managed_name(name: &str) -> bool { - let up = name.to_ascii_uppercase(); - up.starts_with("STRATA_") || up.starts_with("LELEKA_") -} - -/// Every STRATA_* / LELEKA_* variable the process sees. -fn managed_env_now() -> BTreeMap { - std::env::vars_os() - .filter_map(|(k, v)| Some((k.into_string().ok()?, v.into_string().ok()?))) - .filter(|(k, _)| is_managed_name(k)) - .collect() -} - -fn json_env(env: &BTreeMap) -> String { - format!("{{{}}}", env.iter().map(|(k, v)| format!("{}: {}", jstr(k), jstr(v))).collect::>().join(", ")) -} - -// ------------------------------------------------------------------------------------------------ time (one fresh process) - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -enum RegimeSel { - Both, - Resident, - Streamed, -} - -#[derive(Debug)] -struct TimeArgs { - dir: PathBuf, - case: String, - slices: usize, - pin: usize, - out: PathBuf, - slice_ms: f64, - regime: RegimeSel, - llc_bytes: Option, -} - -const TIME_FLAGS: [&str; 8] = ["run-dir", "case", "slices", "pin", "out", "slice-ms", "regime", "llc-bytes"]; - -/// The command line of `kab time` (STRA-317), checked the same way. -fn parse_time_args(args: &[String]) -> Result { - let f = Flags::parse(args, &TIME_FLAGS)?; - let slices = f.number::("slices")?.ok_or("--slices is required")?; - let pin = f.number::("pin")?.ok_or("--pin is required")?; - let slice_ms = f.number::("slice-ms")?.unwrap_or(DEFAULT_SLICE_MS); - if !(1..=100_000).contains(&slices) { - return Err("--slices must be 1..100000".to_owned()); - } - if !(1.0..=10_000.0).contains(&slice_ms) { - return Err("--slice-ms must be 1..10000".to_owned()); - } - let regime = match f.get("regime").unwrap_or("both") { - "both" => RegimeSel::Both, - "resident" => RegimeSel::Resident, - "streamed" => RegimeSel::Streamed, - _ => return Err("--regime must be both, resident or streamed".to_owned()), - }; - let case = f.req("case")?.to_owned(); - if !valid_id(&case) { - return Err(format!("--case {case:?} is not a plain identifier")); - } - Ok(TimeArgs { - dir: PathBuf::from(f.req("run-dir")?), - case, - slices, - pin, - out: PathBuf::from(f.req("out")?), - slice_ms, - regime, - llc_bytes: f.number::("llc-bytes")?, - }) -} - -/// A buffer whose usable part starts on a 4096-byte boundary. -struct Arena { - buf: Vec, - off: usize, -} -impl Arena { - fn new(len: usize) -> Self { - let size = std::mem::size_of::(); - let buf = vec![T::default(); len + ALIGN / size]; - let misalign = buf.as_ptr() as usize % ALIGN; - let off = if misalign == 0 { 0 } else { (ALIGN - misalign) / size }; - Self { buf, off } - } - fn slice(&self, len: usize) -> &[T] { - &self.buf[self.off..self.off + len] - } - fn slice_mut(&mut self, len: usize) -> &mut [T] { - &mut self.buf[self.off..self.off + len] - } -} - -/// The timed call: one group of one expert through the crate's public pool, exactly as `compute_case` does it. -struct Timed<'a> { - pool: DirectCpuPool, - gu: GateUpFormat, - down: DownFormat, - header: InHeader, - pairs: Vec<(usize, usize)>, - tokens: &'a [f32], - out: Vec, -} - -impl Timed<'_> { - fn call(&mut self, weights: &[u8]) -> Result<(), String> { - let (g, u) = (self.header.gate, self.header.up); - let expert = BorrowedExpert { - gate: &weights[..g], - up: &weights[g..g + u], - down: &weights[g + u..g + u + self.header.down_bytes], - pairs: &self.pairs, - }; - let experts = [expert]; - let group = BorrowedGroup { tokens: self.tokens, experts: &experts, stride: 1 }; - self.pool - .compute_group(self.gu, self.down, &group, &mut self.out) - .map_err(|e| format!("compute_group failed: {e:?}")) - } -} - -struct Slice { - calls: u64, - wall_ns: u64, - ns_per_call: f64, - ghz_before: f64, - ghz_after: f64, - cycles_per_call: f64, - moved: bool, -} - -/// One slice of `ms` milliseconds cycling over the copies; the shape of `time_slice()` in tq_cpu_parity.cpp (lines 290-304). -fn time_slice(t: &mut Timed, copies: &[&[u8]], ms: f64, next: &mut usize) -> Result { - let ghz_before = core_ghz(); - let mut calls = 0u64; - let ns0 = mono_ns(); - let mut ns1; - loop { - t.call(copies[*next % copies.len()])?; - *next += 1; - calls += 1; - ns1 = mono_ns(); - if (ns1 - ns0) as f64 >= ms * 1e6 && calls >= 2 { - break; - } - } - let ghz_after = core_ghz(); - let wall = ns1 - ns0; - let ns_per_call = wall as f64 / calls as f64; - let ghz_mean = 0.5 * (ghz_before + ghz_after); - Ok(Slice { - calls, - wall_ns: wall, - ns_per_call, - ghz_before, - ghz_after, - cycles_per_call: ns_per_call * ghz_mean, - moved: ghz_mean > 0.0 && (ghz_after - ghz_before).abs() > CLOCK_MOVED_FRACTION * ghz_before, - }) -} - -fn slice_json(s: &Slice, idx: usize) -> String { - format!( - "{{\"i\": {idx}, \"calls\": {}, \"wall_ns\": {}, \"ns_per_call\": {}, \"ghz_before\": {}, \"ghz_after\": {}, \"cycles_per_call\": {}}}", - s.calls, - s.wall_ns, - jnum(s.ns_per_call, 3), - jnum(s.ghz_before, 6), - jnum(s.ghz_after, 6), - jnum(s.cycles_per_call, 1) - ) -} - -/// Slices with their index within the regime. -type Numbered = Vec<(usize, Slice)>; - -struct RegimeRun { - json: String, - kept: usize, - ok: bool, -} - -struct RegimeSpec<'a> { - label: &'a str, - copies: Vec<&'a [u8]>, - expert_bytes: usize, - stride: usize, - llc: &'a Llc, - slices: usize, - slice_ms: f64, - pin: usize, - selfcheck: bool, -} - -fn run_regime(t: &mut Timed, spec: &RegimeSpec) -> Result { - let mut next = 0usize; - // warm-up (not recorded): tables and buffers, and for STREAMED one full pass over the copies so every page is resident - for _ in 0..3 { - t.call(spec.copies[next % spec.copies.len()])?; - next += 1; - } - if spec.copies.len() > 1 { - for _ in 0..spec.copies.len() { - t.call(spec.copies[next % spec.copies.len()])?; - next += 1; - } - } - let (mut kept, mut dropped): (Numbered, Numbered) = (Vec::new(), Vec::new()); - let mut migrated: Option = cfg!(target_os = "linux").then_some(0); - for i in 0..spec.slices { - let before = current_cpu(); - let s = time_slice(t, &spec.copies, spec.slice_ms, &mut next)?; - if let Some(m) = migrated.as_mut() - && (before != Some(spec.pin) || current_cpu() != Some(spec.pin)) - { - *m += 1; - } - if s.moved { dropped.push((i, s)) } else { kept.push((i, s)) } - } - let ns: Vec = kept.iter().map(|k| k.1.ns_per_call).collect(); - let cyc: Vec = kept.iter().map(|k| k.1.cycles_per_call).collect(); - let med = |v: &[f64], d: usize| if v.is_empty() { "null".to_owned() } else { jnum(median_of(v), d) }; - let list = |v: &[(usize, Slice)]| v.iter().map(|(i, s)| slice_json(s, *i)).collect::>().join(",\n "); - let json = format!( - "{{\"regime\": {}, \"copies_k\": {}, \"expert_bytes\": {}, \"copy_stride_bytes\": {}, \"working_set_bytes\": {}, \"llc_level\": {}, \"llc_bytes\": {}, \"llc_source\": {}, \"working_set_over_llc\": {}, \"slice_ms\": {}, \"slices_requested\": {}, \"slices_kept\": {}, \"dropped_count\": {}, \"selfcheck_bitwise_equal_first_call\": {}, \"migrated_slices\": {}, \"median_ns_per_call\": {}, \"median_cycles_per_call\": {},\n \"slices\": [\n {}],\n \"dropped\": [\n {}]}}", - jstr(spec.label), - spec.copies.len(), - spec.expert_bytes, - spec.stride, - spec.expert_bytes * spec.copies.len(), - spec.llc.level, - spec.llc.bytes, - jstr(&spec.llc.source), - spec.copies.len() > 1, - jnum(spec.slice_ms, 1), - spec.slices, - kept.len(), - dropped.len(), - spec.selfcheck, - migrated.map_or("null".to_owned(), |m| m.to_string()), - med(&ns, 3), - med(&cyc, 1), - list(&kept), - list(&dropped) - ); - Ok(RegimeRun { json, kept: kept.len(), ok: !kept.is_empty() && migrated.is_none_or(|m| m == 0) }) -} - -fn f32_bits_sha(values: &[f32]) -> String { - let mut b = Vec::with_capacity(values.len() * 4); - for v in values { - b.extend_from_slice(&v.to_bits().to_le_bytes()); - } - sha_hex(&b) -} - -/// `kernel_ab time ...`: one fresh process, one case, the resident and the streamed regime, JSON written by tmp + rename. Exit codes as -/// `kab time`: 0 ok; 1 usage / refused input; 3 a regime kept no slice or a slice migrated off the pin; 4 the final output differs. -fn cmd_time(args: &[String]) -> Result { - let t = parse_time_args(args)?; - let wall0 = mono_ns(); - // pin first (before any buffer or pool exists, so the pool's threads inherit the mask), then the facts about the pin - if rust_topology::pin_current_thread(t.pin as i32) < 0 { - return Err(format!("the pin to CPU {} was refused", t.pin)); - } - if cfg!(target_os = "linux") && current_cpu() != Some(t.pin) { - return Err(format!("the process is not running on CPU {} after the pin", t.pin)); - } - let cpu_dir = format!("/sys/devices/system/cpu/cpu{}", t.pin); - let sib_text = read_text(&format!("{cpu_dir}/topology/thread_siblings_list")); - let sibling = parse_cpu_list(&sib_text).into_iter().rfind(|c| *c != t.pin); - let sib0 = sibling.and_then(proc_stat_cpu); - let pin0 = proc_stat_cpu(t.pin); - let load0 = read_text("/proc/loadavg"); - - // the case: the KAB1 reader rule (validate, then use) and the manifest and case input hashes - let (manifest_bytes, _provenance, cases, _files) = read_manifest(&t.dir).map_err(|e| e.to_string())?; - let manifest_sha = sha_hex(&manifest_bytes); - let entry = - cases.iter().find(|c| c.id == t.case).ok_or_else(|| format!("case {} is not in the manifest", t.case))?; - let case = read_case_in(&t.dir, entry).map_err(|e| e.to_string())?; - let header = case.header; - let weights = &case.blob[IN_HEADER..header.input_at()]; - let expert_bytes = weights.len(); - - // environment and tree - let env = managed_env_now(); - let report = cpu_kernel_report(); - let tree = family_of(&report).ok_or("no process kernel family line in cpu_kernel_report")?; - - // the streamed set: K copies, K x stride at least 2 x the last-level cache of the pinned CPU (the design choice of kab_time.cpp) - let llc = match (t.llc_bytes, llc_of_cpu(t.pin)) { - (Some(bytes), found) => { - Llc { level: found.map_or(0, |l| l.level), bytes, source: "--llc-bytes (override)".to_owned() } - } - (None, Some(l)) => l, - (None, None) => { - return Err(format!("cannot read the last-level cache size of CPU {} from sysfs; pass --llc-bytes", t.pin)); - } - }; - if llc.bytes == 0 { - return Err("--llc-bytes must be positive".to_owned()); - } - let stride = expert_bytes.div_ceil(ALIGN) * ALIGN; - let copies_k = ((2 * llc.bytes) / stride as u64) as usize + 1; - if copies_k * stride > (4usize << 30) { - return Err("the streamed working set would exceed 4 GiB; check --llc-bytes".to_owned()); - } - - // the pool is created AFTER the pin: its worker inherits the one-CPU mask (rust_platform::cores sees a one-CPU affinity) - let mut pool = DirectCpuPool::new(1).map_err(|e| format!("DirectCpuPool::new(1) failed: {e:?}"))?; - let want = compute_case(&mut pool, &case)?; - let want_bits: Vec = want.iter().map(|v| v.to_bits()).collect(); - let output_sha = f32_bits_sha(&want); - - let mut tokens = Arena::::new(header.rows * H); - tokens.slice_mut(header.rows * H).copy_from_slice(&case.input()); - let mut resident = Arena::::new(stride); - resident.slice_mut(expert_bytes).copy_from_slice(weights); - let mut streamed = Arena::::new(stride * copies_k); - for k in 0..copies_k { - streamed.slice_mut(stride * copies_k)[k * stride..k * stride + expert_bytes].copy_from_slice(weights); - } - let res_copies: Vec<&[u8]> = vec![resident.slice(expert_bytes)]; - let stm_all = streamed.slice(stride * copies_k); - let stm_copies: Vec<&[u8]> = (0..copies_k).map(|k| &stm_all[k * stride..k * stride + expert_bytes]).collect(); - - let mut timed = Timed { - pool, - gu: gate_up_row(header.gu).ok_or("gate/up type")?.1, - down: down_row(header.down).ok_or("down type")?.1, - header, - pairs: (0..header.rows).map(|r| (r, 0)).collect(), - tokens: tokens.slice(header.rows * H), - out: vec![0.0f32; header.rows * H], - }; - // selfcheck: the timed call's output on every aligned copy is bit-identical to the first (unaligned) call's - let mut selfcheck = true; - for w in [res_copies[0], stm_copies[0], stm_copies[copies_k - 1]] { - timed.call(w)?; - selfcheck &= timed.out.iter().map(|v| v.to_bits()).eq(want_bits.iter().copied()); - } - if !selfcheck { - return Err("selfcheck failed: the timed call differs from the first call".to_owned()); - } - - let ghz0 = core_ghz(); - let mut regimes = Vec::new(); - let mut all_ok = true; - let (mut kept_res, mut kept_stm) = (0, 0); - for (label, copies, sel) in - [("RESIDENT", &res_copies, RegimeSel::Resident), ("STREAMED", &stm_copies, RegimeSel::Streamed)] - { - if t.regime != RegimeSel::Both && t.regime != sel { - continue; - } - let spec = RegimeSpec { - label, - copies: copies.clone(), - expert_bytes, - stride, - llc: &llc, - slices: t.slices, - slice_ms: t.slice_ms, - pin: t.pin, - selfcheck, - }; - let r = run_regime(&mut timed, &spec)?; - all_ok &= r.ok; - if sel == RegimeSel::Resident { - kept_res = r.kept - } else { - kept_stm = r.kept - } - regimes.push(r.json); - } - let ghz1 = core_ghz(); - timed.call(res_copies[0])?; - let final_same = timed.out.iter().map(|v| v.to_bits()).eq(want_bits.iter().copied()); - - let threads = observed_threads(); - let sib1 = sibling.and_then(proc_stat_cpu); - let pin1 = proc_stat_cpu(t.pin); - let frac = |f: Option| f.map_or("null".to_owned(), |v| jnum(v, 4)); - let rust_fmt = |l: &str| jstr(l); - let (gu_name, down_name) = - (gate_up_row(header.gu).map_or("?", |x| x.4), down_row(header.down).map_or("?", |x| x.4)); - let in_name = format!("case-{}.in", t.case); - let command_line = format!( - "time --run-dir {} --case {} --slices {} --pin {} --out {}{}{}", - t.dir.display(), - t.case, - t.slices, - t.pin, - t.out.display(), - if args.iter().any(|a| a == "--slice-ms") { format!(" --slice-ms {}", t.slice_ms) } else { String::new() }, - match t.regime { - RegimeSel::Both => String::new(), - RegimeSel::Resident => " --regime resident".to_owned(), - RegimeSel::Streamed => " --regime streamed".to_owned(), - } - ); - let mut j = String::from( - "{\n \"format\": \"KAB1-time\",\n \"version\": 1,\n \"mode\": \"time\",\n \"writer\": \"rust\",\n", - ); - j += &format!( - " \"command_line\": {},\n \"run_dir\": {},\n \"manifest_sha256\": {},\n", - jstr(&command_line), - jstr(&t.dir.display().to_string()), - jstr(&manifest_sha) - ); - j += &format!( - " \"case\": {{\"id\": {}, \"gu_type\": {}, \"down_type\": {}, \"gu_name\": {}, \"down_name\": {}, \"rows\": {}, \"input_file\": {}, \"input_sha256\": {}, \"input_sha256_matches_manifest\": true, \"expert_bytes\": {}}},\n", - jstr(&t.case), - header.gu, - header.down, - jstr(gu_name), - jstr(down_name), - header.rows, - jstr(&in_name), - jstr(&entry.in_sha256), - expert_bytes - ); - j += &format!( - " \"tree\": {},\n \"tree_detail\": {{\"tree\": {}, \"cpu_report\": [{}], \"strata_env\": {}}},\n \"effective_env\": {},\n", - jstr(tree), - jstr(tree), - report.iter().map(|l| rust_fmt(l)).collect::>().join(", "), - json_env(&env), - json_env(&env) - ); - j += &format!( - " \"pool\": {{\"workers\": 1, \"host_drains\": true, \"threads_observed\": [{}], \"note\": \"DirectCpuPool::new(1): one worker thread plus the calling thread that drains beside it (pool.cpp host_works_); both inherit the one-CPU mask of the pin\"}},\n", - threads - .iter() - .map(|(n, c)| format!( - "{{\"name\": {}, \"cpu\": {}}}", - jstr(n), - c.map_or("null".to_owned(), |c| c.to_string()) - )) - .collect::>() - .join(", ") - ); - j += &format!( - " \"pin\": {{\"cpu\": {}, \"thread_siblings_list\": {}, \"sibling_cpu\": {}, \"physical_core_id\": {}, \"pin_busy_fraction_during_run\": {}, \"sibling_busy_fraction_during_run\": {}, \"sibling_busy_note\": \"/proc/stat jiffies of the sibling logical CPU between the start and the end of this process; it is recorded, no threshold is applied here\", \"scaling_governor\": {}, \"cpufreq_boost\": {}, \"loadavg_start\": {}, \"loadavg_end\": {}, \"final_cpu\": {}}},\n", - t.pin, - jstr(&sib_text), - sibling.map_or("null".to_owned(), |s| s.to_string()), - jstr(&read_text(&format!("{cpu_dir}/topology/core_id"))), - frac(busy_fraction(pin0, pin1)), - if sibling.is_some() { frac(busy_fraction(sib0, sib1)) } else { "null".to_owned() }, - jstr(&read_text(&format!("{cpu_dir}/cpufreq/scaling_governor"))), - jstr(&read_text("/sys/devices/system/cpu/cpufreq/boost")), - jstr(&load0), - jstr(&read_text("/proc/loadavg")), - current_cpu().map_or("null".to_owned(), |c| c.to_string()) - ); - j += &format!( - " \"buffers\": {{\"alignment_bytes\": {ALIGN}, \"expert_copy_stride_bytes\": {stride}, \"activations_aligned\": true, \"scratch_aligned\": false, \"scratch_note\": \"the pool's own scratch is allocated inside the crate\"}},\n" - ); - j += &format!( - " \"clock_calibration\": {{\"method\": {}, \"source\": \"engine/strata/src/kernels/cpu/tq_cpu_parity.cpp --bench: core_ghz() lines 273-284, time_slice() lines 290-304; the dependent-add chain needs inline assembly, so the safe Rust twin chains multiplies\", \"drop_rule\": {{\"source_file\": \"engine/strata/src/kernels/cpu/tq_cpu_parity.cpp\", \"source_line\": 303, \"source_text\": \"std::fabs(g1 - g0) > 0.05 * g0\", \"fraction\": {}, \"meaning\": \"a slice whose calibrated clock moved by more than 5 percent between its before and after calibration is dropped\"}}, \"slice_ms_source\": \"tq_cpu_parity.cpp:461 slice_ms = quick ? 40 : 60\", \"ghz_at_start\": {}, \"ghz_at_end\": {}, \"tsc_invariant\": null, \"clocks\": \"monotonic ns (std::time::Instant); no TSC read: rdtsc and lfence are unsafe intrinsics and the crate keeps unsafe_code = deny\"}},\n", - jstr(CLOCK_METHOD), - jnum(CLOCK_MOVED_FRACTION, 2), - jnum(ghz0, 6), - jnum(ghz1, 6) - ); - j += &format!( - " \"build\": {{\"profile\": {}, \"rustflags\": {}, \"example\": \"crates/native-cpu-expert/examples/kernel_ab.rs\"}},\n", - jstr(if cfg!(debug_assertions) { "dev" } else { "release" }), - jstr(&std::env::var("RUSTFLAGS").unwrap_or_default()) - ); - j += &format!( - " \"selfcheck_bitwise_equal_first_call\": {selfcheck},\n \"final_output_unchanged\": {final_same},\n \"output_sha256\": {},\n \"duration_ns\": {},\n \"timing_caveat\": \"numbers from a shared host are not evidence by themselves; loadavg and the sibling busy fraction are recorded above\",\n \"regimes\": [\n {}\n ]\n}}\n", - jstr(&output_sha), - mono_ns() - wall0, - regimes.join(",\n ") - ); - let tmp = PathBuf::from(format!("{}.tmp", t.out.display())); - fs::write(&tmp, j.as_bytes()).map_err(|e| format!("{}: {e}", tmp.display()))?; - fs::rename(&tmp, &t.out).map_err(|e| format!("rename to {}: {e}", t.out.display()))?; - println!( - "kernel_ab time: case={} tree={tree} pin={} slices={} resident_kept={kept_res} streamed_kept={kept_stm} K={copies_k} out={}", - t.case, - t.pin, - t.slices, - t.out.display() - ); - if !all_ok { - eprintln!("kernel_ab time: a regime has no kept slice or a slice migrated off CPU {}", t.pin); - return Ok(ExitCode::from(3)); - } - if !final_same { - eprintln!("kernel_ab time: the final output differs from the first call's"); - return Ok(ExitCode::from(4)); - } - Ok(ExitCode::SUCCESS) -} - -// ------------------------------------------------------------------------------------------------ alternate: cells, environment, schedule - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] -enum Impl { - Cpp, - Rust, -} -impl Impl { - fn name(self) -> &'static str { - match self { - Impl::Cpp => "cpp", - Impl::Rust => "rust", - } - } -} - -/// One process of a round: an implementation, a tree and a replicate (`a` is the A/B process, `b` the A/A twin). -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] -struct Proc { - imp: Impl, - tree: &'static str, - rep: char, -} -impl Proc { - fn name(&self) -> String { - format!("{}-{}-{}", self.imp.name(), self.tree, self.rep) - } - fn parse(s: &str) -> Option { - let mut p = s.split('-'); - let imp = match p.next()? { - "cpp" => Impl::Cpp, - "rust" => Impl::Rust, - _ => return None, - }; - let wanted = p.next()?; - let tree = *TREES.iter().find(|t| **t == wanted)?; - let rep = match p.next()? { - "a" => 'a', - "b" => 'b', - _ => return None, - }; - p.next().is_none().then_some(Proc { imp, tree, rep }) - } -} - -/// Every process of a round for the given trees, in canonical order. -fn procs_for(trees: &[&'static str]) -> Vec { - let mut v = Vec::new(); - for imp in [Impl::Cpp, Impl::Rust] { - for tree in trees { - for rep in ['a', 'b'] { - v.push(Proc { imp, tree, rep }); - } - } - } - v -} - -/// The environment a cell needs and nothing else. The avx2 trees set `STRATA_FORCE_AVX2=1`, which both implementations honour. The -/// Rust cells run `DirectCpuPool::new(1)`, a worker thread plus the draining caller, both confined to the one pinned CPU: the pool must -/// not re-pin its caller (`LELEKA_CPU_POOL_PIN_HOST=off`, so the pin is the requested one) and its worker must not spin after a batch -/// (`STRATA_POOL_SPIN_US=0`; with the 20 ms default the worker spins on the caller's only CPU and costs it half its time). -fn cell_env(p: &Proc) -> Vec<(String, String)> { - let mut v = Vec::new(); - if p.tree == "avx2" { - v.push(("STRATA_FORCE_AVX2".to_owned(), "1".to_owned())); - } - if p.imp == Impl::Rust { - v.push(("LELEKA_CPU_POOL_PIN_HOST".to_owned(), "off".to_owned())); - v.push(("STRATA_POOL_SPIN_US".to_owned(), "0".to_owned())); - } - v.sort(); - v -} - -/// A command whose environment is exactly: the parent's variables minus every STRATA_* / LELEKA_* one, plus the cell's variables. -fn scrubbed_command(program: &Path, parent_env: &[(OsString, OsString)], cell: &[(String, String)]) -> Command { - let mut c = Command::new(program); - c.env_clear(); - for (k, v) in parent_env { - if !is_managed_name(&k.to_string_lossy()) { - c.env(k, v); - } - } - for (k, v) in cell { - c.env(k, v); - } - c -} - -/// Runs a prepared cell command; a failure names the cell. -fn run_cell(cmd: &mut Command, cell: &str) -> Result { - let out = cmd.output().map_err(|e| format!("cell {cell}: cannot start the process: {e}"))?; - if out.status.success() { - return Ok(out); - } - let tail = |b: &[u8]| { - String::from_utf8_lossy(b) - .lines() - .rev() - .take(3) - .collect::>() - .into_iter() - .rev() - .collect::>() - .join(" | ") - }; - Err(format!( - "cell {cell} failed ({}): stderr: {}; stdout: {}", - out.status.code().map_or("killed by a signal".to_owned(), |c| format!("exit {c}")), - tail(&out.stderr), - tail(&out.stdout) - )) -} - -fn splitmix(state: &mut u64) -> u64 { - *state = state.wrapping_add(0x9E37_79B9_7F4A_7C15); - let mut z = *state; - z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); - z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); - z ^ (z >> 31) -} - -/// The schedule of one batch: round `i` (0-based) rotates a seeded permutation by `i mod n`; every block of `n` rounds draws a fresh -/// permutation, so each process takes each position equally often within a block. A pure function of (seed, batch, rounds, procs). -fn make_schedule(seed: u64, batch: u32, rounds: u32, procs: &[Proc]) -> Vec> { - let n = procs.len(); - let mut out = Vec::new(); - let mut base: Vec = Vec::new(); - for i in 0..rounds as usize { - if i % n == 0 { - let mut st = seed; - for x in [u64::from(batch), (i / n) as u64] { - st = st.wrapping_add(x.wrapping_mul(0x9E37_79B9_7F4A_7C15)); - st = splitmix(&mut st); - } - base = procs.to_vec(); - for j in (1..n).rev() { - let k = (splitmix(&mut st) % (j as u64 + 1)) as usize; - base.swap(j, k); - } - } - let mut order = base.clone(); - order.rotate_left(i % n); - out.push(order); - } - out -} - -const SCHEDULE_MAGIC: &str = "# KAB1-alt schedule v1"; - -fn schedule_text( - seed: u64, - batch: u32, - rounds: u32, - case: &str, - pin: usize, - first_round: u32, - order: &[Vec], -) -> String { - let mut t = format!( - "{SCHEDULE_MAGIC} (written before the first run; the runner reads this file back)\n# seed={seed} batch={batch} rounds={rounds} case={case} pin={pin}\n" - ); - for (i, o) in order.iter().enumerate() { - t += &format!("{}\t{}\n", first_round + i as u32, o.iter().map(Proc::name).collect::>().join(",")); - } - t -} - -/// Reads a schedule back: (round number, processes in order) per round. Every round must name each process of the first round once. -fn parse_schedule(text: &str) -> Result)>, String> { - let mut lines = text.lines(); - if !lines.next().is_some_and(|l| l.starts_with(SCHEDULE_MAGIC)) { - return Err("not a KAB1-alt schedule".to_owned()); - } - let mut rounds: Vec<(u32, Vec)> = Vec::new(); - for l in lines.filter(|l| !l.starts_with('#') && !l.is_empty()) { - let (no, list) = l.split_once('\t').ok_or_else(|| format!("bad schedule line {l:?}"))?; - let no = no.parse::().map_err(|_| format!("bad round number in {l:?}"))?; - let order: Vec = list - .split(',') - .map(|n| Proc::parse(n).ok_or_else(|| format!("unknown process {n:?} in the schedule"))) - .collect::>()?; - if let Some(prev) = rounds.last() - && (no != prev.0 + 1 - || BTreeSet::from_iter(order.iter()) != BTreeSet::from_iter(prev.1.iter()) - || order.len() != prev.1.len()) - { - return Err(format!("round {no} does not follow round {} with the same processes", prev.0)); - } - rounds.push((no, order)); - } - if rounds.is_empty() { - return Err("the schedule has no round".to_owned()); - } - Ok(rounds) -} - -/// Refuses a path that is, or lies inside, a Git checkout (generated artifacts stay out of Git). -fn inside_git_checkout(path: &Path) -> bool { - let abs = std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()); - abs.ancestors().any(|a| a.join(".git").exists()) -} - -// ------------------------------------------------------------------------------------------------ alternate: reading a process's JSON - -#[derive(Debug, Clone)] -struct RegimeStat { - copies_k: usize, - expert_bytes: usize, - llc_bytes: u64, - requested: usize, - dropped: usize, - median_ns: f64, - median_cycles: f64, - ns: Vec, - cycles: Vec, - max_drift: f64, - selfcheck: bool, -} - -#[derive(Debug, Clone)] -struct ProcOut { - proc: Proc, - regimes: BTreeMap, - ghz_start: f64, - ghz_end: f64, - /// None: unknown; Some(true): the sibling was idle (or there is none) under the 5 percent rule. - sibling_idle: Option, - final_unchanged: bool, - output_sha: Option, - tree_text: String, - cpu_model: Option, -} - -/// What a process's JSON must say about the run that produced it. -struct Expect<'a> { - manifest_sha: &'a str, - input_sha: &'a str, - case: &'a str, - pin: usize, -} - -fn parse_regime(r: &Json, imp: Impl) -> Result { - let mut ns = Vec::new(); - let mut cycles = Vec::new(); - let mut max_drift = 0.0f64; - for (key, keep) in [("slices", true), ("dropped", false)] { - for s in r.array(key)? { - let (g0, g1) = (s.float("ghz_before")?, s.float("ghz_after")?); - if g0 > 0.0 { - max_drift = max_drift.max(((g1 - g0).abs() / g0).min(1.0)); - } - if keep { - ns.push(s.float("ns_per_call")?); - cycles.push(s.float("cycles_per_call")?); - } - } - } - let selfcheck_key = - if imp == Impl::Cpp { "selfcheck_bitwise_equal_compose_expert" } else { "selfcheck_bitwise_equal_first_call" }; - let kept = r.uint("slices_kept")? as usize; - if kept != ns.len() || kept == 0 { - return Err(format!("slices_kept {kept} disagrees with the {} kept slices (or none was kept)", ns.len())); - } - Ok(RegimeStat { - copies_k: r.uint("copies_k")? as usize, - expert_bytes: r.uint("expert_bytes")? as usize, - llc_bytes: r.uint("llc_bytes")?, - requested: r.uint("slices_requested")? as usize, - dropped: r.uint("dropped_count")? as usize, - median_ns: r.float("median_ns_per_call")?, - median_cycles: r.float("median_cycles_per_call")?, - ns, - cycles, - max_drift, - selfcheck: r.flag(selfcheck_key)?, - }) -} - -fn describe_cpp_tree(d: &Json) -> String { - let b = |k: &str| { - d.get(k).map_or("?".to_owned(), |v| match v { - Json::Bool(x) => x.to_string(), - Json::Num(n) => n.clone(), - _ => "?".to_owned(), - }) - }; - let env = match d.get("strata_env") { - Some(Json::Obj(items)) if !items.is_empty() => items - .iter() - .map(|(k, v)| format!("{k}={}", if let Json::Str(s) = v { s.as_str() } else { "?" })) - .collect::>() - .join(" "), - _ => "no STRATA_* variable set (STRATA_NO_IQ512, STRATA_NO_IQ256 and STRATA_IQ_GATHER unset)".to_owned(), - }; - format!( - "avx2_ok={} avx512_ok={} iq512_gather_on={} iq256_gather_setting={}; {env}", - b("avx2_ok"), - b("avx512_ok"), - b("iq512_gather_on"), - b("iq256_gather_setting") - ) -} - -/// Parses a process's KAB1-time JSON and checks it against the cell that was started: writer, tree, manifest and input hashes, case, -/// pin, and that the effective STRATA_* / LELEKA_* environment is exactly the cell's. -fn parse_proc_json(p: &Proc, bytes: &[u8], expect: &Expect) -> Result { - let j = parse_json(bytes)?; - let name = p.name(); - let fail = |what: String| format!("cell {name}: {what}"); - if j.str("format").map_err(fail)? != "KAB1-time" || j.uint("version").map_err(fail)? != 1 { - return Err(fail("the output is not KAB1-time version 1".to_owned())); - } - if j.str("writer").map_err(fail)? != p.imp.name() { - return Err(fail(format!( - "the output's writer is {:?}, expected {}", - j.str("writer").unwrap_or("?"), - p.imp.name() - ))); - } - if j.str("tree").map_err(fail)? != p.tree { - return Err(fail(format!( - "the process ran the {} tree, the cell asks for {}", - j.str("tree").unwrap_or("?"), - p.tree - ))); - } - if j.str("manifest_sha256").map_err(fail)? != expect.manifest_sha { - return Err(fail("manifest_sha256 differs from the run directory's".to_owned())); - } - let c = j.req("case").map_err(fail)?; - if c.str("id").map_err(fail)? != expect.case || c.str("input_sha256").map_err(fail)? != expect.input_sha { - return Err(fail("the case id or its input hash differs from the manifest's".to_owned())); - } - let pin = j.req("pin").map_err(fail)?; - if pin.uint("cpu").map_err(fail)? as usize != expect.pin { - return Err(fail(format!("pinned to CPU {}, expected {}", pin.uint("cpu").unwrap_or(u64::MAX), expect.pin))); - } - let want_env: BTreeMap = cell_env(p).into_iter().collect(); - let mut seen_env = BTreeMap::new(); - if let Json::Obj(items) = j.req("effective_env").map_err(fail)? { - for (k, v) in items { - seen_env.insert( - k.clone(), - match v { - Json::Str(s) => s.clone(), - Json::Num(n) => n.clone(), - _ => "?".to_owned(), - }, - ); - } - } - if seen_env != want_env { - return Err(fail(format!("effective environment {seen_env:?} differs from the cell's {want_env:?}"))); - } - let mut regimes = BTreeMap::new(); - for r in j.array("regimes").map_err(fail)? { - let label = r.str("regime").map_err(fail)?.to_owned(); - regimes.insert(label, parse_regime(r, p.imp).map_err(fail)?); - } - for want in ["RESIDENT", "STREAMED"] { - if !regimes.contains_key(want) { - return Err(fail(format!("regime {want} is missing"))); - } - } - let clock = j.req("clock_calibration").map_err(fail)?; - let sibling_idle = match pin.req("sibling_cpu").map_err(fail)? { - Json::Null => Some(true), - _ => pin.float_or_null("sibling_busy_fraction_during_run").map_err(fail)?.map(|f| f < SIBLING_BUSY_LIMIT), - }; - let detail = j.req("tree_detail").map_err(fail)?; - let (tree_text, cpu_report) = if p.imp == Impl::Rust { - let report: Vec = detail - .array("cpu_report") - .map_err(fail)? - .iter() - .filter_map(|l| if let Json::Str(s) = l { Some(s.clone()) } else { None }) - .collect(); - let line = report - .iter() - .find(|l| l.starts_with("cpu: process kernel family")) - .cloned() - .ok_or_else(|| fail("no process kernel family line".to_owned()))?; - (format!("leleka-serve {line}"), report) - } else { - (describe_cpp_tree(detail), Vec::new()) - }; - let cpu_model = (!cpu_report.is_empty()).then(|| cpu_model_of(&cpu_report)); - Ok(ProcOut { - proc: *p, - regimes, - ghz_start: clock.float("ghz_at_start").map_err(fail)?, - ghz_end: clock.float("ghz_at_end").map_err(fail)?, - sibling_idle, - final_unchanged: j.flag("final_output_unchanged").map_err(fail)?, - output_sha: j.get("output_sha256").and_then(|v| if let Json::Str(s) = v { Some(s.clone()) } else { None }), - tree_text, - cpu_model, - }) -} - -// ------------------------------------------------------------------------------------------------ alternate: round records - -struct Tool { - compiler: String, - version: String, - triple: String, - flags: String, -} - -struct SideStat { - median: f64, - p05: f64, - p95: f64, -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -enum Kind { - Ab, - AaCpp, - AaRust, -} -impl Kind { - fn slug(self) -> &'static str { - match self { - Kind::Ab => "ab", - Kind::AaCpp => "aa-cpp", - Kind::AaRust => "aa-rust", - } - } -} - -/// Everything a round record needs that does not change within a batch. -struct BatchCtx<'a> { - verified: &'a Verified, - case: &'a CaseEntry, - pin: usize, - machine_role: String, - os: String, - cpu_model: String, - started_utc: String, - rust_tool: Tool, - batch: u32, - /// Equality of our tree against the C++ reference per tree, from the equality phase. - equality: &'a BTreeMap<&'static str, Outcome>, -} - -fn side_stat(r: &RegimeStat, cycles: bool) -> SideStat { - let v = if cycles { &r.cycles } else { &r.ns }; - SideStat { - median: if cycles { r.median_cycles } else { r.median_ns }, - p05: percentile_of(v, 0.05), - p95: percentile_of(v, 0.95), - } -} - -fn stat_json(s: &SideStat) -> String { - format!("{{\"median\": {}, \"p05\": {}, \"p95\": {}}}", jnum(s.median, 6), jnum(s.p05, 6), jnum(s.p95, 6)) -} - -fn tool_json(t: &Tool) -> String { - format!( - "{{\"compiler\": {}, \"version\": {}, \"target_triple\": {}, \"flags\": {}}}", - jstr(&t.compiler), - jstr(&t.version), - jstr(&t.triple), - jstr(&t.flags) - ) -} - -fn equality_block(c: &CaseEntry, o: &Outcome) -> String { - let tolerance = c.tolerance.as_ref().map_or(String::new(), |t| { - format!( - ",\n \"tolerance\": {{\"value\": {:e}, \"basis\": {}, \"basis_written_utc\": {}}}", - t.value, - jstr(&format!("{} [metric: {TOLERANCE_METRIC}]", t.basis)), - jstr(&t.basis_written_utc) - ) - }); - format!( - "{{\n \"mode\": \"{}\",\n \"verdict\": \"{}\",\n \"compared_values\": {},\n \"mismatches\": {}{tolerance}\n }}", - if c.tolerance.is_some() { "tolerance" } else { "bitwise" }, - if o.equal() { "EQUAL" } else { "NOT_EQUAL" }, - o.compared, - o.mismatches - ) -} - -/// The A/A equality: the same implementation in two fresh processes. Rust: the output hashes of the two processes (and each one's -/// selfcheck); C++: each process's timed composition equals `compose_expert()` bit for bit (selfcheck), which is the same function. -fn aa_outcome(a: &ProcOut, b: &ProcOut, rows: usize) -> (Outcome, String) { - let compared = rows * H; - let selfchecks = - a.regimes.values().chain(b.regimes.values()).all(|r| r.selfcheck) && a.final_unchanged && b.final_unchanged; - let same = selfchecks && (a.proc.imp == Impl::Cpp || (a.output_sha.is_some() && a.output_sha == b.output_sha)); - let note = if a.proc.imp == Impl::Cpp { - "selfcheck of both processes against compose_expert()" - } else { - "output sha256 of both processes" - }; - let outcome = Outcome { - compared, - mismatches: usize::from(!same), - differing_bits: usize::from(!same), - max_abs_error: 0.0, - first_mismatch: None, - }; - (outcome, note.to_owned()) -} - -/// The records of one round: per tree and regime the A/B record (ours = Rust `a`, reference = C++ `a`) and the two A/A records. -fn round_records(ctx: &BatchCtx, round_no: u32, done: &[ProcOut]) -> Result, String> { - let find = |imp: Impl, tree: &str, rep: char| { - done.iter() - .find(|p| p.proc.imp == imp && p.proc.tree == tree && p.proc.rep == rep) - .ok_or_else(|| format!("round {round_no}: process {}-{tree}-{rep} did not run", imp.name())) - }; - let p = &ctx.verified.provenance; - let c = ctx.case; - let cpp_tool = Tool { - compiler: p.compiler_id.clone(), - version: p.compiler_version.clone(), - triple: p.target_triple.clone(), - flags: p.reference_flags.clone(), - }; - let (gu, down) = (gate_up_row(c.gu).map_or("?", |x| x.4), down_row(c.down).map_or("?", |x| x.4)); - if done.is_empty() { - return Err("empty round".to_owned()); - } - let position = |p: &ProcOut| done.iter().position(|d| d.proc == p.proc).unwrap_or(0); - let mut files = Vec::new(); - let trees: Vec<&'static str> = TREES.iter().copied().filter(|t| done.iter().any(|d| d.proc.tree == *t)).collect(); - for tree in trees { - let (cpp_a, cpp_b, rust_a, rust_b) = ( - find(Impl::Cpp, tree, 'a')?, - find(Impl::Cpp, tree, 'b')?, - find(Impl::Rust, tree, 'a')?, - find(Impl::Rust, tree, 'b')?, - ); - for regime in ["RESIDENT", "STREAMED"] { - for kind in [Kind::Ab, Kind::AaCpp, Kind::AaRust] { - let (ours, reference, ours_tool, ref_tool) = match kind { - Kind::Ab => (rust_a, cpp_a, &ctx.rust_tool, &cpp_tool), - Kind::AaCpp => (cpp_a, cpp_b, &cpp_tool, &cpp_tool), - Kind::AaRust => (rust_a, rust_b, &ctx.rust_tool, &ctx.rust_tool), - }; - let (o, r) = (&ours.regimes[regime], &reference.regimes[regime]); - if (o.copies_k, o.expert_bytes, o.llc_bytes) != (r.copies_k, r.expert_bytes, r.llc_bytes) { - return Err(format!( - "round {round_no} {tree} {regime}: the streamed set differs between {} and {} (K {} vs {}, LLC {} vs {})", - ours.proc.name(), - reference.proc.name(), - o.copies_k, - r.copies_k, - o.llc_bytes, - r.llc_bytes - )); - } - let (equality, equality_note) = match kind { - Kind::Ab => (equality_block(c, &ctx.equality[tree]), "Rust output against the C++ reference .out file of the run directory, from the equality phase of this batch".to_owned()), - _ => { - let (outcome, note) = aa_outcome(ours, reference, c.rows); - (aa_equality_block(&outcome), format!("{note}, the same implementation in two fresh processes")) - } - }; - let kernel = format!( - "routed-expert-gate-up-down {gu}+{down} rows={} regime {regime} ROUND RECORD {} (batch {}, round {round_no}); ours-slot process {}, reference-slot process {}; tree ours: {}; tree reference: {}; equality: {equality_note}; aa_noise_floor is a PLACEHOLDER (n=1, CI 0): the A/A evaluation is S0.10b, this record carries one round's medians only", - c.rows, - match kind { - Kind::Ab => "A/B (ours = Rust, reference = C++)", - Kind::AaCpp => "A/A (C++ process a in the ours slot, C++ process b in the reference slot)", - Kind::AaRust => "A/A (Rust process a in the ours slot, Rust process b in the reference slot)", - }, - ctx.batch, - ours.proc.name(), - reference.proc.name(), - ours.tree_text, - reference.tree_text - ); - let drift = o.max_drift.max(r.max_drift); - // the two processes of this record, earliest first: the clock before the earlier one, after the later one - let (earlier, later) = - if position(ours) <= position(reference) { (ours, reference) } else { (reference, ours) }; - let sibling_idle = ours.sibling_idle == Some(true) && reference.sibling_idle == Some(true); - let streamed = if regime == "STREAMED" { - format!( - ",\n \"streamed\": {{\"copies\": {}, \"expert_bytes\": {}, \"llc_bytes\": {}}}", - o.copies_k, o.expert_bytes, o.llc_bytes - ) - } else { - String::new() - }; - let rowtype = - |unit: &str| format!("{gu}+{down} rows={} {} [{unit}]", c.rows, regime.to_ascii_lowercase()); - let json = format!( - "{{\n \"schema_version\": \"1\",\n \"level\": \"COMPONENT_KERNEL\",\n \"record_id\": {rid},\n \"created_utc\": {created},\n \"run_started_utc\": {started},\n \"machine\": {{\"machine_role\": {role}, \"cpu_model\": {cpu}, \"gpu_name\": \"none\", \"os\": {os}}},\n \"kernel\": {kernel},\n \"toolchain\": {{\n \"ours\": {ot},\n \"reference\": {rt}\n }},\n \"case_id\": {cid},\n \"input_sha256\": {insha},\n \"kab1_manifest_sha256\": {msha},\n \"tree\": {{\"ours\": {tree_q}, \"reference\": {tree_q}}},\n \"regime\": {regime_q}{streamed},\n \"pin\": {{\"logical_cpu\": {pin}, \"sibling_idle\": {sib}}},\n \"strata_upstream_commit\": {commit},\n \"clock_calibration\": {{\"method\": {method}, \"ghz_before\": {g0}, \"ghz_after\": {g1}, \"max_drift_fraction\": {drift}, \"slices_total\": {total}, \"slices_dropped\": {dropped}}},\n \"rows\": [\n {{\"row_type\": {rt_ns}, \"unit\": \"ns\", \"rounds\": 1, \"ours\": {on}, \"reference\": {rn}}},\n {{\"row_type\": {rt_cy}, \"unit\": \"cycles\", \"rounds\": 1, \"ours\": {oc}, \"reference\": {rc}}}\n ],\n \"aa_noise_floor\": {{\"ours_vs_ours\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"reference_vs_reference\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"floor_fraction\": 0}},\n \"equality\": {equality}\n}}\n", - rid = jstr(&format!( - "kab1alt-{}-{}-b{}-r{round_no:05}-{}-{tree}-{}", - ctx.verified.provenance.run_id, - c.id, - ctx.batch, - kind.slug(), - regime.to_ascii_lowercase() - )), - created = jstr(&now_utc()), - started = jstr(&ctx.started_utc), - role = jstr(&ctx.machine_role), - cpu = jstr(&ctx.cpu_model), - os = jstr(&ctx.os), - kernel = jstr(&kernel), - ot = tool_json(ours_tool), - rt = tool_json(ref_tool), - cid = jstr(&c.id), - insha = jstr(&c.in_sha256), - msha = jstr(&ctx.verified.manifest_sha256), - tree_q = jstr(tree), - regime_q = jstr(®ime.to_ascii_lowercase()), - pin = ctx.pin, - sib = sibling_idle, - commit = jstr(&p.engine_strata_pin), - method = jstr(&format!( - "{CLOCK_METHOD}; ghz_before is the ghz_at_start of the earlier process of this record ({}), ghz_after the ghz_at_end of the later one ({}); sibling_idle: the SMT sibling stayed under 5 percent busy during both processes; max_drift_fraction is the largest |g1 - g0| / g0 over every slice of the two processes of this record, slices_total and slices_dropped count their requested and dropped slices", - earlier.proc.name(), - later.proc.name() - )), - g0 = jnum(earlier.ghz_start, 6), - g1 = jnum(later.ghz_end, 6), - drift = jnum(drift, 6), - total = o.requested + r.requested, - dropped = o.dropped + r.dropped, - rt_ns = jstr(&rowtype("ns")), - rt_cy = jstr(&rowtype("cycles")), - on = stat_json(&side_stat(o, false)), - rn = stat_json(&side_stat(r, false)), - oc = stat_json(&side_stat(o, true)), - rc = stat_json(&side_stat(r, true)), - ); - files.push(( - format!("r{round_no:05}.{}.{tree}.{}.json", kind.slug(), regime.to_ascii_lowercase()), - json, - )); - } - } - } - Ok(files) -} - -fn aa_equality_block(o: &Outcome) -> String { - format!( - "{{\n \"mode\": \"bitwise\",\n \"verdict\": \"{}\",\n \"compared_values\": {},\n \"mismatches\": {}\n }}", - if o.equal() { "EQUAL" } else { "NOT_EQUAL" }, - o.compared, - o.mismatches - ) -} - -// ------------------------------------------------------------------------------------------------ alternate: the runner - -const ALT_FLAGS: [&str; 13] = [ - "run-dir", - "case", - "rounds", - "batch", - "pin", - "schedule", - "seed", - "out", - "slices", - "slice-ms", - "llc-bytes", - "machine-role", - "kab", -]; - -#[derive(Debug)] -struct AltArgs { - dir: PathBuf, - case: String, - rounds: u32, - batch: u32, - pin: usize, - schedule: PathBuf, - seed: u64, - out: Option, - slices: usize, - slice_ms: Option, - llc_bytes: Option, - machine_role: Option, - kab: Option, -} - -fn parse_alt_args(args: &[String]) -> Result { - let f = Flags::parse(args, &ALT_FLAGS)?; - let rounds = f.number::("rounds")?.ok_or("--rounds is required")?; - let batch = f.number::("batch")?.ok_or("--batch is required")?; - if !(1..=10_000).contains(&rounds) || !(1..=1000).contains(&batch) { - return Err("--rounds must be 1..10000 and --batch 1..1000 (the batch number, counted from 1)".to_owned()); - } - let case = f.req("case")?.to_owned(); - if !valid_id(&case) { - return Err(format!("--case {case:?} is not a plain identifier")); - } - let slices = f.number::("slices")?.unwrap_or(20); - if !(1..=100_000).contains(&slices) { - return Err("--slices must be 1..100000".to_owned()); - } - Ok(AltArgs { - dir: PathBuf::from(f.req("run-dir")?), - case, - rounds, - batch, - pin: f.number::("pin")?.ok_or("--pin is required")?, - schedule: PathBuf::from(f.req("schedule")?), - seed: f.number::("seed")?.unwrap_or(1), - out: f.get("out").map(PathBuf::from), - slices, - slice_ms: f.number::("slice-ms")?, - llc_bytes: f.number::("llc-bytes")?, - machine_role: f.get("machine-role").map(str::to_owned), - kab: f.get("kab").map(PathBuf::from), - }) -} - -fn create_new_file(path: &Path, bytes: &[u8]) -> Result<(), String> { - let mut f = fs::OpenOptions::new() - .write(true) - .create_new(true) - .open(path) - .map_err(|e| format!("{}: {e} (nothing is overwritten)", path.display()))?; - f.write_all(bytes).map_err(|e| format!("{}: {e}", path.display())) -} - -fn file_sha(path: &Path) -> Result { - fs::read(path).map(|b| sha_hex(&b)).map_err(|e| format!("{}: {e}", path.display())) -} - -fn ours_flags() -> String { - format!( - "cargo profile {}; RUSTFLAGS={:?}; target-cpu default", - if cfg!(debug_assertions) { "dev" } else { "release" }, - std::env::var("RUSTFLAGS").unwrap_or_default() - ) -} - -fn cmd_alternate(args: &[String]) -> Result { - let a = parse_alt_args(args)?; - let started = now_utc(); - let verified = match verify_dir(&a.dir) { - Ok(v) => v, - Err(e) => { - println!("{e}"); - return Ok(ExitCode::from(if e.incomplete { 2 } else { 1 })); - } - }; - let case = verified - .cases - .iter() - .find(|c| c.id == a.case) - .ok_or_else(|| format!("case {} is not in the manifest", a.case))? - .clone(); - let out = a.out.clone().unwrap_or_else(|| { - let name = a.dir.file_name().map_or_else(|| "kab1".to_owned(), |n| n.to_string_lossy().into_owned()); - a.dir.parent().unwrap_or(Path::new(".")).join(format!("{name}.alt-{}", a.case)) - }); - let abs = |p: &Path| std::path::absolute(p).unwrap_or_else(|_| p.to_path_buf()); - if abs(&out).starts_with(abs(&a.dir)) || abs(&a.dir).starts_with(abs(&out)) { - return Err("--out must not contain or lie inside the KAB1 directory".to_owned()); - } - if inside_git_checkout(&out) || inside_git_checkout(&a.schedule) { - return Err( - "--out and --schedule must lie outside every Git checkout (generated artifacts stay out of Git)".to_owned() - ); - } - let own_exe = std::env::current_exe().map_err(|e| format!("current_exe: {e}"))?; - let kab = a.kab.clone().or_else(|| std::env::var_os("KAB").map(PathBuf::from)).unwrap_or_else(|| { - PathBuf::from( - std::env::var("E2E_ROOT") - .unwrap_or_else(|_| format!("{}/work/leleka-e2e", std::env::var("HOME").unwrap_or_default())), - ) - .join("build/kernel-ab/kab") - }); - if !kab.is_file() { - return Err(format!( - "the C++ driver {} does not exist (build tools/kernel-ab/cpp, or pass --kab / set KAB)", - kab.display() - )); - } - // a host without AVX-512 has no avx512 cells (the C++ reference trees are identical by construction there) - let trees: Vec<&'static str> = - TREES.iter().copied().filter(|t| *t != "avx512" || verified.provenance.avx512_ok != Some(false)).collect(); - let procs = procs_for(&trees); - - // the schedule, written BEFORE the first run and read back: the file, not the generator, drives the batch - let first_round = (a.batch - 1) * a.rounds + 1; - let planned = make_schedule(a.seed, a.batch, a.rounds, &procs); - let text = schedule_text(a.seed, a.batch, a.rounds, &a.case, a.pin, first_round, &planned); - fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?; - if let Some(parent) = a.schedule.parent().filter(|p| !p.as_os_str().is_empty()) { - fs::create_dir_all(parent).map_err(|e| format!("{}: {e}", parent.display()))?; - } - create_new_file(&a.schedule, text.as_bytes())?; - let schedule = - parse_schedule(&fs::read_to_string(&a.schedule).map_err(|e| format!("{}: {e}", a.schedule.display()))?)?; - println!( - "schedule written to {} (sha256 {}) before the first run: {} rounds x {} processes", - a.schedule.display(), - sha_hex(text.as_bytes()), - schedule.len(), - procs.len() - ); - let (records_dir, proc_dir) = (out.join("records"), out.join("processes")); - for d in [&records_dir, &proc_dir] { - fs::create_dir_all(d).map_err(|e| format!("{}: {e}", d.display()))?; - } - let parent_env: Vec<(OsString, OsString)> = std::env::vars_os().collect(); - let sibling_at_start = sibling_idle(a.pin); - let machine_role = a - .machine_role - .clone() - .or_else(|| std::env::var("HOSTNAME").ok()) - .or_else(|| std::env::var("COMPUTERNAME").ok()) - .unwrap_or_else(|| "unknown".to_owned()); - let (rustc_version, triple) = rustc_info(); - - // equality phase: our tree against the C++ reference .out file, per tree, in fresh processes (the kernels are not touched by timing) - let eq_dir = out.join(format!("equality-b{:04}", a.batch)); - let mut equality: BTreeMap<&'static str, Outcome> = BTreeMap::new(); - for tree in &trees { - let p = Proc { imp: Impl::Rust, tree, rep: 'a' }; - let mut cmd = scrubbed_command(&own_exe, &parent_env, &cell_env(&p)); - cmd.arg("run-tree") - .arg(&a.dir) - .args(["--tree", tree, "--case", &a.case, "--out"]) - .arg(&eq_dir) - .args(["--pin", &a.pin.to_string()]); - run_cell(&mut cmd, &format!("{}/equality", p.name()))?; - let ours_name = format!("case-{}.rust-{tree}.out", a.case); - let ours = read_out(&eq_dir.join(&ours_name), &ours_name, case.rows, tree, None).map_err(|e| e.to_string())?; - let o = case.outs.iter().find(|o| o.tree == *tree).ok_or("missing reference out")?; - let reference = read_out(&a.dir.join(&o.name), &o.name, case.rows, tree, Some((&o.sha256, o.bytes))) - .map_err(|e| e.to_string())?; - let outcome = compare_bits(&ours, &reference, case.tolerance.as_ref()); - println!( - "EQUALITY {} [{tree}] {}{}", - a.case, - if outcome.equal() { "EQUAL" } else { "NOT_EQUAL" }, - outcome.first_mismatch.map_or(format!("; {} values", outcome.compared), |(i, x, y)| format!( - "; {} of {} values differ, first at {i}: ours {x:#010x} reference {y:#010x}, max abs error {:e}", - outcome.mismatches, outcome.compared, outcome.max_abs_error - )) - ); - equality.insert(tree, outcome); - } - - let mut cpu_model = String::new(); - let batch_json = |cpu_model: String, equality: &BTreeMap<&'static str, Outcome>| -> Result { - let eq = equality - .iter() - .map(|(t, o)| { - format!( - "{{\"tree\": {}, \"verdict\": \"{}\", \"mode\": \"{}\", \"compared_values\": {}, \"mismatches\": {}}}", - jstr(t), - if o.equal() { "EQUAL" } else { "NOT_EQUAL" }, - if case.tolerance.is_some() { "tolerance" } else { "bitwise" }, - o.compared, - o.mismatches - ) - }) - .collect::>() - .join(", "); - let cells = procs - .iter() - .map(|p| format!("{{\"process\": {}, \"impl\": {}, \"tree\": {}, \"env_set\": {}, \"env_scrubbed\": \"every STRATA_* and LELEKA_* variable of the parent\"}}", jstr(&p.name()), jstr(p.imp.name()), jstr(p.tree), json_env(&cell_env(p).into_iter().collect()))) - .collect::>() - .join(", "); - Ok(format!( - "{{\n \"format\": \"KAB1-alt\",\n \"version\": 1,\n \"batch\": {},\n \"rounds\": {},\n \"first_round\": {first_round},\n \"run_started_utc\": {},\n \"case\": {},\n \"run_dir\": {},\n \"manifest_sha256\": {},\n \"input_sha256\": {},\n \"pin\": {{\"logical_cpu\": {}, \"sibling_idle_at_start\": {sibling_at_start}}},\n \"pool\": {{\"workers\": 1}},\n \"machine\": {{\"machine_role\": {}, \"cpu_model\": {}, \"os\": {}}},\n \"seed\": {},\n \"schedule\": {{\"file\": {}, \"sha256\": {}}},\n \"kab\": {{\"path\": {}, \"sha256\": {}}},\n \"rust_example\": {{\"path\": {}, \"sha256\": {}}},\n \"slices_per_regime\": {},\n \"slice_ms\": {},\n \"equality\": [{eq}],\n \"cells\": [{cells}],\n \"no_statistics\": \"this file computes no class, no interval and no A/A verdict (S0.10b, STRA-313)\"\n}}\n", - a.batch, - a.rounds, - jstr(&started), - jstr(&a.case), - jstr(&a.dir.display().to_string()), - jstr(&verified.manifest_sha256), - jstr(&case.in_sha256), - a.pin, - jstr(&machine_role), - jstr(&cpu_model), - jstr(&host_os()), - a.seed, - jstr(&a.schedule.display().to_string()), - jstr(&sha_hex(text.as_bytes())), - jstr(&kab.display().to_string()), - jstr(&file_sha(&kab)?), - jstr(&own_exe.display().to_string()), - jstr(&file_sha(&own_exe)?), - a.slices, - a.slice_ms.map_or("null".to_owned(), |m| jnum(m, 1)) - )) - }; - - let expect = - Expect { manifest_sha: &verified.manifest_sha256, input_sha: &case.in_sha256, case: &a.case, pin: a.pin }; - let mut ctx = BatchCtx { - verified: &verified, - case: &case, - pin: a.pin, - machine_role: machine_role.clone(), - os: host_os(), - cpu_model: String::new(), - started_utc: started.clone(), - rust_tool: Tool { compiler: "rustc".to_owned(), version: rustc_version, triple, flags: ours_flags() }, - batch: a.batch, - equality: &equality, - }; - let mut written = Vec::new(); - for (round_no, order) in &schedule { - let mut done: Vec = Vec::new(); - for p in order { - let name = p.name(); - let file = proc_dir.join(format!("r{round_no:05}-{name}.json")); - let mut cmd = scrubbed_command(if p.imp == Impl::Cpp { &kab } else { &own_exe }, &parent_env, &cell_env(p)); - cmd.arg("time") - .args(["--run-dir"]) - .arg(&a.dir) - .args(["--case", &a.case, "--slices", &a.slices.to_string(), "--pin", &a.pin.to_string(), "--out"]) - .arg(&file); - if let Some(ms) = a.slice_ms { - cmd.args(["--slice-ms", &ms.to_string()]); - } - if let Some(b) = a.llc_bytes { - cmd.args(["--llc-bytes", &b.to_string()]); - } - let res = run_cell(&mut cmd, &name)?; - fs::write(file.with_extension("log"), [&res.stdout[..], &res.stderr[..]].concat()) - .map_err(|e| format!("{}: {e}", file.display()))?; - let bytes = fs::read(&file) - .map_err(|e| format!("cell {name}: its output {} was not written: {e}", file.display()))?; - done.push(parse_proc_json(p, &bytes, &expect)?); - } - if cpu_model.is_empty() { - cpu_model = done.iter().find_map(|d| d.cpu_model.clone()).unwrap_or_else(|| "unknown model".to_owned()); - ctx.cpu_model = cpu_model.clone(); - create_new_file( - &out.join(format!("batch-{:04}.json", a.batch)), - batch_json(cpu_model.clone(), &equality)?.as_bytes(), - )?; - } - for (name, json) in round_records(&ctx, *round_no, &done)? { - create_new_file(&records_dir.join(&name), json.as_bytes())?; - written.push(name); - } - println!("round {round_no} done: {}", order.iter().map(Proc::name).collect::>().join(" ")); - } - println!( - "ALTERNATE OK batch={} rounds={} records={} dir={}", - a.batch, - a.rounds, - written.len(), - records_dir.display() - ); - for (t, o) in &equality { - println!("EQUALITY-SUMMARY {} {t} {}", a.case, if o.equal() { "EQUAL" } else { "NOT_EQUAL" }); - } - Ok(ExitCode::SUCCESS) -} - -// ------------------------------------------------------------------------------------------------ main - -fn usage() -> ExitCode { - eprintln!( - "usage: kernel_ab verify D | compare D [--out R] [--pin CPU] [--machine-role NAME] [--trees avx512,avx2] | run-tree D --tree T --out R [--pin CPU] [--case ID]" - ); - eprintln!( - " kernel_ab time --run-dir D --case ID --slices N --pin CPU --out F.json [--slice-ms 60] [--regime both|resident|streamed] [--llc-bytes B]" - ); - eprintln!( - " kernel_ab alternate --run-dir D --case ID --rounds N --batch K --pin CPU --schedule FILE [--seed S] [--out R] [--slices N] [--slice-ms MS] [--llc-bytes B] [--machine-role NAME] [--kab PATH]" - ); - ExitCode::from(64) -} - -fn main() -> ExitCode { - let args: Vec = std::env::args().skip(1).collect(); - // `time` and `alternate` take flags only (the command line of `kab time`); the older commands take the directory first - if let Some(cmd @ ("time" | "alternate")) = args.first().map(String::as_str) { - let result = if cmd == "time" { cmd_time(&args[1..]) } else { cmd_alternate(&args[1..]) }; - return result.unwrap_or_else(|e| { - eprintln!("kernel_ab {cmd}: {e}"); - ExitCode::from(1) - }); - } - let (Some(cmd), Some(dir)) = (args.first(), args.get(1)) else { return usage() }; - let dir = Path::new(dir); - let opts = match parse_options(&args[2..]) { - Ok(o) => o, - Err(e) => { - eprintln!("kernel_ab: {e}"); - return usage(); - } - }; - let result = match cmd.as_str() { - "verify" => match verify_dir(dir) { - Ok(v) => { - println!("OK {} files (manifest sha256 {})", v.file_count, v.manifest_sha256); - Ok(ExitCode::SUCCESS) - } - Err(e) => { - println!("{e}"); - Ok(ExitCode::from(if e.incomplete { 2 } else { 1 })) - } - }, - "compare" => cmd_compare(dir, &opts), - "run-tree" => match (&opts.tree, &opts.out) { - (Some(t), Some(o)) => cmd_run_tree(dir, t, o, opts.pin, opts.case.as_deref()), - _ => return usage(), - }, - _ => return usage(), - }; - result.unwrap_or_else(|e| { - eprintln!("kernel_ab: {e}"); - ExitCode::from(1) - }) -} - -// ------------------------------------------------------------------------------------------------ tests - -#[cfg(test)] -mod tests { - use super::*; - use std::sync::atomic::{AtomicUsize, Ordering}; - - static COUNTER: AtomicUsize = AtomicUsize::new(0); - - struct TempDir(PathBuf); - impl TempDir { - fn new() -> Self { - let p = std::env::temp_dir().join(format!( - "kab1-test-{}-{}", - std::process::id(), - COUNTER.fetch_add(1, Ordering::SeqCst) - )); - fs::create_dir_all(&p).unwrap(); - Self(p) - } - } - impl Drop for TempDir { - fn drop(&mut self) { - let _ = fs::remove_dir_all(&self.0); - } - } - - fn block_filled(len: usize, block: usize, seed: u8) -> Vec { - let mut v: Vec = (0..len).map(|i| (i as u8).wrapping_mul(31).wrapping_add(seed)).collect(); - for at in (0..len).step_by(block) { - v[at] = 0x00; - v[at + 1] = 0x3c; // FP16 1.0 - } - v - } - - fn in_file(gu: i32, down: i32, rows: usize) -> Vec { - let (gq, gb) = (gate_up_row(gu).unwrap().2, gate_up_row(gu).unwrap().3); - let (dq, db) = (down_row(down).unwrap().2, down_row(down).unwrap().3); - let (gsize, dsize) = (H / gq * gb * FF, FF / dq * db * H); - let mut b = Vec::new(); - for w in [ - IN_MAGIC, - 1, - gu as u32, - down as u32, - rows as u32, - H as u32, - FF as u32, - gsize as u32, - gsize as u32, - dsize as u32, - ] { - b.extend_from_slice(&w.to_le_bytes()); - } - b.resize(IN_HEADER, 0); - b.extend(block_filled(gsize, gb, 1)); - b.extend(block_filled(gsize, gb, 2)); - b.extend(block_filled(dsize, db, 3)); - for i in 0..rows * H { - b.extend_from_slice(&(((i % 97) as f32 - 48.0) / 16.0).to_bits().to_le_bytes()); - } - b - } - - fn out_file(rows: usize, tree: u32) -> Vec { - let mut b = Vec::new(); - for w in [OUT_MAGIC, 1, rows as u32, H as u32, tree] { - b.extend_from_slice(&w.to_le_bytes()); - } - for i in 0..rows * H { - b.extend_from_slice(&((i as f32) * 0.25).to_bits().to_le_bytes()); - } - b - } - - struct Spec { - gu: i32, - down: i32, - rows: usize, - tolerance: Option<&'static str>, - } - - /// Builds a synthetic KAB1 directory; `mutate` edits the `.in` bytes before the manifest records their hash. - fn build(dir: &Path, specs: &[Spec], mutate: impl Fn(&mut Vec)) { - let mut cases = Vec::new(); - let mut files = Vec::new(); - for s in specs { - let id = format!("{}-{}-r{}", s.gu, s.down, s.rows); - let mut inb = in_file(s.gu, s.down, s.rows); - mutate(&mut inb); - fs::write(dir.join(format!("case-{id}.in")), &inb).unwrap(); - let mut entry = format!( - "{{\"id\": \"{id}\", \"gu_type\": {}, \"down_type\": {}, \"rows\": {}, \"seed\": 18446744073709551615, \"equality\": \"{}\", \"tolerance\": {}, \"in\": \"case-{id}.in\", \"in_sha256\": \"{}\", \"in_bytes\": {}", - s.gu, - s.down, - s.rows, - if s.tolerance.is_some() { "tolerance" } else { "bitwise" }, - s.tolerance.unwrap_or("null"), - sha_hex(&inb), - inb.len() - ); - files.push(format!("\"case-{id}.in\": {{\"sha256\": \"{}\", \"bytes\": {}}}", sha_hex(&inb), inb.len())); - for (k, tree) in TREES.iter().enumerate() { - let ob = out_file(s.rows, k as u32); - fs::write(dir.join(format!("case-{id}.cpp-{tree}.out")), &ob).unwrap(); - entry += &format!( - ", \"out_cpp_{tree}\": \"case-{id}.cpp-{tree}.out\", \"out_cpp_{tree}_sha256\": \"{}\", \"out_cpp_{tree}_bytes\": {}", - sha_hex(&ob), - ob.len() - ); - files.push(format!( - "\"case-{id}.cpp-{tree}.out\": {{\"sha256\": \"{}\", \"bytes\": {}}}", - sha_hex(&ob), - ob.len() - )); - } - cases.push(entry + "}"); - } - let manifest = format!( - "{{\"format\": \"KAB1\", \"version\": 1, \"run_id\": \"synthetic\", \"writer\": \"cpp\", \"provenance\": {{\"engine_strata_pin\": \"41cf05a06a25dd29103b7b27a2279a3f60c21876\", \"compiler_id\": \"GNU\", \"compiler_version\": \"15.2.0\", \"target_triple\": \"x86_64-linux-gnu\", \"built_at_utc\": \"2026-10-28T19:05:05Z\", \"avx512_ok\": true, \"flags\": {{\"strata_cxx_flags\": \"-O3 -DNDEBUG\", \"ggml_cpu_arch_flags\": \"-march=native\"}}}}, \"cases\": [{}], \"files\": {{{}}}}}", - cases.join(", "), - files.join(", ") - ); - fs::write(dir.join("manifest.json"), manifest).unwrap(); - } - - fn two_cases() -> Vec { - vec![Spec { gu: 42, down: 42, rows: 2, tolerance: None }, Spec { gu: 18, down: 20, rows: 1, tolerance: None }] - } - - fn one_case() -> Vec { - vec![Spec { gu: 42, down: 42, rows: 1, tolerance: None }] - } - - fn id(file: &str) -> String { - format!("case-42-42-r1.{file}") - } - - #[test] - fn a_good_directory_verifies() { - let t = TempDir::new(); - build(&t.0, &two_cases(), |_| {}); - let v = verify_dir(&t.0).unwrap(); - assert_eq!(v.cases.len(), 2); - assert_eq!(v.file_count, 2 * 3 + 1); - assert_eq!(v.manifest_sha256.len(), 64); - assert_eq!(v.cases[0].in_sha256, sha_hex(&fs::read(t.0.join("case-42-42-r2.in")).unwrap())); - } - - #[test] - fn a_flipped_byte_refuses_the_directory_and_names_the_file() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - let p = t.0.join(id("in")); - let mut b = fs::read(&p).unwrap(); - b[IN_HEADER + 7] ^= 0x40; - fs::write(&p, b).unwrap(); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "case-42-42-r1.in"); - assert!(e.reason.contains("sha256"), "{e}"); - } - - #[test] - fn a_truncated_file_refuses_the_directory_and_names_the_file() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - let p = t.0.join(id("cpp-avx2.out")); - let b = fs::read(&p).unwrap(); - fs::write(&p, &b[..b.len() - 4]).unwrap(); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "case-42-42-r1.cpp-avx2.out"); - assert!(e.reason.contains("length"), "{e}"); - } - - #[test] - fn a_wrong_magic_is_refused() { - let t = TempDir::new(); - build(&t.0, &one_case(), |b| b[0] ^= 0xff); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "case-42-42-r1.in"); - assert!(e.reason.contains("magic"), "{e}"); - } - - #[test] - fn a_wrong_version_is_refused() { - let t = TempDir::new(); - build(&t.0, &one_case(), |b| b[4] = 2); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "case-42-42-r1.in"); - assert!(e.reason.contains("version"), "{e}"); - } - - #[test] - fn a_byte_count_that_disagrees_with_the_format_is_refused() { - let t = TempDir::new(); - build(&t.0, &one_case(), |b| { - let wrong = (le32(b, 28) + 18).to_le_bytes(); - b[28..32].copy_from_slice(&wrong); - }); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "case-42-42-r1.in"); - assert!(e.reason.contains("format-derived"), "{e}"); - } - - #[test] - fn a_non_finite_fp16_header_is_refused() { - let t = TempDir::new(); - // the manifest records the hash of the mutated file, so only the FP16 rule can refuse it - build(&t.0, &one_case(), |b| { - let at = IN_HEADER + 18 * 3; - b[at] = 0x00; - b[at + 1] = 0x7c; // FP16 +inf - }); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "case-42-42-r1.in"); - assert!(e.reason.contains("non-finite FP16"), "{e}"); - } - - #[test] - fn a_non_finite_activation_is_refused() { - let t = TempDir::new(); - build(&t.0, &one_case(), |b| { - let at = b.len() - 4; - b[at..].copy_from_slice(&f32::NAN.to_bits().to_le_bytes()); - }); - let e = verify_dir(&t.0).unwrap_err(); - assert!(e.reason.contains("non-finite activation"), "{e}"); - } - - #[test] - fn a_missing_manifest_is_incomplete_and_named() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - fs::remove_file(t.0.join("manifest.json")).unwrap(); - let e = verify_dir(&t.0).unwrap_err(); - assert_eq!(e.file, "manifest.json"); - assert!(e.incomplete); - assert!(e.to_string().contains("manifest.json")); - } - - #[test] - fn an_extra_or_missing_file_refuses_the_directory() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - fs::write(t.0.join("stray.txt"), b"x").unwrap(); - assert_eq!(verify_dir(&t.0).unwrap_err().file, "stray.txt"); - fs::remove_file(t.0.join("stray.txt")).unwrap(); - fs::remove_file(t.0.join(id("cpp-avx512.out"))).unwrap(); - assert_eq!(verify_dir(&t.0).unwrap_err().file, "case-42-42-r1.cpp-avx512.out"); - } - - #[test] - fn an_absurd_length_is_refused_without_taking_a_buffer() { - // header says gate_bytes = 4 GiB - 16; the pure header check refuses it before any buffer exists - let mut h = [0u8; IN_HEADER]; - h.copy_from_slice(&in_file(42, 42, 1)[..IN_HEADER]); - h[28..32].copy_from_slice(&(u32::MAX - 15).to_le_bytes()); - BUFFERS.with(|c| c.set(0)); - assert!(validate_in_header(&h, 1 << 20).unwrap_err().contains("format-derived")); - assert_eq!(BUFFERS.with(Cell::get), 0); - // and through the file reader: manifest and file agree on a file whose header lies about its size - let t = TempDir::new(); - build(&t.0, &one_case(), |b| b[28..32].copy_from_slice(&(u32::MAX - 15).to_le_bytes())); - BUFFERS.with(|c| c.set(0)); - let (m, _) = (fs::read(t.0.join("manifest.json")).unwrap(), 0); - let (_, cases, _) = parse_manifest(&parse_json(&m).unwrap()).unwrap(); - let e = read_case_in(&t.0, &cases[0]).err().unwrap(); - assert!(e.reason.contains("format-derived"), "{e}"); - assert_eq!(BUFFERS.with(Cell::get), 0, "a buffer was taken before the header was validated"); - // a manifest that declares an absurd length for a file is refused before a buffer too - let mut lying = cases[0].clone(); - lying.in_bytes = u64::MAX; - assert!(read_case_in(&t.0, &lying).unwrap_err().reason.contains("differs from the manifest")); - assert_eq!(BUFFERS.with(Cell::get), 0); - // the good path takes exactly one buffer per file - let g = TempDir::new(); - build(&g.0, &one_case(), |_| {}); - BUFFERS.with(|c| c.set(0)); - let (_, cases, _) = - parse_manifest(&parse_json(&fs::read(g.0.join("manifest.json")).unwrap()).unwrap()).unwrap(); - read_case_in(&g.0, &cases[0]).unwrap(); - assert_eq!(BUFFERS.with(Cell::get), 1); - } - - #[test] - fn a_tolerance_needs_basis_metric_and_a_time_before_the_reference_run() { - let ok = "{\"value\": 0.003, \"metric\": \"max_abs_error_over_max_abs_reference\", \"basis\": \"order-only difference\", \"basis_written_utc\": \"2026-10-28T10:00:00Z\"}"; - let t = TempDir::new(); - build(&t.0, &[Spec { gu: 42, down: 42, rows: 1, tolerance: Some(ok) }], |_| {}); - let v = verify_dir(&t.0).unwrap(); - assert_eq!(v.cases[0].tolerance.as_ref().unwrap().value, 0.003); - for (bad, why) in [ - (ok.replace("0.003", "0"), "positive"), - (ok.replace("max_abs_error_over_max_abs_reference", "ulp"), "metric"), - (ok.replace("order-only difference", " "), "basis"), - (ok.replace("2026-10-28T10:00:00Z", "2026-10-28T20:00:00Z"), "after the reference run"), - ] { - let leaked: &'static str = Box::leak(bad.into_boxed_str()); - let d = TempDir::new(); - build(&d.0, &[Spec { gu: 42, down: 42, rows: 1, tolerance: Some(leaked) }], |_| {}); - let e = verify_dir(&d.0).unwrap_err(); - assert_eq!(e.file, "manifest.json"); - assert!(e.reason.contains(why), "{why}: {e}"); - } - } - - #[test] - fn the_json_reader_handles_the_manifest_forms_and_refuses_the_rest() { - let j = parse_json(b"{\"a\": [1, -2.5e3, true, null, \"x\\n\\u00e9\\ud83d\\ude00\"], \"b\": {}}").unwrap(); - assert_eq!( - j.get("a"), - Some(&Json::Arr(vec![ - Json::Num("1".into()), - Json::Num("-2.5e3".into()), - Json::Bool(true), - Json::Null, - Json::Str("x\n\u{e9}\u{1f600}".into()) - ])) - ); - assert_eq!(parse_json(b"{\"s\": 18446744073709551615}").unwrap().uint("s").unwrap(), u64::MAX); - for bad in [ - "{\"a\": 1, \"a\": 2}", - "{\"a\": 1,}", - "[1 2]", - "{\"a\": \"\\ud800\"}", - "{} x", - "", - "{\"a\": 01x}", - "\"\u{1}\"", - ] { - assert!(parse_json(bad.as_bytes()).is_err(), "{bad}"); - } - assert!(parse_json("[".repeat(40).as_bytes()).is_err()); - } - - #[test] - fn bitwise_compare_sees_signed_zero_and_one_ulp_and_tolerance_is_normalised() { - let a = [1.0f32.to_bits(), 0.0f32.to_bits(), 2.0f32.to_bits()]; - assert!(compare_bits(&a, &a, None).equal()); - let neg0 = [1.0f32.to_bits(), (-0.0f32).to_bits(), 2.0f32.to_bits()]; - let o = compare_bits(&neg0, &a, None); - assert_eq!((o.mismatches, o.first_mismatch), (1, Some((1, (-0.0f32).to_bits(), 0.0f32.to_bits())))); - let ulp = [1.0f32.to_bits(), 0.0f32.to_bits(), 2.0f32.to_bits() + 1]; - assert_eq!(compare_bits(&ulp, &a, None).mismatches, 1); - let tol = Tolerance { value: 1e-6, basis: "test".into(), basis_written_utc: "2026-01-01T00:00:00Z".into() }; - assert!(compare_bits(&ulp, &a, Some(&tol)).equal()); - let far = [1.0f32.to_bits(), 0.0f32.to_bits(), 2.1f32.to_bits()]; - assert_eq!(compare_bits(&far, &a, Some(&tol)).mismatches, 1); - assert_eq!(compare_bits(&a[..2], &a, None).mismatches, 1); - } - - #[test] - fn our_trees_run_on_a_verified_synthetic_case_and_the_record_is_well_formed() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - let v = verify_dir(&t.0).unwrap(); - let case = read_case_in(&v.dir, &v.cases[0]).unwrap(); - let mut pool = DirectCpuPool::new(1).unwrap(); - let first = compute_case(&mut pool, &case).unwrap(); - let second = compute_case(&mut pool, &case).unwrap(); - assert_eq!(first.len(), H); - assert!( - first.iter().zip(&second).all(|(a, b)| a.to_bits() == b.to_bits()), - "the same case twice must be bit-identical" - ); - let path = t.0.join("ours.rust-avx2.out"); - write_out(&path, 1, "avx2", &first).unwrap(); - let back = read_out(&path, "ours.rust-avx2.out", 1, "avx2", None).unwrap(); - assert_eq!(back, first.iter().map(|v| v.to_bits()).collect::>()); - let outcome = compare_bits(&back, &back, None); - let json = record_json(&RecordInput { - record_id: "kab1-synthetic-r".into(), - created_utc: "2026-10-28T20:00:00Z".into(), - run_started_utc: "2026-10-28T19:59:00Z".into(), - machine_role: "m\"1".into(), - cpu_model: "cpu".into(), - os: "os".into(), - ours_compiler: "rustc".into(), - ours_version: "rustc 1.99.0".into(), - ours_triple: "x86_64-unknown-linux-gnu".into(), - ours_flags: "f".into(), - tree: "avx2", - verified: &v, - case: &v.cases[0], - pin_cpu: 0, - sibling_idle: true, - outcome: &outcome, - }); - let rec = parse_json(json.as_bytes()).unwrap(); - for key in [ - "schema_version", - "level", - "record_id", - "created_utc", - "run_started_utc", - "machine", - "kernel", - "toolchain", - "case_id", - "input_sha256", - "kab1_manifest_sha256", - "tree", - "regime", - "pin", - "strata_upstream_commit", - "clock_calibration", - "rows", - "aa_noise_floor", - "equality", - ] { - assert!(rec.get(key).is_some(), "{key}"); - } - assert_eq!(rec.req("equality").unwrap().str("verdict").unwrap(), "EQUAL"); - assert_eq!(rec.req("machine").unwrap().str("machine_role").unwrap(), "m\"1"); - assert_eq!(rec.str("kab1_manifest_sha256").unwrap(), v.manifest_sha256); - } - - // ---------------------------------------------------------------------------------------------------- alternation (STRA-318) - - #[test] - fn the_schedule_is_reproducible_from_the_seed() { - let procs = procs_for(&TREES); - let a = make_schedule(7, 1, 30, &procs); - assert_eq!(a, make_schedule(7, 1, 30, &procs)); - assert_ne!(a, make_schedule(8, 1, 30, &procs), "another seed gives another schedule"); - assert_ne!(a, make_schedule(7, 2, 30, &procs), "another batch gives another schedule"); - assert_eq!(a.len(), 30); - // the text round-trips through the file format and names the seed - let text = schedule_text(7, 1, 30, "18-20-r1", 9, 1, &a); - assert!(text.contains("seed=7 batch=1 rounds=30 case=18-20-r1 pin=9")); - let back = parse_schedule(&text).unwrap(); - assert_eq!(back.iter().map(|r| r.1.clone()).collect::>(), a); - assert_eq!(back[0].0, 1); - assert_eq!(back[29].0, 30); - } - - #[test] - fn the_rotation_gives_every_process_every_position_within_a_block() { - let procs = procs_for(&TREES); - assert_eq!(procs.len(), 8); - let s = make_schedule(3, 1, 16, &procs); - for block in s.chunks(8) { - for round in block { - let mut names: Vec<_> = round.iter().map(Proc::name).collect(); - names.sort(); - assert_eq!(names.len(), 8); - names.dedup(); - assert_eq!(names.len(), 8, "every process exactly once per round"); - } - for pos in 0..8 { - let at: BTreeSet<_> = block.iter().map(|r| r[pos]).collect(); - assert_eq!(at.len(), 8, "position {pos} is taken by every process once per block of 8 rounds"); - } - } - // a host without AVX-512 has only the avx2 cells - assert_eq!(procs_for(&["avx2"]).len(), 4); - } - - #[test] - fn a_schedule_file_is_written_once_and_a_bad_one_is_refused() { - let t = TempDir::new(); - let f = t.0.join("schedule.tsv"); - create_new_file(&f, b"x").unwrap(); - assert!(create_new_file(&f, b"y").unwrap_err().contains("nothing is overwritten")); - assert_eq!(fs::read(&f).unwrap(), b"x"); - let procs = procs_for(&TREES); - let good = schedule_text(1, 1, 3, "c", 0, 1, &make_schedule(1, 1, 3, &procs)); - assert!(parse_schedule(&good).is_ok()); - assert!(parse_schedule("nope").is_err()); - assert!(parse_schedule(&good.replace("cpp-avx2-a", "cpp-avx2-z")).unwrap_err().contains("unknown process")); - assert!(parse_schedule(&good.replacen("\n2\t", "\n5\t", 1)).unwrap_err().contains("does not follow")); - // a round that names one process twice (and so lacks another) is refused - let dup = good - .lines() - .map(|l| { - if l.starts_with("2\t") { - l.replacen("rust-avx2-b", "rust-avx2-a", 1).replacen("rust-avx2-b", "rust-avx2-a", 1) - } else { - l.to_owned() - } - }) - .collect::>() - .join("\n"); - assert!(parse_schedule(&dup).is_err()); - } - - /// The child side of the environment test: prints the managed variables it sees. Does nothing in a normal run. - #[test] - fn env_probe_child() { - if std::env::var_os("KAB_TEST_CHILD").as_deref() != Some(std::ffi::OsStr::new("probe")) { - return; - } - for (k, v) in std::env::vars() { - if is_managed_name(&k) { - println!("PROBE {k}={v}"); - } - } - } - - /// The child side of the failure test. - #[test] - fn failing_child() { - if std::env::var_os("KAB_TEST_CHILD").as_deref() == Some(std::ffi::OsStr::new("fail")) { - eprintln!("simulated kernel failure"); - std::process::exit(3); - } - } - - fn child(test: &str, mode: &str, planted: &[(&str, &str)], cell: &[(String, String)]) -> Command { - let mut parent: Vec<(OsString, OsString)> = - std::env::vars_os().filter(|(k, _)| !is_managed_name(&k.to_string_lossy())).collect(); - parent.push(("KAB_TEST_CHILD".into(), mode.into())); - parent.extend(planted.iter().map(|(k, v)| ((*k).into(), (*v).into()))); - let mut c = scrubbed_command(&std::env::current_exe().unwrap(), &parent, cell); - c.args(["--exact", test, "--nocapture", "--test-threads=1"]); - c - } - - #[test] - fn environment_scrubbing_removes_a_planted_strata_variable_and_keeps_only_the_cell() { - let cell = cell_env(&Proc { imp: Impl::Rust, tree: "avx2", rep: 'a' }); - assert_eq!( - cell, - vec![ - ("LELEKA_CPU_POOL_PIN_HOST".to_owned(), "off".to_owned()), - ("STRATA_FORCE_AVX2".to_owned(), "1".to_owned()), - ("STRATA_POOL_SPIN_US".to_owned(), "0".to_owned()) - ] - ); - assert!(cell_env(&Proc { imp: Impl::Cpp, tree: "avx512", rep: 'b' }).is_empty()); - let out = run_cell( - &mut child( - "tests::env_probe_child", - "probe", - &[("STRATA_X", "planted"), ("LELEKA_Y", "planted"), ("strata_lower", "planted")], - &cell, - ), - "rust-avx2-a", - ) - .unwrap(); - let text = String::from_utf8_lossy(&out.stdout); - // libtest prints "test ... " before the child's own output on the same line - let mut probes: Vec<&str> = text.lines().flat_map(|l| l.split("PROBE ").skip(1)).collect(); - probes.sort_unstable(); - assert_eq!( - probes, - vec!["LELEKA_CPU_POOL_PIN_HOST=off", "STRATA_FORCE_AVX2=1", "STRATA_POOL_SPIN_US=0"], - "only the cell's variables survive:\n{text}" - ); - // the cpp avx512 cell sets nothing at all - let out = - run_cell(&mut child("tests::env_probe_child", "probe", &[("STRATA_X", "planted")], &[]), "cpp-avx512-a") - .unwrap(); - assert!(!String::from_utf8_lossy(&out.stdout).contains("PROBE ")); - } - - #[test] - fn a_child_failure_is_reported_with_the_cell_named() { - let e = run_cell(&mut child("tests::failing_child", "fail", &[], &[]), "cpp-avx2-b").unwrap_err(); - assert!(e.starts_with("cell cpp-avx2-b failed (exit 3)"), "{e}"); - assert!(e.contains("simulated kernel failure"), "{e}"); - let e = run_cell(&mut Command::new("kab-does-not-exist-318"), "rust-avx512-a").unwrap_err(); - assert!(e.starts_with("cell rust-avx512-a: cannot start"), "{e}"); - } - - #[test] - fn the_time_command_line_is_the_one_of_kab_time() { - let v = |a: &[&str]| a.iter().map(|s| (*s).to_owned()).collect::>(); - let t = parse_time_args(&v(&[ - "--run-dir", - "D", - "--case", - "18-20-r1", - "--slices", - "50", - "--pin", - "9", - "--out", - "t.json", - ])) - .unwrap(); - assert_eq!((t.slices, t.pin, t.slice_ms, t.regime, t.llc_bytes), (50, 9, 60.0, RegimeSel::Both, None)); - let t = parse_time_args(&v(&[ - "--run-dir", - "D", - "--case", - "c", - "--slices", - "2", - "--pin", - "0", - "--out", - "o", - "--slice-ms", - "5", - "--regime", - "streamed", - "--llc-bytes", - "1000", - ])) - .unwrap(); - assert_eq!((t.slice_ms, t.regime, t.llc_bytes), (5.0, RegimeSel::Streamed, Some(1000))); - for bad in [ - v(&["--run-dir", "D", "--case", "c", "--slices", "0", "--pin", "0", "--out", "o"]), - v(&["--run-dir", "D", "--case", "c", "--slices", "1", "--out", "o"]), - v(&["--run-dir", "D", "--case", "c", "--slices", "1", "--pin", "0", "--out", "o", "--regime", "both2"]), - v(&["--run-dir", "D", "--case", "../c", "--slices", "1", "--pin", "0", "--out", "o"]), - v(&["--run-dir", "D", "--case", "c", "--slices", "1", "--pin", "0", "--out", "o", "--bogus", "1"]), - v(&["--run-dir", "D", "--run-dir", "E", "--case", "c", "--slices", "1", "--pin", "0", "--out", "o"]), - ] { - assert!(parse_time_args(&bad).is_err(), "{bad:?}"); - } - let a = parse_alt_args(&v(&[ - "--run-dir", - "D", - "--case", - "c", - "--rounds", - "30", - "--batch", - "1", - "--pin", - "9", - "--schedule", - "s.tsv", - ])) - .unwrap(); - assert_eq!((a.rounds, a.batch, a.seed, a.slices), (30, 1, 1, 20)); - assert!( - parse_alt_args(&v(&[ - "--run-dir", - "D", - "--case", - "c", - "--rounds", - "30", - "--batch", - "0", - "--pin", - "9", - "--schedule", - "s" - ])) - .is_err() - ); - } - - #[test] - fn medians_percentiles_and_parsers_agree_with_the_reference_rules() { - assert_eq!(median_of(&[3.0, 1.0, 2.0, 10.0]), 3.0, "sorted, element size/2 as the C++ reference"); - assert_eq!(median_of(&[]), 0.0); - let v: Vec = (1..=21).map(f64::from).collect(); - assert_eq!((percentile_of(&v, 0.05), percentile_of(&v, 0.95)), (2.0, 20.0)); - assert_eq!(parse_cpu_list("2,18"), vec![2, 18]); - assert_eq!(parse_cpu_list("0-3,8"), vec![0, 1, 2, 3, 8]); - assert_eq!((parse_size("32768K"), parse_size("32M"), parse_size("512")), (32 << 20, 32 << 20, 512)); - assert_eq!(busy_fraction(Some((10, 100)), Some((30, 200))), Some(0.2)); - assert_eq!(busy_fraction(None, Some((1, 1))), None); - // the calibrated clock of any x86-64 core is in this range (the chain must not be folded away: 175 GHz was the folded multiply chain) - let ghz = core_ghz(); - assert!((0.3..12.0).contains(&ghz), "{ghz}"); - } - - #[test] - fn an_output_inside_a_git_checkout_is_detected() { - let t = TempDir::new(); - let inner = t.0.join("a/b"); - fs::create_dir_all(&inner).unwrap(); - assert!(!inside_git_checkout(&inner)); - fs::create_dir_all(t.0.join(".git")).unwrap(); - assert!(inside_git_checkout(&inner)); - assert!(inside_git_checkout(&t.0.join("not/yet/created/schedule.tsv"))); - } - - fn json_regime(label: &str, k: usize, self_key: &str) -> String { - let slice = |g1: f64| { - format!( - "{{\"i\": 0, \"calls\": 10, \"wall_ns\": 100, \"ns_per_call\": 10.0, \"ghz_before\": 5.0, \"ghz_after\": {g1}, \"cycles_per_call\": 50.0}}" - ) - }; - format!( - "{{\"regime\": \"{label}\", \"copies_k\": {k}, \"expert_bytes\": 1000, \"llc_bytes\": 500, \"slices_requested\": 3, \"slices_kept\": 2, \"dropped_count\": 1, \"{self_key}\": true, \"median_ns_per_call\": 10.0, \"median_cycles_per_call\": 50.0, \"slices\": [{}, {}], \"dropped\": [{}]}}", - slice(5.0), - slice(5.1), - slice(4.0) - ) - } - - /// A process JSON as the C++ writer (`imp` cpp) or this example (rust) writes it, with `env` as its effective environment. - fn proc_fixture(p: &Proc, env: &str) -> String { - let (self_key, detail) = if p.imp == Impl::Cpp { - ("selfcheck_bitwise_equal_compose_expert", "{\"tree\": \"avx512\", \"avx2_ok\": true, \"avx512_ok\": true, \"iq512_gather_on\": false, \"iq256_gather_setting\": -1, \"strata_env\": {}}".to_owned()) - } else { - ( - "selfcheck_bitwise_equal_first_call", - format!( - "{{\"tree\": \"{}\", \"cpu_report\": [\"cpu: logical 16 (8 physical): Test CPU; x\", \"cpu: process kernel family AVX-512 (test)\"], \"strata_env\": {{}}}}", - p.tree - ), - ) - }; - format!( - "{{\"format\": \"KAB1-time\", \"version\": 1, \"writer\": \"{}\", \"manifest_sha256\": \"m\", \"case\": {{\"id\": \"c\", \"input_sha256\": \"i\"}}, \"tree\": \"{}\", \"tree_detail\": {detail}, \"effective_env\": {env}, \"pin\": {{\"cpu\": 9, \"sibling_cpu\": 25, \"sibling_busy_fraction_during_run\": 0.01}}, \"clock_calibration\": {{\"ghz_at_start\": 5.0, \"ghz_at_end\": 5.1}}, \"final_output_unchanged\": true, \"output_sha256\": \"{}\", \"regimes\": [{}, {}]}}", - p.imp.name(), - p.tree, - "cd".repeat(32), - json_regime("RESIDENT", 1, self_key), - json_regime("STREAMED", 3, self_key) - ) - } - - #[test] - fn a_process_json_is_checked_against_the_cell_that_was_started() { - let expect = Expect { manifest_sha: "m", input_sha: "i", case: "c", pin: 9 }; - for p in [Proc { imp: Impl::Cpp, tree: "avx2", rep: 'a' }, Proc { imp: Impl::Rust, tree: "avx512", rep: 'b' }] { - let env = json_env(&cell_env(&p).into_iter().collect()); - let ok = parse_proc_json(&p, proc_fixture(&p, &env).as_bytes(), &expect).unwrap(); - assert_eq!(ok.regimes.len(), 2); - let r = &ok.regimes["STREAMED"]; - assert_eq!((r.copies_k, r.ns.len(), r.dropped, r.requested), (3, 2, 1, 3)); - assert!( - (r.max_drift - 0.2).abs() < 1e-9, - "the dropped slice's 20 percent drift is the maximum: {}", - r.max_drift - ); - assert_eq!(ok.sibling_idle, Some(true)); - // the environment the process saw must be exactly the cell's - let planted = json_env(&BTreeMap::from([("STRATA_X".to_owned(), "1".to_owned())])); - let e = parse_proc_json(&p, proc_fixture(&p, &planted).as_bytes(), &expect).unwrap_err(); - assert!(e.starts_with(&format!("cell {}: effective environment", p.name())), "{e}"); - // wrong pin, wrong manifest, wrong input, wrong writer: each names the cell - for (bad_expect, what) in [ - (Expect { manifest_sha: "m", input_sha: "i", case: "c", pin: 8 }, "pinned to CPU"), - (Expect { manifest_sha: "other", input_sha: "i", case: "c", pin: 9 }, "manifest_sha256"), - (Expect { manifest_sha: "m", input_sha: "x", case: "c", pin: 9 }, "input hash"), - ] { - let e = parse_proc_json(&p, proc_fixture(&p, &env).as_bytes(), &bad_expect).unwrap_err(); - assert!(e.starts_with(&format!("cell {}:", p.name())) && e.contains(what), "{e}"); - } - let other = Proc { imp: if p.imp == Impl::Cpp { Impl::Rust } else { Impl::Cpp }, ..p }; - assert!( - parse_proc_json(&other, proc_fixture(&p, &env).as_bytes(), &expect).unwrap_err().contains("writer") - ); - } - } - - fn fake_proc(p: Proc, base: f64) -> ProcOut { - let regime = |k: usize| RegimeStat { - copies_k: k, - expert_bytes: 1_000_000, - llc_bytes: 1_000, - requested: 10, - dropped: 1, - median_ns: base, - median_cycles: base * 5.0, - ns: vec![base * 0.9, base, base * 1.1], - cycles: vec![base * 4.5, base * 5.0, base * 5.5], - max_drift: 0.01, - selfcheck: true, - }; - ProcOut { - proc: p, - regimes: BTreeMap::from([("RESIDENT".to_owned(), regime(1)), ("STREAMED".to_owned(), regime(3))]), - ghz_start: 5.0, - ghz_end: 5.1, - sibling_idle: Some(true), - final_unchanged: true, - output_sha: Some("ab".repeat(32)), - tree_text: format!("tree text of {}", p.name()), - cpu_model: Some("Test CPU".to_owned()), - } - } - - #[test] - fn round_records_have_the_schema_shape_and_keep_not_equal() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - let v = verify_dir(&t.0).unwrap(); - let outcome = |bad: usize| Outcome { - compared: H, - mismatches: bad, - differing_bits: bad, - max_abs_error: 0.0, - first_mismatch: None, - }; - let equality = BTreeMap::from([("avx512", outcome(0)), ("avx2", outcome(1835))]); - let ctx = BatchCtx { - verified: &v, - case: &v.cases[0], - pin: 9, - machine_role: "m".into(), - os: "os".into(), - cpu_model: "cpu".into(), - started_utc: "2026-10-28T20:00:00Z".into(), - rust_tool: Tool { - compiler: "rustc".into(), - version: "rustc 1.99.0".into(), - triple: "x86_64-unknown-linux-gnu".into(), - flags: "f".into(), - }, - batch: 2, - equality: &equality, - }; - let mut done: Vec = - procs_for(&TREES).into_iter().enumerate().map(|(i, p)| fake_proc(p, 100.0 + i as f64)).collect(); - done.reverse(); // the order of execution does not matter to the records - done.iter_mut().find(|p| p.proc == Proc { imp: Impl::Cpp, tree: "avx2", rep: 'b' }).unwrap().sibling_idle = - Some(false); - let files = round_records(&ctx, 31, &done).unwrap(); - assert_eq!(files.len(), 12, "2 trees x 2 regimes x (A/B + A/A cpp + A/A rust)"); - let names: BTreeSet<_> = files.iter().map(|f| f.0.as_str()).collect(); - assert_eq!(names.len(), 12); - assert!( - names.contains("r00031.ab.avx2.streamed.json") - && names.contains("r00031.aa-cpp.avx512.resident.json") - && names.contains("r00031.aa-rust.avx2.resident.json") - ); - for (name, json) in &files { - let rec = parse_json(json.as_bytes()).unwrap_or_else(|e| panic!("{name}: {e}")); - for key in [ - "schema_version", - "level", - "record_id", - "created_utc", - "run_started_utc", - "machine", - "kernel", - "toolchain", - "case_id", - "input_sha256", - "kab1_manifest_sha256", - "tree", - "regime", - "pin", - "strata_upstream_commit", - "clock_calibration", - "rows", - "aa_noise_floor", - "equality", - ] { - assert!(rec.get(key).is_some(), "{name}: {key}"); - } - assert_eq!(rec.str("level").unwrap(), "COMPONENT_KERNEL"); - assert_eq!(rec.str("kab1_manifest_sha256").unwrap(), v.manifest_sha256); - assert_eq!(rec.str("input_sha256").unwrap(), v.cases[0].in_sha256); - let Some(Json::Arr(rows)) = rec.get("rows") else { panic!("rows") }; - let units: Vec<_> = rows.iter().map(|r| r.str("unit").unwrap().to_owned()).collect(); - assert_eq!(units, ["ns", "cycles"]); - assert_ne!(rows[0].str("row_type").unwrap(), rows[1].str("row_type").unwrap(), "no repeated row type"); - let regime = rec.str("regime").unwrap(); - assert_eq!(rec.get("streamed").is_some(), regime == "streamed", "{name}"); - assert!(rec.str("kernel").unwrap().contains("PLACEHOLDER")); - let eq = rec.req("equality").unwrap(); - let tree = rec.req("tree").unwrap().str("ours").unwrap(); - let want = if name.contains(".ab.") && tree == "avx2" { "NOT_EQUAL" } else { "EQUAL" }; - assert_eq!(eq.str("verdict").unwrap(), want, "{name}"); - if want == "NOT_EQUAL" { - assert_eq!(eq.uint("mismatches").unwrap(), 1835, "the A/B mismatch count is carried, not hidden"); - } - } - // the A/B record puts Rust in the ours slot and C++ in the reference slot; the A/A records use one implementation on both - let ab = - parse_json(files.iter().find(|f| f.0 == "r00031.ab.avx512.resident.json").unwrap().1.as_bytes()).unwrap(); - assert!( - ab.str("kernel").unwrap().contains("ours-slot process rust-avx512-a, reference-slot process cpp-avx512-a") - ); - assert_eq!(ab.req("toolchain").unwrap().req("ours").unwrap().str("compiler").unwrap(), "rustc"); - let aa = parse_json(files.iter().find(|f| f.0 == "r00031.aa-cpp.avx512.resident.json").unwrap().1.as_bytes()) - .unwrap(); - assert!( - aa.str("kernel").unwrap().contains("ours-slot process cpp-avx512-a, reference-slot process cpp-avx512-b") - ); - assert_eq!(aa.req("equality").unwrap().str("mode").unwrap(), "bitwise"); - // sibling_idle belongs to the two processes of a record: only the A/A cpp avx2 records see the busy sibling of cpp-avx2-b - for (name, json) in &files { - let rec = parse_json(json.as_bytes()).unwrap(); - let busy = name.contains(".aa-cpp.avx2."); - assert_eq!(matches!(rec.req("pin").unwrap().get("sibling_idle"), Some(Json::Bool(false))), busy, "{name}"); - } - // a streamed set that differs between the two sides of a record is refused - let mut skewed = done.clone(); - skewed - .iter_mut() - .find(|p| p.proc == Proc { imp: Impl::Cpp, tree: "avx2", rep: 'a' }) - .unwrap() - .regimes - .get_mut("STREAMED") - .unwrap() - .copies_k = 4; - assert!(round_records(&ctx, 31, &skewed).unwrap_err().contains("streamed set differs")); - // a missing process is named - assert!(round_records(&ctx, 31, &done[1..]).unwrap_err().contains("did not run")); - } - - #[test] - fn the_rust_time_mode_writes_a_process_json_the_runner_accepts() { - let t = TempDir::new(); - build(&t.0, &one_case(), |_| {}); - let out = TempDir::new(); - let file = out.0.join("t.json"); - let args: Vec = [ - "--run-dir", - t.0.to_str().unwrap(), - "--case", - "42-42-r1", - "--slices", - "40", - "--pin", - "0", - "--out", - file.to_str().unwrap(), - "--slice-ms", - "1", - "--llc-bytes", - "8000000", - ] - .iter() - .map(|s| (*s).to_owned()) - .collect(); - // exit 0, or 3 when a 1 ms slice of a ramping clock was dropped in every slice of a regime (kept slices are the loaded host's call) - let code = format!("{:?}", cmd_time(&args).unwrap()); - assert!(code == format!("{:?}", ExitCode::SUCCESS) || code == format!("{:?}", ExitCode::from(3)), "{code}"); - let text = fs::read_to_string(&file).unwrap(); - let j = parse_json(text.as_bytes()).unwrap(); - assert_eq!(j.str("writer").unwrap(), "rust"); - assert_eq!(j.str("format").unwrap(), "KAB1-time"); - assert!(j.flag("selfcheck_bitwise_equal_first_call").unwrap()); - assert_eq!(j.str("output_sha256").unwrap().len(), 64); - let tree = j.str("tree").unwrap().to_owned(); - let p = Proc { imp: Impl::Rust, tree: TREES.iter().find(|t| **t == tree).copied().unwrap(), rep: 'a' }; - if !code.contains("(0)") { - return; - } - let manifest = fs::read(t.0.join("manifest.json")).unwrap(); - let (_, _, cases, _) = read_manifest(&t.0).unwrap(); - let sha = sha_hex(&manifest); - let expect = Expect { manifest_sha: &sha, input_sha: &cases[0].in_sha256, case: "42-42-r1", pin: 0 }; - // the test process runs unscrubbed (its effective environment is empty), so the runner's environment check refuses it ... - assert!(parse_proc_json(&p, text.as_bytes(), &expect).unwrap_err().contains("effective environment")); - // ... and accepts it once the recorded environment is the cell's - let want_env = json_env(&cell_env(&p).into_iter().collect()); - let as_cell = text.replacen("\"effective_env\": {}", &format!("\"effective_env\": {want_env}"), 1); - let ok = parse_proc_json(&p, as_cell.as_bytes(), &expect).unwrap(); - for r in ["RESIDENT", "STREAMED"] { - let s = &ok.regimes[r]; - assert!(s.median_ns > 0.0 && s.median_cycles > 0.0 && !s.ns.is_empty(), "{r}"); - assert_eq!(s.requested, 40); - } - assert_eq!(ok.regimes["RESIDENT"].copies_k, 1); - assert!(ok.regimes["STREAMED"].copies_k >= 2); - assert!(ok.tree_text.starts_with("leleka-serve cpu: process kernel family")); - // a lie about the pin is refused - assert!( - parse_proc_json(&p, as_cell.as_bytes(), &Expect { pin: 3, ..expect }) - .unwrap_err() - .contains("pinned to CPU") - ); - } - - #[test] - fn utc_formatting_is_exact() { - assert_eq!(utc_of(0), "1970-01-01T00:00:00Z"); - assert_eq!(utc_of(1_782_000_000), "2026-06-21T00:00:00Z"); - assert!(is_utc(&now_utc())); - } -} diff --git a/crates/native-cpu-expert/examples/kernel_ab/cmd_alternate_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/cmd_alternate_fn.rs new file mode 100644 index 00000000..b5457164 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/cmd_alternate_fn.rs @@ -0,0 +1,242 @@ +//! Moved out of the parent module by STRA-338: fn cmd_alternate, fn usage. + +#[allow(unused_imports)] +use super::*; + + +pub(super) fn cmd_alternate(args: &[String]) -> Result { + let a = parse_alt_args(args)?; + let started = now_utc(); + let verified = match verify_dir(&a.dir) { + Ok(v) => v, + Err(e) => { + println!("{e}"); + return Ok(ExitCode::from(if e.incomplete { 2 } else { 1 })); + } + }; + let case = verified + .cases + .iter() + .find(|c| c.id == a.case) + .ok_or_else(|| format!("case {} is not in the manifest", a.case))? + .clone(); + let out = a.out.clone().unwrap_or_else(|| { + let name = a.dir.file_name().map_or_else(|| "kab1".to_owned(), |n| n.to_string_lossy().into_owned()); + a.dir.parent().unwrap_or(Path::new(".")).join(format!("{name}.alt-{}", a.case)) + }); + let abs = |p: &Path| std::path::absolute(p).unwrap_or_else(|_| p.to_path_buf()); + if abs(&out).starts_with(abs(&a.dir)) || abs(&a.dir).starts_with(abs(&out)) { + return Err("--out must not contain or lie inside the KAB1 directory".to_owned()); + } + if inside_git_checkout(&out) || inside_git_checkout(&a.schedule) { + return Err( + "--out and --schedule must lie outside every Git checkout (generated artifacts stay out of Git)".to_owned() + ); + } + let own_exe = std::env::current_exe().map_err(|e| format!("current_exe: {e}"))?; + let kab = a.kab.clone().or_else(|| std::env::var_os("KAB").map(PathBuf::from)).unwrap_or_else(|| { + PathBuf::from( + std::env::var("E2E_ROOT") + .unwrap_or_else(|_| format!("{}/work/leleka-e2e", std::env::var("HOME").unwrap_or_default())), + ) + .join("build/kernel-ab/kab") + }); + if !kab.is_file() { + return Err(format!( + "the C++ driver {} does not exist (build tools/kernel-ab/cpp, or pass --kab / set KAB)", + kab.display() + )); + } + // a host without AVX-512 has no avx512 cells (the C++ reference trees are identical by construction there) + let trees: Vec<&'static str> = + TREES.iter().copied().filter(|t| *t != "avx512" || verified.provenance.avx512_ok != Some(false)).collect(); + let procs = procs_for(&trees); + + // the schedule, written BEFORE the first run and read back: the file, not the generator, drives the batch + let first_round = (a.batch - 1) * a.rounds + 1; + let planned = make_schedule(a.seed, a.batch, a.rounds, &procs); + let text = schedule_text(a.seed, a.batch, a.rounds, &a.case, a.pin, first_round, &planned); + fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?; + if let Some(parent) = a.schedule.parent().filter(|p| !p.as_os_str().is_empty()) { + fs::create_dir_all(parent).map_err(|e| format!("{}: {e}", parent.display()))?; + } + create_new_file(&a.schedule, text.as_bytes())?; + let schedule = + parse_schedule(&fs::read_to_string(&a.schedule).map_err(|e| format!("{}: {e}", a.schedule.display()))?)?; + println!( + "schedule written to {} (sha256 {}) before the first run: {} rounds x {} processes", + a.schedule.display(), + sha_hex(text.as_bytes()), + schedule.len(), + procs.len() + ); + let (records_dir, proc_dir) = (out.join("records"), out.join("processes")); + for d in [&records_dir, &proc_dir] { + fs::create_dir_all(d).map_err(|e| format!("{}: {e}", d.display()))?; + } + let parent_env: Vec<(OsString, OsString)> = std::env::vars_os().collect(); + let sibling_at_start = sibling_idle(a.pin); + let machine_role = a + .machine_role + .clone() + .or_else(|| std::env::var("HOSTNAME").ok()) + .or_else(|| std::env::var("COMPUTERNAME").ok()) + .unwrap_or_else(|| "unknown".to_owned()); + let (rustc_version, triple) = rustc_info(); + + // equality phase: our tree against the C++ reference .out file, per tree, in fresh processes (the kernels are not touched by timing) + let eq_dir = out.join(format!("equality-b{:04}", a.batch)); + let mut equality: BTreeMap<&'static str, Outcome> = BTreeMap::new(); + for tree in &trees { + let p = Proc { imp: Impl::Rust, tree, rep: 'a' }; + let mut cmd = scrubbed_command(&own_exe, &parent_env, &cell_env(&p)); + cmd.arg("run-tree") + .arg(&a.dir) + .args(["--tree", tree, "--case", &a.case, "--out"]) + .arg(&eq_dir) + .args(["--pin", &a.pin.to_string()]); + run_cell(&mut cmd, &format!("{}/equality", p.name()))?; + let ours_name = format!("case-{}.rust-{tree}.out", a.case); + let ours = read_out(&eq_dir.join(&ours_name), &ours_name, case.rows, tree, None).map_err(|e| e.to_string())?; + let o = case.outs.iter().find(|o| o.tree == *tree).ok_or("missing reference out")?; + let reference = read_out(&a.dir.join(&o.name), &o.name, case.rows, tree, Some((&o.sha256, o.bytes))) + .map_err(|e| e.to_string())?; + let outcome = compare_bits(&ours, &reference, case.tolerance.as_ref()); + println!( + "EQUALITY {} [{tree}] {}{}", + a.case, + if outcome.equal() { "EQUAL" } else { "NOT_EQUAL" }, + outcome.first_mismatch.map_or(format!("; {} values", outcome.compared), |(i, x, y)| format!( + "; {} of {} values differ, first at {i}: ours {x:#010x} reference {y:#010x}, max abs error {:e}", + outcome.mismatches, outcome.compared, outcome.max_abs_error + )) + ); + equality.insert(tree, outcome); + } + + let mut cpu_model = String::new(); + let batch_json = |cpu_model: String, equality: &BTreeMap<&'static str, Outcome>| -> Result { + let eq = equality + .iter() + .map(|(t, o)| { + format!( + "{{\"tree\": {}, \"verdict\": \"{}\", \"mode\": \"{}\", \"compared_values\": {}, \"mismatches\": {}}}", + jstr(t), + if o.equal() { "EQUAL" } else { "NOT_EQUAL" }, + if case.tolerance.is_some() { "tolerance" } else { "bitwise" }, + o.compared, + o.mismatches + ) + }) + .collect::>() + .join(", "); + let cells = procs + .iter() + .map(|p| format!("{{\"process\": {}, \"impl\": {}, \"tree\": {}, \"env_set\": {}, \"env_scrubbed\": \"every STRATA_* and LELEKA_* variable of the parent\"}}", jstr(&p.name()), jstr(p.imp.name()), jstr(p.tree), json_env(&cell_env(p).into_iter().collect()))) + .collect::>() + .join(", "); + Ok(format!( + "{{\n \"format\": \"KAB1-alt\",\n \"version\": 1,\n \"batch\": {},\n \"rounds\": {},\n \"first_round\": {first_round},\n \"run_started_utc\": {},\n \"case\": {},\n \"run_dir\": {},\n \"manifest_sha256\": {},\n \"input_sha256\": {},\n \"pin\": {{\"logical_cpu\": {}, \"sibling_idle_at_start\": {sibling_at_start}}},\n \"pool\": {{\"workers\": 1}},\n \"machine\": {{\"machine_role\": {}, \"cpu_model\": {}, \"os\": {}}},\n \"seed\": {},\n \"schedule\": {{\"file\": {}, \"sha256\": {}}},\n \"kab\": {{\"path\": {}, \"sha256\": {}}},\n \"rust_example\": {{\"path\": {}, \"sha256\": {}}},\n \"slices_per_regime\": {},\n \"slice_ms\": {},\n \"equality\": [{eq}],\n \"cells\": [{cells}],\n \"no_statistics\": \"this file computes no class, no interval and no A/A verdict (S0.10b, STRA-313)\"\n}}\n", + a.batch, + a.rounds, + jstr(&started), + jstr(&a.case), + jstr(&a.dir.display().to_string()), + jstr(&verified.manifest_sha256), + jstr(&case.in_sha256), + a.pin, + jstr(&machine_role), + jstr(&cpu_model), + jstr(&host_os()), + a.seed, + jstr(&a.schedule.display().to_string()), + jstr(&sha_hex(text.as_bytes())), + jstr(&kab.display().to_string()), + jstr(&file_sha(&kab)?), + jstr(&own_exe.display().to_string()), + jstr(&file_sha(&own_exe)?), + a.slices, + a.slice_ms.map_or("null".to_owned(), |m| jnum(m, 1)) + )) + }; + + let expect = + Expect { manifest_sha: &verified.manifest_sha256, input_sha: &case.in_sha256, case: &a.case, pin: a.pin }; + let mut ctx = BatchCtx { + verified: &verified, + case: &case, + pin: a.pin, + machine_role: machine_role.clone(), + os: host_os(), + cpu_model: String::new(), + started_utc: started.clone(), + rust_tool: Tool { compiler: "rustc".to_owned(), version: rustc_version, triple, flags: ours_flags() }, + batch: a.batch, + equality: &equality, + }; + let mut written = Vec::new(); + for (round_no, order) in &schedule { + let mut done: Vec = Vec::new(); + for p in order { + let name = p.name(); + let file = proc_dir.join(format!("r{round_no:05}-{name}.json")); + let mut cmd = scrubbed_command(if p.imp == Impl::Cpp { &kab } else { &own_exe }, &parent_env, &cell_env(p)); + cmd.arg("time") + .args(["--run-dir"]) + .arg(&a.dir) + .args(["--case", &a.case, "--slices", &a.slices.to_string(), "--pin", &a.pin.to_string(), "--out"]) + .arg(&file); + if let Some(ms) = a.slice_ms { + cmd.args(["--slice-ms", &ms.to_string()]); + } + if let Some(b) = a.llc_bytes { + cmd.args(["--llc-bytes", &b.to_string()]); + } + let res = run_cell(&mut cmd, &name)?; + fs::write(file.with_extension("log"), [&res.stdout[..], &res.stderr[..]].concat()) + .map_err(|e| format!("{}: {e}", file.display()))?; + let bytes = fs::read(&file) + .map_err(|e| format!("cell {name}: its output {} was not written: {e}", file.display()))?; + done.push(parse_proc_json(p, &bytes, &expect)?); + } + if cpu_model.is_empty() { + cpu_model = done.iter().find_map(|d| d.cpu_model.clone()).unwrap_or_else(|| "unknown model".to_owned()); + ctx.cpu_model = cpu_model.clone(); + create_new_file( + &out.join(format!("batch-{:04}.json", a.batch)), + batch_json(cpu_model.clone(), &equality)?.as_bytes(), + )?; + } + for (name, json) in round_records(&ctx, *round_no, &done)? { + create_new_file(&records_dir.join(&name), json.as_bytes())?; + written.push(name); + } + println!("round {round_no} done: {}", order.iter().map(Proc::name).collect::>().join(" ")); + } + println!( + "ALTERNATE OK batch={} rounds={} records={} dir={}", + a.batch, + a.rounds, + written.len(), + records_dir.display() + ); + for (t, o) in &equality { + println!("EQUALITY-SUMMARY {} {t} {}", a.case, if o.equal() { "EQUAL" } else { "NOT_EQUAL" }); + } + Ok(ExitCode::SUCCESS) +} + +// ------------------------------------------------------------------------------------------------ main + +pub(super) fn usage() -> ExitCode { + eprintln!( + "usage: kernel_ab verify D | compare D [--out R] [--pin CPU] [--machine-role NAME] [--trees avx512,avx2] | run-tree D --tree T --out R [--pin CPU] [--case ID]" + ); + eprintln!( + " kernel_ab time --run-dir D --case ID --slices N --pin CPU --out F.json [--slice-ms 60] [--regime both|resident|streamed] [--llc-bytes B]" + ); + eprintln!( + " kernel_ab alternate --run-dir D --case ID --rounds N --batch K --pin CPU --schedule FILE [--seed S] [--out R] [--slices N] [--slice-ms MS] [--llc-bytes B] [--machine-role NAME] [--kab PATH]" + ); + ExitCode::from(64) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/cmd_compare_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/cmd_compare_fn.rs new file mode 100644 index 00000000..7bee4fcc --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/cmd_compare_fn.rs @@ -0,0 +1,242 @@ +//! Moved out of the parent module by STRA-338: fn cmd_compare, impl Flags, fn mono_ns, fn core_ghz, fn median_of, fn percentile_of .... + +#[allow(unused_imports)] +use super::*; + + +pub(super) fn cmd_compare(dir: &Path, opts: &Options) -> Result { + let started = now_utc(); + let verified = match verify_dir(dir) { + Ok(v) => v, + Err(e) => { + println!("{e}"); + return Ok(ExitCode::from(if e.incomplete { 2 } else { 1 })); + } + }; + println!( + "KAB1 directory verified: {} files, {} cases, manifest sha256 {}", + verified.file_count, + verified.cases.len(), + verified.manifest_sha256 + ); + let out = opts.out.clone().unwrap_or_else(|| { + let name = dir.file_name().map_or_else(|| "kab1".to_owned(), |n| n.to_string_lossy().into_owned()); + dir.parent().unwrap_or(Path::new(".")).join(format!("{name}.rust")) + }); + if out.starts_with(dir) || dir.starts_with(&out) { + return Err("--out must not contain or lie inside the KAB1 directory".to_owned()); + } + if out.exists() && fs::read_dir(&out).map_err(|e| format!("{}: {e}", out.display()))?.next().is_some() { + return Err(format!("{} exists and is not empty (nothing is overwritten or deleted)", out.display())); + } + let records = out.join("records"); + fs::create_dir_all(&records).map_err(|e| format!("{}: {e}", records.display()))?; + let exe = std::env::current_exe().map_err(|e| format!("current_exe: {e}"))?; + let parent_env: Vec<(OsString, OsString)> = std::env::vars_os().collect(); + let machine_role = opts + .machine_role + .clone() + .or_else(|| std::env::var("HOSTNAME").ok()) + .or_else(|| std::env::var("COMPUTERNAME").ok()) + .unwrap_or_else(|| "unknown".to_owned()); + let (rustc_version, triple) = rustc_info(); + let flags = format!( + "cargo profile {}; RUSTFLAGS={:?}; target-cpu default", + if cfg!(debug_assertions) { "dev" } else { "release" }, + std::env::var("RUSTFLAGS").unwrap_or_default() + ); + let mut all_equal = true; + let mut cells = 0usize; + for tree in &opts.trees { + let sibling = sibling_idle(opts.pin); + let probe = Proc { + imp: Impl::Rust, + tree: TREES.iter().find(|t| **t == tree.as_str()).copied().unwrap_or("avx2"), + rep: 'a', + }; + let mut cmd = scrubbed_command(&exe, &parent_env, &cell_env(&probe)); + cmd.arg("run-tree").arg(dir).args(["--tree", tree, "--out"]).arg(&out).args(["--pin", &opts.pin.to_string()]); + let res = cmd.output().map_err(|e| format!("cannot start the {tree} process: {e}"))?; + let stdout = String::from_utf8_lossy(&res.stdout).into_owned(); + let report: Vec = stdout.lines().filter_map(|l| l.strip_prefix("REPORT ")).map(str::to_owned).collect(); + match res.status.code() { + Some(0) => {} + Some(3) if tree == "avx512" && verified.provenance.avx512_ok == Some(false) => { + println!( + "tree avx512: SKIPPED, this host has no AVX-512 (manifest avx512_ok=false; the reference trees are identical by construction)" + ); + continue; + } + code => { + eprint!("{}", String::from_utf8_lossy(&res.stderr)); + println!("tree {tree}: the Rust process failed (exit {code:?})"); + return Ok(ExitCode::from(1)); + } + } + println!( + "tree {tree}: {}", + report.iter().find(|l| l.starts_with("cpu: process kernel family")).map_or("", String::as_str) + ); + let tree_name: &str = TREES.iter().find(|t| **t == tree.as_str()).copied().unwrap_or("avx2"); + for c in &verified.cases { + let ours_name = format!("case-{}.rust-{tree}.out", c.id); + let ours = read_out(&out.join(&ours_name), &ours_name, c.rows, tree, None).map_err(|e| e.to_string())?; + let o = c.outs.iter().find(|o| o.tree == tree_name).ok_or("missing reference out")?; + let reference = read_out(&verified.dir.join(&o.name), &o.name, c.rows, tree, Some((&o.sha256, o.bytes))) + .map_err(|e| e.to_string())?; + let outcome = compare_bits(&ours, &reference, c.tolerance.as_ref()); + let label = match (&c.tolerance, outcome.equal()) { + (None, true) => "bitwise EQUAL".to_owned(), + (None, false) => "bitwise NOT EQUAL".to_owned(), + (Some(t), eq) => format!( + "{} within tolerance {:e} (metric {TOLERANCE_METRIC}; basis: {})", + if eq { "EQUAL" } else { "NOT EQUAL" }, + t.value, + t.basis + ), + }; + let detail = match outcome.first_mismatch { + Some((i, a, b)) => format!( + "; {} of {} values differ, first at {i}: ours {a:#010x} reference {b:#010x}, max abs error {:e}", + outcome.mismatches, outcome.compared, outcome.max_abs_error + ), + None => format!("; {} values", outcome.compared), + }; + println!("case {} [{tree}] {label}{detail}", c.id); + all_equal &= outcome.equal(); + cells += 1; + let record = record_json(&RecordInput { + record_id: format!( + "kab1-{}-{}-{tree}-{}", + verified.provenance.run_id, + c.id, + started.replace([':', '-'], "") + ), + created_utc: now_utc(), + run_started_utc: started.clone(), + machine_role: machine_role.clone(), + cpu_model: cpu_model_of(&report), + os: host_os(), + ours_compiler: "rustc".to_owned(), + ours_version: rustc_version.clone(), + ours_triple: triple.clone(), + ours_flags: flags.clone(), + tree: tree_name, + verified: &verified, + case: c, + pin_cpu: opts.pin, + sibling_idle: sibling, + outcome: &outcome, + }); + let path = records.join(format!("case-{}.{tree}.record.json", c.id)); + fs::write(&path, record).map_err(|e| format!("{}: {e}", path.display()))?; + } + } + println!( + "compared {cells} cells; records in {}; {}", + records.display(), + if all_equal { "ALL EQUAL" } else { "NOT ALL EQUAL" } + ); + Ok(if all_equal && cells > 0 { ExitCode::SUCCESS } else { ExitCode::from(1) }) +} + +impl Flags { + pub(super) fn parse(args: &[String], known: &[&str]) -> Result { + let mut items: Vec<(String, String)> = Vec::new(); + let mut it = args.iter(); + while let Some(a) = it.next() { + let name = a.strip_prefix("--").ok_or_else(|| format!("unexpected argument {a}"))?; + if !known.contains(&name) { + return Err(format!("unknown option {a}")); + } + if items.iter().any(|(k, _)| k == name) { + return Err(format!("option {a} given twice")); + } + let v = it.next().ok_or_else(|| format!("{a} needs a value"))?; + items.push((name.to_owned(), v.clone())); + } + Ok(Self(items)) + } + pub(super) fn get(&self, k: &str) -> Option<&str> { + self.0.iter().find(|(n, _)| n == k).map(|(_, v)| v.as_str()) + } + pub(super) fn req(&self, k: &str) -> Result<&str, String> { + self.get(k).ok_or_else(|| format!("--{k} is required")) + } + pub(super) fn number(&self, k: &str) -> Result, String> { + self.get(k).map(|v| v.parse::().map_err(|_| format!("--{k} {v:?} is not a valid number"))).transpose() + } +} + +pub(super) fn mono_ns() -> u64 { + static ORIGIN: OnceLock = OnceLock::new(); + ORIGIN.get_or_init(Instant::now).elapsed().as_nanos() as u64 +} + +/// The core clock in GHz from a chain of dependent steps (safe code: the C++ chain of dependent adds needs inline assembly). A plain +/// chain of multiplies by an opaque constant is folded by LLVM (measured: 175 GHz), so every step also xors in a shifted copy of the +/// running value, which no reassociation can remove. +pub(super) fn core_ghz() -> f64 { + let k = std::hint::black_box(0x9E37_79B9_7F4A_7C15u64 | 1); + let mut x = std::hint::black_box(1u64); + let n = 1_000_000u64; + let t0 = mono_ns(); + for _ in 0..n { + x = x.wrapping_mul(k) ^ (x >> 17); + x = x.wrapping_mul(k) ^ (x >> 17); + x = x.wrapping_mul(k) ^ (x >> 17); + x = x.wrapping_mul(k) ^ (x >> 17); + } + let dt = mono_ns().saturating_sub(t0).max(1); + std::hint::black_box(x); + CHAIN_STEP_CYCLES * 4.0 * n as f64 / dt as f64 +} + +pub(super) fn median_of(v: &[f64]) -> f64 { + if v.is_empty() { + return 0.0; + } + let mut s = v.to_vec(); + s.sort_by(f64::total_cmp); + s[s.len() / 2] +} + +/// Nearest-rank percentile of raw slice values (a description of the slices, not an inference). +pub(super) fn percentile_of(v: &[f64], p: f64) -> f64 { + if v.is_empty() { + return 0.0; + } + let mut s = v.to_vec(); + s.sort_by(f64::total_cmp); + s[((s.len() - 1) as f64 * p).round() as usize] +} + +pub(super) fn jnum(v: f64, decimals: usize) -> String { + if v.is_finite() { format!("{v:.decimals$}") } else { "null".to_owned() } +} + +pub(super) fn read_text(path: &str) -> String { + fs::read_to_string(path).map(|s| s.trim().to_owned()).unwrap_or_default() +} + +pub(super) fn parse_cpu_list(s: &str) -> Vec { + let mut v = Vec::new(); + for part in s.trim().split(',').filter(|p| !p.is_empty()) { + let (a, b) = part.split_once('-').unwrap_or((part, part)); + if let (Ok(a), Ok(b)) = (a.trim().parse::(), b.trim().parse::()) { + v.extend(a..=b); + } + } + v +} + +pub(super) fn parse_size(s: &str) -> u64 { + let digits: String = s.chars().take_while(char::is_ascii_digit).collect(); + let n = digits.parse::().unwrap_or(0); + match s[digits.len()..].chars().next() { + Some('K' | 'k') => n << 10, + Some('M' | 'm') => n << 20, + Some('G' | 'g') => n << 30, + _ => n, + } +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/cmd_time_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/cmd_time_fn.rs new file mode 100644 index 00000000..3a57f29c --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/cmd_time_fn.rs @@ -0,0 +1,248 @@ +//! Moved out of the parent module by STRA-338: fn cmd_time. + +#[allow(unused_imports)] +use super::*; + + +/// `kernel_ab time ...`: one fresh process, one case, the resident and the streamed regime, JSON written by tmp + rename. Exit codes as +/// `kab time`: 0 ok; 1 usage / refused input; 3 a regime kept no slice or a slice migrated off the pin; 4 the final output differs. +pub(super) fn cmd_time(args: &[String]) -> Result { + let t = parse_time_args(args)?; + let wall0 = mono_ns(); + // pin first (before any buffer or pool exists, so the pool's threads inherit the mask), then the facts about the pin + if rust_topology::pin_current_thread(t.pin as i32) < 0 { + return Err(format!("the pin to CPU {} was refused", t.pin)); + } + if cfg!(target_os = "linux") && current_cpu() != Some(t.pin) { + return Err(format!("the process is not running on CPU {} after the pin", t.pin)); + } + let cpu_dir = format!("/sys/devices/system/cpu/cpu{}", t.pin); + let sib_text = read_text(&format!("{cpu_dir}/topology/thread_siblings_list")); + let sibling = parse_cpu_list(&sib_text).into_iter().rfind(|c| *c != t.pin); + let sib0 = sibling.and_then(proc_stat_cpu); + let pin0 = proc_stat_cpu(t.pin); + let load0 = read_text("/proc/loadavg"); + + // the case: the KAB1 reader rule (validate, then use) and the manifest and case input hashes + let (manifest_bytes, _provenance, cases, _files) = read_manifest(&t.dir).map_err(|e| e.to_string())?; + let manifest_sha = sha_hex(&manifest_bytes); + let entry = + cases.iter().find(|c| c.id == t.case).ok_or_else(|| format!("case {} is not in the manifest", t.case))?; + let case = read_case_in(&t.dir, entry).map_err(|e| e.to_string())?; + let header = case.header; + let weights = &case.blob[IN_HEADER..header.input_at()]; + let expert_bytes = weights.len(); + + // environment and tree + let env = managed_env_now(); + let report = cpu_kernel_report(); + let tree = family_of(&report).ok_or("no process kernel family line in cpu_kernel_report")?; + + // the streamed set: K copies, K x stride at least 2 x the last-level cache of the pinned CPU (the design choice of kab_time.cpp) + let llc = match (t.llc_bytes, llc_of_cpu(t.pin)) { + (Some(bytes), found) => { + Llc { level: found.map_or(0, |l| l.level), bytes, source: "--llc-bytes (override)".to_owned() } + } + (None, Some(l)) => l, + (None, None) => { + return Err(format!("cannot read the last-level cache size of CPU {} from sysfs; pass --llc-bytes", t.pin)); + } + }; + if llc.bytes == 0 { + return Err("--llc-bytes must be positive".to_owned()); + } + let stride = expert_bytes.div_ceil(ALIGN) * ALIGN; + let copies_k = ((2 * llc.bytes) / stride as u64) as usize + 1; + if copies_k * stride > (4usize << 30) { + return Err("the streamed working set would exceed 4 GiB; check --llc-bytes".to_owned()); + } + + // the pool is created AFTER the pin: its worker inherits the one-CPU mask (rust_platform::cores sees a one-CPU affinity) + let mut pool = DirectCpuPool::new(1).map_err(|e| format!("DirectCpuPool::new(1) failed: {e:?}"))?; + let want = compute_case(&mut pool, &case)?; + let want_bits: Vec = want.iter().map(|v| v.to_bits()).collect(); + let output_sha = f32_bits_sha(&want); + + let mut tokens = Arena::::new(header.rows * H); + tokens.slice_mut(header.rows * H).copy_from_slice(&case.input()); + let mut resident = Arena::::new(stride); + resident.slice_mut(expert_bytes).copy_from_slice(weights); + let mut streamed = Arena::::new(stride * copies_k); + for k in 0..copies_k { + streamed.slice_mut(stride * copies_k)[k * stride..k * stride + expert_bytes].copy_from_slice(weights); + } + let res_copies: Vec<&[u8]> = vec![resident.slice(expert_bytes)]; + let stm_all = streamed.slice(stride * copies_k); + let stm_copies: Vec<&[u8]> = (0..copies_k).map(|k| &stm_all[k * stride..k * stride + expert_bytes]).collect(); + + let mut timed = Timed { + pool, + gu: gate_up_row(header.gu).ok_or("gate/up type")?.1, + down: down_row(header.down).ok_or("down type")?.1, + header, + pairs: (0..header.rows).map(|r| (r, 0)).collect(), + tokens: tokens.slice(header.rows * H), + out: vec![0.0f32; header.rows * H], + }; + // selfcheck: the timed call's output on every aligned copy is bit-identical to the first (unaligned) call's + let mut selfcheck = true; + for w in [res_copies[0], stm_copies[0], stm_copies[copies_k - 1]] { + timed.call(w)?; + selfcheck &= timed.out.iter().map(|v| v.to_bits()).eq(want_bits.iter().copied()); + } + if !selfcheck { + return Err("selfcheck failed: the timed call differs from the first call".to_owned()); + } + + let ghz0 = core_ghz(); + let mut regimes = Vec::new(); + let mut all_ok = true; + let (mut kept_res, mut kept_stm) = (0, 0); + for (label, copies, sel) in + [("RESIDENT", &res_copies, RegimeSel::Resident), ("STREAMED", &stm_copies, RegimeSel::Streamed)] + { + if t.regime != RegimeSel::Both && t.regime != sel { + continue; + } + let spec = RegimeSpec { + label, + copies: copies.clone(), + expert_bytes, + stride, + llc: &llc, + slices: t.slices, + slice_ms: t.slice_ms, + pin: t.pin, + selfcheck, + }; + let r = run_regime(&mut timed, &spec)?; + all_ok &= r.ok; + if sel == RegimeSel::Resident { + kept_res = r.kept + } else { + kept_stm = r.kept + } + regimes.push(r.json); + } + let ghz1 = core_ghz(); + timed.call(res_copies[0])?; + let final_same = timed.out.iter().map(|v| v.to_bits()).eq(want_bits.iter().copied()); + + let threads = observed_threads(); + let sib1 = sibling.and_then(proc_stat_cpu); + let pin1 = proc_stat_cpu(t.pin); + let frac = |f: Option| f.map_or("null".to_owned(), |v| jnum(v, 4)); + let rust_fmt = |l: &str| jstr(l); + let (gu_name, down_name) = + (gate_up_row(header.gu).map_or("?", |x| x.4), down_row(header.down).map_or("?", |x| x.4)); + let in_name = format!("case-{}.in", t.case); + let command_line = format!( + "time --run-dir {} --case {} --slices {} --pin {} --out {}{}{}", + t.dir.display(), + t.case, + t.slices, + t.pin, + t.out.display(), + if args.iter().any(|a| a == "--slice-ms") { format!(" --slice-ms {}", t.slice_ms) } else { String::new() }, + match t.regime { + RegimeSel::Both => String::new(), + RegimeSel::Resident => " --regime resident".to_owned(), + RegimeSel::Streamed => " --regime streamed".to_owned(), + } + ); + let mut j = String::from( + "{\n \"format\": \"KAB1-time\",\n \"version\": 1,\n \"mode\": \"time\",\n \"writer\": \"rust\",\n", + ); + j += &format!( + " \"command_line\": {},\n \"run_dir\": {},\n \"manifest_sha256\": {},\n", + jstr(&command_line), + jstr(&t.dir.display().to_string()), + jstr(&manifest_sha) + ); + j += &format!( + " \"case\": {{\"id\": {}, \"gu_type\": {}, \"down_type\": {}, \"gu_name\": {}, \"down_name\": {}, \"rows\": {}, \"input_file\": {}, \"input_sha256\": {}, \"input_sha256_matches_manifest\": true, \"expert_bytes\": {}}},\n", + jstr(&t.case), + header.gu, + header.down, + jstr(gu_name), + jstr(down_name), + header.rows, + jstr(&in_name), + jstr(&entry.in_sha256), + expert_bytes + ); + j += &format!( + " \"tree\": {},\n \"tree_detail\": {{\"tree\": {}, \"cpu_report\": [{}], \"strata_env\": {}}},\n \"effective_env\": {},\n", + jstr(tree), + jstr(tree), + report.iter().map(|l| rust_fmt(l)).collect::>().join(", "), + json_env(&env), + json_env(&env) + ); + j += &format!( + " \"pool\": {{\"workers\": 1, \"host_drains\": true, \"threads_observed\": [{}], \"note\": \"DirectCpuPool::new(1): one worker thread plus the calling thread that drains beside it (pool.cpp host_works_); both inherit the one-CPU mask of the pin\"}},\n", + threads + .iter() + .map(|(n, c)| format!( + "{{\"name\": {}, \"cpu\": {}}}", + jstr(n), + c.map_or("null".to_owned(), |c| c.to_string()) + )) + .collect::>() + .join(", ") + ); + j += &format!( + " \"pin\": {{\"cpu\": {}, \"thread_siblings_list\": {}, \"sibling_cpu\": {}, \"physical_core_id\": {}, \"pin_busy_fraction_during_run\": {}, \"sibling_busy_fraction_during_run\": {}, \"sibling_busy_note\": \"/proc/stat jiffies of the sibling logical CPU between the start and the end of this process; it is recorded, no threshold is applied here\", \"scaling_governor\": {}, \"cpufreq_boost\": {}, \"loadavg_start\": {}, \"loadavg_end\": {}, \"final_cpu\": {}}},\n", + t.pin, + jstr(&sib_text), + sibling.map_or("null".to_owned(), |s| s.to_string()), + jstr(&read_text(&format!("{cpu_dir}/topology/core_id"))), + frac(busy_fraction(pin0, pin1)), + if sibling.is_some() { frac(busy_fraction(sib0, sib1)) } else { "null".to_owned() }, + jstr(&read_text(&format!("{cpu_dir}/cpufreq/scaling_governor"))), + jstr(&read_text("/sys/devices/system/cpu/cpufreq/boost")), + jstr(&load0), + jstr(&read_text("/proc/loadavg")), + current_cpu().map_or("null".to_owned(), |c| c.to_string()) + ); + j += &format!( + " \"buffers\": {{\"alignment_bytes\": {ALIGN}, \"expert_copy_stride_bytes\": {stride}, \"activations_aligned\": true, \"scratch_aligned\": false, \"scratch_note\": \"the pool's own scratch is allocated inside the crate\"}},\n" + ); + j += &format!( + " \"clock_calibration\": {{\"method\": {}, \"source\": \"engine/strata/src/kernels/cpu/tq_cpu_parity.cpp --bench: core_ghz() lines 273-284, time_slice() lines 290-304; the dependent-add chain needs inline assembly, so the safe Rust twin chains multiplies\", \"drop_rule\": {{\"source_file\": \"engine/strata/src/kernels/cpu/tq_cpu_parity.cpp\", \"source_line\": 303, \"source_text\": \"std::fabs(g1 - g0) > 0.05 * g0\", \"fraction\": {}, \"meaning\": \"a slice whose calibrated clock moved by more than 5 percent between its before and after calibration is dropped\"}}, \"slice_ms_source\": \"tq_cpu_parity.cpp:461 slice_ms = quick ? 40 : 60\", \"ghz_at_start\": {}, \"ghz_at_end\": {}, \"tsc_invariant\": null, \"clocks\": \"monotonic ns (std::time::Instant); no TSC read: rdtsc and lfence are unsafe intrinsics and the crate keeps unsafe_code = deny\"}},\n", + jstr(CLOCK_METHOD), + jnum(CLOCK_MOVED_FRACTION, 2), + jnum(ghz0, 6), + jnum(ghz1, 6) + ); + j += &format!( + " \"build\": {{\"profile\": {}, \"rustflags\": {}, \"example\": \"crates/native-cpu-expert/examples/kernel_ab.rs\"}},\n", + jstr(if cfg!(debug_assertions) { "dev" } else { "release" }), + jstr(&std::env::var("RUSTFLAGS").unwrap_or_default()) + ); + j += &format!( + " \"selfcheck_bitwise_equal_first_call\": {selfcheck},\n \"final_output_unchanged\": {final_same},\n \"output_sha256\": {},\n \"duration_ns\": {},\n \"timing_caveat\": \"numbers from a shared host are not evidence by themselves; loadavg and the sibling busy fraction are recorded above\",\n \"regimes\": [\n {}\n ]\n}}\n", + jstr(&output_sha), + mono_ns() - wall0, + regimes.join(",\n ") + ); + let tmp = PathBuf::from(format!("{}.tmp", t.out.display())); + fs::write(&tmp, j.as_bytes()).map_err(|e| format!("{}: {e}", tmp.display()))?; + fs::rename(&tmp, &t.out).map_err(|e| format!("rename to {}: {e}", t.out.display()))?; + println!( + "kernel_ab time: case={} tree={tree} pin={} slices={} resident_kept={kept_res} streamed_kept={kept_stm} K={copies_k} out={}", + t.case, + t.pin, + t.slices, + t.out.display() + ); + if !all_ok { + eprintln!("kernel_ab time: a regime has no kept slice or a slice migrated off CPU {}", t.pin); + return Ok(ExitCode::from(3)); + } + if !final_same { + eprintln!("kernel_ab time: the final output differs from the first call's"); + return Ok(ExitCode::from(4)); + } + Ok(ExitCode::SUCCESS) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/describe_cpp_tree_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/describe_cpp_tree_fn.rs new file mode 100644 index 00000000..4f5423eb --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/describe_cpp_tree_fn.rs @@ -0,0 +1,199 @@ +//! Moved out of the parent module by STRA-338: fn describe_cpp_tree, fn parse_proc_json, impl Kind, fn side_stat, fn stat_json, fn tool_json .... + +#[allow(unused_imports)] +use super::*; + + +pub(super) fn describe_cpp_tree(d: &Json) -> String { + let b = |k: &str| { + d.get(k).map_or("?".to_owned(), |v| match v { + Json::Bool(x) => x.to_string(), + Json::Num(n) => n.clone(), + _ => "?".to_owned(), + }) + }; + let env = match d.get("strata_env") { + Some(Json::Obj(items)) if !items.is_empty() => items + .iter() + .map(|(k, v)| format!("{k}={}", if let Json::Str(s) = v { s.as_str() } else { "?" })) + .collect::>() + .join(" "), + _ => "no STRATA_* variable set (STRATA_NO_IQ512, STRATA_NO_IQ256 and STRATA_IQ_GATHER unset)".to_owned(), + }; + format!( + "avx2_ok={} avx512_ok={} iq512_gather_on={} iq256_gather_setting={}; {env}", + b("avx2_ok"), + b("avx512_ok"), + b("iq512_gather_on"), + b("iq256_gather_setting") + ) +} + +/// Parses a process's KAB1-time JSON and checks it against the cell that was started: writer, tree, manifest and input hashes, case, +/// pin, and that the effective STRATA_* / LELEKA_* environment is exactly the cell's. +pub(super) fn parse_proc_json(p: &Proc, bytes: &[u8], expect: &Expect) -> Result { + let j = parse_json(bytes)?; + let name = p.name(); + let fail = |what: String| format!("cell {name}: {what}"); + if j.str("format").map_err(fail)? != "KAB1-time" || j.uint("version").map_err(fail)? != 1 { + return Err(fail("the output is not KAB1-time version 1".to_owned())); + } + if j.str("writer").map_err(fail)? != p.imp.name() { + return Err(fail(format!( + "the output's writer is {:?}, expected {}", + j.str("writer").unwrap_or("?"), + p.imp.name() + ))); + } + if j.str("tree").map_err(fail)? != p.tree { + return Err(fail(format!( + "the process ran the {} tree, the cell asks for {}", + j.str("tree").unwrap_or("?"), + p.tree + ))); + } + if j.str("manifest_sha256").map_err(fail)? != expect.manifest_sha { + return Err(fail("manifest_sha256 differs from the run directory's".to_owned())); + } + let c = j.req("case").map_err(fail)?; + if c.str("id").map_err(fail)? != expect.case || c.str("input_sha256").map_err(fail)? != expect.input_sha { + return Err(fail("the case id or its input hash differs from the manifest's".to_owned())); + } + let pin = j.req("pin").map_err(fail)?; + if pin.uint("cpu").map_err(fail)? as usize != expect.pin { + return Err(fail(format!("pinned to CPU {}, expected {}", pin.uint("cpu").unwrap_or(u64::MAX), expect.pin))); + } + let want_env: BTreeMap = cell_env(p).into_iter().collect(); + let mut seen_env = BTreeMap::new(); + if let Json::Obj(items) = j.req("effective_env").map_err(fail)? { + for (k, v) in items { + seen_env.insert( + k.clone(), + match v { + Json::Str(s) => s.clone(), + Json::Num(n) => n.clone(), + _ => "?".to_owned(), + }, + ); + } + } + if seen_env != want_env { + return Err(fail(format!("effective environment {seen_env:?} differs from the cell's {want_env:?}"))); + } + let mut regimes = BTreeMap::new(); + for r in j.array("regimes").map_err(fail)? { + let label = r.str("regime").map_err(fail)?.to_owned(); + regimes.insert(label, parse_regime(r, p.imp).map_err(fail)?); + } + for want in ["RESIDENT", "STREAMED"] { + if !regimes.contains_key(want) { + return Err(fail(format!("regime {want} is missing"))); + } + } + let clock = j.req("clock_calibration").map_err(fail)?; + let sibling_idle = match pin.req("sibling_cpu").map_err(fail)? { + Json::Null => Some(true), + _ => pin.float_or_null("sibling_busy_fraction_during_run").map_err(fail)?.map(|f| f < SIBLING_BUSY_LIMIT), + }; + let detail = j.req("tree_detail").map_err(fail)?; + let (tree_text, cpu_report) = if p.imp == Impl::Rust { + let report: Vec = detail + .array("cpu_report") + .map_err(fail)? + .iter() + .filter_map(|l| if let Json::Str(s) = l { Some(s.clone()) } else { None }) + .collect(); + let line = report + .iter() + .find(|l| l.starts_with("cpu: process kernel family")) + .cloned() + .ok_or_else(|| fail("no process kernel family line".to_owned()))?; + (format!("leleka-serve {line}"), report) + } else { + (describe_cpp_tree(detail), Vec::new()) + }; + let cpu_model = (!cpu_report.is_empty()).then(|| cpu_model_of(&cpu_report)); + Ok(ProcOut { + proc: *p, + regimes, + ghz_start: clock.float("ghz_at_start").map_err(fail)?, + ghz_end: clock.float("ghz_at_end").map_err(fail)?, + sibling_idle, + final_unchanged: j.flag("final_output_unchanged").map_err(fail)?, + output_sha: j.get("output_sha256").and_then(|v| if let Json::Str(s) = v { Some(s.clone()) } else { None }), + tree_text, + cpu_model, + }) +} +impl Kind { + pub(super) fn slug(self) -> &'static str { + match self { + Kind::Ab => "ab", + Kind::AaCpp => "aa-cpp", + Kind::AaRust => "aa-rust", + } + } +} + +pub(super) fn side_stat(r: &RegimeStat, cycles: bool) -> SideStat { + let v = if cycles { &r.cycles } else { &r.ns }; + SideStat { + median: if cycles { r.median_cycles } else { r.median_ns }, + p05: percentile_of(v, 0.05), + p95: percentile_of(v, 0.95), + } +} + +pub(super) fn stat_json(s: &SideStat) -> String { + format!("{{\"median\": {}, \"p05\": {}, \"p95\": {}}}", jnum(s.median, 6), jnum(s.p05, 6), jnum(s.p95, 6)) +} + +pub(super) fn tool_json(t: &Tool) -> String { + format!( + "{{\"compiler\": {}, \"version\": {}, \"target_triple\": {}, \"flags\": {}}}", + jstr(&t.compiler), + jstr(&t.version), + jstr(&t.triple), + jstr(&t.flags) + ) +} + +pub(super) fn equality_block(c: &CaseEntry, o: &Outcome) -> String { + let tolerance = c.tolerance.as_ref().map_or(String::new(), |t| { + format!( + ",\n \"tolerance\": {{\"value\": {:e}, \"basis\": {}, \"basis_written_utc\": {}}}", + t.value, + jstr(&format!("{} [metric: {TOLERANCE_METRIC}]", t.basis)), + jstr(&t.basis_written_utc) + ) + }); + format!( + "{{\n \"mode\": \"{}\",\n \"verdict\": \"{}\",\n \"compared_values\": {},\n \"mismatches\": {}{tolerance}\n }}", + if c.tolerance.is_some() { "tolerance" } else { "bitwise" }, + if o.equal() { "EQUAL" } else { "NOT_EQUAL" }, + o.compared, + o.mismatches + ) +} + +/// The A/A equality: the same implementation in two fresh processes. Rust: the output hashes of the two processes (and each one's +/// selfcheck); C++: each process's timed composition equals `compose_expert()` bit for bit (selfcheck), which is the same function. +pub(super) fn aa_outcome(a: &ProcOut, b: &ProcOut, rows: usize) -> (Outcome, String) { + let compared = rows * H; + let selfchecks = + a.regimes.values().chain(b.regimes.values()).all(|r| r.selfcheck) && a.final_unchanged && b.final_unchanged; + let same = selfchecks && (a.proc.imp == Impl::Cpp || (a.output_sha.is_some() && a.output_sha == b.output_sha)); + let note = if a.proc.imp == Impl::Cpp { + "selfcheck of both processes against compose_expert()" + } else { + "output sha256 of both processes" + }; + let outcome = Outcome { + compared, + mismatches: usize::from(!same), + differing_bits: usize::from(!same), + max_abs_error: 0.0, + first_mismatch: None, + }; + (outcome, note.to_owned()) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/gate_up_row_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/gate_up_row_fn.rs new file mode 100644 index 00000000..35e1414e --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/gate_up_row_fn.rs @@ -0,0 +1,94 @@ +//! Moved out of the parent module by STRA-338: fn gate_up_row, fn down_row, impl Refusal, impl std_fmt_Display, fn sha_hex, fn take_buffer .... + +#[allow(unused_imports)] +use super::*; + + +pub(super) fn gate_up_row(id: i32) -> Option<&'static (i32, GateUpFormat, usize, usize, &'static str)> { + GATE_UP.iter().find(|r| r.0 == id) +} +pub(super) fn down_row(id: i32) -> Option<&'static (i32, DownFormat, usize, usize, &'static str)> { + DOWN.iter().find(|r| r.0 == id) +} +impl Refusal { + pub(super) fn new(file: &str, reason: impl Into) -> Self { + Self { file: file.to_owned(), reason: reason.into(), incomplete: false } + } +} +impl std::fmt::Display for Refusal { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.incomplete { + write!(f, "incomplete directory: {}: {}", self.file, self.reason) + } else { + write!(f, "REFUSED {}: {}", self.file, self.reason) + } + } +} + +// ------------------------------------------------------------------------------------------------ helpers + +pub(super) fn sha_hex(bytes: &[u8]) -> String { + let digest = Sha256::digest(bytes); + digest.iter().map(|b| format!("{b:02x}")).collect() +} + +/// The only place a buffer is taken from a length that came from a file; every caller validates the length first. +pub(super) fn take_buffer(len: usize) -> Result, String> { + BUFFERS.with(|c| c.set(c.get() + 1)); + let mut v = Vec::new(); + v.try_reserve_exact(len).map_err(|_| format!("a buffer of {len} bytes was refused"))?; + v.resize(len, 0); + Ok(v) +} + +/// Little-endian words of a byte slice (a trailing partial word is ignored; callers pass exact multiples). +pub(super) fn words_le(bytes: &[u8]) -> Vec { + bytes.as_chunks::<4>().0.iter().map(|c| u32::from_le_bytes(*c)).collect() +} + +pub(super) fn le32(b: &[u8], at: usize) -> u32 { + u32::from_le_bytes([b[at], b[at + 1], b[at + 2], b[at + 3]]) +} + +pub(super) fn civil_from_days(z: i64) -> (i64, u32, u32) { + let z = z + 719_468; + let era = z.div_euclid(146_097); + let doe = z.rem_euclid(146_097); + let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; + let y = yoe + era * 400; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let d = (doy - (153 * mp + 2) / 5 + 1) as u32; + let m = if mp < 10 { mp + 3 } else { mp - 9 } as u32; + (if m <= 2 { y + 1 } else { y }, m, d) +} + +pub(super) fn utc_of(secs: u64) -> String { + let (y, m, d) = civil_from_days((secs / 86_400) as i64); + let s = secs % 86_400; + format!("{y:04}-{m:02}-{d:02}T{:02}:{:02}:{:02}Z", s / 3600, s % 3600 / 60, s % 60) +} + +pub(super) fn now_utc() -> String { + utc_of(SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |d| d.as_secs())) +} + +pub(super) fn is_utc(s: &str) -> bool { + let b = s.as_bytes(); + b.len() == 20 + && b.iter().enumerate().all(|(i, c)| match i { + 4 | 7 => *c == b'-', + 10 => *c == b'T', + 13 | 16 => *c == b':', + 19 => *c == b'Z', + _ => c.is_ascii_digit(), + }) +} + +pub(super) fn is_hex(s: &str, min: usize, max: usize) -> bool { + (min..=max).contains(&s.len()) && s.bytes().all(|c| c.is_ascii_digit() || (b'a'..=b'f').contains(&c)) +} + +pub(super) fn valid_id(id: &str) -> bool { + !id.is_empty() && id.len() <= 64 && id.bytes().all(|c| c.is_ascii_alphanumeric() || c == b'-' || c == b'_') +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/impl_impl.rs b/crates/native-cpu-expert/examples/kernel_ab/impl_impl.rs new file mode 100644 index 00000000..8b92a407 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/impl_impl.rs @@ -0,0 +1,228 @@ +//! Moved out of the parent module by STRA-338: impl Impl, impl Proc, fn procs_for, fn cell_env, fn scrubbed_command, fn run_cell .... + +#[allow(unused_imports)] +use super::*; + +impl Impl { + pub(super) fn name(self) -> &'static str { + match self { + Impl::Cpp => "cpp", + Impl::Rust => "rust", + } + } +} +impl Proc { + pub(super) fn name(&self) -> String { + format!("{}-{}-{}", self.imp.name(), self.tree, self.rep) + } + pub(super) fn parse(s: &str) -> Option { + let mut p = s.split('-'); + let imp = match p.next()? { + "cpp" => Impl::Cpp, + "rust" => Impl::Rust, + _ => return None, + }; + let wanted = p.next()?; + let tree = *TREES.iter().find(|t| **t == wanted)?; + let rep = match p.next()? { + "a" => 'a', + "b" => 'b', + _ => return None, + }; + p.next().is_none().then_some(Proc { imp, tree, rep }) + } +} + +/// Every process of a round for the given trees, in canonical order. +pub(super) fn procs_for(trees: &[&'static str]) -> Vec { + let mut v = Vec::new(); + for imp in [Impl::Cpp, Impl::Rust] { + for tree in trees { + for rep in ['a', 'b'] { + v.push(Proc { imp, tree, rep }); + } + } + } + v +} + +/// The environment a cell needs and nothing else. The avx2 trees set `STRATA_FORCE_AVX2=1`, which both implementations honour. The +/// Rust cells run `DirectCpuPool::new(1)`, a worker thread plus the draining caller, both confined to the one pinned CPU: the pool must +/// not re-pin its caller (`LELEKA_CPU_POOL_PIN_HOST=off`, so the pin is the requested one) and its worker must not spin after a batch +/// (`STRATA_POOL_SPIN_US=0`; with the 20 ms default the worker spins on the caller's only CPU and costs it half its time). +pub(super) fn cell_env(p: &Proc) -> Vec<(String, String)> { + let mut v = Vec::new(); + if p.tree == "avx2" { + v.push(("STRATA_FORCE_AVX2".to_owned(), "1".to_owned())); + } + if p.imp == Impl::Rust { + v.push(("LELEKA_CPU_POOL_PIN_HOST".to_owned(), "off".to_owned())); + v.push(("STRATA_POOL_SPIN_US".to_owned(), "0".to_owned())); + } + v.sort(); + v +} + +/// A command whose environment is exactly: the parent's variables minus every STRATA_* / LELEKA_* one, plus the cell's variables. +pub(super) fn scrubbed_command(program: &Path, parent_env: &[(OsString, OsString)], cell: &[(String, String)]) -> Command { + let mut c = Command::new(program); + c.env_clear(); + for (k, v) in parent_env { + if !is_managed_name(&k.to_string_lossy()) { + c.env(k, v); + } + } + for (k, v) in cell { + c.env(k, v); + } + c +} + +/// Runs a prepared cell command; a failure names the cell. +pub(super) fn run_cell(cmd: &mut Command, cell: &str) -> Result { + let out = cmd.output().map_err(|e| format!("cell {cell}: cannot start the process: {e}"))?; + if out.status.success() { + return Ok(out); + } + let tail = |b: &[u8]| { + String::from_utf8_lossy(b) + .lines() + .rev() + .take(3) + .collect::>() + .into_iter() + .rev() + .collect::>() + .join(" | ") + }; + Err(format!( + "cell {cell} failed ({}): stderr: {}; stdout: {}", + out.status.code().map_or("killed by a signal".to_owned(), |c| format!("exit {c}")), + tail(&out.stderr), + tail(&out.stdout) + )) +} + +pub(super) fn splitmix(state: &mut u64) -> u64 { + *state = state.wrapping_add(0x9E37_79B9_7F4A_7C15); + let mut z = *state; + z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); + z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); + z ^ (z >> 31) +} + +/// The schedule of one batch: round `i` (0-based) rotates a seeded permutation by `i mod n`; every block of `n` rounds draws a fresh +/// permutation, so each process takes each position equally often within a block. A pure function of (seed, batch, rounds, procs). +pub(super) fn make_schedule(seed: u64, batch: u32, rounds: u32, procs: &[Proc]) -> Vec> { + let n = procs.len(); + let mut out = Vec::new(); + let mut base: Vec = Vec::new(); + for i in 0..rounds as usize { + if i % n == 0 { + let mut st = seed; + for x in [u64::from(batch), (i / n) as u64] { + st = st.wrapping_add(x.wrapping_mul(0x9E37_79B9_7F4A_7C15)); + st = splitmix(&mut st); + } + base = procs.to_vec(); + for j in (1..n).rev() { + let k = (splitmix(&mut st) % (j as u64 + 1)) as usize; + base.swap(j, k); + } + } + let mut order = base.clone(); + order.rotate_left(i % n); + out.push(order); + } + out +} + +pub(super) fn schedule_text( + seed: u64, + batch: u32, + rounds: u32, + case: &str, + pin: usize, + first_round: u32, + order: &[Vec], +) -> String { + let mut t = format!( + "{SCHEDULE_MAGIC} (written before the first run; the runner reads this file back)\n# seed={seed} batch={batch} rounds={rounds} case={case} pin={pin}\n" + ); + for (i, o) in order.iter().enumerate() { + t += &format!("{}\t{}\n", first_round + i as u32, o.iter().map(Proc::name).collect::>().join(",")); + } + t +} + +/// Reads a schedule back: (round number, processes in order) per round. Every round must name each process of the first round once. +pub(super) fn parse_schedule(text: &str) -> Result)>, String> { + let mut lines = text.lines(); + if !lines.next().is_some_and(|l| l.starts_with(SCHEDULE_MAGIC)) { + return Err("not a KAB1-alt schedule".to_owned()); + } + let mut rounds: Vec<(u32, Vec)> = Vec::new(); + for l in lines.filter(|l| !l.starts_with('#') && !l.is_empty()) { + let (no, list) = l.split_once('\t').ok_or_else(|| format!("bad schedule line {l:?}"))?; + let no = no.parse::().map_err(|_| format!("bad round number in {l:?}"))?; + let order: Vec = list + .split(',') + .map(|n| Proc::parse(n).ok_or_else(|| format!("unknown process {n:?} in the schedule"))) + .collect::>()?; + if let Some(prev) = rounds.last() + && (no != prev.0 + 1 + || BTreeSet::from_iter(order.iter()) != BTreeSet::from_iter(prev.1.iter()) + || order.len() != prev.1.len()) + { + return Err(format!("round {no} does not follow round {} with the same processes", prev.0)); + } + rounds.push((no, order)); + } + if rounds.is_empty() { + return Err("the schedule has no round".to_owned()); + } + Ok(rounds) +} + +/// Refuses a path that is, or lies inside, a Git checkout (generated artifacts stay out of Git). +pub(super) fn inside_git_checkout(path: &Path) -> bool { + let abs = std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()); + abs.ancestors().any(|a| a.join(".git").exists()) +} + +pub(super) fn parse_regime(r: &Json, imp: Impl) -> Result { + let mut ns = Vec::new(); + let mut cycles = Vec::new(); + let mut max_drift = 0.0f64; + for (key, keep) in [("slices", true), ("dropped", false)] { + for s in r.array(key)? { + let (g0, g1) = (s.float("ghz_before")?, s.float("ghz_after")?); + if g0 > 0.0 { + max_drift = max_drift.max(((g1 - g0).abs() / g0).min(1.0)); + } + if keep { + ns.push(s.float("ns_per_call")?); + cycles.push(s.float("cycles_per_call")?); + } + } + } + let selfcheck_key = + if imp == Impl::Cpp { "selfcheck_bitwise_equal_compose_expert" } else { "selfcheck_bitwise_equal_first_call" }; + let kept = r.uint("slices_kept")? as usize; + if kept != ns.len() || kept == 0 { + return Err(format!("slices_kept {kept} disagrees with the {} kept slices (or none was kept)", ns.len())); + } + Ok(RegimeStat { + copies_k: r.uint("copies_k")? as usize, + expert_bytes: r.uint("expert_bytes")? as usize, + llc_bytes: r.uint("llc_bytes")?, + requested: r.uint("slices_requested")? as usize, + dropped: r.uint("dropped_count")? as usize, + median_ns: r.float("median_ns_per_call")?, + median_cycles: r.float("median_cycles_per_call")?, + ns, + cycles, + max_drift, + selfcheck: r.flag(selfcheck_key)?, + }) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/impl_parser.rs b/crates/native-cpu-expert/examples/kernel_ab/impl_parser.rs new file mode 100644 index 00000000..e976cd8c --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/impl_parser.rs @@ -0,0 +1,234 @@ +//! Moved out of the parent module by STRA-338: impl Parser, fn parse_json, impl Json, impl InHeader. + +#[allow(unused_imports)] +use super::*; + + +impl Parser<'_> { + pub(super) fn ws(&mut self) { + while self.at < self.b.len() && matches!(self.b[self.at], b' ' | b'\t' | b'\n' | b'\r') { + self.at += 1; + } + } + pub(super) fn err(&self, what: &str) -> Result { + Err(format!("JSON error at byte {}: {what}", self.at)) + } + pub(super) fn lit(&mut self, word: &str, v: Json) -> Result { + if self.b[self.at..].starts_with(word.as_bytes()) { + self.at += word.len(); + Ok(v) + } else { + self.err("unknown literal") + } + } + pub(super) fn hex4(&mut self) -> Result { + if self.at + 4 > self.b.len() { + return self.err("short \\u escape"); + } + let s = std::str::from_utf8(&self.b[self.at..self.at + 4]).map_err(|_| "bad \\u escape".to_owned())?; + let v = u32::from_str_radix(s, 16).map_err(|_| "bad \\u escape".to_owned())?; + self.at += 4; + Ok(v) + } + pub(super) fn string(&mut self) -> Result { + self.at += 1; + let mut out: Vec = Vec::new(); + loop { + let Some(&c) = self.b.get(self.at) else { return self.err("unterminated string") }; + self.at += 1; + match c { + b'"' => return String::from_utf8(out).map_err(|_| "string is not UTF-8".to_owned()), + b'\\' => { + let Some(&e) = self.b.get(self.at) else { return self.err("unterminated escape") }; + self.at += 1; + let ch = match e { + b'"' => '"', + b'\\' => '\\', + b'/' => '/', + b'b' => '\u{8}', + b'f' => '\u{c}', + b'n' => '\n', + b'r' => '\r', + b't' => '\t', + b'u' => { + let hi = self.hex4()?; + let cp = if (0xD800..0xDC00).contains(&hi) { + if !self.b[self.at..].starts_with(b"\\u") { + return self.err("lone surrogate"); + } + self.at += 2; + let lo = self.hex4()?; + if !(0xDC00..0xE000).contains(&lo) { + return self.err("lone surrogate"); + } + 0x10000 + ((hi - 0xD800) << 10) + (lo - 0xDC00) + } else { + hi + }; + match char::from_u32(cp) { + Some(c) => c, + None => return self.err("lone surrogate"), + } + } + _ => return self.err("unknown escape"), + }; + let mut buf = [0u8; 4]; + out.extend_from_slice(ch.encode_utf8(&mut buf).as_bytes()); + } + 0..=0x1f => return self.err("control character in string"), + _ => out.push(c), + } + } + } + pub(super) fn number(&mut self) -> Result { + let start = self.at; + while self.at < self.b.len() && matches!(self.b[self.at], b'-' | b'+' | b'.' | b'e' | b'E' | b'0'..=b'9') { + self.at += 1; + } + let text = std::str::from_utf8(&self.b[start..self.at]).map_err(|_| "bad number".to_owned())?; + if text.parse::().is_err() { + return self.err("bad number"); + } + Ok(Json::Num(text.to_owned())) + } + pub(super) fn value(&mut self, depth: usize) -> Result { + if depth > 32 { + return self.err("nesting deeper than 32"); + } + self.ws(); + match self.b.get(self.at) { + None => self.err("unexpected end"), + Some(b'{') => { + self.at += 1; + let mut items: Vec<(String, Json)> = Vec::new(); + self.ws(); + if self.b.get(self.at) == Some(&b'}') { + self.at += 1; + return Ok(Json::Obj(items)); + } + loop { + self.ws(); + if self.b.get(self.at) != Some(&b'"') { + return self.err("object key expected"); + } + let key = self.string()?; + if items.iter().any(|(k, _)| *k == key) { + return self.err(&format!("duplicate key {key:?}")); + } + self.ws(); + if self.b.get(self.at) != Some(&b':') { + return self.err("':' expected"); + } + self.at += 1; + let v = self.value(depth + 1)?; + items.push((key, v)); + self.ws(); + match self.b.get(self.at) { + Some(b',') => self.at += 1, + Some(b'}') => { + self.at += 1; + return Ok(Json::Obj(items)); + } + _ => return self.err("',' or '}' expected"), + } + } + } + Some(b'[') => { + self.at += 1; + let mut items = Vec::new(); + self.ws(); + if self.b.get(self.at) == Some(&b']') { + self.at += 1; + return Ok(Json::Arr(items)); + } + loop { + items.push(self.value(depth + 1)?); + self.ws(); + match self.b.get(self.at) { + Some(b',') => self.at += 1, + Some(b']') => { + self.at += 1; + return Ok(Json::Arr(items)); + } + _ => return self.err("',' or ']' expected"), + } + } + } + Some(b'"') => Ok(Json::Str(self.string()?)), + Some(b't') => self.lit("true", Json::Bool(true)), + Some(b'f') => self.lit("false", Json::Bool(false)), + Some(b'n') => self.lit("null", Json::Null), + Some(b'-' | b'0'..=b'9') => self.number(), + Some(_) => self.err("unexpected character"), + } + } +} + +pub(super) fn parse_json(bytes: &[u8]) -> Result { + let mut p = Parser { b: bytes, at: 0 }; + let v = p.value(0)?; + p.ws(); + if p.at != bytes.len() { + return p.err("trailing data"); + } + Ok(v) +} + +impl Json { + pub(super) fn get(&self, key: &str) -> Option<&Json> { + match self { + Json::Obj(items) => items.iter().find(|(k, _)| k == key).map(|(_, v)| v), + _ => None, + } + } + pub(super) fn req(&self, key: &str) -> Result<&Json, String> { + self.get(key).ok_or_else(|| format!("missing key {key:?}")) + } + pub(super) fn str(&self, key: &str) -> Result<&str, String> { + match self.req(key)? { + Json::Str(s) => Ok(s), + _ => Err(format!("key {key:?} is not a string")), + } + } + pub(super) fn uint(&self, key: &str) -> Result { + match self.req(key)? { + Json::Num(n) => n.parse::().map_err(|_| format!("key {key:?} is not an unsigned integer")), + _ => Err(format!("key {key:?} is not a number")), + } + } + pub(super) fn float(&self, key: &str) -> Result { + match self.req(key)? { + Json::Num(n) => n + .parse::() + .ok() + .filter(|v| v.is_finite()) + .ok_or_else(|| format!("key {key:?} is not a finite number")), + _ => Err(format!("key {key:?} is not a number")), + } + } + /// A number, or None for a JSON null (the C++ writer prints null for a value it could not measure). + pub(super) fn float_or_null(&self, key: &str) -> Result, String> { + match self.req(key)? { + Json::Null => Ok(None), + _ => self.float(key).map(Some), + } + } + pub(super) fn flag(&self, key: &str) -> Result { + match self.req(key)? { + Json::Bool(b) => Ok(*b), + _ => Err(format!("key {key:?} is not a boolean")), + } + } + pub(super) fn array(&self, key: &str) -> Result<&[Json], String> { + match self.req(key)? { + Json::Arr(a) => Ok(a), + _ => Err(format!("key {key:?} is not an array")), + } + } +} + +impl InHeader { + pub(super) fn input_at(&self) -> usize { + IN_HEADER + self.gate + self.up + self.down_bytes + } +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/llc_of_cpu_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/llc_of_cpu_fn.rs new file mode 100644 index 00000000..22d8a253 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/llc_of_cpu_fn.rs @@ -0,0 +1,189 @@ +//! Moved out of the parent module by STRA-338: fn llc_of_cpu, fn proc_stat_cpu, fn busy_fraction, fn current_cpu, fn observed_threads, fn is_managed_name .... + +#[allow(unused_imports)] +use super::*; + + +/// Linux: the highest-level data or unified cache of `cpu` from sysfs. Elsewhere: None (the caller passes `--llc-bytes`). +pub(super) fn llc_of_cpu(cpu: usize) -> Option { + let mut best: Option = None; + for i in 0..16 { + let d = format!("/sys/devices/system/cpu/cpu{cpu}/cache/index{i}"); + let (level, kind, size) = + (read_text(&format!("{d}/level")), read_text(&format!("{d}/type")), read_text(&format!("{d}/size"))); + if level.is_empty() || size.is_empty() || kind == "Instruction" { + continue; + } + let level_n = level.parse::().unwrap_or(0); + if best.as_ref().is_none_or(|b| level_n >= b.level) { + best = Some(Llc { level: level_n, bytes: parse_size(&size), source: format!("{d}/size = {size}") }); + } + } + best.filter(|l| l.bytes > 0) +} + +/// (busy, total) jiffies of one logical CPU from /proc/stat (Linux). +pub(super) fn proc_stat_cpu(cpu: usize) -> Option<(u64, u64)> { + let stat = fs::read_to_string("/proc/stat").ok()?; + let line = stat.lines().find(|l| l.starts_with(&format!("cpu{cpu} ")))?; + let f: Vec = line.split_whitespace().skip(1).filter_map(|x| x.parse().ok()).collect(); + let total: u64 = f.iter().take(8).sum(); + Some((total - f.get(3)? - f.get(4).copied().unwrap_or(0), total)) +} + +pub(super) fn busy_fraction(before: Option<(u64, u64)>, after: Option<(u64, u64)>) -> Option { + let (b, a) = (before?, after?); + (a.1 > b.1).then(|| (a.0.saturating_sub(b.0)) as f64 / (a.1 - b.1) as f64) +} + +/// Linux: the logical CPU the calling thread last ran on (field 39 of /proc/thread-self/stat). Elsewhere: None. +pub(super) fn current_cpu() -> Option { + if !cfg!(target_os = "linux") { + return None; + } + let s = fs::read_to_string("/proc/thread-self/stat").ok()?; + let rest = &s[s.rfind(')')? + 1..]; + rest.split_whitespace().nth(36)?.parse().ok() +} + +/// Linux: every thread of this process with the CPU it last ran on (the pool's worker is one of them). +pub(super) fn observed_threads() -> Vec<(String, Option)> { + let mut v = Vec::new(); + if let Ok(dir) = fs::read_dir("/proc/self/task") { + for e in dir.flatten() { + let p = e.path(); + let name = read_text(&format!("{}/comm", p.display())); + let cpu = fs::read_to_string(p.join("stat")) + .ok() + .and_then(|s| s.get(s.rfind(')')? + 1..)?.split_whitespace().nth(36)?.parse().ok()); + v.push((name, cpu)); + } + } + v.sort(); + v +} + +pub(super) fn is_managed_name(name: &str) -> bool { + let up = name.to_ascii_uppercase(); + up.starts_with("STRATA_") || up.starts_with("LELEKA_") +} + +/// Every STRATA_* / LELEKA_* variable the process sees. +pub(super) fn managed_env_now() -> BTreeMap { + std::env::vars_os() + .filter_map(|(k, v)| Some((k.into_string().ok()?, v.into_string().ok()?))) + .filter(|(k, _)| is_managed_name(k)) + .collect() +} + +pub(super) fn json_env(env: &BTreeMap) -> String { + format!("{{{}}}", env.iter().map(|(k, v)| format!("{}: {}", jstr(k), jstr(v))).collect::>().join(", ")) +} + +/// The command line of `kab time` (STRA-317), checked the same way. +pub(super) fn parse_time_args(args: &[String]) -> Result { + let f = Flags::parse(args, &TIME_FLAGS)?; + let slices = f.number::("slices")?.ok_or("--slices is required")?; + let pin = f.number::("pin")?.ok_or("--pin is required")?; + let slice_ms = f.number::("slice-ms")?.unwrap_or(DEFAULT_SLICE_MS); + if !(1..=100_000).contains(&slices) { + return Err("--slices must be 1..100000".to_owned()); + } + if !(1.0..=10_000.0).contains(&slice_ms) { + return Err("--slice-ms must be 1..10000".to_owned()); + } + let regime = match f.get("regime").unwrap_or("both") { + "both" => RegimeSel::Both, + "resident" => RegimeSel::Resident, + "streamed" => RegimeSel::Streamed, + _ => return Err("--regime must be both, resident or streamed".to_owned()), + }; + let case = f.req("case")?.to_owned(); + if !valid_id(&case) { + return Err(format!("--case {case:?} is not a plain identifier")); + } + Ok(TimeArgs { + dir: PathBuf::from(f.req("run-dir")?), + case, + slices, + pin, + out: PathBuf::from(f.req("out")?), + slice_ms, + regime, + llc_bytes: f.number::("llc-bytes")?, + }) +} +impl Arena { + pub(super) fn new(len: usize) -> Self { + let size = std::mem::size_of::(); + let buf = vec![T::default(); len + ALIGN / size]; + let misalign = buf.as_ptr() as usize % ALIGN; + let off = if misalign == 0 { 0 } else { (ALIGN - misalign) / size }; + Self { buf, off } + } + pub(super) fn slice(&self, len: usize) -> &[T] { + &self.buf[self.off..self.off + len] + } + pub(super) fn slice_mut(&mut self, len: usize) -> &mut [T] { + &mut self.buf[self.off..self.off + len] + } +} + +impl Timed<'_> { + pub(super) fn call(&mut self, weights: &[u8]) -> Result<(), String> { + let (g, u) = (self.header.gate, self.header.up); + let expert = BorrowedExpert { + gate: &weights[..g], + up: &weights[g..g + u], + down: &weights[g + u..g + u + self.header.down_bytes], + pairs: &self.pairs, + }; + let experts = [expert]; + let group = BorrowedGroup { tokens: self.tokens, experts: &experts, stride: 1 }; + self.pool + .compute_group(self.gu, self.down, &group, &mut self.out) + .map_err(|e| format!("compute_group failed: {e:?}")) + } +} + +/// One slice of `ms` milliseconds cycling over the copies; the shape of `time_slice()` in tq_cpu_parity.cpp (lines 290-304). +pub(super) fn time_slice(t: &mut Timed, copies: &[&[u8]], ms: f64, next: &mut usize) -> Result { + let ghz_before = core_ghz(); + let mut calls = 0u64; + let ns0 = mono_ns(); + let mut ns1; + loop { + t.call(copies[*next % copies.len()])?; + *next += 1; + calls += 1; + ns1 = mono_ns(); + if (ns1 - ns0) as f64 >= ms * 1e6 && calls >= 2 { + break; + } + } + let ghz_after = core_ghz(); + let wall = ns1 - ns0; + let ns_per_call = wall as f64 / calls as f64; + let ghz_mean = 0.5 * (ghz_before + ghz_after); + Ok(Slice { + calls, + wall_ns: wall, + ns_per_call, + ghz_before, + ghz_after, + cycles_per_call: ns_per_call * ghz_mean, + moved: ghz_mean > 0.0 && (ghz_after - ghz_before).abs() > CLOCK_MOVED_FRACTION * ghz_before, + }) +} + +pub(super) fn slice_json(s: &Slice, idx: usize) -> String { + format!( + "{{\"i\": {idx}, \"calls\": {}, \"wall_ns\": {}, \"ns_per_call\": {}, \"ghz_before\": {}, \"ghz_after\": {}, \"cycles_per_call\": {}}}", + s.calls, + s.wall_ns, + jnum(s.ns_per_call, 3), + jnum(s.ghz_before, 6), + jnum(s.ghz_after, 6), + jnum(s.cycles_per_call, 1) + ) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/main.rs b/crates/native-cpu-expert/examples/kernel_ab/main.rs new file mode 100644 index 00000000..ce48f928 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/main.rs @@ -0,0 +1,1635 @@ +#![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] +// This file is its own lint gate: `cargo clippy -- -D warnings` also lints the other workspace crates, which carry warnings of their own. +#![deny(warnings, clippy::all)] +//! Rust half of the CPU kernel A/B, part 1 (STRA-289, S0.8b): the KAB1 reader, the comparison against the C++ reference outputs and +//! the COMPONENT_KERNEL record writer. The C++ driver (`tools/kernel-ab`, STRA-248) writes a run directory `D`; this example only +//! reads it. C++ and Rust meet through files: no FFI, no unsafe, public API of the crate only, no module in the production library. +//! +//! kernel_ab verify D the reader rule: manifest, every sha256 and length, header-derived sizes, finite +//! FP16 block headers and activations; any mismatch refuses the WHOLE directory +//! kernel_ab compare D [--out R] [--pin CPU] [--machine-role NAME] [--trees avx512,avx2] +//! verify D, run our trees in fresh processes (`run-tree`), compare with the C++ +//! `.out` files (bitwise on the f32 bit patterns, or the tolerance the manifest case +//! declares with its basis), write `R/case-.rust-.out` and one +//! COMPONENT_KERNEL record per case and tree to `R/records/` +//! kernel_ab run-tree D --tree T --out R [--pin CPU] [--case ID] +//! internal: one fresh process, one tree (T = avx512 | avx2), all cases or only ID +//! +//! Timing is not in `verify` / `compare`. The records written by `compare` carry the fields the schema requires for timing with the +//! explicit NOT_MEASURED marker (see `NOT_MEASURED`), never a measurement. Timing is the second half (STRA-318, S0.8b2): +//! +//! kernel_ab time --run-dir D --case ID --slices N --pin CPU --out F.json [--slice-ms 60] [--regime both|resident|streamed] +//! [--llc-bytes B] +//! the Rust twin of `kab time` (tools/kernel-ab, STRA-317): ONE fresh process times ONE +//! case in the resident and the streamed regime on the pinned CPU and writes the KAB1-time +//! JSON (writer "rust"); no statistics +//! kernel_ab alternate --run-dir D --case ID --rounds N --batch K --pin CPU --schedule FILE [--seed S] [--out R] [--slices N] +//! [--slice-ms MS] [--llc-bytes B] [--machine-role NAME] [--kab PATH] +//! the alternation runner (ARCHITECT 395f0394 sec 1.3): std::process::Command only. Per +//! round it starts FRESH processes for the cells {cpp, rust} x {avx512, avx2} (each twice, +//! a and b, for the A/A pairs) in the order of a seeded schedule file written before the +//! first run, and writes COMPONENT_KERNEL round records. It computes NO statistics: no +//! class, no interval, no A/A verdict (those are S0.10b, STRA-313). +//! +//! cargo run --release -p leleka-native-cpu-expert --example kernel_ab -- compare D +//! cargo test -p leleka-native-cpu-expert --example kernel_ab + +use leleka_native_cpu_expert::{ + BorrowedExpert, BorrowedGroup, DirectCpuPool, DownFormat, GateUpFormat, PreparedJob, cpu_kernel_report, + rust_topology, +}; +use sha2::{Digest, Sha256}; +use std::cell::Cell; +use std::collections::{BTreeMap, BTreeSet}; +use std::ffi::OsString; +use std::fs::{self, File}; +use std::io::{Read, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Command, ExitCode}; +use std::sync::OnceLock; +use std::time::{Instant, SystemTime, UNIX_EPOCH}; + +const IN_MAGIC: u32 = 0x4942_414B; +const OUT_MAGIC: u32 = 0x4F42_414B; +const IN_HEADER: usize = 64; +const OUT_HEADER: usize = 20; +const H: usize = 2560; +const FF: usize = 640; +const MAX_ROWS: usize = 8; +/// Largest legitimate file of the format is about 2.7 MB; anything above this is refused before any buffer is taken. +const MAX_FILE_BYTES: u64 = 16 << 20; +const MAX_MANIFEST_BYTES: u64 = 8 << 20; +const MAX_CASES: usize = 1024; +const TOLERANCE_METRIC: &str = "max_abs_error_over_max_abs_reference"; +/// Marker of every schema-required timing field this part does not measure (STRA-318 fills them): a text marker where the schema takes +/// text, the smallest positive double (`5e-324`) where it takes a positive number, 1 where it takes a positive count. +const NOT_MEASURED: &str = "NOT_MEASURED (filled by STRA-318, the alternation runner)"; +const TREES: [&str; 2] = ["avx512", "avx2"]; + +thread_local! { static BUFFERS: Cell = const { Cell::new(0) }; } + +// ------------------------------------------------------------------------------------------------ formats + +/// (ggml id, format, block elements, block bytes, name) as `lib.rs kind()/block()`. +const GATE_UP: [(i32, GateUpFormat, usize, usize, &str); 7] = [ + (18, GateUpFormat::Iq3Xxs, 256, 98, "IQ3_XXS"), + (21, GateUpFormat::Iq3S, 256, 110, "IQ3_S"), + (22, GateUpFormat::Iq2S, 256, 82, "IQ2_S"), + (23, GateUpFormat::Iq4Xs, 256, 136, "IQ4_XS"), + (42, GateUpFormat::Q2_0, 64, 18, "Q2_0"), + (16, GateUpFormat::Iq2Xxs, 256, 66, "IQ2_XXS"), + (17, GateUpFormat::Iq2Xs, 256, 74, "IQ2_XS"), +]; +const DOWN: [(i32, DownFormat, usize, usize, &str); 2] = + [(20, DownFormat::Iq4Nl, 32, 18, "IQ4_NL"), (42, DownFormat::Q2_0, 64, 18, "Q2_0")]; + +// ------------------------------------------------------------------------------------------------ errors + +/// A refusal of the whole directory: names the file and says why. `incomplete` is the missing-manifest case. +#[derive(Debug)] +struct Refusal { + file: String, + reason: String, + incomplete: bool, +} + +// ------------------------------------------------------------------------------------------------ JSON (read) + +#[derive(Debug, Clone, PartialEq)] +enum Json { + Null, + Bool(bool), + Num(String), + Str(String), + Arr(Vec), + Obj(Vec<(String, Json)>), +} + +struct Parser<'a> { + b: &'a [u8], + at: usize, +} + +// ------------------------------------------------------------------------------------------------ KAB1 headers + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct InHeader { + gu: i32, + down: i32, + rows: usize, + gate: usize, + up: usize, + down_bytes: usize, +} + +// ------------------------------------------------------------------------------------------------ manifest + +#[derive(Debug, Clone, PartialEq)] +struct Tolerance { + value: f64, + basis: String, + basis_written_utc: String, +} + +#[derive(Debug, Clone)] +struct OutRef { + tree: &'static str, + name: String, + sha256: String, + bytes: u64, +} + +#[derive(Debug, Clone)] +struct CaseEntry { + id: String, + gu: i32, + down: i32, + rows: usize, + in_name: String, + in_sha256: String, + in_bytes: u64, + outs: Vec, + tolerance: Option, +} + +#[derive(Debug, Clone)] +struct Provenance { + run_id: String, + engine_strata_pin: String, + compiler_id: String, + compiler_version: String, + target_triple: String, + reference_flags: String, + avx512_ok: Option, +} + +#[derive(Debug)] +struct Verified { + dir: PathBuf, + manifest_sha256: String, + provenance: Provenance, + cases: Vec, + file_count: usize, +} + +type FileTable = Vec<(String, String, u64)>; + +// ------------------------------------------------------------------------------------------------ file readers + +#[derive(Debug)] +struct CaseIn { + header: InHeader, + blob: Vec, +} + +// ------------------------------------------------------------------------------------------------ compare + +#[derive(Debug, PartialEq)] +struct Outcome { + compared: usize, + mismatches: usize, + differing_bits: usize, + max_abs_error: f64, + first_mismatch: Option<(usize, u32, u32)>, +} + +struct RecordInput<'a> { + record_id: String, + created_utc: String, + run_started_utc: String, + machine_role: String, + cpu_model: String, + os: String, + ours_compiler: String, + ours_version: String, + ours_triple: String, + ours_flags: String, + tree: &'a str, + verified: &'a Verified, + case: &'a CaseEntry, + pin_cpu: usize, + sibling_idle: bool, + outcome: &'a Outcome, +} + +struct Options { + out: Option, + pin: usize, + machine_role: Option, + trees: Vec, + tree: Option, + case: Option, +} + +// ------------------------------------------------------------------------------------------------ flags (time, alternate) + +struct Flags(Vec<(String, String)>); + +// ------------------------------------------------------------------------------------------------ clocks and host facts + +/// The 60 ms slice of `tq_cpu_parity.cpp:461` (`slice_ms = quick ? 40 : 60`), the same value `kab time` uses. +const DEFAULT_SLICE_MS: f64 = 60.0; +/// `tq_cpu_parity.cpp:303`: a slice whose calibrated clock moved by more than this fraction is dropped. Copied, not chosen here. +const CLOCK_MOVED_FRACTION: f64 = 0.05; +/// An SMT sibling busier than this fraction is not idle (the 5 percent rule of `sibling_idle`). +const SIBLING_BUSY_LIMIT: f64 = 0.05; +const ALIGN: usize = 4096; +/// Cycles of one step of the calibration chain `x = (x * k) ^ (x >> 17)`: a 64-bit multiply (3 cycles on Intel Skylake to Golden Cove +/// and AMD Zen 1 to 5) then an xor (1 cycle); the shift runs beside the multiply. +const CHAIN_STEP_CYCLES: f64 = 4.0; +const CLOCK_METHOD: &str = "chain of dependent steps x = (x * k) ^ (x >> 17), 4 cycles per step (3 multiply + 1 xor), 1000000 iterations of 4 steps, ghz = 4 * 4e6 / (elapsed ns); before and after every slice"; + +struct Llc { + level: u32, + bytes: u64, + source: String, +} + +// ------------------------------------------------------------------------------------------------ time (one fresh process) + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +enum RegimeSel { + Both, + Resident, + Streamed, +} + +#[derive(Debug)] +struct TimeArgs { + dir: PathBuf, + case: String, + slices: usize, + pin: usize, + out: PathBuf, + slice_ms: f64, + regime: RegimeSel, + llc_bytes: Option, +} + +const TIME_FLAGS: [&str; 8] = ["run-dir", "case", "slices", "pin", "out", "slice-ms", "regime", "llc-bytes"]; + +/// A buffer whose usable part starts on a 4096-byte boundary. +struct Arena { + buf: Vec, + off: usize, +} + +/// The timed call: one group of one expert through the crate's public pool, exactly as `compute_case` does it. +struct Timed<'a> { + pool: DirectCpuPool, + gu: GateUpFormat, + down: DownFormat, + header: InHeader, + pairs: Vec<(usize, usize)>, + tokens: &'a [f32], + out: Vec, +} + +struct Slice { + calls: u64, + wall_ns: u64, + ns_per_call: f64, + ghz_before: f64, + ghz_after: f64, + cycles_per_call: f64, + moved: bool, +} + +/// Slices with their index within the regime. +type Numbered = Vec<(usize, Slice)>; + +struct RegimeRun { + json: String, + kept: usize, + ok: bool, +} + +struct RegimeSpec<'a> { + label: &'a str, + copies: Vec<&'a [u8]>, + expert_bytes: usize, + stride: usize, + llc: &'a Llc, + slices: usize, + slice_ms: f64, + pin: usize, + selfcheck: bool, +} + +// ------------------------------------------------------------------------------------------------ alternate: cells, environment, schedule + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +enum Impl { + Cpp, + Rust, +} + +/// One process of a round: an implementation, a tree and a replicate (`a` is the A/B process, `b` the A/A twin). +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +struct Proc { + imp: Impl, + tree: &'static str, + rep: char, +} + +const SCHEDULE_MAGIC: &str = "# KAB1-alt schedule v1"; + +// ------------------------------------------------------------------------------------------------ alternate: reading a process's JSON + +#[derive(Debug, Clone)] +struct RegimeStat { + copies_k: usize, + expert_bytes: usize, + llc_bytes: u64, + requested: usize, + dropped: usize, + median_ns: f64, + median_cycles: f64, + ns: Vec, + cycles: Vec, + max_drift: f64, + selfcheck: bool, +} + +#[derive(Debug, Clone)] +struct ProcOut { + proc: Proc, + regimes: BTreeMap, + ghz_start: f64, + ghz_end: f64, + /// None: unknown; Some(true): the sibling was idle (or there is none) under the 5 percent rule. + sibling_idle: Option, + final_unchanged: bool, + output_sha: Option, + tree_text: String, + cpu_model: Option, +} + +/// What a process's JSON must say about the run that produced it. +struct Expect<'a> { + manifest_sha: &'a str, + input_sha: &'a str, + case: &'a str, + pin: usize, +} + +// ------------------------------------------------------------------------------------------------ alternate: round records + +struct Tool { + compiler: String, + version: String, + triple: String, + flags: String, +} + +struct SideStat { + median: f64, + p05: f64, + p95: f64, +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +enum Kind { + Ab, + AaCpp, + AaRust, +} + +/// Everything a round record needs that does not change within a batch. +struct BatchCtx<'a> { + verified: &'a Verified, + case: &'a CaseEntry, + pin: usize, + machine_role: String, + os: String, + cpu_model: String, + started_utc: String, + rust_tool: Tool, + batch: u32, + /// Equality of our tree against the C++ reference per tree, from the equality phase. + equality: &'a BTreeMap<&'static str, Outcome>, +} + +// ------------------------------------------------------------------------------------------------ alternate: the runner + +const ALT_FLAGS: [&str; 13] = [ + "run-dir", + "case", + "rounds", + "batch", + "pin", + "schedule", + "seed", + "out", + "slices", + "slice-ms", + "llc-bytes", + "machine-role", + "kab", +]; + +#[derive(Debug)] +struct AltArgs { + dir: PathBuf, + case: String, + rounds: u32, + batch: u32, + pin: usize, + schedule: PathBuf, + seed: u64, + out: Option, + slices: usize, + slice_ms: Option, + llc_bytes: Option, + machine_role: Option, + kab: Option, +} + +fn main() -> ExitCode { + let args: Vec = std::env::args().skip(1).collect(); + // `time` and `alternate` take flags only (the command line of `kab time`); the older commands take the directory first + if let Some(cmd @ ("time" | "alternate")) = args.first().map(String::as_str) { + let result = if cmd == "time" { cmd_time(&args[1..]) } else { cmd_alternate(&args[1..]) }; + return result.unwrap_or_else(|e| { + eprintln!("kernel_ab {cmd}: {e}"); + ExitCode::from(1) + }); + } + let (Some(cmd), Some(dir)) = (args.first(), args.get(1)) else { return usage() }; + let dir = Path::new(dir); + let opts = match parse_options(&args[2..]) { + Ok(o) => o, + Err(e) => { + eprintln!("kernel_ab: {e}"); + return usage(); + } + }; + let result = match cmd.as_str() { + "verify" => match verify_dir(dir) { + Ok(v) => { + println!("OK {} files (manifest sha256 {})", v.file_count, v.manifest_sha256); + Ok(ExitCode::SUCCESS) + } + Err(e) => { + println!("{e}"); + Ok(ExitCode::from(if e.incomplete { 2 } else { 1 })) + } + }, + "compare" => cmd_compare(dir, &opts), + "run-tree" => match (&opts.tree, &opts.out) { + (Some(t), Some(o)) => cmd_run_tree(dir, t, o, opts.pin, opts.case.as_deref()), + _ => return usage(), + }, + _ => return usage(), + }; + result.unwrap_or_else(|e| { + eprintln!("kernel_ab: {e}"); + ExitCode::from(1) + }) +} + +// ------------------------------------------------------------------------------------------------ tests + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::atomic::{AtomicUsize, Ordering}; + + static COUNTER: AtomicUsize = AtomicUsize::new(0); + + struct TempDir(PathBuf); + impl TempDir { + fn new() -> Self { + let p = std::env::temp_dir().join(format!( + "kab1-test-{}-{}", + std::process::id(), + COUNTER.fetch_add(1, Ordering::SeqCst) + )); + fs::create_dir_all(&p).unwrap(); + Self(p) + } + } + impl Drop for TempDir { + fn drop(&mut self) { + let _ = fs::remove_dir_all(&self.0); + } + } + + fn block_filled(len: usize, block: usize, seed: u8) -> Vec { + let mut v: Vec = (0..len).map(|i| (i as u8).wrapping_mul(31).wrapping_add(seed)).collect(); + for at in (0..len).step_by(block) { + v[at] = 0x00; + v[at + 1] = 0x3c; // FP16 1.0 + } + v + } + + fn in_file(gu: i32, down: i32, rows: usize) -> Vec { + let (gq, gb) = (gate_up_row(gu).unwrap().2, gate_up_row(gu).unwrap().3); + let (dq, db) = (down_row(down).unwrap().2, down_row(down).unwrap().3); + let (gsize, dsize) = (H / gq * gb * FF, FF / dq * db * H); + let mut b = Vec::new(); + for w in [ + IN_MAGIC, + 1, + gu as u32, + down as u32, + rows as u32, + H as u32, + FF as u32, + gsize as u32, + gsize as u32, + dsize as u32, + ] { + b.extend_from_slice(&w.to_le_bytes()); + } + b.resize(IN_HEADER, 0); + b.extend(block_filled(gsize, gb, 1)); + b.extend(block_filled(gsize, gb, 2)); + b.extend(block_filled(dsize, db, 3)); + for i in 0..rows * H { + b.extend_from_slice(&(((i % 97) as f32 - 48.0) / 16.0).to_bits().to_le_bytes()); + } + b + } + + fn out_file(rows: usize, tree: u32) -> Vec { + let mut b = Vec::new(); + for w in [OUT_MAGIC, 1, rows as u32, H as u32, tree] { + b.extend_from_slice(&w.to_le_bytes()); + } + for i in 0..rows * H { + b.extend_from_slice(&((i as f32) * 0.25).to_bits().to_le_bytes()); + } + b + } + + struct Spec { + gu: i32, + down: i32, + rows: usize, + tolerance: Option<&'static str>, + } + + /// Builds a synthetic KAB1 directory; `mutate` edits the `.in` bytes before the manifest records their hash. + fn build(dir: &Path, specs: &[Spec], mutate: impl Fn(&mut Vec)) { + let mut cases = Vec::new(); + let mut files = Vec::new(); + for s in specs { + let id = format!("{}-{}-r{}", s.gu, s.down, s.rows); + let mut inb = in_file(s.gu, s.down, s.rows); + mutate(&mut inb); + fs::write(dir.join(format!("case-{id}.in")), &inb).unwrap(); + let mut entry = format!( + "{{\"id\": \"{id}\", \"gu_type\": {}, \"down_type\": {}, \"rows\": {}, \"seed\": 18446744073709551615, \"equality\": \"{}\", \"tolerance\": {}, \"in\": \"case-{id}.in\", \"in_sha256\": \"{}\", \"in_bytes\": {}", + s.gu, + s.down, + s.rows, + if s.tolerance.is_some() { "tolerance" } else { "bitwise" }, + s.tolerance.unwrap_or("null"), + sha_hex(&inb), + inb.len() + ); + files.push(format!("\"case-{id}.in\": {{\"sha256\": \"{}\", \"bytes\": {}}}", sha_hex(&inb), inb.len())); + for (k, tree) in TREES.iter().enumerate() { + let ob = out_file(s.rows, k as u32); + fs::write(dir.join(format!("case-{id}.cpp-{tree}.out")), &ob).unwrap(); + entry += &format!( + ", \"out_cpp_{tree}\": \"case-{id}.cpp-{tree}.out\", \"out_cpp_{tree}_sha256\": \"{}\", \"out_cpp_{tree}_bytes\": {}", + sha_hex(&ob), + ob.len() + ); + files.push(format!( + "\"case-{id}.cpp-{tree}.out\": {{\"sha256\": \"{}\", \"bytes\": {}}}", + sha_hex(&ob), + ob.len() + )); + } + cases.push(entry + "}"); + } + let manifest = format!( + "{{\"format\": \"KAB1\", \"version\": 1, \"run_id\": \"synthetic\", \"writer\": \"cpp\", \"provenance\": {{\"engine_strata_pin\": \"41cf05a06a25dd29103b7b27a2279a3f60c21876\", \"compiler_id\": \"GNU\", \"compiler_version\": \"15.2.0\", \"target_triple\": \"x86_64-linux-gnu\", \"built_at_utc\": \"2026-10-28T19:05:05Z\", \"avx512_ok\": true, \"flags\": {{\"strata_cxx_flags\": \"-O3 -DNDEBUG\", \"ggml_cpu_arch_flags\": \"-march=native\"}}}}, \"cases\": [{}], \"files\": {{{}}}}}", + cases.join(", "), + files.join(", ") + ); + fs::write(dir.join("manifest.json"), manifest).unwrap(); + } + + fn two_cases() -> Vec { + vec![Spec { gu: 42, down: 42, rows: 2, tolerance: None }, Spec { gu: 18, down: 20, rows: 1, tolerance: None }] + } + + fn one_case() -> Vec { + vec![Spec { gu: 42, down: 42, rows: 1, tolerance: None }] + } + + fn id(file: &str) -> String { + format!("case-42-42-r1.{file}") + } + + #[test] + fn a_good_directory_verifies() { + let t = TempDir::new(); + build(&t.0, &two_cases(), |_| {}); + let v = verify_dir(&t.0).unwrap(); + assert_eq!(v.cases.len(), 2); + assert_eq!(v.file_count, 2 * 3 + 1); + assert_eq!(v.manifest_sha256.len(), 64); + assert_eq!(v.cases[0].in_sha256, sha_hex(&fs::read(t.0.join("case-42-42-r2.in")).unwrap())); + } + + #[test] + fn a_flipped_byte_refuses_the_directory_and_names_the_file() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + let p = t.0.join(id("in")); + let mut b = fs::read(&p).unwrap(); + b[IN_HEADER + 7] ^= 0x40; + fs::write(&p, b).unwrap(); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "case-42-42-r1.in"); + assert!(e.reason.contains("sha256"), "{e}"); + } + + #[test] + fn a_truncated_file_refuses_the_directory_and_names_the_file() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + let p = t.0.join(id("cpp-avx2.out")); + let b = fs::read(&p).unwrap(); + fs::write(&p, &b[..b.len() - 4]).unwrap(); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "case-42-42-r1.cpp-avx2.out"); + assert!(e.reason.contains("length"), "{e}"); + } + + #[test] + fn a_wrong_magic_is_refused() { + let t = TempDir::new(); + build(&t.0, &one_case(), |b| b[0] ^= 0xff); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "case-42-42-r1.in"); + assert!(e.reason.contains("magic"), "{e}"); + } + + #[test] + fn a_wrong_version_is_refused() { + let t = TempDir::new(); + build(&t.0, &one_case(), |b| b[4] = 2); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "case-42-42-r1.in"); + assert!(e.reason.contains("version"), "{e}"); + } + + #[test] + fn a_byte_count_that_disagrees_with_the_format_is_refused() { + let t = TempDir::new(); + build(&t.0, &one_case(), |b| { + let wrong = (le32(b, 28) + 18).to_le_bytes(); + b[28..32].copy_from_slice(&wrong); + }); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "case-42-42-r1.in"); + assert!(e.reason.contains("format-derived"), "{e}"); + } + + #[test] + fn a_non_finite_fp16_header_is_refused() { + let t = TempDir::new(); + // the manifest records the hash of the mutated file, so only the FP16 rule can refuse it + build(&t.0, &one_case(), |b| { + let at = IN_HEADER + 18 * 3; + b[at] = 0x00; + b[at + 1] = 0x7c; // FP16 +inf + }); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "case-42-42-r1.in"); + assert!(e.reason.contains("non-finite FP16"), "{e}"); + } + + #[test] + fn a_non_finite_activation_is_refused() { + let t = TempDir::new(); + build(&t.0, &one_case(), |b| { + let at = b.len() - 4; + b[at..].copy_from_slice(&f32::NAN.to_bits().to_le_bytes()); + }); + let e = verify_dir(&t.0).unwrap_err(); + assert!(e.reason.contains("non-finite activation"), "{e}"); + } + + #[test] + fn a_missing_manifest_is_incomplete_and_named() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + fs::remove_file(t.0.join("manifest.json")).unwrap(); + let e = verify_dir(&t.0).unwrap_err(); + assert_eq!(e.file, "manifest.json"); + assert!(e.incomplete); + assert!(e.to_string().contains("manifest.json")); + } + + #[test] + fn an_extra_or_missing_file_refuses_the_directory() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + fs::write(t.0.join("stray.txt"), b"x").unwrap(); + assert_eq!(verify_dir(&t.0).unwrap_err().file, "stray.txt"); + fs::remove_file(t.0.join("stray.txt")).unwrap(); + fs::remove_file(t.0.join(id("cpp-avx512.out"))).unwrap(); + assert_eq!(verify_dir(&t.0).unwrap_err().file, "case-42-42-r1.cpp-avx512.out"); + } + + #[test] + fn an_absurd_length_is_refused_without_taking_a_buffer() { + // header says gate_bytes = 4 GiB - 16; the pure header check refuses it before any buffer exists + let mut h = [0u8; IN_HEADER]; + h.copy_from_slice(&in_file(42, 42, 1)[..IN_HEADER]); + h[28..32].copy_from_slice(&(u32::MAX - 15).to_le_bytes()); + BUFFERS.with(|c| c.set(0)); + assert!(validate_in_header(&h, 1 << 20).unwrap_err().contains("format-derived")); + assert_eq!(BUFFERS.with(Cell::get), 0); + // and through the file reader: manifest and file agree on a file whose header lies about its size + let t = TempDir::new(); + build(&t.0, &one_case(), |b| b[28..32].copy_from_slice(&(u32::MAX - 15).to_le_bytes())); + BUFFERS.with(|c| c.set(0)); + let (m, _) = (fs::read(t.0.join("manifest.json")).unwrap(), 0); + let (_, cases, _) = parse_manifest(&parse_json(&m).unwrap()).unwrap(); + let e = read_case_in(&t.0, &cases[0]).err().unwrap(); + assert!(e.reason.contains("format-derived"), "{e}"); + assert_eq!(BUFFERS.with(Cell::get), 0, "a buffer was taken before the header was validated"); + // a manifest that declares an absurd length for a file is refused before a buffer too + let mut lying = cases[0].clone(); + lying.in_bytes = u64::MAX; + assert!(read_case_in(&t.0, &lying).unwrap_err().reason.contains("differs from the manifest")); + assert_eq!(BUFFERS.with(Cell::get), 0); + // the good path takes exactly one buffer per file + let g = TempDir::new(); + build(&g.0, &one_case(), |_| {}); + BUFFERS.with(|c| c.set(0)); + let (_, cases, _) = + parse_manifest(&parse_json(&fs::read(g.0.join("manifest.json")).unwrap()).unwrap()).unwrap(); + read_case_in(&g.0, &cases[0]).unwrap(); + assert_eq!(BUFFERS.with(Cell::get), 1); + } + + #[test] + fn a_tolerance_needs_basis_metric_and_a_time_before_the_reference_run() { + let ok = "{\"value\": 0.003, \"metric\": \"max_abs_error_over_max_abs_reference\", \"basis\": \"order-only difference\", \"basis_written_utc\": \"2026-10-28T10:00:00Z\"}"; + let t = TempDir::new(); + build(&t.0, &[Spec { gu: 42, down: 42, rows: 1, tolerance: Some(ok) }], |_| {}); + let v = verify_dir(&t.0).unwrap(); + assert_eq!(v.cases[0].tolerance.as_ref().unwrap().value, 0.003); + for (bad, why) in [ + (ok.replace("0.003", "0"), "positive"), + (ok.replace("max_abs_error_over_max_abs_reference", "ulp"), "metric"), + (ok.replace("order-only difference", " "), "basis"), + (ok.replace("2026-10-28T10:00:00Z", "2026-10-28T20:00:00Z"), "after the reference run"), + ] { + let leaked: &'static str = Box::leak(bad.into_boxed_str()); + let d = TempDir::new(); + build(&d.0, &[Spec { gu: 42, down: 42, rows: 1, tolerance: Some(leaked) }], |_| {}); + let e = verify_dir(&d.0).unwrap_err(); + assert_eq!(e.file, "manifest.json"); + assert!(e.reason.contains(why), "{why}: {e}"); + } + } + + #[test] + fn the_json_reader_handles_the_manifest_forms_and_refuses_the_rest() { + let j = parse_json(b"{\"a\": [1, -2.5e3, true, null, \"x\\n\\u00e9\\ud83d\\ude00\"], \"b\": {}}").unwrap(); + assert_eq!( + j.get("a"), + Some(&Json::Arr(vec![ + Json::Num("1".into()), + Json::Num("-2.5e3".into()), + Json::Bool(true), + Json::Null, + Json::Str("x\n\u{e9}\u{1f600}".into()) + ])) + ); + assert_eq!(parse_json(b"{\"s\": 18446744073709551615}").unwrap().uint("s").unwrap(), u64::MAX); + for bad in [ + "{\"a\": 1, \"a\": 2}", + "{\"a\": 1,}", + "[1 2]", + "{\"a\": \"\\ud800\"}", + "{} x", + "", + "{\"a\": 01x}", + "\"\u{1}\"", + ] { + assert!(parse_json(bad.as_bytes()).is_err(), "{bad}"); + } + assert!(parse_json("[".repeat(40).as_bytes()).is_err()); + } + + #[test] + fn bitwise_compare_sees_signed_zero_and_one_ulp_and_tolerance_is_normalised() { + let a = [1.0f32.to_bits(), 0.0f32.to_bits(), 2.0f32.to_bits()]; + assert!(compare_bits(&a, &a, None).equal()); + let neg0 = [1.0f32.to_bits(), (-0.0f32).to_bits(), 2.0f32.to_bits()]; + let o = compare_bits(&neg0, &a, None); + assert_eq!((o.mismatches, o.first_mismatch), (1, Some((1, (-0.0f32).to_bits(), 0.0f32.to_bits())))); + let ulp = [1.0f32.to_bits(), 0.0f32.to_bits(), 2.0f32.to_bits() + 1]; + assert_eq!(compare_bits(&ulp, &a, None).mismatches, 1); + let tol = Tolerance { value: 1e-6, basis: "test".into(), basis_written_utc: "2026-01-01T00:00:00Z".into() }; + assert!(compare_bits(&ulp, &a, Some(&tol)).equal()); + let far = [1.0f32.to_bits(), 0.0f32.to_bits(), 2.1f32.to_bits()]; + assert_eq!(compare_bits(&far, &a, Some(&tol)).mismatches, 1); + assert_eq!(compare_bits(&a[..2], &a, None).mismatches, 1); + } + + #[test] + fn our_trees_run_on_a_verified_synthetic_case_and_the_record_is_well_formed() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + let v = verify_dir(&t.0).unwrap(); + let case = read_case_in(&v.dir, &v.cases[0]).unwrap(); + let mut pool = DirectCpuPool::new(1).unwrap(); + let first = compute_case(&mut pool, &case).unwrap(); + let second = compute_case(&mut pool, &case).unwrap(); + assert_eq!(first.len(), H); + assert!( + first.iter().zip(&second).all(|(a, b)| a.to_bits() == b.to_bits()), + "the same case twice must be bit-identical" + ); + let path = t.0.join("ours.rust-avx2.out"); + write_out(&path, 1, "avx2", &first).unwrap(); + let back = read_out(&path, "ours.rust-avx2.out", 1, "avx2", None).unwrap(); + assert_eq!(back, first.iter().map(|v| v.to_bits()).collect::>()); + let outcome = compare_bits(&back, &back, None); + let json = record_json(&RecordInput { + record_id: "kab1-synthetic-r".into(), + created_utc: "2026-10-28T20:00:00Z".into(), + run_started_utc: "2026-10-28T19:59:00Z".into(), + machine_role: "m\"1".into(), + cpu_model: "cpu".into(), + os: "os".into(), + ours_compiler: "rustc".into(), + ours_version: "rustc 1.99.0".into(), + ours_triple: "x86_64-unknown-linux-gnu".into(), + ours_flags: "f".into(), + tree: "avx2", + verified: &v, + case: &v.cases[0], + pin_cpu: 0, + sibling_idle: true, + outcome: &outcome, + }); + let rec = parse_json(json.as_bytes()).unwrap(); + for key in [ + "schema_version", + "level", + "record_id", + "created_utc", + "run_started_utc", + "machine", + "kernel", + "toolchain", + "case_id", + "input_sha256", + "kab1_manifest_sha256", + "tree", + "regime", + "pin", + "strata_upstream_commit", + "clock_calibration", + "rows", + "aa_noise_floor", + "equality", + ] { + assert!(rec.get(key).is_some(), "{key}"); + } + assert_eq!(rec.req("equality").unwrap().str("verdict").unwrap(), "EQUAL"); + assert_eq!(rec.req("machine").unwrap().str("machine_role").unwrap(), "m\"1"); + assert_eq!(rec.str("kab1_manifest_sha256").unwrap(), v.manifest_sha256); + } + + // ---------------------------------------------------------------------------------------------------- alternation (STRA-318) + + #[test] + fn the_schedule_is_reproducible_from_the_seed() { + let procs = procs_for(&TREES); + let a = make_schedule(7, 1, 30, &procs); + assert_eq!(a, make_schedule(7, 1, 30, &procs)); + assert_ne!(a, make_schedule(8, 1, 30, &procs), "another seed gives another schedule"); + assert_ne!(a, make_schedule(7, 2, 30, &procs), "another batch gives another schedule"); + assert_eq!(a.len(), 30); + // the text round-trips through the file format and names the seed + let text = schedule_text(7, 1, 30, "18-20-r1", 9, 1, &a); + assert!(text.contains("seed=7 batch=1 rounds=30 case=18-20-r1 pin=9")); + let back = parse_schedule(&text).unwrap(); + assert_eq!(back.iter().map(|r| r.1.clone()).collect::>(), a); + assert_eq!(back[0].0, 1); + assert_eq!(back[29].0, 30); + } + + #[test] + fn the_rotation_gives_every_process_every_position_within_a_block() { + let procs = procs_for(&TREES); + assert_eq!(procs.len(), 8); + let s = make_schedule(3, 1, 16, &procs); + for block in s.chunks(8) { + for round in block { + let mut names: Vec<_> = round.iter().map(Proc::name).collect(); + names.sort(); + assert_eq!(names.len(), 8); + names.dedup(); + assert_eq!(names.len(), 8, "every process exactly once per round"); + } + for pos in 0..8 { + let at: BTreeSet<_> = block.iter().map(|r| r[pos]).collect(); + assert_eq!(at.len(), 8, "position {pos} is taken by every process once per block of 8 rounds"); + } + } + // a host without AVX-512 has only the avx2 cells + assert_eq!(procs_for(&["avx2"]).len(), 4); + } + + #[test] + fn a_schedule_file_is_written_once_and_a_bad_one_is_refused() { + let t = TempDir::new(); + let f = t.0.join("schedule.tsv"); + create_new_file(&f, b"x").unwrap(); + assert!(create_new_file(&f, b"y").unwrap_err().contains("nothing is overwritten")); + assert_eq!(fs::read(&f).unwrap(), b"x"); + let procs = procs_for(&TREES); + let good = schedule_text(1, 1, 3, "c", 0, 1, &make_schedule(1, 1, 3, &procs)); + assert!(parse_schedule(&good).is_ok()); + assert!(parse_schedule("nope").is_err()); + assert!(parse_schedule(&good.replace("cpp-avx2-a", "cpp-avx2-z")).unwrap_err().contains("unknown process")); + assert!(parse_schedule(&good.replacen("\n2\t", "\n5\t", 1)).unwrap_err().contains("does not follow")); + // a round that names one process twice (and so lacks another) is refused + let dup = good + .lines() + .map(|l| { + if l.starts_with("2\t") { + l.replacen("rust-avx2-b", "rust-avx2-a", 1).replacen("rust-avx2-b", "rust-avx2-a", 1) + } else { + l.to_owned() + } + }) + .collect::>() + .join("\n"); + assert!(parse_schedule(&dup).is_err()); + } + + /// The child side of the environment test: prints the managed variables it sees. Does nothing in a normal run. + #[test] + fn env_probe_child() { + if std::env::var_os("KAB_TEST_CHILD").as_deref() != Some(std::ffi::OsStr::new("probe")) { + return; + } + for (k, v) in std::env::vars() { + if is_managed_name(&k) { + println!("PROBE {k}={v}"); + } + } + } + + /// The child side of the failure test. + #[test] + fn failing_child() { + if std::env::var_os("KAB_TEST_CHILD").as_deref() == Some(std::ffi::OsStr::new("fail")) { + eprintln!("simulated kernel failure"); + std::process::exit(3); + } + } + + fn child(test: &str, mode: &str, planted: &[(&str, &str)], cell: &[(String, String)]) -> Command { + let mut parent: Vec<(OsString, OsString)> = + std::env::vars_os().filter(|(k, _)| !is_managed_name(&k.to_string_lossy())).collect(); + parent.push(("KAB_TEST_CHILD".into(), mode.into())); + parent.extend(planted.iter().map(|(k, v)| ((*k).into(), (*v).into()))); + let mut c = scrubbed_command(&std::env::current_exe().unwrap(), &parent, cell); + c.args(["--exact", test, "--nocapture", "--test-threads=1"]); + c + } + + #[test] + fn environment_scrubbing_removes_a_planted_strata_variable_and_keeps_only_the_cell() { + let cell = cell_env(&Proc { imp: Impl::Rust, tree: "avx2", rep: 'a' }); + assert_eq!( + cell, + vec![ + ("LELEKA_CPU_POOL_PIN_HOST".to_owned(), "off".to_owned()), + ("STRATA_FORCE_AVX2".to_owned(), "1".to_owned()), + ("STRATA_POOL_SPIN_US".to_owned(), "0".to_owned()) + ] + ); + assert!(cell_env(&Proc { imp: Impl::Cpp, tree: "avx512", rep: 'b' }).is_empty()); + let out = run_cell( + &mut child( + "tests::env_probe_child", + "probe", + &[("STRATA_X", "planted"), ("LELEKA_Y", "planted"), ("strata_lower", "planted")], + &cell, + ), + "rust-avx2-a", + ) + .unwrap(); + let text = String::from_utf8_lossy(&out.stdout); + // libtest prints "test ... " before the child's own output on the same line + let mut probes: Vec<&str> = text.lines().flat_map(|l| l.split("PROBE ").skip(1)).collect(); + probes.sort_unstable(); + assert_eq!( + probes, + vec!["LELEKA_CPU_POOL_PIN_HOST=off", "STRATA_FORCE_AVX2=1", "STRATA_POOL_SPIN_US=0"], + "only the cell's variables survive:\n{text}" + ); + // the cpp avx512 cell sets nothing at all + let out = + run_cell(&mut child("tests::env_probe_child", "probe", &[("STRATA_X", "planted")], &[]), "cpp-avx512-a") + .unwrap(); + assert!(!String::from_utf8_lossy(&out.stdout).contains("PROBE ")); + } + + #[test] + fn a_child_failure_is_reported_with_the_cell_named() { + let e = run_cell(&mut child("tests::failing_child", "fail", &[], &[]), "cpp-avx2-b").unwrap_err(); + assert!(e.starts_with("cell cpp-avx2-b failed (exit 3)"), "{e}"); + assert!(e.contains("simulated kernel failure"), "{e}"); + let e = run_cell(&mut Command::new("kab-does-not-exist-318"), "rust-avx512-a").unwrap_err(); + assert!(e.starts_with("cell rust-avx512-a: cannot start"), "{e}"); + } + + #[test] + fn the_time_command_line_is_the_one_of_kab_time() { + let v = |a: &[&str]| a.iter().map(|s| (*s).to_owned()).collect::>(); + let t = parse_time_args(&v(&[ + "--run-dir", + "D", + "--case", + "18-20-r1", + "--slices", + "50", + "--pin", + "9", + "--out", + "t.json", + ])) + .unwrap(); + assert_eq!((t.slices, t.pin, t.slice_ms, t.regime, t.llc_bytes), (50, 9, 60.0, RegimeSel::Both, None)); + let t = parse_time_args(&v(&[ + "--run-dir", + "D", + "--case", + "c", + "--slices", + "2", + "--pin", + "0", + "--out", + "o", + "--slice-ms", + "5", + "--regime", + "streamed", + "--llc-bytes", + "1000", + ])) + .unwrap(); + assert_eq!((t.slice_ms, t.regime, t.llc_bytes), (5.0, RegimeSel::Streamed, Some(1000))); + for bad in [ + v(&["--run-dir", "D", "--case", "c", "--slices", "0", "--pin", "0", "--out", "o"]), + v(&["--run-dir", "D", "--case", "c", "--slices", "1", "--out", "o"]), + v(&["--run-dir", "D", "--case", "c", "--slices", "1", "--pin", "0", "--out", "o", "--regime", "both2"]), + v(&["--run-dir", "D", "--case", "../c", "--slices", "1", "--pin", "0", "--out", "o"]), + v(&["--run-dir", "D", "--case", "c", "--slices", "1", "--pin", "0", "--out", "o", "--bogus", "1"]), + v(&["--run-dir", "D", "--run-dir", "E", "--case", "c", "--slices", "1", "--pin", "0", "--out", "o"]), + ] { + assert!(parse_time_args(&bad).is_err(), "{bad:?}"); + } + let a = parse_alt_args(&v(&[ + "--run-dir", + "D", + "--case", + "c", + "--rounds", + "30", + "--batch", + "1", + "--pin", + "9", + "--schedule", + "s.tsv", + ])) + .unwrap(); + assert_eq!((a.rounds, a.batch, a.seed, a.slices), (30, 1, 1, 20)); + assert!( + parse_alt_args(&v(&[ + "--run-dir", + "D", + "--case", + "c", + "--rounds", + "30", + "--batch", + "0", + "--pin", + "9", + "--schedule", + "s" + ])) + .is_err() + ); + } + + #[test] + fn medians_percentiles_and_parsers_agree_with_the_reference_rules() { + assert_eq!(median_of(&[3.0, 1.0, 2.0, 10.0]), 3.0, "sorted, element size/2 as the C++ reference"); + assert_eq!(median_of(&[]), 0.0); + let v: Vec = (1..=21).map(f64::from).collect(); + assert_eq!((percentile_of(&v, 0.05), percentile_of(&v, 0.95)), (2.0, 20.0)); + assert_eq!(parse_cpu_list("2,18"), vec![2, 18]); + assert_eq!(parse_cpu_list("0-3,8"), vec![0, 1, 2, 3, 8]); + assert_eq!((parse_size("32768K"), parse_size("32M"), parse_size("512")), (32 << 20, 32 << 20, 512)); + assert_eq!(busy_fraction(Some((10, 100)), Some((30, 200))), Some(0.2)); + assert_eq!(busy_fraction(None, Some((1, 1))), None); + // the calibrated clock of any x86-64 core is in this range (the chain must not be folded away: 175 GHz was the folded multiply chain) + let ghz = core_ghz(); + assert!((0.3..12.0).contains(&ghz), "{ghz}"); + } + + #[test] + fn an_output_inside_a_git_checkout_is_detected() { + let t = TempDir::new(); + let inner = t.0.join("a/b"); + fs::create_dir_all(&inner).unwrap(); + assert!(!inside_git_checkout(&inner)); + fs::create_dir_all(t.0.join(".git")).unwrap(); + assert!(inside_git_checkout(&inner)); + assert!(inside_git_checkout(&t.0.join("not/yet/created/schedule.tsv"))); + } + + fn json_regime(label: &str, k: usize, self_key: &str) -> String { + let slice = |g1: f64| { + format!( + "{{\"i\": 0, \"calls\": 10, \"wall_ns\": 100, \"ns_per_call\": 10.0, \"ghz_before\": 5.0, \"ghz_after\": {g1}, \"cycles_per_call\": 50.0}}" + ) + }; + format!( + "{{\"regime\": \"{label}\", \"copies_k\": {k}, \"expert_bytes\": 1000, \"llc_bytes\": 500, \"slices_requested\": 3, \"slices_kept\": 2, \"dropped_count\": 1, \"{self_key}\": true, \"median_ns_per_call\": 10.0, \"median_cycles_per_call\": 50.0, \"slices\": [{}, {}], \"dropped\": [{}]}}", + slice(5.0), + slice(5.1), + slice(4.0) + ) + } + + /// A process JSON as the C++ writer (`imp` cpp) or this example (rust) writes it, with `env` as its effective environment. + fn proc_fixture(p: &Proc, env: &str) -> String { + let (self_key, detail) = if p.imp == Impl::Cpp { + ("selfcheck_bitwise_equal_compose_expert", "{\"tree\": \"avx512\", \"avx2_ok\": true, \"avx512_ok\": true, \"iq512_gather_on\": false, \"iq256_gather_setting\": -1, \"strata_env\": {}}".to_owned()) + } else { + ( + "selfcheck_bitwise_equal_first_call", + format!( + "{{\"tree\": \"{}\", \"cpu_report\": [\"cpu: logical 16 (8 physical): Test CPU; x\", \"cpu: process kernel family AVX-512 (test)\"], \"strata_env\": {{}}}}", + p.tree + ), + ) + }; + format!( + "{{\"format\": \"KAB1-time\", \"version\": 1, \"writer\": \"{}\", \"manifest_sha256\": \"m\", \"case\": {{\"id\": \"c\", \"input_sha256\": \"i\"}}, \"tree\": \"{}\", \"tree_detail\": {detail}, \"effective_env\": {env}, \"pin\": {{\"cpu\": 9, \"sibling_cpu\": 25, \"sibling_busy_fraction_during_run\": 0.01}}, \"clock_calibration\": {{\"ghz_at_start\": 5.0, \"ghz_at_end\": 5.1}}, \"final_output_unchanged\": true, \"output_sha256\": \"{}\", \"regimes\": [{}, {}]}}", + p.imp.name(), + p.tree, + "cd".repeat(32), + json_regime("RESIDENT", 1, self_key), + json_regime("STREAMED", 3, self_key) + ) + } + + #[test] + fn a_process_json_is_checked_against_the_cell_that_was_started() { + let expect = Expect { manifest_sha: "m", input_sha: "i", case: "c", pin: 9 }; + for p in [Proc { imp: Impl::Cpp, tree: "avx2", rep: 'a' }, Proc { imp: Impl::Rust, tree: "avx512", rep: 'b' }] { + let env = json_env(&cell_env(&p).into_iter().collect()); + let ok = parse_proc_json(&p, proc_fixture(&p, &env).as_bytes(), &expect).unwrap(); + assert_eq!(ok.regimes.len(), 2); + let r = &ok.regimes["STREAMED"]; + assert_eq!((r.copies_k, r.ns.len(), r.dropped, r.requested), (3, 2, 1, 3)); + assert!( + (r.max_drift - 0.2).abs() < 1e-9, + "the dropped slice's 20 percent drift is the maximum: {}", + r.max_drift + ); + assert_eq!(ok.sibling_idle, Some(true)); + // the environment the process saw must be exactly the cell's + let planted = json_env(&BTreeMap::from([("STRATA_X".to_owned(), "1".to_owned())])); + let e = parse_proc_json(&p, proc_fixture(&p, &planted).as_bytes(), &expect).unwrap_err(); + assert!(e.starts_with(&format!("cell {}: effective environment", p.name())), "{e}"); + // wrong pin, wrong manifest, wrong input, wrong writer: each names the cell + for (bad_expect, what) in [ + (Expect { manifest_sha: "m", input_sha: "i", case: "c", pin: 8 }, "pinned to CPU"), + (Expect { manifest_sha: "other", input_sha: "i", case: "c", pin: 9 }, "manifest_sha256"), + (Expect { manifest_sha: "m", input_sha: "x", case: "c", pin: 9 }, "input hash"), + ] { + let e = parse_proc_json(&p, proc_fixture(&p, &env).as_bytes(), &bad_expect).unwrap_err(); + assert!(e.starts_with(&format!("cell {}:", p.name())) && e.contains(what), "{e}"); + } + let other = Proc { imp: if p.imp == Impl::Cpp { Impl::Rust } else { Impl::Cpp }, ..p }; + assert!( + parse_proc_json(&other, proc_fixture(&p, &env).as_bytes(), &expect).unwrap_err().contains("writer") + ); + } + } + + fn fake_proc(p: Proc, base: f64) -> ProcOut { + let regime = |k: usize| RegimeStat { + copies_k: k, + expert_bytes: 1_000_000, + llc_bytes: 1_000, + requested: 10, + dropped: 1, + median_ns: base, + median_cycles: base * 5.0, + ns: vec![base * 0.9, base, base * 1.1], + cycles: vec![base * 4.5, base * 5.0, base * 5.5], + max_drift: 0.01, + selfcheck: true, + }; + ProcOut { + proc: p, + regimes: BTreeMap::from([("RESIDENT".to_owned(), regime(1)), ("STREAMED".to_owned(), regime(3))]), + ghz_start: 5.0, + ghz_end: 5.1, + sibling_idle: Some(true), + final_unchanged: true, + output_sha: Some("ab".repeat(32)), + tree_text: format!("tree text of {}", p.name()), + cpu_model: Some("Test CPU".to_owned()), + } + } + + #[test] + fn round_records_have_the_schema_shape_and_keep_not_equal() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + let v = verify_dir(&t.0).unwrap(); + let outcome = |bad: usize| Outcome { + compared: H, + mismatches: bad, + differing_bits: bad, + max_abs_error: 0.0, + first_mismatch: None, + }; + let equality = BTreeMap::from([("avx512", outcome(0)), ("avx2", outcome(1835))]); + let ctx = BatchCtx { + verified: &v, + case: &v.cases[0], + pin: 9, + machine_role: "m".into(), + os: "os".into(), + cpu_model: "cpu".into(), + started_utc: "2026-10-28T20:00:00Z".into(), + rust_tool: Tool { + compiler: "rustc".into(), + version: "rustc 1.99.0".into(), + triple: "x86_64-unknown-linux-gnu".into(), + flags: "f".into(), + }, + batch: 2, + equality: &equality, + }; + let mut done: Vec = + procs_for(&TREES).into_iter().enumerate().map(|(i, p)| fake_proc(p, 100.0 + i as f64)).collect(); + done.reverse(); // the order of execution does not matter to the records + done.iter_mut().find(|p| p.proc == Proc { imp: Impl::Cpp, tree: "avx2", rep: 'b' }).unwrap().sibling_idle = + Some(false); + let files = round_records(&ctx, 31, &done).unwrap(); + assert_eq!(files.len(), 12, "2 trees x 2 regimes x (A/B + A/A cpp + A/A rust)"); + let names: BTreeSet<_> = files.iter().map(|f| f.0.as_str()).collect(); + assert_eq!(names.len(), 12); + assert!( + names.contains("r00031.ab.avx2.streamed.json") + && names.contains("r00031.aa-cpp.avx512.resident.json") + && names.contains("r00031.aa-rust.avx2.resident.json") + ); + for (name, json) in &files { + let rec = parse_json(json.as_bytes()).unwrap_or_else(|e| panic!("{name}: {e}")); + for key in [ + "schema_version", + "level", + "record_id", + "created_utc", + "run_started_utc", + "machine", + "kernel", + "toolchain", + "case_id", + "input_sha256", + "kab1_manifest_sha256", + "tree", + "regime", + "pin", + "strata_upstream_commit", + "clock_calibration", + "rows", + "aa_noise_floor", + "equality", + ] { + assert!(rec.get(key).is_some(), "{name}: {key}"); + } + assert_eq!(rec.str("level").unwrap(), "COMPONENT_KERNEL"); + assert_eq!(rec.str("kab1_manifest_sha256").unwrap(), v.manifest_sha256); + assert_eq!(rec.str("input_sha256").unwrap(), v.cases[0].in_sha256); + let Some(Json::Arr(rows)) = rec.get("rows") else { panic!("rows") }; + let units: Vec<_> = rows.iter().map(|r| r.str("unit").unwrap().to_owned()).collect(); + assert_eq!(units, ["ns", "cycles"]); + assert_ne!(rows[0].str("row_type").unwrap(), rows[1].str("row_type").unwrap(), "no repeated row type"); + let regime = rec.str("regime").unwrap(); + assert_eq!(rec.get("streamed").is_some(), regime == "streamed", "{name}"); + assert!(rec.str("kernel").unwrap().contains("PLACEHOLDER")); + let eq = rec.req("equality").unwrap(); + let tree = rec.req("tree").unwrap().str("ours").unwrap(); + let want = if name.contains(".ab.") && tree == "avx2" { "NOT_EQUAL" } else { "EQUAL" }; + assert_eq!(eq.str("verdict").unwrap(), want, "{name}"); + if want == "NOT_EQUAL" { + assert_eq!(eq.uint("mismatches").unwrap(), 1835, "the A/B mismatch count is carried, not hidden"); + } + } + // the A/B record puts Rust in the ours slot and C++ in the reference slot; the A/A records use one implementation on both + let ab = + parse_json(files.iter().find(|f| f.0 == "r00031.ab.avx512.resident.json").unwrap().1.as_bytes()).unwrap(); + assert!( + ab.str("kernel").unwrap().contains("ours-slot process rust-avx512-a, reference-slot process cpp-avx512-a") + ); + assert_eq!(ab.req("toolchain").unwrap().req("ours").unwrap().str("compiler").unwrap(), "rustc"); + let aa = parse_json(files.iter().find(|f| f.0 == "r00031.aa-cpp.avx512.resident.json").unwrap().1.as_bytes()) + .unwrap(); + assert!( + aa.str("kernel").unwrap().contains("ours-slot process cpp-avx512-a, reference-slot process cpp-avx512-b") + ); + assert_eq!(aa.req("equality").unwrap().str("mode").unwrap(), "bitwise"); + // sibling_idle belongs to the two processes of a record: only the A/A cpp avx2 records see the busy sibling of cpp-avx2-b + for (name, json) in &files { + let rec = parse_json(json.as_bytes()).unwrap(); + let busy = name.contains(".aa-cpp.avx2."); + assert_eq!(matches!(rec.req("pin").unwrap().get("sibling_idle"), Some(Json::Bool(false))), busy, "{name}"); + } + // a streamed set that differs between the two sides of a record is refused + let mut skewed = done.clone(); + skewed + .iter_mut() + .find(|p| p.proc == Proc { imp: Impl::Cpp, tree: "avx2", rep: 'a' }) + .unwrap() + .regimes + .get_mut("STREAMED") + .unwrap() + .copies_k = 4; + assert!(round_records(&ctx, 31, &skewed).unwrap_err().contains("streamed set differs")); + // a missing process is named + assert!(round_records(&ctx, 31, &done[1..]).unwrap_err().contains("did not run")); + } + + #[test] + fn the_rust_time_mode_writes_a_process_json_the_runner_accepts() { + let t = TempDir::new(); + build(&t.0, &one_case(), |_| {}); + let out = TempDir::new(); + let file = out.0.join("t.json"); + let args: Vec = [ + "--run-dir", + t.0.to_str().unwrap(), + "--case", + "42-42-r1", + "--slices", + "40", + "--pin", + "0", + "--out", + file.to_str().unwrap(), + "--slice-ms", + "1", + "--llc-bytes", + "8000000", + ] + .iter() + .map(|s| (*s).to_owned()) + .collect(); + // exit 0, or 3 when a 1 ms slice of a ramping clock was dropped in every slice of a regime (kept slices are the loaded host's call) + let code = format!("{:?}", cmd_time(&args).unwrap()); + assert!(code == format!("{:?}", ExitCode::SUCCESS) || code == format!("{:?}", ExitCode::from(3)), "{code}"); + let text = fs::read_to_string(&file).unwrap(); + let j = parse_json(text.as_bytes()).unwrap(); + assert_eq!(j.str("writer").unwrap(), "rust"); + assert_eq!(j.str("format").unwrap(), "KAB1-time"); + assert!(j.flag("selfcheck_bitwise_equal_first_call").unwrap()); + assert_eq!(j.str("output_sha256").unwrap().len(), 64); + let tree = j.str("tree").unwrap().to_owned(); + let p = Proc { imp: Impl::Rust, tree: TREES.iter().find(|t| **t == tree).copied().unwrap(), rep: 'a' }; + if !code.contains("(0)") { + return; + } + let manifest = fs::read(t.0.join("manifest.json")).unwrap(); + let (_, _, cases, _) = read_manifest(&t.0).unwrap(); + let sha = sha_hex(&manifest); + let expect = Expect { manifest_sha: &sha, input_sha: &cases[0].in_sha256, case: "42-42-r1", pin: 0 }; + // the test process runs unscrubbed (its effective environment is empty), so the runner's environment check refuses it ... + assert!(parse_proc_json(&p, text.as_bytes(), &expect).unwrap_err().contains("effective environment")); + // ... and accepts it once the recorded environment is the cell's + let want_env = json_env(&cell_env(&p).into_iter().collect()); + let as_cell = text.replacen("\"effective_env\": {}", &format!("\"effective_env\": {want_env}"), 1); + let ok = parse_proc_json(&p, as_cell.as_bytes(), &expect).unwrap(); + for r in ["RESIDENT", "STREAMED"] { + let s = &ok.regimes[r]; + assert!(s.median_ns > 0.0 && s.median_cycles > 0.0 && !s.ns.is_empty(), "{r}"); + assert_eq!(s.requested, 40); + } + assert_eq!(ok.regimes["RESIDENT"].copies_k, 1); + assert!(ok.regimes["STREAMED"].copies_k >= 2); + assert!(ok.tree_text.starts_with("leleka-serve cpu: process kernel family")); + // a lie about the pin is refused + assert!( + parse_proc_json(&p, as_cell.as_bytes(), &Expect { pin: 3, ..expect }) + .unwrap_err() + .contains("pinned to CPU") + ); + } + + #[test] + fn utc_formatting_is_exact() { + assert_eq!(utc_of(0), "1970-01-01T00:00:00Z"); + assert_eq!(utc_of(1_782_000_000), "2026-06-21T00:00:00Z"); + assert!(is_utc(&now_utc())); + } +} + +mod gate_up_row_fn; +#[allow(unused_imports)] +use gate_up_row_fn::gate_up_row; +#[allow(unused_imports)] +use gate_up_row_fn::down_row; +#[allow(unused_imports)] +use gate_up_row_fn::sha_hex; +#[allow(unused_imports)] +use gate_up_row_fn::take_buffer; +#[allow(unused_imports)] +use gate_up_row_fn::words_le; +#[allow(unused_imports)] +use gate_up_row_fn::le32; +#[allow(unused_imports)] +use gate_up_row_fn::civil_from_days; +#[allow(unused_imports)] +use gate_up_row_fn::utc_of; +#[allow(unused_imports)] +use gate_up_row_fn::now_utc; +#[allow(unused_imports)] +use gate_up_row_fn::is_utc; +#[allow(unused_imports)] +use gate_up_row_fn::is_hex; +#[allow(unused_imports)] +use gate_up_row_fn::valid_id; +mod impl_parser; +#[allow(unused_imports)] +use impl_parser::parse_json; +mod validate_in_header_fn; +#[allow(unused_imports)] +use validate_in_header_fn::validate_in_header; +#[allow(unused_imports)] +use validate_in_header_fn::validate_out_header; +#[allow(unused_imports)] +use validate_in_header_fn::fp16_finite; +#[allow(unused_imports)] +use validate_in_header_fn::parse_manifest; +#[allow(unused_imports)] +use validate_in_header_fn::case_files; +mod read_case_in_fn; +#[allow(unused_imports)] +use read_case_in_fn::read_case_in; +#[allow(unused_imports)] +use read_case_in_fn::read_out; +#[allow(unused_imports)] +use read_case_in_fn::read_manifest; +#[allow(unused_imports)] +use read_case_in_fn::verify_dir; +#[allow(unused_imports)] +use read_case_in_fn::compare_bits; +#[allow(unused_imports)] +use read_case_in_fn::jstr; +#[allow(unused_imports)] +use read_case_in_fn::record_json; +mod write_out_fn; +#[allow(unused_imports)] +use write_out_fn::write_out; +#[allow(unused_imports)] +use write_out_fn::compute_case; +#[allow(unused_imports)] +use write_out_fn::family_of; +#[allow(unused_imports)] +use write_out_fn::cmd_run_tree; +#[allow(unused_imports)] +use write_out_fn::sibling_idle; +#[allow(unused_imports)] +use write_out_fn::rustc_info; +#[allow(unused_imports)] +use write_out_fn::host_os; +#[allow(unused_imports)] +use write_out_fn::cpu_model_of; +#[allow(unused_imports)] +use write_out_fn::parse_options; +mod cmd_compare_fn; +#[allow(unused_imports)] +use cmd_compare_fn::cmd_compare; +#[allow(unused_imports)] +use cmd_compare_fn::mono_ns; +#[allow(unused_imports)] +use cmd_compare_fn::core_ghz; +#[allow(unused_imports)] +use cmd_compare_fn::median_of; +#[allow(unused_imports)] +use cmd_compare_fn::percentile_of; +#[allow(unused_imports)] +use cmd_compare_fn::jnum; +#[allow(unused_imports)] +use cmd_compare_fn::read_text; +#[allow(unused_imports)] +use cmd_compare_fn::parse_cpu_list; +#[allow(unused_imports)] +use cmd_compare_fn::parse_size; +mod llc_of_cpu_fn; +#[allow(unused_imports)] +use llc_of_cpu_fn::llc_of_cpu; +#[allow(unused_imports)] +use llc_of_cpu_fn::proc_stat_cpu; +#[allow(unused_imports)] +use llc_of_cpu_fn::busy_fraction; +#[allow(unused_imports)] +use llc_of_cpu_fn::current_cpu; +#[allow(unused_imports)] +use llc_of_cpu_fn::observed_threads; +#[allow(unused_imports)] +use llc_of_cpu_fn::is_managed_name; +#[allow(unused_imports)] +use llc_of_cpu_fn::managed_env_now; +#[allow(unused_imports)] +use llc_of_cpu_fn::json_env; +#[allow(unused_imports)] +use llc_of_cpu_fn::parse_time_args; +#[allow(unused_imports)] +use llc_of_cpu_fn::time_slice; +#[allow(unused_imports)] +use llc_of_cpu_fn::slice_json; +mod run_regime_fn; +#[allow(unused_imports)] +use run_regime_fn::run_regime; +#[allow(unused_imports)] +use run_regime_fn::f32_bits_sha; +mod cmd_time_fn; +#[allow(unused_imports)] +use cmd_time_fn::cmd_time; +mod impl_impl; +#[allow(unused_imports)] +use impl_impl::procs_for; +#[allow(unused_imports)] +use impl_impl::cell_env; +#[allow(unused_imports)] +use impl_impl::scrubbed_command; +#[allow(unused_imports)] +use impl_impl::run_cell; +#[allow(unused_imports)] +use impl_impl::splitmix; +#[allow(unused_imports)] +use impl_impl::make_schedule; +#[allow(unused_imports)] +use impl_impl::schedule_text; +#[allow(unused_imports)] +use impl_impl::parse_schedule; +#[allow(unused_imports)] +use impl_impl::inside_git_checkout; +#[allow(unused_imports)] +use impl_impl::parse_regime; +mod describe_cpp_tree_fn; +#[allow(unused_imports)] +use describe_cpp_tree_fn::describe_cpp_tree; +#[allow(unused_imports)] +use describe_cpp_tree_fn::parse_proc_json; +#[allow(unused_imports)] +use describe_cpp_tree_fn::side_stat; +#[allow(unused_imports)] +use describe_cpp_tree_fn::stat_json; +#[allow(unused_imports)] +use describe_cpp_tree_fn::tool_json; +#[allow(unused_imports)] +use describe_cpp_tree_fn::equality_block; +#[allow(unused_imports)] +use describe_cpp_tree_fn::aa_outcome; +mod round_records_fn; +#[allow(unused_imports)] +use round_records_fn::round_records; +#[allow(unused_imports)] +use round_records_fn::aa_equality_block; +#[allow(unused_imports)] +use round_records_fn::parse_alt_args; +#[allow(unused_imports)] +use round_records_fn::create_new_file; +#[allow(unused_imports)] +use round_records_fn::file_sha; +#[allow(unused_imports)] +use round_records_fn::ours_flags; +mod cmd_alternate_fn; +#[allow(unused_imports)] +use cmd_alternate_fn::cmd_alternate; +#[allow(unused_imports)] +use cmd_alternate_fn::usage; diff --git a/crates/native-cpu-expert/examples/kernel_ab/read_case_in_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/read_case_in_fn.rs new file mode 100644 index 00000000..149a25d1 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/read_case_in_fn.rs @@ -0,0 +1,243 @@ +//! Moved out of the parent module by STRA-338: fn read_case_in, fn read_out, fn read_manifest, fn verify_dir, impl Outcome, fn compare_bits .... + +#[allow(unused_imports)] +use super::*; + + +/// Reads one case input: length against the manifest and the limit, header decision, THEN the buffer, then sha256, FP16 headers and +/// finite activations. Any failure names the file. +pub(super) fn read_case_in(dir: &Path, c: &CaseEntry) -> Result { + let name = c.in_name.as_str(); + let r = |reason: String| Refusal::new(name, reason); + let mut f = File::open(dir.join(name)).map_err(|e| r(format!("cannot open: {e}")))?; + let len = f.metadata().map_err(|e| r(format!("cannot stat: {e}")))?.len(); + if len != c.in_bytes { + return Err(r(format!("length {len} differs from the manifest's {}", c.in_bytes))); + } + if len > MAX_FILE_BYTES || len < IN_HEADER as u64 { + return Err(r(format!("length {len} outside {IN_HEADER}..={MAX_FILE_BYTES}"))); + } + let mut hdr = [0u8; IN_HEADER]; + f.read_exact(&mut hdr).map_err(|e| r(format!("cannot read the header: {e}")))?; + let header = validate_in_header(&hdr, len).map_err(r)?; + if header.gu != c.gu || header.down != c.down || header.rows != c.rows { + return Err(r("the header's types / rows differ from the manifest case".to_owned())); + } + let mut blob = take_buffer(len as usize).map_err(r)?; + blob[..IN_HEADER].copy_from_slice(&hdr); + f.read_exact(&mut blob[IN_HEADER..]).map_err(|e| r(format!("cannot read the body: {e}")))?; + if sha_hex(&blob) != c.in_sha256 { + return Err(r("sha256 differs from the manifest".to_owned())); + } + let case = CaseIn { header, blob }; + let (gb, db) = (gate_up_row(header.gu).map_or(1, |x| x.3), down_row(header.down).map_or(1, |x| x.3)); + for (role, bytes, block) in [("gate", case.gate(), gb), ("up", case.up(), gb), ("down", case.down(), db)] { + if let Some(at) = fp16_finite(bytes, block) { + return Err(r(format!("non-finite FP16 block header in {role} at byte {at}"))); + } + } + if words_le(&case.blob[header.input_at()..]).into_iter().any(|w| !f32::from_bits(w).is_finite()) { + return Err(r("non-finite activation".to_owned())); + } + Ok(case) +} + +/// Reads an `.out` file as f32 bit patterns. `expect` is the manifest's (sha256, bytes) for a C++ file; ours has none. +pub(super) fn read_out( + path: &Path, + name: &str, + rows: usize, + tree: &str, + expect: Option<(&str, u64)>, +) -> Result, Refusal> { + let r = |reason: String| Refusal::new(name, reason); + let mut f = File::open(path).map_err(|e| r(format!("cannot open: {e}")))?; + let len = f.metadata().map_err(|e| r(format!("cannot stat: {e}")))?.len(); + if let Some((_, bytes)) = expect + && len != bytes + { + return Err(r(format!("length {len} differs from the manifest's {bytes}"))); + } + if len > MAX_FILE_BYTES || len < OUT_HEADER as u64 { + return Err(r(format!("length {len} outside {OUT_HEADER}..={MAX_FILE_BYTES}"))); + } + let mut hdr = [0u8; OUT_HEADER]; + f.read_exact(&mut hdr).map_err(|e| r(format!("cannot read the header: {e}")))?; + validate_out_header(&hdr, len, rows, tree).map_err(r)?; + let mut blob = take_buffer(len as usize).map_err(r)?; + blob[..OUT_HEADER].copy_from_slice(&hdr); + f.read_exact(&mut blob[OUT_HEADER..]).map_err(|e| r(format!("cannot read the body: {e}")))?; + if let Some((sha, _)) = expect + && sha_hex(&blob) != sha + { + return Err(r("sha256 differs from the manifest".to_owned())); + } + let bits = words_le(&blob[OUT_HEADER..]); + if bits.iter().any(|b| !f32::from_bits(*b).is_finite()) { + return Err(r("non-finite value".to_owned())); + } + Ok(bits) +} + +/// Reads and parses `manifest.json` (size cap first). Returns its bytes (the caller hashes them), the provenance, the cases and the flat +/// files table. A missing manifest is the `incomplete` refusal. +pub(super) fn read_manifest(dir: &Path) -> Result<(Vec, Provenance, Vec, FileTable), Refusal> { + let mpath = dir.join("manifest.json"); + let mname = "manifest.json"; + if !mpath.is_file() { + let mut r = Refusal::new(mname, "no manifest.json (the writer publishes it last)"); + r.incomplete = true; + return Err(r); + } + let r = |reason: String| Refusal::new(mname, reason); + let mut f = File::open(&mpath).map_err(|e| r(format!("cannot open: {e}")))?; + let mlen = f.metadata().map_err(|e| r(format!("cannot stat: {e}")))?.len(); + if mlen > MAX_MANIFEST_BYTES { + return Err(r(format!("length {mlen} above the limit {MAX_MANIFEST_BYTES}"))); + } + let mut mbytes = take_buffer(mlen as usize).map_err(r)?; + f.read_exact(&mut mbytes).map_err(|e| r(format!("cannot read: {e}")))?; + let manifest = parse_json(&mbytes).map_err(r)?; + let (provenance, cases, files) = parse_manifest(&manifest).map_err(r)?; + Ok((mbytes, provenance, cases, files)) +} + +/// The reader rule. Everything in the directory is checked before anything is used; any problem refuses the whole directory. +pub(super) fn verify_dir(dir: &Path) -> Result { + let mname = "manifest.json"; + let r = |reason: String| Refusal::new(mname, reason); + let (mbytes, provenance, cases, files) = read_manifest(dir)?; + // the flat files table and the case entries must describe exactly the same files + let mut expected: Vec<(&str, &str, u64)> = cases.iter().flat_map(case_files).collect(); + expected.sort_unstable(); + let mut table: Vec<(&str, &str, u64)> = files.iter().map(|(n, s, b)| (n.as_str(), s.as_str(), *b)).collect(); + table.sort_unstable(); + if expected != table { + return Err(r("the flat files table and the case entries disagree".to_owned())); + } + let names: BTreeSet<&str> = expected.iter().map(|e| e.0).collect(); + let listing = fs::read_dir(dir).map_err(|e| r(format!("cannot list the directory: {e}")))?; + for entry in listing { + let entry = entry.map_err(|e| r(format!("cannot list the directory: {e}")))?; + let n = entry.file_name().to_string_lossy().into_owned(); + if n != mname && !names.contains(n.as_str()) { + return Err(Refusal::new(&n, "file is not in the manifest")); + } + } + let file_count = names.len() + 1; + for c in &cases { + read_case_in(dir, c)?; + for o in &c.outs { + read_out(&dir.join(&o.name), &o.name, c.rows, o.tree, Some((&o.sha256, o.bytes)))?; + } + } + Ok(Verified { dir: dir.to_owned(), manifest_sha256: sha_hex(&mbytes), provenance, cases, file_count }) +} +impl Outcome { + pub(super) fn equal(&self) -> bool { + self.mismatches == 0 + } +} + +/// Bitwise on the f32 bit patterns (so -0 and +0 differ) when `tol` is None; otherwise `|ours - ref| <= value * max|ref|` per value +/// (the one metric the reader knows, `TOLERANCE_METRIC`). +pub(super) fn compare_bits(ours: &[u32], reference: &[u32], tol: Option<&Tolerance>) -> Outcome { + let scale = reference.iter().map(|b| f64::from(f32::from_bits(*b)).abs()).fold(0.0, f64::max); + let mut o = Outcome { + compared: reference.len(), + mismatches: 0, + differing_bits: 0, + max_abs_error: 0.0, + first_mismatch: None, + }; + for (i, (a, b)) in ours.iter().zip(reference).enumerate() { + let err = (f64::from(f32::from_bits(*a)) - f64::from(f32::from_bits(*b))).abs(); + if a != b { + o.differing_bits += 1; + } + if err.is_finite() { + o.max_abs_error = o.max_abs_error.max(err); + } + let bad = match tol { + None => a != b, + Some(t) => err.partial_cmp(&(t.value * scale)).is_none_or(|o| o == std::cmp::Ordering::Greater), + }; + if bad { + o.mismatches += 1; + o.first_mismatch.get_or_insert((i, *a, *b)); + } + } + if ours.len() != reference.len() { + o.mismatches += ours.len().abs_diff(reference.len()); + } + o +} + +// ------------------------------------------------------------------------------------------------ record (hand-written JSON) + +pub(super) fn jstr(s: &str) -> String { + let mut o = String::with_capacity(s.len() + 2); + o.push('"'); + for c in s.chars() { + match c { + '"' => o.push_str("\\\""), + '\\' => o.push_str("\\\\"), + '\n' => o.push_str("\\n"), + '\r' => o.push_str("\\r"), + '\t' => o.push_str("\\t"), + c if (c as u32) < 0x20 => o.push_str(&format!("\\u{:04x}", c as u32)), + c => o.push(c), + } + } + o.push('"'); + o +} + +pub(super) fn record_json(r: &RecordInput) -> String { + let p = &r.verified.provenance; + let c = r.case; + let mode = if c.tolerance.is_some() { "tolerance" } else { "bitwise" }; + let tolerance = c.tolerance.as_ref().map_or(String::new(), |t| { + format!( + ",\n \"tolerance\": {{\"value\": {:e}, \"basis\": {}, \"basis_written_utc\": {}}}", + t.value, + jstr(&format!("{} [metric: {TOLERANCE_METRIC}]", t.basis)), + jstr(&t.basis_written_utc) + ) + }); + let tiny = format!("{:e}", f64::from_bits(1)); + let (gu, down) = (gate_up_row(c.gu).map_or("?", |x| x.4), down_row(c.down).map_or("?", |x| x.4)); + format!( + "{{\n \"schema_version\": \"1\",\n \"level\": \"COMPONENT_KERNEL\",\n \"record_id\": {rid},\n \"created_utc\": {created},\n \"run_started_utc\": {started},\n \"machine\": {{\"machine_role\": {role}, \"cpu_model\": {cpu}, \"gpu_name\": \"none\", \"os\": {os}}},\n \"kernel\": {kernel},\n \"toolchain\": {{\n \"ours\": {{\"compiler\": {oc}, \"version\": {ov}, \"target_triple\": {ot}, \"flags\": {of}}},\n \"reference\": {{\"compiler\": {rc}, \"version\": {rv}, \"target_triple\": {rt}, \"flags\": {rf}}}\n }},\n \"case_id\": {cid},\n \"input_sha256\": {insha},\n \"kab1_manifest_sha256\": {msha},\n \"tree\": {{\"ours\": {tree}, \"reference\": {tree}}},\n \"regime\": \"resident\",\n \"pin\": {{\"logical_cpu\": {pin}, \"sibling_idle\": {sib}}},\n \"strata_upstream_commit\": {commit},\n \"clock_calibration\": {{\"method\": {nm}, \"ghz_before\": {tiny}, \"ghz_after\": {tiny}, \"max_drift_fraction\": 0, \"slices_total\": 1, \"slices_dropped\": 0}},\n \"rows\": [\n {{\"row_type\": {rowtype}, \"unit\": \"ns\", \"rounds\": 1, \"ours\": {{\"median\": {tiny}, \"p05\": {tiny}, \"p95\": {tiny}}}, \"reference\": {{\"median\": {tiny}, \"p05\": {tiny}, \"p95\": {tiny}}}}}\n ],\n \"aa_noise_floor\": {{\"ours_vs_ours\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"reference_vs_reference\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"floor_fraction\": 0}},\n \"equality\": {{\n \"mode\": \"{mode}\",\n \"verdict\": \"{verdict}\",\n \"compared_values\": {compared},\n \"mismatches\": {mism}{tolerance}\n }}\n}}\n", + rid = jstr(&r.record_id), + created = jstr(&r.created_utc), + started = jstr(&r.run_started_utc), + role = jstr(&r.machine_role), + cpu = jstr(&r.cpu_model), + os = jstr(&r.os), + kernel = jstr(&format!( + "routed-expert-gate-up-down {gu}+{down} rows={} (equality only; timing {NOT_MEASURED})", + c.rows + )), + oc = jstr(&r.ours_compiler), + ov = jstr(&r.ours_version), + ot = jstr(&r.ours_triple), + of = jstr(&r.ours_flags), + rc = jstr(&p.compiler_id), + rv = jstr(&p.compiler_version), + rt = jstr(&p.target_triple), + rf = jstr(&p.reference_flags), + cid = jstr(&c.id), + insha = jstr(&c.in_sha256), + msha = jstr(&r.verified.manifest_sha256), + tree = jstr(r.tree), + pin = r.pin_cpu, + sib = r.sibling_idle, + commit = jstr(&p.engine_strata_pin), + nm = jstr(NOT_MEASURED), + rowtype = jstr(&format!("{gu}+{down} r{} {NOT_MEASURED}", c.rows)), + verdict = if r.outcome.equal() { "EQUAL" } else { "NOT_EQUAL" }, + compared = r.outcome.compared, + mism = r.outcome.mismatches, + ) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/round_records_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/round_records_fn.rs new file mode 100644 index 00000000..1cc198a8 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/round_records_fn.rs @@ -0,0 +1,204 @@ +//! Moved out of the parent module by STRA-338: fn round_records, fn aa_equality_block, fn parse_alt_args, fn create_new_file, fn file_sha, fn ours_flags. + +#[allow(unused_imports)] +use super::*; + + +/// The records of one round: per tree and regime the A/B record (ours = Rust `a`, reference = C++ `a`) and the two A/A records. +pub(super) fn round_records(ctx: &BatchCtx, round_no: u32, done: &[ProcOut]) -> Result, String> { + let find = |imp: Impl, tree: &str, rep: char| { + done.iter() + .find(|p| p.proc.imp == imp && p.proc.tree == tree && p.proc.rep == rep) + .ok_or_else(|| format!("round {round_no}: process {}-{tree}-{rep} did not run", imp.name())) + }; + let p = &ctx.verified.provenance; + let c = ctx.case; + let cpp_tool = Tool { + compiler: p.compiler_id.clone(), + version: p.compiler_version.clone(), + triple: p.target_triple.clone(), + flags: p.reference_flags.clone(), + }; + let (gu, down) = (gate_up_row(c.gu).map_or("?", |x| x.4), down_row(c.down).map_or("?", |x| x.4)); + if done.is_empty() { + return Err("empty round".to_owned()); + } + let position = |p: &ProcOut| done.iter().position(|d| d.proc == p.proc).unwrap_or(0); + let mut files = Vec::new(); + let trees: Vec<&'static str> = TREES.iter().copied().filter(|t| done.iter().any(|d| d.proc.tree == *t)).collect(); + for tree in trees { + let (cpp_a, cpp_b, rust_a, rust_b) = ( + find(Impl::Cpp, tree, 'a')?, + find(Impl::Cpp, tree, 'b')?, + find(Impl::Rust, tree, 'a')?, + find(Impl::Rust, tree, 'b')?, + ); + for regime in ["RESIDENT", "STREAMED"] { + for kind in [Kind::Ab, Kind::AaCpp, Kind::AaRust] { + let (ours, reference, ours_tool, ref_tool) = match kind { + Kind::Ab => (rust_a, cpp_a, &ctx.rust_tool, &cpp_tool), + Kind::AaCpp => (cpp_a, cpp_b, &cpp_tool, &cpp_tool), + Kind::AaRust => (rust_a, rust_b, &ctx.rust_tool, &ctx.rust_tool), + }; + let (o, r) = (&ours.regimes[regime], &reference.regimes[regime]); + if (o.copies_k, o.expert_bytes, o.llc_bytes) != (r.copies_k, r.expert_bytes, r.llc_bytes) { + return Err(format!( + "round {round_no} {tree} {regime}: the streamed set differs between {} and {} (K {} vs {}, LLC {} vs {})", + ours.proc.name(), + reference.proc.name(), + o.copies_k, + r.copies_k, + o.llc_bytes, + r.llc_bytes + )); + } + let (equality, equality_note) = match kind { + Kind::Ab => (equality_block(c, &ctx.equality[tree]), "Rust output against the C++ reference .out file of the run directory, from the equality phase of this batch".to_owned()), + _ => { + let (outcome, note) = aa_outcome(ours, reference, c.rows); + (aa_equality_block(&outcome), format!("{note}, the same implementation in two fresh processes")) + } + }; + let kernel = format!( + "routed-expert-gate-up-down {gu}+{down} rows={} regime {regime} ROUND RECORD {} (batch {}, round {round_no}); ours-slot process {}, reference-slot process {}; tree ours: {}; tree reference: {}; equality: {equality_note}; aa_noise_floor is a PLACEHOLDER (n=1, CI 0): the A/A evaluation is S0.10b, this record carries one round's medians only", + c.rows, + match kind { + Kind::Ab => "A/B (ours = Rust, reference = C++)", + Kind::AaCpp => "A/A (C++ process a in the ours slot, C++ process b in the reference slot)", + Kind::AaRust => "A/A (Rust process a in the ours slot, Rust process b in the reference slot)", + }, + ctx.batch, + ours.proc.name(), + reference.proc.name(), + ours.tree_text, + reference.tree_text + ); + let drift = o.max_drift.max(r.max_drift); + // the two processes of this record, earliest first: the clock before the earlier one, after the later one + let (earlier, later) = + if position(ours) <= position(reference) { (ours, reference) } else { (reference, ours) }; + let sibling_idle = ours.sibling_idle == Some(true) && reference.sibling_idle == Some(true); + let streamed = if regime == "STREAMED" { + format!( + ",\n \"streamed\": {{\"copies\": {}, \"expert_bytes\": {}, \"llc_bytes\": {}}}", + o.copies_k, o.expert_bytes, o.llc_bytes + ) + } else { + String::new() + }; + let rowtype = + |unit: &str| format!("{gu}+{down} rows={} {} [{unit}]", c.rows, regime.to_ascii_lowercase()); + let json = format!( + "{{\n \"schema_version\": \"1\",\n \"level\": \"COMPONENT_KERNEL\",\n \"record_id\": {rid},\n \"created_utc\": {created},\n \"run_started_utc\": {started},\n \"machine\": {{\"machine_role\": {role}, \"cpu_model\": {cpu}, \"gpu_name\": \"none\", \"os\": {os}}},\n \"kernel\": {kernel},\n \"toolchain\": {{\n \"ours\": {ot},\n \"reference\": {rt}\n }},\n \"case_id\": {cid},\n \"input_sha256\": {insha},\n \"kab1_manifest_sha256\": {msha},\n \"tree\": {{\"ours\": {tree_q}, \"reference\": {tree_q}}},\n \"regime\": {regime_q}{streamed},\n \"pin\": {{\"logical_cpu\": {pin}, \"sibling_idle\": {sib}}},\n \"strata_upstream_commit\": {commit},\n \"clock_calibration\": {{\"method\": {method}, \"ghz_before\": {g0}, \"ghz_after\": {g1}, \"max_drift_fraction\": {drift}, \"slices_total\": {total}, \"slices_dropped\": {dropped}}},\n \"rows\": [\n {{\"row_type\": {rt_ns}, \"unit\": \"ns\", \"rounds\": 1, \"ours\": {on}, \"reference\": {rn}}},\n {{\"row_type\": {rt_cy}, \"unit\": \"cycles\", \"rounds\": 1, \"ours\": {oc}, \"reference\": {rc}}}\n ],\n \"aa_noise_floor\": {{\"ours_vs_ours\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"reference_vs_reference\": {{\"n\": 1, \"ci95_low\": 0, \"ci95_high\": 0}}, \"floor_fraction\": 0}},\n \"equality\": {equality}\n}}\n", + rid = jstr(&format!( + "kab1alt-{}-{}-b{}-r{round_no:05}-{}-{tree}-{}", + ctx.verified.provenance.run_id, + c.id, + ctx.batch, + kind.slug(), + regime.to_ascii_lowercase() + )), + created = jstr(&now_utc()), + started = jstr(&ctx.started_utc), + role = jstr(&ctx.machine_role), + cpu = jstr(&ctx.cpu_model), + os = jstr(&ctx.os), + kernel = jstr(&kernel), + ot = tool_json(ours_tool), + rt = tool_json(ref_tool), + cid = jstr(&c.id), + insha = jstr(&c.in_sha256), + msha = jstr(&ctx.verified.manifest_sha256), + tree_q = jstr(tree), + regime_q = jstr(®ime.to_ascii_lowercase()), + pin = ctx.pin, + sib = sibling_idle, + commit = jstr(&p.engine_strata_pin), + method = jstr(&format!( + "{CLOCK_METHOD}; ghz_before is the ghz_at_start of the earlier process of this record ({}), ghz_after the ghz_at_end of the later one ({}); sibling_idle: the SMT sibling stayed under 5 percent busy during both processes; max_drift_fraction is the largest |g1 - g0| / g0 over every slice of the two processes of this record, slices_total and slices_dropped count their requested and dropped slices", + earlier.proc.name(), + later.proc.name() + )), + g0 = jnum(earlier.ghz_start, 6), + g1 = jnum(later.ghz_end, 6), + drift = jnum(drift, 6), + total = o.requested + r.requested, + dropped = o.dropped + r.dropped, + rt_ns = jstr(&rowtype("ns")), + rt_cy = jstr(&rowtype("cycles")), + on = stat_json(&side_stat(o, false)), + rn = stat_json(&side_stat(r, false)), + oc = stat_json(&side_stat(o, true)), + rc = stat_json(&side_stat(r, true)), + ); + files.push(( + format!("r{round_no:05}.{}.{tree}.{}.json", kind.slug(), regime.to_ascii_lowercase()), + json, + )); + } + } + } + Ok(files) +} + +pub(super) fn aa_equality_block(o: &Outcome) -> String { + format!( + "{{\n \"mode\": \"bitwise\",\n \"verdict\": \"{}\",\n \"compared_values\": {},\n \"mismatches\": {}\n }}", + if o.equal() { "EQUAL" } else { "NOT_EQUAL" }, + o.compared, + o.mismatches + ) +} + +pub(super) fn parse_alt_args(args: &[String]) -> Result { + let f = Flags::parse(args, &ALT_FLAGS)?; + let rounds = f.number::("rounds")?.ok_or("--rounds is required")?; + let batch = f.number::("batch")?.ok_or("--batch is required")?; + if !(1..=10_000).contains(&rounds) || !(1..=1000).contains(&batch) { + return Err("--rounds must be 1..10000 and --batch 1..1000 (the batch number, counted from 1)".to_owned()); + } + let case = f.req("case")?.to_owned(); + if !valid_id(&case) { + return Err(format!("--case {case:?} is not a plain identifier")); + } + let slices = f.number::("slices")?.unwrap_or(20); + if !(1..=100_000).contains(&slices) { + return Err("--slices must be 1..100000".to_owned()); + } + Ok(AltArgs { + dir: PathBuf::from(f.req("run-dir")?), + case, + rounds, + batch, + pin: f.number::("pin")?.ok_or("--pin is required")?, + schedule: PathBuf::from(f.req("schedule")?), + seed: f.number::("seed")?.unwrap_or(1), + out: f.get("out").map(PathBuf::from), + slices, + slice_ms: f.number::("slice-ms")?, + llc_bytes: f.number::("llc-bytes")?, + machine_role: f.get("machine-role").map(str::to_owned), + kab: f.get("kab").map(PathBuf::from), + }) +} + +pub(super) fn create_new_file(path: &Path, bytes: &[u8]) -> Result<(), String> { + let mut f = fs::OpenOptions::new() + .write(true) + .create_new(true) + .open(path) + .map_err(|e| format!("{}: {e} (nothing is overwritten)", path.display()))?; + f.write_all(bytes).map_err(|e| format!("{}: {e}", path.display())) +} + +pub(super) fn file_sha(path: &Path) -> Result { + fs::read(path).map(|b| sha_hex(&b)).map_err(|e| format!("{}: {e}", path.display())) +} + +pub(super) fn ours_flags() -> String { + format!( + "cargo profile {}; RUSTFLAGS={:?}; target-cpu default", + if cfg!(debug_assertions) { "dev" } else { "release" }, + std::env::var("RUSTFLAGS").unwrap_or_default() + ) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/run_regime_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/run_regime_fn.rs new file mode 100644 index 00000000..27bf4ddb --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/run_regime_fn.rs @@ -0,0 +1,67 @@ +//! Moved out of the parent module by STRA-338: fn run_regime, fn f32_bits_sha. + +#[allow(unused_imports)] +use super::*; + + +pub(super) fn run_regime(t: &mut Timed, spec: &RegimeSpec) -> Result { + let mut next = 0usize; + // warm-up (not recorded): tables and buffers, and for STREAMED one full pass over the copies so every page is resident + for _ in 0..3 { + t.call(spec.copies[next % spec.copies.len()])?; + next += 1; + } + if spec.copies.len() > 1 { + for _ in 0..spec.copies.len() { + t.call(spec.copies[next % spec.copies.len()])?; + next += 1; + } + } + let (mut kept, mut dropped): (Numbered, Numbered) = (Vec::new(), Vec::new()); + let mut migrated: Option = cfg!(target_os = "linux").then_some(0); + for i in 0..spec.slices { + let before = current_cpu(); + let s = time_slice(t, &spec.copies, spec.slice_ms, &mut next)?; + if let Some(m) = migrated.as_mut() + && (before != Some(spec.pin) || current_cpu() != Some(spec.pin)) + { + *m += 1; + } + if s.moved { dropped.push((i, s)) } else { kept.push((i, s)) } + } + let ns: Vec = kept.iter().map(|k| k.1.ns_per_call).collect(); + let cyc: Vec = kept.iter().map(|k| k.1.cycles_per_call).collect(); + let med = |v: &[f64], d: usize| if v.is_empty() { "null".to_owned() } else { jnum(median_of(v), d) }; + let list = |v: &[(usize, Slice)]| v.iter().map(|(i, s)| slice_json(s, *i)).collect::>().join(",\n "); + let json = format!( + "{{\"regime\": {}, \"copies_k\": {}, \"expert_bytes\": {}, \"copy_stride_bytes\": {}, \"working_set_bytes\": {}, \"llc_level\": {}, \"llc_bytes\": {}, \"llc_source\": {}, \"working_set_over_llc\": {}, \"slice_ms\": {}, \"slices_requested\": {}, \"slices_kept\": {}, \"dropped_count\": {}, \"selfcheck_bitwise_equal_first_call\": {}, \"migrated_slices\": {}, \"median_ns_per_call\": {}, \"median_cycles_per_call\": {},\n \"slices\": [\n {}],\n \"dropped\": [\n {}]}}", + jstr(spec.label), + spec.copies.len(), + spec.expert_bytes, + spec.stride, + spec.expert_bytes * spec.copies.len(), + spec.llc.level, + spec.llc.bytes, + jstr(&spec.llc.source), + spec.copies.len() > 1, + jnum(spec.slice_ms, 1), + spec.slices, + kept.len(), + dropped.len(), + spec.selfcheck, + migrated.map_or("null".to_owned(), |m| m.to_string()), + med(&ns, 3), + med(&cyc, 1), + list(&kept), + list(&dropped) + ); + Ok(RegimeRun { json, kept: kept.len(), ok: !kept.is_empty() && migrated.is_none_or(|m| m == 0) }) +} + +pub(super) fn f32_bits_sha(values: &[f32]) -> String { + let mut b = Vec::with_capacity(values.len() * 4); + for v in values { + b.extend_from_slice(&v.to_bits().to_le_bytes()); + } + sha_hex(&b) +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/validate_in_header_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/validate_in_header_fn.rs new file mode 100644 index 00000000..1dc6c1fc --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/validate_in_header_fn.rs @@ -0,0 +1,223 @@ +//! Moved out of the parent module by STRA-338: fn validate_in_header, fn validate_out_header, fn fp16_finite, fn parse_manifest, fn case_files, impl CaseIn. + +#[allow(unused_imports)] +use super::*; + + +/// Pure: decides from 64 header bytes and the file length, allocates nothing. +pub(super) fn validate_in_header(h: &[u8; IN_HEADER], file_len: u64) -> Result { + if le32(h, 0) != IN_MAGIC { + return Err(format!("wrong magic 0x{:08x}, expected 0x{IN_MAGIC:08x}", le32(h, 0))); + } + if le32(h, 4) != 1 { + return Err(format!("unsupported version {}, expected 1", le32(h, 4))); + } + let (gu, down) = (le32(h, 8) as i32, le32(h, 12) as i32); + let Some(&(_, _, gq, gb, _)) = gate_up_row(gu) else { + return Err(format!("gate/up type {gu} is not in the KAB1 list")); + }; + let Some(&(_, _, dq, db, _)) = down_row(down) else { + return Err(format!("down type {down} is not in the KAB1 list")); + }; + let rows = le32(h, 16) as usize; + if !(1..=MAX_ROWS).contains(&rows) { + return Err(format!("rows {rows} outside 1..={MAX_ROWS}")); + } + if le32(h, 20) as usize != H || le32(h, 24) as usize != FF { + return Err(format!("n_embd {} / n_ff {} differ from {H} / {FF}", le32(h, 20), le32(h, 24))); + } + let gsize = (H / gq * gb * FF) as u64; + let dsize = (FF / dq * db * H) as u64; + let (g, u, d) = (le32(h, 28) as u64, le32(h, 32) as u64, le32(h, 36) as u64); + if g != gsize || u != gsize || d != dsize { + return Err(format!( + "byte counts gate/up/down {g}/{u}/{d} differ from the format-derived {gsize}/{gsize}/{dsize}" + )); + } + if h[40..].iter().any(|b| *b != 0) { + return Err("header padding is not zero".to_owned()); + } + let total = IN_HEADER as u64 + g + u + d + (rows * H * 4) as u64; + if total != file_len { + return Err(format!("file length {file_len} differs from the header-derived {total}")); + } + Ok(InHeader { gu, down, rows, gate: g as usize, up: u as usize, down_bytes: d as usize }) +} + +/// Pure: 20 bytes and the file length. +pub(super) fn validate_out_header(h: &[u8; OUT_HEADER], file_len: u64, rows: usize, tree: &str) -> Result<(), String> { + if le32(h, 0) != OUT_MAGIC { + return Err(format!("wrong magic 0x{:08x}, expected 0x{OUT_MAGIC:08x}", le32(h, 0))); + } + if le32(h, 4) != 1 { + return Err(format!("unsupported version {}, expected 1", le32(h, 4))); + } + if le32(h, 8) as usize != rows || le32(h, 12) as usize != H { + return Err(format!("rows {} / n_embd {} differ from the case ({rows} / {H})", le32(h, 8), le32(h, 12))); + } + let tree_id = TREES.iter().position(|t| *t == tree).map_or(u32::MAX, |i| i as u32); + if le32(h, 16) != tree_id { + return Err(format!("tree id {} differs from the file name's tree {tree} ({tree_id})", le32(h, 16))); + } + let total = (OUT_HEADER + rows * H * 4) as u64; + if total != file_len { + return Err(format!("file length {file_len} differs from the header-derived {total}")); + } + Ok(()) +} + +pub(super) fn fp16_finite(bytes: &[u8], block: usize) -> Option { + (0..bytes.len()).step_by(block).find(|&at| u16::from_le_bytes([bytes[at], bytes[at + 1]]) & 0x7c00 == 0x7c00) +} + +pub(super) fn parse_manifest(m: &Json) -> Result<(Provenance, Vec, FileTable), String> { + if m.str("format")? != "KAB1" || m.uint("version")? != 1 { + return Err("format is not KAB1 version 1".to_owned()); + } + let p = m.req("provenance")?; + let flags = p.req("flags")?; + let commit = p.str("engine_strata_pin")?; + if !is_hex(commit, 7, 40) { + return Err("provenance.engine_strata_pin is not a commit hash".to_owned()); + } + let built = p.str("built_at_utc")?; + if !is_utc(built) { + return Err("provenance.built_at_utc is not a UTC timestamp".to_owned()); + } + let avx512_ok = match p.get("avx512_ok") { + Some(Json::Bool(b)) => Some(*b), + _ => None, + }; + let provenance = Provenance { + run_id: m.str("run_id")?.to_owned(), + engine_strata_pin: commit.to_owned(), + compiler_id: p.str("compiler_id")?.to_owned(), + compiler_version: p.str("compiler_version")?.to_owned(), + target_triple: p.str("target_triple")?.to_owned(), + reference_flags: format!( + "strata_cxx_flags: {}; ggml_cpu_arch_flags: {}", + flags.str("strata_cxx_flags")?, + flags.str("ggml_cpu_arch_flags")? + ), + avx512_ok, + }; + let Json::Arr(cases_json) = m.req("cases")? else { return Err("cases is not an array".to_owned()) }; + if cases_json.is_empty() || cases_json.len() > MAX_CASES { + return Err(format!("{} cases (1..={MAX_CASES} allowed)", cases_json.len())); + } + let mut cases = Vec::new(); + for c in cases_json { + let id = c.str("id")?.to_owned(); + if !valid_id(&id) { + return Err(format!("case id {id:?} is not a plain identifier")); + } + let rows = c.uint("rows")? as usize; + let in_name = format!("case-{id}.in"); + if c.str("in")? != in_name { + return Err(format!("case {id}: file name {:?} is not {in_name}", c.str("in")?)); + } + let mut outs = Vec::new(); + for tree in TREES { + let key = format!("out_cpp_{tree}"); + let name = format!("case-{id}.cpp-{tree}.out"); + if c.str(&key)? != name { + return Err(format!("case {id}: file name {:?} is not {name}", c.str(&key)?)); + } + outs.push(OutRef { + tree, + name, + sha256: c.str(&format!("{key}_sha256"))?.to_owned(), + bytes: c.uint(&format!("{key}_bytes"))?, + }); + } + let tolerance = match (c.str("equality")?, c.req("tolerance")?) { + ("bitwise", Json::Null) => None, + ("tolerance", t @ Json::Obj(_)) => { + if t.str("metric")? != TOLERANCE_METRIC { + return Err(format!( + "case {id}: tolerance metric {:?} is not {TOLERANCE_METRIC}", + t.str("metric")? + )); + } + let value = match t.req("value")? { + Json::Num(n) => n.parse::().ok().filter(|v| v.is_finite() && *v > 0.0), + _ => None, + } + .ok_or_else(|| format!("case {id}: tolerance.value is not a positive number"))?; + let basis = t.str("basis")?.to_owned(); + let written = t.str("basis_written_utc")?.to_owned(); + if basis.trim().is_empty() || !is_utc(&written) { + return Err(format!("case {id}: tolerance needs a non-empty basis and a UTC basis_written_utc")); + } + if written.as_str() > built { + return Err(format!( + "case {id}: the tolerance basis was written {written}, after the reference run {built}" + )); + } + Some(Tolerance { value, basis, basis_written_utc: written }) + } + (other, _) => { + return Err(format!( + "case {id}: equality {other:?} and tolerance disagree (bitwise needs null, tolerance an object)" + )); + } + }; + let in_sha256 = c.str("in_sha256")?.to_owned(); + let gu = c.uint("gu_type")? as i32; + let down = c.uint("down_type")? as i32; + cases.push(CaseEntry { + id, + gu, + down, + rows, + in_name, + in_sha256, + in_bytes: c.uint("in_bytes")?, + outs, + tolerance, + }); + } + let Json::Obj(files_json) = m.req("files")? else { return Err("files is not an object".to_owned()) }; + let mut files = Vec::new(); + for (name, v) in files_json { + let sha = v.str("sha256")?; + if !is_hex(sha, 64, 64) { + return Err(format!("files.{name}.sha256 is not a sha256")); + } + files.push((name.clone(), sha.to_owned(), v.uint("bytes")?)); + } + let mut seen = BTreeSet::new(); + for c in &cases { + if !seen.insert(c.id.clone()) { + return Err(format!("case id {} appears twice", c.id)); + } + for sha in std::iter::once(&c.in_sha256).chain(c.outs.iter().map(|o| &o.sha256)) { + if !is_hex(sha, 64, 64) { + return Err(format!("case {}: a sha256 is not 64 lowercase hex digits", c.id)); + } + } + } + Ok((provenance, cases, files)) +} + +pub(super) fn case_files(c: &CaseEntry) -> Vec<(&str, &str, u64)> { + let mut v = vec![(c.in_name.as_str(), c.in_sha256.as_str(), c.in_bytes)]; + v.extend(c.outs.iter().map(|o| (o.name.as_str(), o.sha256.as_str(), o.bytes))); + v +} +impl CaseIn { + pub(super) fn gate(&self) -> &[u8] { + &self.blob[IN_HEADER..IN_HEADER + self.header.gate] + } + pub(super) fn up(&self) -> &[u8] { + let s = IN_HEADER + self.header.gate; + &self.blob[s..s + self.header.up] + } + pub(super) fn down(&self) -> &[u8] { + let s = IN_HEADER + self.header.gate + self.header.up; + &self.blob[s..s + self.header.down_bytes] + } + pub(super) fn input(&self) -> Vec { + words_le(&self.blob[self.header.input_at()..]).into_iter().map(f32::from_bits).collect() + } +} diff --git a/crates/native-cpu-expert/examples/kernel_ab/write_out_fn.rs b/crates/native-cpu-expert/examples/kernel_ab/write_out_fn.rs new file mode 100644 index 00000000..aa2906a0 --- /dev/null +++ b/crates/native-cpu-expert/examples/kernel_ab/write_out_fn.rs @@ -0,0 +1,187 @@ +//! Moved out of the parent module by STRA-338: fn write_out, fn compute_case, fn family_of, fn cmd_run_tree, fn sibling_idle, fn rustc_info .... + +#[allow(unused_imports)] +use super::*; + + +// ------------------------------------------------------------------------------------------------ run-tree (one fresh process) + +pub(super) fn write_out(path: &Path, rows: usize, tree: &str, values: &[f32]) -> Result<(), String> { + let tree_id = TREES.iter().position(|t| *t == tree).ok_or("unknown tree")? as u32; + let mut b = Vec::with_capacity(OUT_HEADER + values.len() * 4); + for w in [OUT_MAGIC, 1, rows as u32, H as u32, tree_id] { + b.extend_from_slice(&w.to_le_bytes()); + } + for v in values { + b.extend_from_slice(&v.to_bits().to_le_bytes()); + } + File::create(path).and_then(|mut f| f.write_all(&b)).map_err(|e| format!("{}: {e}", path.display())) +} + +/// Our kernels on one verified case through the public API: PreparedJob only for the input validation it performs, then one +/// `compute_group` over borrowed bytes (one expert, `rows` tokens, pairs `(t, 0)`, stride 1). +pub(super) fn compute_case(pool: &mut DirectCpuPool, case: &CaseIn) -> Result, String> { + let (gu, down) = + (gate_up_row(case.header.gu).ok_or("gate/up type")?.1, down_row(case.header.down).ok_or("down type")?.1); + let input = case.input(); + PreparedJob::new( + gu, + down, + case.gate().into(), + case.up().into(), + case.down().into(), + input.clone().into(), + case.header.rows, + ) + .map_err(|e| format!("PreparedJob refused the input: {e:?}"))?; + let pairs: Vec<(usize, usize)> = (0..case.header.rows).map(|t| (t, 0)).collect(); + let expert = BorrowedExpert { gate: case.gate(), up: case.up(), down: case.down(), pairs: &pairs }; + let experts = [expert]; + let group = BorrowedGroup { tokens: &input, experts: &experts, stride: 1 }; + let mut out = vec![0.0f32; case.header.rows * H]; + pool.compute_group(gu, down, &group, &mut out).map_err(|e| format!("compute_group failed: {e:?}"))?; + Ok(out) +} + +pub(super) fn family_of(report: &[String]) -> Option<&'static str> { + report + .iter() + .find(|l| l.starts_with("cpu: process kernel family ")) + .map(|l| if l.starts_with("cpu: process kernel family AVX-512") { "avx512" } else { "avx2" }) +} + +pub(super) fn cmd_run_tree(dir: &Path, tree: &str, out: &Path, pin: usize, only_case: Option<&str>) -> Result { + let verified = verify_dir(dir).map_err(|e| e.to_string())?; + let previous = rust_topology::pin_current_thread(pin as i32); + if previous < 0 { + eprintln!("kernel_ab: the pin to CPU {pin} was refused; running unpinned"); + } + let report = cpu_kernel_report(); + for line in &report { + println!("REPORT {line}"); + } + let family = family_of(&report).ok_or("no process kernel family line in cpu_kernel_report")?; + if family != tree { + eprintln!("kernel_ab: this process runs the {family} family, not {tree}"); + return Ok(ExitCode::from(3)); + } + fs::create_dir_all(out).map_err(|e| format!("{}: {e}", out.display()))?; + let mut pool = DirectCpuPool::new(1).map_err(|e| format!("DirectCpuPool::new(1) failed: {e:?}"))?; + let mut done = 0usize; + for c in verified.cases.iter().filter(|c| only_case.is_none_or(|id| c.id == id)) { + let case = read_case_in(&verified.dir, c).map_err(|e| e.to_string())?; + let values = compute_case(&mut pool, &case).map_err(|e| format!("case {}: {e}", c.id))?; + write_out(&out.join(format!("case-{}.rust-{tree}.out", c.id)), c.rows, tree, &values)?; + done += 1; + } + if done == 0 { + return Err(format!("case {} is not in the manifest", only_case.unwrap_or("?"))); + } + println!("RUN-TREE {tree} cases={done}"); + Ok(ExitCode::SUCCESS) +} + +// ------------------------------------------------------------------------------------------------ compare driver + +/// Linux: is the SMT sibling of `cpu` idle (below 5 percent busy over 200 ms)? No sibling counts as idle. Elsewhere: false (unknown). +pub(super) fn sibling_idle(cpu: usize) -> bool { + if !cfg!(target_os = "linux") { + return false; + } + let Ok(list) = fs::read_to_string(format!("/sys/devices/system/cpu/cpu{cpu}/topology/thread_siblings_list")) else { + return false; + }; + let mut siblings = Vec::new(); + for part in list.trim().split(',') { + let (a, b) = part.split_once('-').unwrap_or((part, part)); + let (Ok(a), Ok(b)) = (a.trim().parse::(), b.trim().parse::()) else { return false }; + siblings.extend((a..=b).filter(|s| *s != cpu)); + } + if siblings.is_empty() { + return true; + } + let sample = |cpu: usize| -> Option<(u64, u64)> { + let stat = fs::read_to_string("/proc/stat").ok()?; + let line = stat.lines().find(|l| l.starts_with(&format!("cpu{cpu} ")))?; + let f: Vec = line.split_whitespace().skip(1).filter_map(|x| x.parse().ok()).collect(); + let idle = f.get(3)? + f.get(4).copied().unwrap_or(0); + Some((f.iter().sum(), idle)) + }; + let before: Vec<_> = siblings.iter().map(|s| sample(*s)).collect(); + std::thread::sleep(std::time::Duration::from_millis(200)); + siblings.iter().zip(before).all(|(s, b)| match (b, sample(*s)) { + (Some(b), Some(a)) => { + let total = a.0.saturating_sub(b.0); + let idle = a.1.saturating_sub(b.1); + total > 0 && (total - idle.min(total)) * 20 < total + } + _ => false, + }) +} + +pub(super) fn rustc_info() -> (String, String) { + // $RUSTC, then `rustc` on the PATH, then the rustup shim of the user (a non-login shell has no cargo bin directory on its PATH) + let home = std::env::var("HOME").or_else(|_| std::env::var("USERPROFILE")).unwrap_or_default(); + let shim = format!("{home}/.cargo/bin/{}", if cfg!(windows) { "rustc.exe" } else { "rustc" }); + let candidates = [std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_owned()), "rustc".to_owned(), shim]; + let triple = if cfg!(windows) { "x86_64-pc-windows-msvc" } else { "x86_64-unknown-linux-gnu" }; + let version = candidates + .iter() + .find_map(|rustc| { + Command::new(rustc) + .arg("--version") + .output() + .ok() + .filter(|o| o.status.success()) + .and_then(|o| String::from_utf8(o.stdout).ok()) + }) + .map_or_else(|| "unknown (rustc not runnable at record time)".to_owned(), |s| s.trim().to_owned()); + (version, triple.to_owned()) +} + +pub(super) fn host_os() -> String { + if cfg!(target_os = "linux") + && let Ok(text) = fs::read_to_string("/etc/os-release") + && let Some(l) = text.lines().find(|l| l.starts_with("PRETTY_NAME=")) + { + return l["PRETTY_NAME=".len()..].trim_matches('"').to_owned(); + } + std::env::consts::OS.to_owned() +} + +pub(super) fn cpu_model_of(report: &[String]) -> String { + report + .iter() + .find(|l| l.starts_with("cpu: logical ")) + .and_then(|l| l.split_once("): ").map(|x| x.1)) + .and_then(|rest| rest.split(';').next()) + .map_or_else(|| "unknown model".to_owned(), |s| s.trim().to_owned()) +} + +pub(super) fn parse_options(args: &[String]) -> Result { + let mut o = Options { + out: None, + pin: 0, + machine_role: None, + trees: TREES.iter().map(|t| (*t).to_owned()).collect(), + tree: None, + case: None, + }; + let mut it = args.iter(); + while let Some(a) = it.next() { + let mut value = |what: &str| it.next().cloned().ok_or_else(|| format!("{what} needs a value")); + match a.as_str() { + "--out" => o.out = Some(PathBuf::from(value("--out")?)), + "--pin" => o.pin = value("--pin")?.parse().map_err(|_| "--pin takes a logical CPU number".to_owned())?, + "--machine-role" => o.machine_role = Some(value("--machine-role")?), + "--trees" => o.trees = value("--trees")?.split(',').map(str::to_owned).collect(), + "--tree" => o.tree = Some(value("--tree")?), + "--case" => o.case = Some(value("--case")?), + other => return Err(format!("unknown option {other}")), + } + } + if let Some(bad) = o.trees.iter().find(|t| !TREES.contains(&t.as_str())) { + return Err(format!("unknown tree {bad} (avx512 | avx2)")); + } + Ok(o) +} diff --git a/crates/native-cpu-expert/src/rust_codebooks.rs b/crates/native-cpu-expert/src/rust_codebooks.rs index def6ae06..d5c2af92 100644 --- a/crates/native-cpu-expert/src/rust_codebooks.rs +++ b/crates/native-cpu-expert/src/rust_codebooks.rs @@ -1,1905 +1,367 @@ //! Literal numerical codebooks from pinned ggml-common.h. See LICENSE.ggml. +#[rustfmt::skip] pub(super) const KSIGNS_IQ2XS: [u8; 128] = [ - 0, 129, 130, 3, 132, 5, 6, 135, 136, 9, 10, 139, 12, 141, 142, 15, 144, 17, 18, 147, 20, 149, 150, 23, 24, 153, - 154, 27, 156, 29, 30, 159, 160, 33, 34, 163, 36, 165, 166, 39, 40, 169, 170, 43, 172, 45, 46, 175, 48, 177, 178, - 51, 180, 53, 54, 183, 184, 57, 58, 187, 60, 189, 190, 63, 192, 65, 66, 195, 68, 197, 198, 71, 72, 201, 202, 75, - 204, 77, 78, 207, 80, 209, 210, 83, 212, 85, 86, 215, 216, 89, 90, 219, 92, 221, 222, 95, 96, 225, 226, 99, 228, - 101, 102, 231, 232, 105, 106, 235, 108, 237, 238, 111, 240, 113, 114, 243, 116, 245, 246, 119, 120, 249, 250, 123, - 252, 125, 126, 255, + 0, 129, 130, 3, 132, 5, 6, 135, + 136, 9, 10, 139, 12, 141, 142, 15, + 144, 17, 18, 147, 20, 149, 150, 23, + 24, 153, 154, 27, 156, 29, 30, 159, + 160, 33, 34, 163, 36, 165, 166, 39, + 40, 169, 170, 43, 172, 45, 46, 175, + 48, 177, 178, 51, 180, 53, 54, 183, + 184, 57, 58, 187, 60, 189, 190, 63, + 192, 65, 66, 195, 68, 197, 198, 71, + 72, 201, 202, 75, 204, 77, 78, 207, + 80, 209, 210, 83, 212, 85, 86, 215, + 216, 89, 90, 219, 92, 221, 222, 95, + 96, 225, 226, 99, 228, 101, 102, 231, + 232, 105, 106, 235, 108, 237, 238, 111, + 240, 113, 114, 243, 116, 245, 246, 119, + 120, 249, 250, 123, 252, 125, 126, 255, ]; +#[rustfmt::skip] pub(super) const IQ2XXS_GRID: [u64; 256] = [ - 0x0808080808080808, - 0x080808080808082b, - 0x0808080808081919, - 0x0808080808082b08, - 0x0808080808082b2b, - 0x0808080808190819, - 0x0808080808191908, - 0x08080808082b0808, - 0x08080808082b082b, - 0x08080808082b2b08, - 0x08080808082b2b2b, - 0x0808080819080819, - 0x0808080819081908, - 0x0808080819190808, - 0x0808080819192b08, - 0x08080808192b0819, - 0x08080808192b1908, - 0x080808082b080808, - 0x080808082b08082b, - 0x080808082b082b2b, - 0x080808082b2b082b, - 0x0808081908080819, - 0x0808081908081908, - 0x0808081908190808, - 0x0808081908191919, - 0x0808081919080808, - 0x080808192b081908, - 0x080808192b192b08, - 0x0808082b08080808, - 0x0808082b0808082b, - 0x0808082b082b082b, - 0x0808082b2b08082b, - 0x0808190808080819, - 0x0808190808081908, - 0x0808190808190808, - 0x08081908082b0819, - 0x08081908082b1908, - 0x0808190819080808, - 0x080819081908082b, - 0x0808190819082b08, - 0x08081908192b0808, - 0x080819082b080819, - 0x080819082b081908, - 0x080819082b190808, - 0x080819082b2b1908, - 0x0808191908080808, - 0x080819190808082b, - 0x0808191908082b08, - 0x08081919082b0808, - 0x080819191908192b, - 0x08081919192b2b19, - 0x080819192b080808, - 0x080819192b190819, - 0x0808192b08082b19, - 0x0808192b08190808, - 0x0808192b19080808, - 0x0808192b2b081908, - 0x0808192b2b2b1908, - 0x08082b0808080808, - 0x08082b0808081919, - 0x08082b0808082b08, - 0x08082b0808191908, - 0x08082b08082b2b08, - 0x08082b0819080819, - 0x08082b0819081908, - 0x08082b0819190808, - 0x08082b081919082b, - 0x08082b082b082b08, - 0x08082b1908081908, - 0x08082b1919080808, - 0x08082b2b0808082b, - 0x08082b2b08191908, - 0x0819080808080819, - 0x0819080808081908, - 0x0819080808190808, - 0x08190808082b0819, - 0x0819080819080808, - 0x08190808192b0808, - 0x081908082b081908, - 0x081908082b190808, - 0x081908082b191919, - 0x0819081908080808, - 0x0819081908082b08, - 0x08190819082b0808, - 0x0819081919190808, - 0x0819081919192b2b, - 0x081908192b080808, - 0x0819082b082b1908, - 0x0819082b19081919, - 0x0819190808080808, - 0x0819190808082b08, - 0x08191908082b0808, - 0x08191908082b1919, - 0x0819190819082b19, - 0x081919082b080808, - 0x0819191908192b08, - 0x08191919192b082b, - 0x0819192b08080808, - 0x0819192b0819192b, - 0x08192b0808080819, - 0x08192b0808081908, - 0x08192b0808190808, - 0x08192b0819080808, - 0x08192b082b080819, - 0x08192b1908080808, - 0x08192b1908081919, - 0x08192b192b2b0808, - 0x08192b2b19190819, - 0x082b080808080808, - 0x082b08080808082b, - 0x082b080808082b2b, - 0x082b080819081908, - 0x082b0808192b0819, - 0x082b08082b080808, - 0x082b08082b08082b, - 0x082b0819082b2b19, - 0x082b081919082b08, - 0x082b082b08080808, - 0x082b082b0808082b, - 0x082b190808080819, - 0x082b190808081908, - 0x082b190808190808, - 0x082b190819080808, - 0x082b19081919192b, - 0x082b191908080808, - 0x082b191919080819, - 0x082b1919192b1908, - 0x082b192b2b190808, - 0x082b2b0808082b08, - 0x082b2b08082b0808, - 0x082b2b082b191908, - 0x082b2b2b19081908, - 0x1908080808080819, - 0x1908080808081908, - 0x1908080808190808, - 0x1908080808192b08, - 0x19080808082b0819, - 0x19080808082b1908, - 0x1908080819080808, - 0x1908080819082b08, - 0x190808081919192b, - 0x19080808192b0808, - 0x190808082b080819, - 0x190808082b081908, - 0x190808082b190808, - 0x1908081908080808, - 0x19080819082b0808, - 0x19080819192b0819, - 0x190808192b080808, - 0x190808192b081919, - 0x1908082b08080819, - 0x1908082b08190808, - 0x1908082b19082b08, - 0x1908082b1919192b, - 0x1908082b192b2b08, - 0x1908190808080808, - 0x1908190808082b08, - 0x19081908082b0808, - 0x190819082b080808, - 0x190819082b192b19, - 0x190819190819082b, - 0x19081919082b1908, - 0x1908192b08080808, - 0x19082b0808080819, - 0x19082b0808081908, - 0x19082b0808190808, - 0x19082b0819080808, - 0x19082b0819081919, - 0x19082b1908080808, - 0x19082b1919192b08, - 0x19082b19192b0819, - 0x19082b192b08082b, - 0x19082b2b19081919, - 0x19082b2b2b190808, - 0x1919080808080808, - 0x1919080808082b08, - 0x1919080808190819, - 0x1919080808192b19, - 0x19190808082b0808, - 0x191908082b080808, - 0x191908082b082b08, - 0x1919081908081908, - 0x191908191908082b, - 0x191908192b2b1908, - 0x1919082b2b190819, - 0x191919082b190808, - 0x191919082b19082b, - 0x1919191908082b2b, - 0x1919192b08080819, - 0x1919192b19191908, - 0x19192b0808080808, - 0x19192b0808190819, - 0x19192b0808192b19, - 0x19192b08192b1908, - 0x19192b1919080808, - 0x19192b2b08082b08, - 0x192b080808081908, - 0x192b080808190808, - 0x192b080819080808, - 0x192b0808192b2b08, - 0x192b081908080808, - 0x192b081919191919, - 0x192b082b08192b08, - 0x192b082b192b0808, - 0x192b190808080808, - 0x192b190808081919, - 0x192b191908190808, - 0x192b19190819082b, - 0x192b19192b081908, - 0x192b2b081908082b, - 0x2b08080808080808, - 0x2b0808080808082b, - 0x2b08080808082b2b, - 0x2b08080819080819, - 0x2b0808082b08082b, - 0x2b08081908081908, - 0x2b08081908192b08, - 0x2b08081919080808, - 0x2b08082b08190819, - 0x2b08190808080819, - 0x2b08190808081908, - 0x2b08190808190808, - 0x2b08190808191919, - 0x2b08190819080808, - 0x2b081908192b0808, - 0x2b08191908080808, - 0x2b0819191908192b, - 0x2b0819192b191908, - 0x2b08192b08082b19, - 0x2b08192b19080808, - 0x2b08192b192b0808, - 0x2b082b080808082b, - 0x2b082b1908081908, - 0x2b082b2b08190819, - 0x2b19080808081908, - 0x2b19080808190808, - 0x2b190808082b1908, - 0x2b19080819080808, - 0x2b1908082b2b0819, - 0x2b1908190819192b, - 0x2b1908192b080808, - 0x2b19082b19081919, - 0x2b19190808080808, - 0x2b191908082b082b, - 0x2b19190819081908, - 0x2b19191919190819, - 0x2b192b082b080819, - 0x2b192b19082b0808, - 0x2b2b08080808082b, - 0x2b2b080819190808, - 0x2b2b08082b081919, - 0x2b2b081908082b19, - 0x2b2b082b08080808, - 0x2b2b190808192b08, - 0x2b2b2b0819190808, - 0x2b2b2b1908081908, + 0x0808080808080808, 0x080808080808082b, 0x0808080808081919, 0x0808080808082b08, 0x0808080808082b2b, 0x0808080808190819, 0x0808080808191908, 0x08080808082b0808, + 0x08080808082b082b, 0x08080808082b2b08, 0x08080808082b2b2b, 0x0808080819080819, 0x0808080819081908, 0x0808080819190808, 0x0808080819192b08, 0x08080808192b0819, + 0x08080808192b1908, 0x080808082b080808, 0x080808082b08082b, 0x080808082b082b2b, 0x080808082b2b082b, 0x0808081908080819, 0x0808081908081908, 0x0808081908190808, + 0x0808081908191919, 0x0808081919080808, 0x080808192b081908, 0x080808192b192b08, 0x0808082b08080808, 0x0808082b0808082b, 0x0808082b082b082b, 0x0808082b2b08082b, + 0x0808190808080819, 0x0808190808081908, 0x0808190808190808, 0x08081908082b0819, 0x08081908082b1908, 0x0808190819080808, 0x080819081908082b, 0x0808190819082b08, + 0x08081908192b0808, 0x080819082b080819, 0x080819082b081908, 0x080819082b190808, 0x080819082b2b1908, 0x0808191908080808, 0x080819190808082b, 0x0808191908082b08, + 0x08081919082b0808, 0x080819191908192b, 0x08081919192b2b19, 0x080819192b080808, 0x080819192b190819, 0x0808192b08082b19, 0x0808192b08190808, 0x0808192b19080808, + 0x0808192b2b081908, 0x0808192b2b2b1908, 0x08082b0808080808, 0x08082b0808081919, 0x08082b0808082b08, 0x08082b0808191908, 0x08082b08082b2b08, 0x08082b0819080819, + 0x08082b0819081908, 0x08082b0819190808, 0x08082b081919082b, 0x08082b082b082b08, 0x08082b1908081908, 0x08082b1919080808, 0x08082b2b0808082b, 0x08082b2b08191908, + 0x0819080808080819, 0x0819080808081908, 0x0819080808190808, 0x08190808082b0819, 0x0819080819080808, 0x08190808192b0808, 0x081908082b081908, 0x081908082b190808, + 0x081908082b191919, 0x0819081908080808, 0x0819081908082b08, 0x08190819082b0808, 0x0819081919190808, 0x0819081919192b2b, 0x081908192b080808, 0x0819082b082b1908, + 0x0819082b19081919, 0x0819190808080808, 0x0819190808082b08, 0x08191908082b0808, 0x08191908082b1919, 0x0819190819082b19, 0x081919082b080808, 0x0819191908192b08, + 0x08191919192b082b, 0x0819192b08080808, 0x0819192b0819192b, 0x08192b0808080819, 0x08192b0808081908, 0x08192b0808190808, 0x08192b0819080808, 0x08192b082b080819, + 0x08192b1908080808, 0x08192b1908081919, 0x08192b192b2b0808, 0x08192b2b19190819, 0x082b080808080808, 0x082b08080808082b, 0x082b080808082b2b, 0x082b080819081908, + 0x082b0808192b0819, 0x082b08082b080808, 0x082b08082b08082b, 0x082b0819082b2b19, 0x082b081919082b08, 0x082b082b08080808, 0x082b082b0808082b, 0x082b190808080819, + 0x082b190808081908, 0x082b190808190808, 0x082b190819080808, 0x082b19081919192b, 0x082b191908080808, 0x082b191919080819, 0x082b1919192b1908, 0x082b192b2b190808, + 0x082b2b0808082b08, 0x082b2b08082b0808, 0x082b2b082b191908, 0x082b2b2b19081908, 0x1908080808080819, 0x1908080808081908, 0x1908080808190808, 0x1908080808192b08, + 0x19080808082b0819, 0x19080808082b1908, 0x1908080819080808, 0x1908080819082b08, 0x190808081919192b, 0x19080808192b0808, 0x190808082b080819, 0x190808082b081908, + 0x190808082b190808, 0x1908081908080808, 0x19080819082b0808, 0x19080819192b0819, 0x190808192b080808, 0x190808192b081919, 0x1908082b08080819, 0x1908082b08190808, + 0x1908082b19082b08, 0x1908082b1919192b, 0x1908082b192b2b08, 0x1908190808080808, 0x1908190808082b08, 0x19081908082b0808, 0x190819082b080808, 0x190819082b192b19, + 0x190819190819082b, 0x19081919082b1908, 0x1908192b08080808, 0x19082b0808080819, 0x19082b0808081908, 0x19082b0808190808, 0x19082b0819080808, 0x19082b0819081919, + 0x19082b1908080808, 0x19082b1919192b08, 0x19082b19192b0819, 0x19082b192b08082b, 0x19082b2b19081919, 0x19082b2b2b190808, 0x1919080808080808, 0x1919080808082b08, + 0x1919080808190819, 0x1919080808192b19, 0x19190808082b0808, 0x191908082b080808, 0x191908082b082b08, 0x1919081908081908, 0x191908191908082b, 0x191908192b2b1908, + 0x1919082b2b190819, 0x191919082b190808, 0x191919082b19082b, 0x1919191908082b2b, 0x1919192b08080819, 0x1919192b19191908, 0x19192b0808080808, 0x19192b0808190819, + 0x19192b0808192b19, 0x19192b08192b1908, 0x19192b1919080808, 0x19192b2b08082b08, 0x192b080808081908, 0x192b080808190808, 0x192b080819080808, 0x192b0808192b2b08, + 0x192b081908080808, 0x192b081919191919, 0x192b082b08192b08, 0x192b082b192b0808, 0x192b190808080808, 0x192b190808081919, 0x192b191908190808, 0x192b19190819082b, + 0x192b19192b081908, 0x192b2b081908082b, 0x2b08080808080808, 0x2b0808080808082b, 0x2b08080808082b2b, 0x2b08080819080819, 0x2b0808082b08082b, 0x2b08081908081908, + 0x2b08081908192b08, 0x2b08081919080808, 0x2b08082b08190819, 0x2b08190808080819, 0x2b08190808081908, 0x2b08190808190808, 0x2b08190808191919, 0x2b08190819080808, + 0x2b081908192b0808, 0x2b08191908080808, 0x2b0819191908192b, 0x2b0819192b191908, 0x2b08192b08082b19, 0x2b08192b19080808, 0x2b08192b192b0808, 0x2b082b080808082b, + 0x2b082b1908081908, 0x2b082b2b08190819, 0x2b19080808081908, 0x2b19080808190808, 0x2b190808082b1908, 0x2b19080819080808, 0x2b1908082b2b0819, 0x2b1908190819192b, + 0x2b1908192b080808, 0x2b19082b19081919, 0x2b19190808080808, 0x2b191908082b082b, 0x2b19190819081908, 0x2b19191919190819, 0x2b192b082b080819, 0x2b192b19082b0808, + 0x2b2b08080808082b, 0x2b2b080819190808, 0x2b2b08082b081919, 0x2b2b081908082b19, 0x2b2b082b08080808, 0x2b2b190808192b08, 0x2b2b2b0819190808, 0x2b2b2b1908081908, ]; +#[rustfmt::skip] pub(super) const IQ2XS_GRID: [u64; 512] = [ - 0x0808080808080808, - 0x080808080808082b, - 0x0808080808081919, - 0x0808080808082b08, - 0x0808080808082b2b, - 0x0808080808190819, - 0x0808080808191908, - 0x080808080819192b, - 0x0808080808192b19, - 0x08080808082b0808, - 0x08080808082b082b, - 0x08080808082b1919, - 0x08080808082b2b08, - 0x0808080819080819, - 0x0808080819081908, - 0x080808081908192b, - 0x0808080819082b19, - 0x0808080819190808, - 0x080808081919082b, - 0x0808080819191919, - 0x0808080819192b08, - 0x08080808192b0819, - 0x08080808192b1908, - 0x080808082b080808, - 0x080808082b08082b, - 0x080808082b081919, - 0x080808082b082b08, - 0x080808082b190819, - 0x080808082b191908, - 0x080808082b192b19, - 0x080808082b2b0808, - 0x0808081908080819, - 0x0808081908081908, - 0x080808190808192b, - 0x0808081908082b19, - 0x0808081908190808, - 0x080808190819082b, - 0x0808081908191919, - 0x0808081908192b08, - 0x0808081908192b2b, - 0x08080819082b0819, - 0x08080819082b1908, - 0x0808081919080808, - 0x080808191908082b, - 0x0808081919081919, - 0x0808081919082b08, - 0x0808081919190819, - 0x0808081919191908, - 0x08080819192b0808, - 0x08080819192b2b08, - 0x080808192b080819, - 0x080808192b081908, - 0x080808192b190808, - 0x0808082b08080808, - 0x0808082b0808082b, - 0x0808082b08081919, - 0x0808082b08082b08, - 0x0808082b08190819, - 0x0808082b08191908, - 0x0808082b082b0808, - 0x0808082b19080819, - 0x0808082b19081908, - 0x0808082b19190808, - 0x0808082b19191919, - 0x0808082b2b080808, - 0x0808082b2b082b2b, - 0x0808190808080819, - 0x0808190808081908, - 0x080819080808192b, - 0x0808190808082b19, - 0x0808190808190808, - 0x080819080819082b, - 0x0808190808191919, - 0x0808190808192b08, - 0x08081908082b0819, - 0x08081908082b1908, - 0x0808190819080808, - 0x080819081908082b, - 0x0808190819081919, - 0x0808190819082b08, - 0x0808190819190819, - 0x0808190819191908, - 0x080819081919192b, - 0x08081908192b0808, - 0x080819082b080819, - 0x080819082b081908, - 0x080819082b190808, - 0x0808191908080808, - 0x080819190808082b, - 0x0808191908081919, - 0x0808191908082b08, - 0x0808191908190819, - 0x0808191908191908, - 0x08081919082b0808, - 0x0808191919080819, - 0x0808191919081908, - 0x0808191919190808, - 0x08081919192b0819, - 0x080819192b080808, - 0x0808192b08080819, - 0x0808192b08081908, - 0x0808192b08190808, - 0x0808192b082b192b, - 0x0808192b19080808, - 0x0808192b1908082b, - 0x0808192b2b081908, - 0x08082b0808080808, - 0x08082b080808082b, - 0x08082b0808081919, - 0x08082b0808082b08, - 0x08082b0808082b2b, - 0x08082b0808190819, - 0x08082b0808191908, - 0x08082b08082b0808, - 0x08082b08082b1919, - 0x08082b0819080819, - 0x08082b0819081908, - 0x08082b0819190808, - 0x08082b0819192b08, - 0x08082b082b080808, - 0x08082b082b2b0808, - 0x08082b082b2b2b2b, - 0x08082b1908080819, - 0x08082b1908081908, - 0x08082b1908190808, - 0x08082b1919080808, - 0x08082b192b080819, - 0x08082b192b082b19, - 0x08082b2b08080808, - 0x08082b2b082b0808, - 0x08082b2b082b2b08, - 0x08082b2b2b19192b, - 0x08082b2b2b2b0808, - 0x0819080808080819, - 0x0819080808081908, - 0x081908080808192b, - 0x0819080808082b19, - 0x0819080808190808, - 0x081908080819082b, - 0x0819080808191919, - 0x0819080808192b08, - 0x08190808082b0819, - 0x08190808082b1908, - 0x0819080819080808, - 0x081908081908082b, - 0x0819080819081919, - 0x0819080819082b08, - 0x0819080819190819, - 0x0819080819191908, - 0x08190808192b0808, - 0x08190808192b2b2b, - 0x081908082b080819, - 0x081908082b081908, - 0x081908082b190808, - 0x0819081908080808, - 0x081908190808082b, - 0x0819081908081919, - 0x0819081908082b08, - 0x0819081908190819, - 0x0819081908191908, - 0x08190819082b0808, - 0x0819081919080819, - 0x0819081919081908, - 0x0819081919190808, - 0x081908192b080808, - 0x081908192b191908, - 0x081908192b19192b, - 0x0819082b08080819, - 0x0819082b08081908, - 0x0819082b0808192b, - 0x0819082b08190808, - 0x0819082b19080808, - 0x0819082b192b0808, - 0x0819190808080808, - 0x081919080808082b, - 0x0819190808081919, - 0x0819190808082b08, - 0x0819190808190819, - 0x0819190808191908, - 0x08191908082b0808, - 0x0819190819080819, - 0x0819190819081908, - 0x0819190819082b19, - 0x0819190819190808, - 0x08191908192b1908, - 0x081919082b080808, - 0x0819191908080819, - 0x0819191908081908, - 0x0819191908190808, - 0x0819191919080808, - 0x0819192b08080808, - 0x0819192b08191908, - 0x0819192b19082b19, - 0x08192b0808080819, - 0x08192b0808081908, - 0x08192b0808190808, - 0x08192b080819082b, - 0x08192b0819080808, - 0x08192b0819191908, - 0x08192b082b08192b, - 0x08192b1908080808, - 0x08192b1908081919, - 0x08192b19192b192b, - 0x08192b2b19190819, - 0x08192b2b2b2b2b19, - 0x082b080808080808, - 0x082b08080808082b, - 0x082b080808081919, - 0x082b080808082b08, - 0x082b080808082b2b, - 0x082b080808190819, - 0x082b080808191908, - 0x082b0808082b0808, - 0x082b080819080819, - 0x082b080819081908, - 0x082b080819190808, - 0x082b08082b080808, - 0x082b08082b2b0808, - 0x082b081908080819, - 0x082b081908081908, - 0x082b081908190808, - 0x082b081919080808, - 0x082b081919082b08, - 0x082b0819192b1919, - 0x082b082b08080808, - 0x082b082b082b082b, - 0x082b082b2b080808, - 0x082b082b2b2b2b08, - 0x082b190808080819, - 0x082b190808081908, - 0x082b190808190808, - 0x082b1908082b2b19, - 0x082b190819080808, - 0x082b191908080808, - 0x082b191919080819, - 0x082b19191919082b, - 0x082b19192b192b19, - 0x082b192b08080819, - 0x082b192b08192b2b, - 0x082b192b2b2b192b, - 0x082b2b0808080808, - 0x082b2b0808082b08, - 0x082b2b0808082b2b, - 0x082b2b08082b0808, - 0x082b2b0819191919, - 0x082b2b082b082b08, - 0x082b2b082b2b082b, - 0x082b2b19192b2b08, - 0x082b2b192b190808, - 0x082b2b2b08082b08, - 0x082b2b2b082b0808, - 0x082b2b2b2b08082b, - 0x082b2b2b2b082b08, - 0x082b2b2b2b082b2b, - 0x1908080808080819, - 0x1908080808081908, - 0x190808080808192b, - 0x1908080808082b19, - 0x1908080808190808, - 0x190808080819082b, - 0x1908080808191919, - 0x1908080808192b08, - 0x19080808082b0819, - 0x19080808082b1908, - 0x1908080819080808, - 0x190808081908082b, - 0x1908080819081919, - 0x1908080819082b08, - 0x1908080819082b2b, - 0x1908080819190819, - 0x1908080819191908, - 0x19080808192b0808, - 0x19080808192b1919, - 0x190808082b080819, - 0x190808082b081908, - 0x190808082b190808, - 0x1908081908080808, - 0x190808190808082b, - 0x1908081908081919, - 0x1908081908082b08, - 0x1908081908190819, - 0x1908081908191908, - 0x19080819082b0808, - 0x1908081919080819, - 0x1908081919081908, - 0x1908081919190808, - 0x190808192b080808, - 0x190808192b081919, - 0x190808192b2b082b, - 0x1908082b08080819, - 0x1908082b08081908, - 0x1908082b08190808, - 0x1908082b0819082b, - 0x1908082b082b2b19, - 0x1908082b19080808, - 0x1908190808080808, - 0x190819080808082b, - 0x1908190808081919, - 0x1908190808082b08, - 0x1908190808190819, - 0x1908190808191908, - 0x1908190808192b19, - 0x19081908082b0808, - 0x1908190819080819, - 0x1908190819081908, - 0x1908190819190808, - 0x190819082b080808, - 0x190819082b191908, - 0x1908191908080819, - 0x1908191908081908, - 0x1908191908190808, - 0x19081919082b1908, - 0x1908191919080808, - 0x190819192b192b2b, - 0x1908192b08080808, - 0x1908192b08082b2b, - 0x1908192b19081908, - 0x1908192b19190808, - 0x19082b0808080819, - 0x19082b0808081908, - 0x19082b0808190808, - 0x19082b0819080808, - 0x19082b0819081919, - 0x19082b0819191908, - 0x19082b08192b082b, - 0x19082b1908080808, - 0x19082b1908190819, - 0x19082b1919081908, - 0x19082b1919190808, - 0x19082b19192b2b19, - 0x19082b2b08081908, - 0x1919080808080808, - 0x191908080808082b, - 0x1919080808081919, - 0x1919080808082b08, - 0x1919080808190819, - 0x1919080808191908, - 0x19190808082b0808, - 0x19190808082b2b08, - 0x1919080819080819, - 0x1919080819081908, - 0x1919080819190808, - 0x191908082b080808, - 0x1919081908080819, - 0x1919081908081908, - 0x1919081908190808, - 0x1919081908191919, - 0x1919081919080808, - 0x191908191908082b, - 0x1919082b08080808, - 0x1919082b19081908, - 0x1919082b2b2b2b2b, - 0x1919190808080819, - 0x1919190808081908, - 0x1919190808190808, - 0x19191908082b0819, - 0x1919190819080808, - 0x19191908192b0808, - 0x191919082b080819, - 0x191919082b2b0819, - 0x1919191908080808, - 0x1919191908082b08, - 0x191919192b080808, - 0x191919192b082b08, - 0x1919192b082b0819, - 0x1919192b192b2b08, - 0x1919192b2b2b0819, - 0x19192b0808080808, - 0x19192b0808191908, - 0x19192b0819080819, - 0x19192b0819190808, - 0x19192b082b192b19, - 0x19192b1908192b2b, - 0x19192b1919080808, - 0x19192b191908082b, - 0x19192b2b2b081919, - 0x192b080808080819, - 0x192b080808081908, - 0x192b080808190808, - 0x192b080819080808, - 0x192b080819191908, - 0x192b0808192b082b, - 0x192b08082b08192b, - 0x192b08082b2b2b19, - 0x192b081908080808, - 0x192b082b082b1908, - 0x192b082b19082b2b, - 0x192b082b2b19082b, - 0x192b190808080808, - 0x192b19080819192b, - 0x192b191908190808, - 0x192b191919080808, - 0x192b191919081919, - 0x192b19192b2b1908, - 0x192b2b0808080819, - 0x192b2b08192b2b2b, - 0x192b2b19082b1919, - 0x192b2b2b0808192b, - 0x192b2b2b19191908, - 0x192b2b2b192b082b, - 0x2b08080808080808, - 0x2b0808080808082b, - 0x2b08080808081919, - 0x2b08080808082b08, - 0x2b08080808190819, - 0x2b08080808191908, - 0x2b080808082b0808, - 0x2b080808082b2b2b, - 0x2b08080819080819, - 0x2b08080819081908, - 0x2b08080819190808, - 0x2b0808082b080808, - 0x2b0808082b08082b, - 0x2b0808082b2b2b08, - 0x2b0808082b2b2b2b, - 0x2b08081908080819, - 0x2b08081908081908, - 0x2b0808190808192b, - 0x2b08081908190808, - 0x2b08081919080808, - 0x2b08081919190819, - 0x2b08081919192b19, - 0x2b08082b08080808, - 0x2b08082b082b0808, - 0x2b08082b2b080808, - 0x2b08082b2b08082b, - 0x2b08082b2b2b0808, - 0x2b08082b2b2b2b08, - 0x2b08190808080819, - 0x2b08190808081908, - 0x2b08190808190808, - 0x2b0819080819082b, - 0x2b08190808191919, - 0x2b08190819080808, - 0x2b081908192b0808, - 0x2b0819082b082b19, - 0x2b08191908080808, - 0x2b08191919081908, - 0x2b0819192b2b1919, - 0x2b08192b08192b08, - 0x2b08192b192b2b2b, - 0x2b082b0808080808, - 0x2b082b0808082b08, - 0x2b082b08082b1919, - 0x2b082b0819192b2b, - 0x2b082b082b080808, - 0x2b082b082b08082b, - 0x2b082b082b2b2b08, - 0x2b082b190808192b, - 0x2b082b2b082b082b, - 0x2b082b2b2b080808, - 0x2b082b2b2b082b08, - 0x2b082b2b2b19192b, - 0x2b082b2b2b2b2b08, - 0x2b19080808080819, - 0x2b19080808081908, - 0x2b19080808190808, - 0x2b19080819080808, - 0x2b1908081919192b, - 0x2b1908082b081908, - 0x2b19081908080808, - 0x2b190819082b082b, - 0x2b190819192b1908, - 0x2b19082b1919192b, - 0x2b19082b2b082b19, - 0x2b19190808080808, - 0x2b19190808081919, - 0x2b19190819081908, - 0x2b19190819190808, - 0x2b19190819192b08, - 0x2b191919082b2b19, - 0x2b1919192b190808, - 0x2b1919192b19082b, - 0x2b19192b19080819, - 0x2b192b0819190819, - 0x2b192b082b2b192b, - 0x2b192b1919082b19, - 0x2b192b2b08191919, - 0x2b192b2b192b0808, - 0x2b2b080808080808, - 0x2b2b08080808082b, - 0x2b2b080808082b08, - 0x2b2b080808082b2b, - 0x2b2b0808082b0808, - 0x2b2b0808082b2b2b, - 0x2b2b08082b2b0808, - 0x2b2b081919190819, - 0x2b2b081919192b19, - 0x2b2b08192b2b192b, - 0x2b2b082b08080808, - 0x2b2b082b0808082b, - 0x2b2b082b08082b08, - 0x2b2b082b082b2b2b, - 0x2b2b082b2b080808, - 0x2b2b082b2b2b0808, - 0x2b2b190819080808, - 0x2b2b19082b191919, - 0x2b2b192b192b1919, - 0x2b2b192b2b192b08, - 0x2b2b2b0808082b2b, - 0x2b2b2b08082b0808, - 0x2b2b2b08082b082b, - 0x2b2b2b08082b2b08, - 0x2b2b2b082b2b0808, - 0x2b2b2b082b2b2b08, - 0x2b2b2b1908081908, - 0x2b2b2b192b081908, - 0x2b2b2b192b08192b, - 0x2b2b2b2b082b2b08, - 0x2b2b2b2b082b2b2b, - 0x2b2b2b2b2b190819, - 0x2b2b2b2b2b2b2b2b, + 0x0808080808080808, 0x080808080808082b, 0x0808080808081919, 0x0808080808082b08, 0x0808080808082b2b, 0x0808080808190819, 0x0808080808191908, 0x080808080819192b, + 0x0808080808192b19, 0x08080808082b0808, 0x08080808082b082b, 0x08080808082b1919, 0x08080808082b2b08, 0x0808080819080819, 0x0808080819081908, 0x080808081908192b, + 0x0808080819082b19, 0x0808080819190808, 0x080808081919082b, 0x0808080819191919, 0x0808080819192b08, 0x08080808192b0819, 0x08080808192b1908, 0x080808082b080808, + 0x080808082b08082b, 0x080808082b081919, 0x080808082b082b08, 0x080808082b190819, 0x080808082b191908, 0x080808082b192b19, 0x080808082b2b0808, 0x0808081908080819, + 0x0808081908081908, 0x080808190808192b, 0x0808081908082b19, 0x0808081908190808, 0x080808190819082b, 0x0808081908191919, 0x0808081908192b08, 0x0808081908192b2b, + 0x08080819082b0819, 0x08080819082b1908, 0x0808081919080808, 0x080808191908082b, 0x0808081919081919, 0x0808081919082b08, 0x0808081919190819, 0x0808081919191908, + 0x08080819192b0808, 0x08080819192b2b08, 0x080808192b080819, 0x080808192b081908, 0x080808192b190808, 0x0808082b08080808, 0x0808082b0808082b, 0x0808082b08081919, + 0x0808082b08082b08, 0x0808082b08190819, 0x0808082b08191908, 0x0808082b082b0808, 0x0808082b19080819, 0x0808082b19081908, 0x0808082b19190808, 0x0808082b19191919, + 0x0808082b2b080808, 0x0808082b2b082b2b, 0x0808190808080819, 0x0808190808081908, 0x080819080808192b, 0x0808190808082b19, 0x0808190808190808, 0x080819080819082b, + 0x0808190808191919, 0x0808190808192b08, 0x08081908082b0819, 0x08081908082b1908, 0x0808190819080808, 0x080819081908082b, 0x0808190819081919, 0x0808190819082b08, + 0x0808190819190819, 0x0808190819191908, 0x080819081919192b, 0x08081908192b0808, 0x080819082b080819, 0x080819082b081908, 0x080819082b190808, 0x0808191908080808, + 0x080819190808082b, 0x0808191908081919, 0x0808191908082b08, 0x0808191908190819, 0x0808191908191908, 0x08081919082b0808, 0x0808191919080819, 0x0808191919081908, + 0x0808191919190808, 0x08081919192b0819, 0x080819192b080808, 0x0808192b08080819, 0x0808192b08081908, 0x0808192b08190808, 0x0808192b082b192b, 0x0808192b19080808, + 0x0808192b1908082b, 0x0808192b2b081908, 0x08082b0808080808, 0x08082b080808082b, 0x08082b0808081919, 0x08082b0808082b08, 0x08082b0808082b2b, 0x08082b0808190819, + 0x08082b0808191908, 0x08082b08082b0808, 0x08082b08082b1919, 0x08082b0819080819, 0x08082b0819081908, 0x08082b0819190808, 0x08082b0819192b08, 0x08082b082b080808, + 0x08082b082b2b0808, 0x08082b082b2b2b2b, 0x08082b1908080819, 0x08082b1908081908, 0x08082b1908190808, 0x08082b1919080808, 0x08082b192b080819, 0x08082b192b082b19, + 0x08082b2b08080808, 0x08082b2b082b0808, 0x08082b2b082b2b08, 0x08082b2b2b19192b, 0x08082b2b2b2b0808, 0x0819080808080819, 0x0819080808081908, 0x081908080808192b, + 0x0819080808082b19, 0x0819080808190808, 0x081908080819082b, 0x0819080808191919, 0x0819080808192b08, 0x08190808082b0819, 0x08190808082b1908, 0x0819080819080808, + 0x081908081908082b, 0x0819080819081919, 0x0819080819082b08, 0x0819080819190819, 0x0819080819191908, 0x08190808192b0808, 0x08190808192b2b2b, 0x081908082b080819, + 0x081908082b081908, 0x081908082b190808, 0x0819081908080808, 0x081908190808082b, 0x0819081908081919, 0x0819081908082b08, 0x0819081908190819, 0x0819081908191908, + 0x08190819082b0808, 0x0819081919080819, 0x0819081919081908, 0x0819081919190808, 0x081908192b080808, 0x081908192b191908, 0x081908192b19192b, 0x0819082b08080819, + 0x0819082b08081908, 0x0819082b0808192b, 0x0819082b08190808, 0x0819082b19080808, 0x0819082b192b0808, 0x0819190808080808, 0x081919080808082b, 0x0819190808081919, + 0x0819190808082b08, 0x0819190808190819, 0x0819190808191908, 0x08191908082b0808, 0x0819190819080819, 0x0819190819081908, 0x0819190819082b19, 0x0819190819190808, + 0x08191908192b1908, 0x081919082b080808, 0x0819191908080819, 0x0819191908081908, 0x0819191908190808, 0x0819191919080808, 0x0819192b08080808, 0x0819192b08191908, + 0x0819192b19082b19, 0x08192b0808080819, 0x08192b0808081908, 0x08192b0808190808, 0x08192b080819082b, 0x08192b0819080808, 0x08192b0819191908, 0x08192b082b08192b, + 0x08192b1908080808, 0x08192b1908081919, 0x08192b19192b192b, 0x08192b2b19190819, 0x08192b2b2b2b2b19, 0x082b080808080808, 0x082b08080808082b, 0x082b080808081919, + 0x082b080808082b08, 0x082b080808082b2b, 0x082b080808190819, 0x082b080808191908, 0x082b0808082b0808, 0x082b080819080819, 0x082b080819081908, 0x082b080819190808, + 0x082b08082b080808, 0x082b08082b2b0808, 0x082b081908080819, 0x082b081908081908, 0x082b081908190808, 0x082b081919080808, 0x082b081919082b08, 0x082b0819192b1919, + 0x082b082b08080808, 0x082b082b082b082b, 0x082b082b2b080808, 0x082b082b2b2b2b08, 0x082b190808080819, 0x082b190808081908, 0x082b190808190808, 0x082b1908082b2b19, + 0x082b190819080808, 0x082b191908080808, 0x082b191919080819, 0x082b19191919082b, 0x082b19192b192b19, 0x082b192b08080819, 0x082b192b08192b2b, 0x082b192b2b2b192b, + 0x082b2b0808080808, 0x082b2b0808082b08, 0x082b2b0808082b2b, 0x082b2b08082b0808, 0x082b2b0819191919, 0x082b2b082b082b08, 0x082b2b082b2b082b, 0x082b2b19192b2b08, + 0x082b2b192b190808, 0x082b2b2b08082b08, 0x082b2b2b082b0808, 0x082b2b2b2b08082b, 0x082b2b2b2b082b08, 0x082b2b2b2b082b2b, 0x1908080808080819, 0x1908080808081908, + 0x190808080808192b, 0x1908080808082b19, 0x1908080808190808, 0x190808080819082b, 0x1908080808191919, 0x1908080808192b08, 0x19080808082b0819, 0x19080808082b1908, + 0x1908080819080808, 0x190808081908082b, 0x1908080819081919, 0x1908080819082b08, 0x1908080819082b2b, 0x1908080819190819, 0x1908080819191908, 0x19080808192b0808, + 0x19080808192b1919, 0x190808082b080819, 0x190808082b081908, 0x190808082b190808, 0x1908081908080808, 0x190808190808082b, 0x1908081908081919, 0x1908081908082b08, + 0x1908081908190819, 0x1908081908191908, 0x19080819082b0808, 0x1908081919080819, 0x1908081919081908, 0x1908081919190808, 0x190808192b080808, 0x190808192b081919, + 0x190808192b2b082b, 0x1908082b08080819, 0x1908082b08081908, 0x1908082b08190808, 0x1908082b0819082b, 0x1908082b082b2b19, 0x1908082b19080808, 0x1908190808080808, + 0x190819080808082b, 0x1908190808081919, 0x1908190808082b08, 0x1908190808190819, 0x1908190808191908, 0x1908190808192b19, 0x19081908082b0808, 0x1908190819080819, + 0x1908190819081908, 0x1908190819190808, 0x190819082b080808, 0x190819082b191908, 0x1908191908080819, 0x1908191908081908, 0x1908191908190808, 0x19081919082b1908, + 0x1908191919080808, 0x190819192b192b2b, 0x1908192b08080808, 0x1908192b08082b2b, 0x1908192b19081908, 0x1908192b19190808, 0x19082b0808080819, 0x19082b0808081908, + 0x19082b0808190808, 0x19082b0819080808, 0x19082b0819081919, 0x19082b0819191908, 0x19082b08192b082b, 0x19082b1908080808, 0x19082b1908190819, 0x19082b1919081908, + 0x19082b1919190808, 0x19082b19192b2b19, 0x19082b2b08081908, 0x1919080808080808, 0x191908080808082b, 0x1919080808081919, 0x1919080808082b08, 0x1919080808190819, + 0x1919080808191908, 0x19190808082b0808, 0x19190808082b2b08, 0x1919080819080819, 0x1919080819081908, 0x1919080819190808, 0x191908082b080808, 0x1919081908080819, + 0x1919081908081908, 0x1919081908190808, 0x1919081908191919, 0x1919081919080808, 0x191908191908082b, 0x1919082b08080808, 0x1919082b19081908, 0x1919082b2b2b2b2b, + 0x1919190808080819, 0x1919190808081908, 0x1919190808190808, 0x19191908082b0819, 0x1919190819080808, 0x19191908192b0808, 0x191919082b080819, 0x191919082b2b0819, + 0x1919191908080808, 0x1919191908082b08, 0x191919192b080808, 0x191919192b082b08, 0x1919192b082b0819, 0x1919192b192b2b08, 0x1919192b2b2b0819, 0x19192b0808080808, + 0x19192b0808191908, 0x19192b0819080819, 0x19192b0819190808, 0x19192b082b192b19, 0x19192b1908192b2b, 0x19192b1919080808, 0x19192b191908082b, 0x19192b2b2b081919, + 0x192b080808080819, 0x192b080808081908, 0x192b080808190808, 0x192b080819080808, 0x192b080819191908, 0x192b0808192b082b, 0x192b08082b08192b, 0x192b08082b2b2b19, + 0x192b081908080808, 0x192b082b082b1908, 0x192b082b19082b2b, 0x192b082b2b19082b, 0x192b190808080808, 0x192b19080819192b, 0x192b191908190808, 0x192b191919080808, + 0x192b191919081919, 0x192b19192b2b1908, 0x192b2b0808080819, 0x192b2b08192b2b2b, 0x192b2b19082b1919, 0x192b2b2b0808192b, 0x192b2b2b19191908, 0x192b2b2b192b082b, + 0x2b08080808080808, 0x2b0808080808082b, 0x2b08080808081919, 0x2b08080808082b08, 0x2b08080808190819, 0x2b08080808191908, 0x2b080808082b0808, 0x2b080808082b2b2b, + 0x2b08080819080819, 0x2b08080819081908, 0x2b08080819190808, 0x2b0808082b080808, 0x2b0808082b08082b, 0x2b0808082b2b2b08, 0x2b0808082b2b2b2b, 0x2b08081908080819, + 0x2b08081908081908, 0x2b0808190808192b, 0x2b08081908190808, 0x2b08081919080808, 0x2b08081919190819, 0x2b08081919192b19, 0x2b08082b08080808, 0x2b08082b082b0808, + 0x2b08082b2b080808, 0x2b08082b2b08082b, 0x2b08082b2b2b0808, 0x2b08082b2b2b2b08, 0x2b08190808080819, 0x2b08190808081908, 0x2b08190808190808, 0x2b0819080819082b, + 0x2b08190808191919, 0x2b08190819080808, 0x2b081908192b0808, 0x2b0819082b082b19, 0x2b08191908080808, 0x2b08191919081908, 0x2b0819192b2b1919, 0x2b08192b08192b08, + 0x2b08192b192b2b2b, 0x2b082b0808080808, 0x2b082b0808082b08, 0x2b082b08082b1919, 0x2b082b0819192b2b, 0x2b082b082b080808, 0x2b082b082b08082b, 0x2b082b082b2b2b08, + 0x2b082b190808192b, 0x2b082b2b082b082b, 0x2b082b2b2b080808, 0x2b082b2b2b082b08, 0x2b082b2b2b19192b, 0x2b082b2b2b2b2b08, 0x2b19080808080819, 0x2b19080808081908, + 0x2b19080808190808, 0x2b19080819080808, 0x2b1908081919192b, 0x2b1908082b081908, 0x2b19081908080808, 0x2b190819082b082b, 0x2b190819192b1908, 0x2b19082b1919192b, + 0x2b19082b2b082b19, 0x2b19190808080808, 0x2b19190808081919, 0x2b19190819081908, 0x2b19190819190808, 0x2b19190819192b08, 0x2b191919082b2b19, 0x2b1919192b190808, + 0x2b1919192b19082b, 0x2b19192b19080819, 0x2b192b0819190819, 0x2b192b082b2b192b, 0x2b192b1919082b19, 0x2b192b2b08191919, 0x2b192b2b192b0808, 0x2b2b080808080808, + 0x2b2b08080808082b, 0x2b2b080808082b08, 0x2b2b080808082b2b, 0x2b2b0808082b0808, 0x2b2b0808082b2b2b, 0x2b2b08082b2b0808, 0x2b2b081919190819, 0x2b2b081919192b19, + 0x2b2b08192b2b192b, 0x2b2b082b08080808, 0x2b2b082b0808082b, 0x2b2b082b08082b08, 0x2b2b082b082b2b2b, 0x2b2b082b2b080808, 0x2b2b082b2b2b0808, 0x2b2b190819080808, + 0x2b2b19082b191919, 0x2b2b192b192b1919, 0x2b2b192b2b192b08, 0x2b2b2b0808082b2b, 0x2b2b2b08082b0808, 0x2b2b2b08082b082b, 0x2b2b2b08082b2b08, 0x2b2b2b082b2b0808, + 0x2b2b2b082b2b2b08, 0x2b2b2b1908081908, 0x2b2b2b192b081908, 0x2b2b2b192b08192b, 0x2b2b2b2b082b2b08, 0x2b2b2b2b082b2b2b, 0x2b2b2b2b2b190819, 0x2b2b2b2b2b2b2b2b, ]; +#[rustfmt::skip] pub(super) const IQ2S_GRID: [u64; 1024] = [ - 0x0808080808080808, - 0x080808080808082b, - 0x0808080808081919, - 0x0808080808082b08, - 0x0808080808082b2b, - 0x0808080808190819, - 0x0808080808191908, - 0x080808080819192b, - 0x0808080808192b19, - 0x08080808082b0808, - 0x08080808082b082b, - 0x08080808082b1919, - 0x08080808082b2b08, - 0x0808080819080819, - 0x0808080819081908, - 0x080808081908192b, - 0x0808080819082b19, - 0x0808080819190808, - 0x080808081919082b, - 0x0808080819191919, - 0x0808080819192b08, - 0x08080808192b0819, - 0x08080808192b1908, - 0x08080808192b192b, - 0x08080808192b2b19, - 0x080808082b080808, - 0x080808082b08082b, - 0x080808082b081919, - 0x080808082b082b08, - 0x080808082b190819, - 0x080808082b191908, - 0x080808082b2b0808, - 0x080808082b2b1919, - 0x080808082b2b2b2b, - 0x0808081908080819, - 0x0808081908081908, - 0x080808190808192b, - 0x0808081908082b19, - 0x0808081908190808, - 0x080808190819082b, - 0x0808081908191919, - 0x0808081908192b08, - 0x08080819082b0819, - 0x08080819082b1908, - 0x0808081919080808, - 0x080808191908082b, - 0x0808081919081919, - 0x0808081919082b08, - 0x0808081919190819, - 0x0808081919191908, - 0x080808191919192b, - 0x0808081919192b19, - 0x08080819192b0808, - 0x08080819192b1919, - 0x08080819192b2b08, - 0x080808192b080819, - 0x080808192b081908, - 0x080808192b190808, - 0x080808192b19082b, - 0x080808192b191919, - 0x080808192b2b0819, - 0x080808192b2b1908, - 0x0808082b08080808, - 0x0808082b0808082b, - 0x0808082b08081919, - 0x0808082b08082b08, - 0x0808082b08190819, - 0x0808082b08191908, - 0x0808082b082b0808, - 0x0808082b082b2b2b, - 0x0808082b19080819, - 0x0808082b19081908, - 0x0808082b1908192b, - 0x0808082b19082b19, - 0x0808082b19190808, - 0x0808082b19191919, - 0x0808082b2b080808, - 0x0808082b2b081919, - 0x0808082b2b082b2b, - 0x0808082b2b191908, - 0x0808082b2b2b082b, - 0x0808190808080819, - 0x0808190808081908, - 0x080819080808192b, - 0x0808190808082b19, - 0x0808190808190808, - 0x080819080819082b, - 0x0808190808191919, - 0x0808190808192b08, - 0x08081908082b0819, - 0x08081908082b1908, - 0x08081908082b192b, - 0x08081908082b2b19, - 0x0808190819080808, - 0x080819081908082b, - 0x0808190819081919, - 0x0808190819082b08, - 0x0808190819082b2b, - 0x0808190819190819, - 0x0808190819191908, - 0x080819081919192b, - 0x0808190819192b19, - 0x08081908192b0808, - 0x08081908192b082b, - 0x08081908192b1919, - 0x080819082b080819, - 0x080819082b081908, - 0x080819082b08192b, - 0x080819082b082b19, - 0x080819082b190808, - 0x080819082b191919, - 0x080819082b192b08, - 0x080819082b2b0819, - 0x080819082b2b1908, - 0x0808191908080808, - 0x080819190808082b, - 0x0808191908081919, - 0x0808191908082b08, - 0x0808191908082b2b, - 0x0808191908190819, - 0x0808191908191908, - 0x080819190819192b, - 0x0808191908192b19, - 0x08081919082b0808, - 0x08081919082b1919, - 0x08081919082b2b08, - 0x0808191919080819, - 0x0808191919081908, - 0x080819191908192b, - 0x0808191919082b19, - 0x0808191919190808, - 0x080819191919082b, - 0x0808191919191919, - 0x0808191919192b08, - 0x08081919192b0819, - 0x08081919192b1908, - 0x080819192b080808, - 0x080819192b08082b, - 0x080819192b081919, - 0x080819192b082b08, - 0x080819192b190819, - 0x080819192b191908, - 0x080819192b2b0808, - 0x0808192b08080819, - 0x0808192b08081908, - 0x0808192b0808192b, - 0x0808192b08082b19, - 0x0808192b08190808, - 0x0808192b08191919, - 0x0808192b19080808, - 0x0808192b19081919, - 0x0808192b19082b08, - 0x0808192b19190819, - 0x0808192b19191908, - 0x0808192b192b0808, - 0x0808192b2b080819, - 0x0808192b2b081908, - 0x0808192b2b190808, - 0x08082b0808080808, - 0x08082b080808082b, - 0x08082b0808081919, - 0x08082b0808082b08, - 0x08082b0808190819, - 0x08082b0808191908, - 0x08082b080819192b, - 0x08082b0808192b19, - 0x08082b08082b0808, - 0x08082b08082b1919, - 0x08082b08082b2b2b, - 0x08082b0819080819, - 0x08082b0819081908, - 0x08082b081908192b, - 0x08082b0819082b19, - 0x08082b0819190808, - 0x08082b081919082b, - 0x08082b0819191919, - 0x08082b0819192b08, - 0x08082b08192b0819, - 0x08082b08192b1908, - 0x08082b082b080808, - 0x08082b082b081919, - 0x08082b082b191908, - 0x08082b082b2b2b2b, - 0x08082b1908080819, - 0x08082b1908081908, - 0x08082b1908190808, - 0x08082b190819082b, - 0x08082b1908191919, - 0x08082b1908192b08, - 0x08082b19082b0819, - 0x08082b1919080808, - 0x08082b1919081919, - 0x08082b1919082b08, - 0x08082b1919190819, - 0x08082b1919191908, - 0x08082b19192b0808, - 0x08082b192b080819, - 0x08082b192b190808, - 0x08082b2b08080808, - 0x08082b2b08190819, - 0x08082b2b08191908, - 0x08082b2b082b082b, - 0x08082b2b082b2b08, - 0x08082b2b082b2b2b, - 0x08082b2b19190808, - 0x08082b2b2b192b19, - 0x0819080808080819, - 0x0819080808081908, - 0x081908080808192b, - 0x0819080808082b19, - 0x0819080808190808, - 0x081908080819082b, - 0x0819080808191919, - 0x0819080808192b08, - 0x08190808082b0819, - 0x08190808082b1908, - 0x08190808082b192b, - 0x0819080819080808, - 0x081908081908082b, - 0x0819080819081919, - 0x0819080819082b08, - 0x0819080819190819, - 0x0819080819191908, - 0x081908081919192b, - 0x0819080819192b19, - 0x08190808192b0808, - 0x08190808192b082b, - 0x08190808192b1919, - 0x08190808192b2b08, - 0x081908082b080819, - 0x081908082b081908, - 0x081908082b08192b, - 0x081908082b190808, - 0x081908082b191919, - 0x081908082b192b08, - 0x081908082b2b0819, - 0x081908082b2b1908, - 0x0819081908080808, - 0x081908190808082b, - 0x0819081908081919, - 0x0819081908082b08, - 0x0819081908082b2b, - 0x0819081908190819, - 0x0819081908191908, - 0x081908190819192b, - 0x0819081908192b19, - 0x08190819082b0808, - 0x08190819082b082b, - 0x08190819082b1919, - 0x08190819082b2b08, - 0x0819081919080819, - 0x0819081919081908, - 0x081908191908192b, - 0x0819081919082b19, - 0x0819081919190808, - 0x081908191919082b, - 0x0819081919191919, - 0x0819081919192b08, - 0x08190819192b0819, - 0x08190819192b1908, - 0x081908192b080808, - 0x081908192b08082b, - 0x081908192b081919, - 0x081908192b082b08, - 0x081908192b190819, - 0x081908192b191908, - 0x0819082b08080819, - 0x0819082b08081908, - 0x0819082b08082b19, - 0x0819082b08190808, - 0x0819082b08191919, - 0x0819082b082b0819, - 0x0819082b082b1908, - 0x0819082b19080808, - 0x0819082b19081919, - 0x0819082b19190819, - 0x0819082b19191908, - 0x0819082b2b080819, - 0x0819082b2b081908, - 0x0819082b2b190808, - 0x0819190808080808, - 0x081919080808082b, - 0x0819190808081919, - 0x0819190808082b08, - 0x0819190808190819, - 0x0819190808191908, - 0x081919080819192b, - 0x0819190808192b19, - 0x08191908082b0808, - 0x08191908082b1919, - 0x08191908082b2b08, - 0x0819190819080819, - 0x0819190819081908, - 0x081919081908192b, - 0x0819190819082b19, - 0x0819190819190808, - 0x081919081919082b, - 0x0819190819191919, - 0x0819190819192b08, - 0x08191908192b0819, - 0x08191908192b1908, - 0x081919082b080808, - 0x081919082b08082b, - 0x081919082b081919, - 0x081919082b082b08, - 0x081919082b190819, - 0x081919082b191908, - 0x081919082b2b0808, - 0x0819191908080819, - 0x0819191908081908, - 0x081919190808192b, - 0x0819191908082b19, - 0x0819191908190808, - 0x081919190819082b, - 0x0819191908191919, - 0x0819191908192b08, - 0x08191919082b0819, - 0x08191919082b1908, - 0x0819191919080808, - 0x081919191908082b, - 0x0819191919081919, - 0x0819191919082b08, - 0x0819191919190819, - 0x0819191919191908, - 0x08191919192b0808, - 0x081919192b080819, - 0x081919192b081908, - 0x081919192b190808, - 0x0819192b08080808, - 0x0819192b08081919, - 0x0819192b08082b08, - 0x0819192b08190819, - 0x0819192b08191908, - 0x0819192b082b0808, - 0x0819192b19080819, - 0x0819192b19081908, - 0x0819192b19190808, - 0x0819192b2b080808, - 0x0819192b2b2b2b2b, - 0x08192b0808080819, - 0x08192b0808081908, - 0x08192b080808192b, - 0x08192b0808082b19, - 0x08192b0808190808, - 0x08192b0808191919, - 0x08192b0808192b08, - 0x08192b08082b0819, - 0x08192b0819080808, - 0x08192b081908082b, - 0x08192b0819081919, - 0x08192b0819082b08, - 0x08192b0819190819, - 0x08192b0819191908, - 0x08192b08192b0808, - 0x08192b082b080819, - 0x08192b082b081908, - 0x08192b1908080808, - 0x08192b190808082b, - 0x08192b1908081919, - 0x08192b1908082b08, - 0x08192b1908190819, - 0x08192b1908191908, - 0x08192b19082b0808, - 0x08192b1919080819, - 0x08192b1919081908, - 0x08192b1919190808, - 0x08192b19192b2b19, - 0x08192b192b2b082b, - 0x08192b2b08081908, - 0x08192b2b08190808, - 0x08192b2b19080808, - 0x08192b2b1919192b, - 0x082b080808080808, - 0x082b08080808082b, - 0x082b080808081919, - 0x082b080808082b08, - 0x082b080808190819, - 0x082b080808191908, - 0x082b08080819192b, - 0x082b080808192b19, - 0x082b0808082b0808, - 0x082b0808082b1919, - 0x082b0808082b2b2b, - 0x082b080819080819, - 0x082b080819081908, - 0x082b080819190808, - 0x082b08081919082b, - 0x082b080819191919, - 0x082b0808192b1908, - 0x082b08082b080808, - 0x082b08082b082b2b, - 0x082b08082b191908, - 0x082b08082b2b2b2b, - 0x082b081908080819, - 0x082b081908081908, - 0x082b081908190808, - 0x082b08190819082b, - 0x082b081908191919, - 0x082b0819082b0819, - 0x082b081919080808, - 0x082b08191908082b, - 0x082b081919081919, - 0x082b081919190819, - 0x082b081919191908, - 0x082b0819192b0808, - 0x082b08192b080819, - 0x082b08192b081908, - 0x082b08192b190808, - 0x082b082b08080808, - 0x082b082b08082b2b, - 0x082b082b082b082b, - 0x082b082b082b2b08, - 0x082b082b082b2b2b, - 0x082b082b19081908, - 0x082b082b19190808, - 0x082b082b2b082b08, - 0x082b082b2b082b2b, - 0x082b082b2b2b2b08, - 0x082b190808080819, - 0x082b190808081908, - 0x082b19080808192b, - 0x082b190808082b19, - 0x082b190808190808, - 0x082b190808191919, - 0x082b190808192b08, - 0x082b1908082b0819, - 0x082b1908082b1908, - 0x082b190819080808, - 0x082b19081908082b, - 0x082b190819081919, - 0x082b190819082b08, - 0x082b190819190819, - 0x082b190819191908, - 0x082b1908192b0808, - 0x082b19082b080819, - 0x082b19082b081908, - 0x082b19082b190808, - 0x082b191908080808, - 0x082b191908081919, - 0x082b191908082b08, - 0x082b191908190819, - 0x082b191908191908, - 0x082b1919082b0808, - 0x082b191919080819, - 0x082b191919081908, - 0x082b191919190808, - 0x082b1919192b192b, - 0x082b19192b080808, - 0x082b192b08080819, - 0x082b192b08081908, - 0x082b192b08190808, - 0x082b192b19080808, - 0x082b192b19192b19, - 0x082b2b0808080808, - 0x082b2b0808081919, - 0x082b2b0808190819, - 0x082b2b0808191908, - 0x082b2b0819080819, - 0x082b2b0819081908, - 0x082b2b0819190808, - 0x082b2b082b082b2b, - 0x082b2b082b2b2b2b, - 0x082b2b1908080819, - 0x082b2b1908081908, - 0x082b2b1908190808, - 0x082b2b192b191919, - 0x082b2b2b08082b2b, - 0x082b2b2b082b082b, - 0x082b2b2b192b1908, - 0x082b2b2b2b082b08, - 0x082b2b2b2b082b2b, - 0x1908080808080819, - 0x1908080808081908, - 0x190808080808192b, - 0x1908080808082b19, - 0x1908080808190808, - 0x190808080819082b, - 0x1908080808191919, - 0x1908080808192b08, - 0x1908080808192b2b, - 0x19080808082b0819, - 0x19080808082b1908, - 0x19080808082b192b, - 0x1908080819080808, - 0x190808081908082b, - 0x1908080819081919, - 0x1908080819082b08, - 0x1908080819082b2b, - 0x1908080819190819, - 0x1908080819191908, - 0x190808081919192b, - 0x1908080819192b19, - 0x19080808192b0808, - 0x19080808192b082b, - 0x19080808192b1919, - 0x190808082b080819, - 0x190808082b081908, - 0x190808082b190808, - 0x190808082b191919, - 0x190808082b192b08, - 0x190808082b2b0819, - 0x190808082b2b1908, - 0x1908081908080808, - 0x190808190808082b, - 0x1908081908081919, - 0x1908081908082b08, - 0x1908081908190819, - 0x1908081908191908, - 0x190808190819192b, - 0x1908081908192b19, - 0x19080819082b0808, - 0x19080819082b082b, - 0x19080819082b1919, - 0x1908081919080819, - 0x1908081919081908, - 0x190808191908192b, - 0x1908081919082b19, - 0x1908081919190808, - 0x190808191919082b, - 0x1908081919191919, - 0x1908081919192b08, - 0x19080819192b0819, - 0x19080819192b1908, - 0x190808192b080808, - 0x190808192b08082b, - 0x190808192b081919, - 0x190808192b082b08, - 0x190808192b190819, - 0x190808192b191908, - 0x190808192b2b0808, - 0x1908082b08080819, - 0x1908082b08081908, - 0x1908082b08190808, - 0x1908082b0819082b, - 0x1908082b08191919, - 0x1908082b08192b08, - 0x1908082b082b1908, - 0x1908082b19080808, - 0x1908082b19081919, - 0x1908082b19082b08, - 0x1908082b19190819, - 0x1908082b19191908, - 0x1908082b192b0808, - 0x1908082b2b080819, - 0x1908082b2b081908, - 0x1908190808080808, - 0x190819080808082b, - 0x1908190808081919, - 0x1908190808082b08, - 0x1908190808082b2b, - 0x1908190808190819, - 0x1908190808191908, - 0x190819080819192b, - 0x1908190808192b19, - 0x19081908082b0808, - 0x19081908082b082b, - 0x19081908082b1919, - 0x19081908082b2b08, - 0x1908190819080819, - 0x1908190819081908, - 0x190819081908192b, - 0x1908190819082b19, - 0x1908190819190808, - 0x190819081919082b, - 0x1908190819191919, - 0x1908190819192b08, - 0x19081908192b0819, - 0x19081908192b1908, - 0x190819082b080808, - 0x190819082b08082b, - 0x190819082b081919, - 0x190819082b082b08, - 0x190819082b190819, - 0x190819082b191908, - 0x190819082b2b0808, - 0x1908191908080819, - 0x1908191908081908, - 0x190819190808192b, - 0x1908191908082b19, - 0x1908191908190808, - 0x190819190819082b, - 0x1908191908191919, - 0x1908191908192b08, - 0x19081919082b0819, - 0x19081919082b1908, - 0x1908191919080808, - 0x190819191908082b, - 0x1908191919081919, - 0x1908191919082b08, - 0x1908191919190819, - 0x1908191919191908, - 0x19081919192b0808, - 0x19081919192b2b2b, - 0x190819192b080819, - 0x190819192b081908, - 0x190819192b190808, - 0x1908192b08080808, - 0x1908192b0808082b, - 0x1908192b08081919, - 0x1908192b08082b08, - 0x1908192b08190819, - 0x1908192b08191908, - 0x1908192b082b0808, - 0x1908192b19080819, - 0x1908192b19081908, - 0x1908192b19190808, - 0x1908192b2b080808, - 0x1908192b2b2b1919, - 0x19082b0808080819, - 0x19082b0808081908, - 0x19082b0808082b19, - 0x19082b0808190808, - 0x19082b080819082b, - 0x19082b0808191919, - 0x19082b0808192b08, - 0x19082b08082b0819, - 0x19082b08082b1908, - 0x19082b0819080808, - 0x19082b081908082b, - 0x19082b0819081919, - 0x19082b0819082b08, - 0x19082b0819190819, - 0x19082b0819191908, - 0x19082b08192b0808, - 0x19082b082b081908, - 0x19082b082b190808, - 0x19082b1908080808, - 0x19082b190808082b, - 0x19082b1908081919, - 0x19082b1908082b08, - 0x19082b1908190819, - 0x19082b1908191908, - 0x19082b19082b0808, - 0x19082b1919080819, - 0x19082b1919081908, - 0x19082b1919190808, - 0x19082b192b080808, - 0x19082b192b19192b, - 0x19082b2b08080819, - 0x19082b2b08081908, - 0x19082b2b08190808, - 0x19082b2b19080808, - 0x1919080808080808, - 0x191908080808082b, - 0x1919080808081919, - 0x1919080808082b08, - 0x1919080808190819, - 0x1919080808191908, - 0x191908080819192b, - 0x1919080808192b19, - 0x19190808082b0808, - 0x19190808082b082b, - 0x19190808082b1919, - 0x19190808082b2b08, - 0x1919080819080819, - 0x1919080819081908, - 0x191908081908192b, - 0x1919080819082b19, - 0x1919080819190808, - 0x191908081919082b, - 0x1919080819191919, - 0x1919080819192b08, - 0x19190808192b0819, - 0x19190808192b1908, - 0x191908082b080808, - 0x191908082b08082b, - 0x191908082b081919, - 0x191908082b082b08, - 0x191908082b190819, - 0x191908082b191908, - 0x1919081908080819, - 0x1919081908081908, - 0x191908190808192b, - 0x1919081908082b19, - 0x1919081908190808, - 0x191908190819082b, - 0x1919081908191919, - 0x1919081908192b08, - 0x19190819082b0819, - 0x19190819082b1908, - 0x1919081919080808, - 0x191908191908082b, - 0x1919081919081919, - 0x1919081919082b08, - 0x1919081919190819, - 0x1919081919191908, - 0x19190819192b0808, - 0x191908192b080819, - 0x191908192b081908, - 0x191908192b190808, - 0x1919082b08080808, - 0x1919082b08081919, - 0x1919082b08082b08, - 0x1919082b08190819, - 0x1919082b08191908, - 0x1919082b082b0808, - 0x1919082b19080819, - 0x1919082b19081908, - 0x1919082b19190808, - 0x1919082b192b2b19, - 0x1919082b2b080808, - 0x1919190808080819, - 0x1919190808081908, - 0x191919080808192b, - 0x1919190808082b19, - 0x1919190808190808, - 0x191919080819082b, - 0x1919190808191919, - 0x1919190808192b08, - 0x19191908082b0819, - 0x19191908082b1908, - 0x1919190819080808, - 0x191919081908082b, - 0x1919190819081919, - 0x1919190819082b08, - 0x1919190819190819, - 0x1919190819191908, - 0x19191908192b0808, - 0x191919082b080819, - 0x191919082b081908, - 0x191919082b190808, - 0x1919191908080808, - 0x191919190808082b, - 0x1919191908081919, - 0x1919191908082b08, - 0x1919191908190819, - 0x1919191908191908, - 0x19191919082b0808, - 0x1919191919080819, - 0x1919191919081908, - 0x1919191919190808, - 0x191919192b080808, - 0x1919192b08080819, - 0x1919192b08081908, - 0x1919192b08190808, - 0x1919192b082b192b, - 0x1919192b19080808, - 0x19192b0808080808, - 0x19192b080808082b, - 0x19192b0808081919, - 0x19192b0808082b08, - 0x19192b0808190819, - 0x19192b0808191908, - 0x19192b08082b0808, - 0x19192b0819080819, - 0x19192b0819081908, - 0x19192b0819190808, - 0x19192b0819192b2b, - 0x19192b082b080808, - 0x19192b1908080819, - 0x19192b1908081908, - 0x19192b1908190808, - 0x19192b1919080808, - 0x19192b2b08080808, - 0x19192b2b08192b19, - 0x19192b2b2b081919, - 0x19192b2b2b2b2b08, - 0x192b080808080819, - 0x192b080808081908, - 0x192b08080808192b, - 0x192b080808190808, - 0x192b08080819082b, - 0x192b080808191919, - 0x192b080808192b08, - 0x192b0808082b0819, - 0x192b0808082b1908, - 0x192b080819080808, - 0x192b080819081919, - 0x192b080819082b08, - 0x192b080819190819, - 0x192b080819191908, - 0x192b0808192b0808, - 0x192b08082b081908, - 0x192b08082b190808, - 0x192b081908080808, - 0x192b08190808082b, - 0x192b081908081919, - 0x192b081908082b08, - 0x192b081908190819, - 0x192b081908191908, - 0x192b0819082b0808, - 0x192b081919080819, - 0x192b081919081908, - 0x192b081919190808, - 0x192b08192b080808, - 0x192b08192b192b19, - 0x192b082b08081908, - 0x192b082b08190808, - 0x192b082b19080808, - 0x192b082b1919192b, - 0x192b082b2b2b0819, - 0x192b190808080808, - 0x192b190808081919, - 0x192b190808082b08, - 0x192b190808190819, - 0x192b190808191908, - 0x192b1908082b0808, - 0x192b190819080819, - 0x192b190819081908, - 0x192b190819190808, - 0x192b19082b080808, - 0x192b191908080819, - 0x192b191908081908, - 0x192b191908190808, - 0x192b191919080808, - 0x192b191919082b2b, - 0x192b1919192b2b08, - 0x192b19192b19082b, - 0x192b192b08080808, - 0x192b192b2b191908, - 0x192b2b0808080819, - 0x192b2b0808081908, - 0x192b2b0808190808, - 0x192b2b08192b1919, - 0x192b2b082b192b08, - 0x192b2b1908080808, - 0x192b2b19082b2b2b, - 0x192b2b2b1908082b, - 0x192b2b2b2b2b0819, - 0x2b08080808080808, - 0x2b0808080808082b, - 0x2b08080808081919, - 0x2b08080808082b08, - 0x2b08080808190819, - 0x2b08080808191908, - 0x2b08080808192b19, - 0x2b080808082b0808, - 0x2b080808082b1919, - 0x2b08080819080819, - 0x2b08080819081908, - 0x2b08080819190808, - 0x2b0808081919082b, - 0x2b08080819191919, - 0x2b08080819192b08, - 0x2b080808192b0819, - 0x2b0808082b080808, - 0x2b0808082b081919, - 0x2b0808082b190819, - 0x2b0808082b191908, - 0x2b08081908080819, - 0x2b08081908081908, - 0x2b08081908082b19, - 0x2b08081908190808, - 0x2b0808190819082b, - 0x2b08081908191919, - 0x2b08081908192b08, - 0x2b080819082b0819, - 0x2b080819082b1908, - 0x2b08081919080808, - 0x2b0808191908082b, - 0x2b08081919081919, - 0x2b08081919082b08, - 0x2b08081919190819, - 0x2b08081919191908, - 0x2b0808192b080819, - 0x2b0808192b081908, - 0x2b0808192b190808, - 0x2b0808192b2b2b19, - 0x2b08082b08080808, - 0x2b08082b08081919, - 0x2b08082b08082b2b, - 0x2b08082b08190819, - 0x2b08082b08191908, - 0x2b08082b19080819, - 0x2b08082b19081908, - 0x2b08082b19190808, - 0x2b08190808080819, - 0x2b08190808081908, - 0x2b0819080808192b, - 0x2b08190808082b19, - 0x2b08190808190808, - 0x2b0819080819082b, - 0x2b08190808191919, - 0x2b08190808192b08, - 0x2b081908082b0819, - 0x2b08190819080808, - 0x2b0819081908082b, - 0x2b08190819081919, - 0x2b08190819082b08, - 0x2b08190819190819, - 0x2b08190819191908, - 0x2b081908192b0808, - 0x2b0819082b080819, - 0x2b0819082b081908, - 0x2b0819082b190808, - 0x2b08191908080808, - 0x2b0819190808082b, - 0x2b08191908081919, - 0x2b08191908082b08, - 0x2b08191908190819, - 0x2b08191908191908, - 0x2b081919082b0808, - 0x2b08191919080819, - 0x2b08191919081908, - 0x2b08191919190808, - 0x2b0819192b080808, - 0x2b0819192b082b2b, - 0x2b08192b08080819, - 0x2b08192b08081908, - 0x2b08192b08190808, - 0x2b08192b082b2b19, - 0x2b08192b19080808, - 0x2b082b0808080808, - 0x2b082b0808081919, - 0x2b082b0808190819, - 0x2b082b0808191908, - 0x2b082b0819080819, - 0x2b082b0819081908, - 0x2b082b0819190808, - 0x2b082b082b2b082b, - 0x2b082b1908080819, - 0x2b082b1908081908, - 0x2b082b1919080808, - 0x2b082b19192b1919, - 0x2b082b2b082b082b, - 0x2b082b2b19192b08, - 0x2b082b2b19192b2b, - 0x2b082b2b2b08082b, - 0x2b082b2b2b2b082b, - 0x2b19080808080819, - 0x2b19080808081908, - 0x2b19080808082b19, - 0x2b19080808190808, - 0x2b1908080819082b, - 0x2b19080808191919, - 0x2b19080808192b08, - 0x2b190808082b1908, - 0x2b19080819080808, - 0x2b1908081908082b, - 0x2b19080819081919, - 0x2b19080819082b08, - 0x2b19080819190819, - 0x2b19080819191908, - 0x2b190808192b0808, - 0x2b1908082b080819, - 0x2b1908082b081908, - 0x2b1908082b190808, - 0x2b19081908080808, - 0x2b19081908081919, - 0x2b19081908190819, - 0x2b19081908191908, - 0x2b19081919080819, - 0x2b19081919081908, - 0x2b19081919190808, - 0x2b19081919192b2b, - 0x2b19082b08080819, - 0x2b19082b08081908, - 0x2b19082b08190808, - 0x2b19082b19080808, - 0x2b19082b2b2b192b, - 0x2b19190808080808, - 0x2b1919080808082b, - 0x2b19190808081919, - 0x2b19190808082b08, - 0x2b19190808190819, - 0x2b19190808191908, - 0x2b191908082b0808, - 0x2b19190819080819, - 0x2b19190819081908, - 0x2b19190819190808, - 0x2b1919082b080808, - 0x2b1919082b19192b, - 0x2b19191908080819, - 0x2b19191908081908, - 0x2b19191908190808, - 0x2b19191919080808, - 0x2b1919192b192b08, - 0x2b1919192b2b0819, - 0x2b19192b08080808, - 0x2b19192b1908192b, - 0x2b19192b192b1908, - 0x2b192b0808080819, - 0x2b192b0808081908, - 0x2b192b0808190808, - 0x2b192b08082b192b, - 0x2b192b0819080808, - 0x2b192b082b2b2b19, - 0x2b192b1908080808, - 0x2b192b1919082b19, - 0x2b192b191919082b, - 0x2b192b2b2b190808, - 0x2b2b080808080808, - 0x2b2b080808081919, - 0x2b2b080808082b2b, - 0x2b2b080808191908, - 0x2b2b0808082b082b, - 0x2b2b0808082b2b2b, - 0x2b2b080819080819, - 0x2b2b080819081908, - 0x2b2b080819190808, - 0x2b2b08082b2b082b, - 0x2b2b08082b2b2b2b, - 0x2b2b081919080808, - 0x2b2b0819192b1919, - 0x2b2b082b0808082b, - 0x2b2b082b08082b2b, - 0x2b2b082b082b082b, - 0x2b2b082b082b2b08, - 0x2b2b082b082b2b2b, - 0x2b2b082b2b08082b, - 0x2b2b082b2b082b08, - 0x2b2b082b2b082b2b, - 0x2b2b082b2b2b2b08, - 0x2b2b190808080819, - 0x2b2b190808081908, - 0x2b2b190808190808, - 0x2b2b190819080808, - 0x2b2b19082b082b19, - 0x2b2b19082b2b1908, - 0x2b2b191908080808, - 0x2b2b191908192b19, - 0x2b2b192b19190819, - 0x2b2b2b0808082b2b, - 0x2b2b2b08082b2b08, - 0x2b2b2b082b2b082b, - 0x2b2b2b1919191908, - 0x2b2b2b192b08192b, - 0x2b2b2b2b08082b08, - 0x2b2b2b2b08082b2b, - 0x2b2b2b2b082b0808, - 0x2b2b2b2b082b082b, - 0x2b2b2b2b082b2b08, - 0x2b2b2b2b2b082b08, - 0x2b2b2b2b2b2b2b2b, + 0x0808080808080808, 0x080808080808082b, 0x0808080808081919, 0x0808080808082b08, 0x0808080808082b2b, 0x0808080808190819, 0x0808080808191908, 0x080808080819192b, + 0x0808080808192b19, 0x08080808082b0808, 0x08080808082b082b, 0x08080808082b1919, 0x08080808082b2b08, 0x0808080819080819, 0x0808080819081908, 0x080808081908192b, + 0x0808080819082b19, 0x0808080819190808, 0x080808081919082b, 0x0808080819191919, 0x0808080819192b08, 0x08080808192b0819, 0x08080808192b1908, 0x08080808192b192b, + 0x08080808192b2b19, 0x080808082b080808, 0x080808082b08082b, 0x080808082b081919, 0x080808082b082b08, 0x080808082b190819, 0x080808082b191908, 0x080808082b2b0808, + 0x080808082b2b1919, 0x080808082b2b2b2b, 0x0808081908080819, 0x0808081908081908, 0x080808190808192b, 0x0808081908082b19, 0x0808081908190808, 0x080808190819082b, + 0x0808081908191919, 0x0808081908192b08, 0x08080819082b0819, 0x08080819082b1908, 0x0808081919080808, 0x080808191908082b, 0x0808081919081919, 0x0808081919082b08, + 0x0808081919190819, 0x0808081919191908, 0x080808191919192b, 0x0808081919192b19, 0x08080819192b0808, 0x08080819192b1919, 0x08080819192b2b08, 0x080808192b080819, + 0x080808192b081908, 0x080808192b190808, 0x080808192b19082b, 0x080808192b191919, 0x080808192b2b0819, 0x080808192b2b1908, 0x0808082b08080808, 0x0808082b0808082b, + 0x0808082b08081919, 0x0808082b08082b08, 0x0808082b08190819, 0x0808082b08191908, 0x0808082b082b0808, 0x0808082b082b2b2b, 0x0808082b19080819, 0x0808082b19081908, + 0x0808082b1908192b, 0x0808082b19082b19, 0x0808082b19190808, 0x0808082b19191919, 0x0808082b2b080808, 0x0808082b2b081919, 0x0808082b2b082b2b, 0x0808082b2b191908, + 0x0808082b2b2b082b, 0x0808190808080819, 0x0808190808081908, 0x080819080808192b, 0x0808190808082b19, 0x0808190808190808, 0x080819080819082b, 0x0808190808191919, + 0x0808190808192b08, 0x08081908082b0819, 0x08081908082b1908, 0x08081908082b192b, 0x08081908082b2b19, 0x0808190819080808, 0x080819081908082b, 0x0808190819081919, + 0x0808190819082b08, 0x0808190819082b2b, 0x0808190819190819, 0x0808190819191908, 0x080819081919192b, 0x0808190819192b19, 0x08081908192b0808, 0x08081908192b082b, + 0x08081908192b1919, 0x080819082b080819, 0x080819082b081908, 0x080819082b08192b, 0x080819082b082b19, 0x080819082b190808, 0x080819082b191919, 0x080819082b192b08, + 0x080819082b2b0819, 0x080819082b2b1908, 0x0808191908080808, 0x080819190808082b, 0x0808191908081919, 0x0808191908082b08, 0x0808191908082b2b, 0x0808191908190819, + 0x0808191908191908, 0x080819190819192b, 0x0808191908192b19, 0x08081919082b0808, 0x08081919082b1919, 0x08081919082b2b08, 0x0808191919080819, 0x0808191919081908, + 0x080819191908192b, 0x0808191919082b19, 0x0808191919190808, 0x080819191919082b, 0x0808191919191919, 0x0808191919192b08, 0x08081919192b0819, 0x08081919192b1908, + 0x080819192b080808, 0x080819192b08082b, 0x080819192b081919, 0x080819192b082b08, 0x080819192b190819, 0x080819192b191908, 0x080819192b2b0808, 0x0808192b08080819, + 0x0808192b08081908, 0x0808192b0808192b, 0x0808192b08082b19, 0x0808192b08190808, 0x0808192b08191919, 0x0808192b19080808, 0x0808192b19081919, 0x0808192b19082b08, + 0x0808192b19190819, 0x0808192b19191908, 0x0808192b192b0808, 0x0808192b2b080819, 0x0808192b2b081908, 0x0808192b2b190808, 0x08082b0808080808, 0x08082b080808082b, + 0x08082b0808081919, 0x08082b0808082b08, 0x08082b0808190819, 0x08082b0808191908, 0x08082b080819192b, 0x08082b0808192b19, 0x08082b08082b0808, 0x08082b08082b1919, + 0x08082b08082b2b2b, 0x08082b0819080819, 0x08082b0819081908, 0x08082b081908192b, 0x08082b0819082b19, 0x08082b0819190808, 0x08082b081919082b, 0x08082b0819191919, + 0x08082b0819192b08, 0x08082b08192b0819, 0x08082b08192b1908, 0x08082b082b080808, 0x08082b082b081919, 0x08082b082b191908, 0x08082b082b2b2b2b, 0x08082b1908080819, + 0x08082b1908081908, 0x08082b1908190808, 0x08082b190819082b, 0x08082b1908191919, 0x08082b1908192b08, 0x08082b19082b0819, 0x08082b1919080808, 0x08082b1919081919, + 0x08082b1919082b08, 0x08082b1919190819, 0x08082b1919191908, 0x08082b19192b0808, 0x08082b192b080819, 0x08082b192b190808, 0x08082b2b08080808, 0x08082b2b08190819, + 0x08082b2b08191908, 0x08082b2b082b082b, 0x08082b2b082b2b08, 0x08082b2b082b2b2b, 0x08082b2b19190808, 0x08082b2b2b192b19, 0x0819080808080819, 0x0819080808081908, + 0x081908080808192b, 0x0819080808082b19, 0x0819080808190808, 0x081908080819082b, 0x0819080808191919, 0x0819080808192b08, 0x08190808082b0819, 0x08190808082b1908, + 0x08190808082b192b, 0x0819080819080808, 0x081908081908082b, 0x0819080819081919, 0x0819080819082b08, 0x0819080819190819, 0x0819080819191908, 0x081908081919192b, + 0x0819080819192b19, 0x08190808192b0808, 0x08190808192b082b, 0x08190808192b1919, 0x08190808192b2b08, 0x081908082b080819, 0x081908082b081908, 0x081908082b08192b, + 0x081908082b190808, 0x081908082b191919, 0x081908082b192b08, 0x081908082b2b0819, 0x081908082b2b1908, 0x0819081908080808, 0x081908190808082b, 0x0819081908081919, + 0x0819081908082b08, 0x0819081908082b2b, 0x0819081908190819, 0x0819081908191908, 0x081908190819192b, 0x0819081908192b19, 0x08190819082b0808, 0x08190819082b082b, + 0x08190819082b1919, 0x08190819082b2b08, 0x0819081919080819, 0x0819081919081908, 0x081908191908192b, 0x0819081919082b19, 0x0819081919190808, 0x081908191919082b, + 0x0819081919191919, 0x0819081919192b08, 0x08190819192b0819, 0x08190819192b1908, 0x081908192b080808, 0x081908192b08082b, 0x081908192b081919, 0x081908192b082b08, + 0x081908192b190819, 0x081908192b191908, 0x0819082b08080819, 0x0819082b08081908, 0x0819082b08082b19, 0x0819082b08190808, 0x0819082b08191919, 0x0819082b082b0819, + 0x0819082b082b1908, 0x0819082b19080808, 0x0819082b19081919, 0x0819082b19190819, 0x0819082b19191908, 0x0819082b2b080819, 0x0819082b2b081908, 0x0819082b2b190808, + 0x0819190808080808, 0x081919080808082b, 0x0819190808081919, 0x0819190808082b08, 0x0819190808190819, 0x0819190808191908, 0x081919080819192b, 0x0819190808192b19, + 0x08191908082b0808, 0x08191908082b1919, 0x08191908082b2b08, 0x0819190819080819, 0x0819190819081908, 0x081919081908192b, 0x0819190819082b19, 0x0819190819190808, + 0x081919081919082b, 0x0819190819191919, 0x0819190819192b08, 0x08191908192b0819, 0x08191908192b1908, 0x081919082b080808, 0x081919082b08082b, 0x081919082b081919, + 0x081919082b082b08, 0x081919082b190819, 0x081919082b191908, 0x081919082b2b0808, 0x0819191908080819, 0x0819191908081908, 0x081919190808192b, 0x0819191908082b19, + 0x0819191908190808, 0x081919190819082b, 0x0819191908191919, 0x0819191908192b08, 0x08191919082b0819, 0x08191919082b1908, 0x0819191919080808, 0x081919191908082b, + 0x0819191919081919, 0x0819191919082b08, 0x0819191919190819, 0x0819191919191908, 0x08191919192b0808, 0x081919192b080819, 0x081919192b081908, 0x081919192b190808, + 0x0819192b08080808, 0x0819192b08081919, 0x0819192b08082b08, 0x0819192b08190819, 0x0819192b08191908, 0x0819192b082b0808, 0x0819192b19080819, 0x0819192b19081908, + 0x0819192b19190808, 0x0819192b2b080808, 0x0819192b2b2b2b2b, 0x08192b0808080819, 0x08192b0808081908, 0x08192b080808192b, 0x08192b0808082b19, 0x08192b0808190808, + 0x08192b0808191919, 0x08192b0808192b08, 0x08192b08082b0819, 0x08192b0819080808, 0x08192b081908082b, 0x08192b0819081919, 0x08192b0819082b08, 0x08192b0819190819, + 0x08192b0819191908, 0x08192b08192b0808, 0x08192b082b080819, 0x08192b082b081908, 0x08192b1908080808, 0x08192b190808082b, 0x08192b1908081919, 0x08192b1908082b08, + 0x08192b1908190819, 0x08192b1908191908, 0x08192b19082b0808, 0x08192b1919080819, 0x08192b1919081908, 0x08192b1919190808, 0x08192b19192b2b19, 0x08192b192b2b082b, + 0x08192b2b08081908, 0x08192b2b08190808, 0x08192b2b19080808, 0x08192b2b1919192b, 0x082b080808080808, 0x082b08080808082b, 0x082b080808081919, 0x082b080808082b08, + 0x082b080808190819, 0x082b080808191908, 0x082b08080819192b, 0x082b080808192b19, 0x082b0808082b0808, 0x082b0808082b1919, 0x082b0808082b2b2b, 0x082b080819080819, + 0x082b080819081908, 0x082b080819190808, 0x082b08081919082b, 0x082b080819191919, 0x082b0808192b1908, 0x082b08082b080808, 0x082b08082b082b2b, 0x082b08082b191908, + 0x082b08082b2b2b2b, 0x082b081908080819, 0x082b081908081908, 0x082b081908190808, 0x082b08190819082b, 0x082b081908191919, 0x082b0819082b0819, 0x082b081919080808, + 0x082b08191908082b, 0x082b081919081919, 0x082b081919190819, 0x082b081919191908, 0x082b0819192b0808, 0x082b08192b080819, 0x082b08192b081908, 0x082b08192b190808, + 0x082b082b08080808, 0x082b082b08082b2b, 0x082b082b082b082b, 0x082b082b082b2b08, 0x082b082b082b2b2b, 0x082b082b19081908, 0x082b082b19190808, 0x082b082b2b082b08, + 0x082b082b2b082b2b, 0x082b082b2b2b2b08, 0x082b190808080819, 0x082b190808081908, 0x082b19080808192b, 0x082b190808082b19, 0x082b190808190808, 0x082b190808191919, + 0x082b190808192b08, 0x082b1908082b0819, 0x082b1908082b1908, 0x082b190819080808, 0x082b19081908082b, 0x082b190819081919, 0x082b190819082b08, 0x082b190819190819, + 0x082b190819191908, 0x082b1908192b0808, 0x082b19082b080819, 0x082b19082b081908, 0x082b19082b190808, 0x082b191908080808, 0x082b191908081919, 0x082b191908082b08, + 0x082b191908190819, 0x082b191908191908, 0x082b1919082b0808, 0x082b191919080819, 0x082b191919081908, 0x082b191919190808, 0x082b1919192b192b, 0x082b19192b080808, + 0x082b192b08080819, 0x082b192b08081908, 0x082b192b08190808, 0x082b192b19080808, 0x082b192b19192b19, 0x082b2b0808080808, 0x082b2b0808081919, 0x082b2b0808190819, + 0x082b2b0808191908, 0x082b2b0819080819, 0x082b2b0819081908, 0x082b2b0819190808, 0x082b2b082b082b2b, 0x082b2b082b2b2b2b, 0x082b2b1908080819, 0x082b2b1908081908, + 0x082b2b1908190808, 0x082b2b192b191919, 0x082b2b2b08082b2b, 0x082b2b2b082b082b, 0x082b2b2b192b1908, 0x082b2b2b2b082b08, 0x082b2b2b2b082b2b, 0x1908080808080819, + 0x1908080808081908, 0x190808080808192b, 0x1908080808082b19, 0x1908080808190808, 0x190808080819082b, 0x1908080808191919, 0x1908080808192b08, 0x1908080808192b2b, + 0x19080808082b0819, 0x19080808082b1908, 0x19080808082b192b, 0x1908080819080808, 0x190808081908082b, 0x1908080819081919, 0x1908080819082b08, 0x1908080819082b2b, + 0x1908080819190819, 0x1908080819191908, 0x190808081919192b, 0x1908080819192b19, 0x19080808192b0808, 0x19080808192b082b, 0x19080808192b1919, 0x190808082b080819, + 0x190808082b081908, 0x190808082b190808, 0x190808082b191919, 0x190808082b192b08, 0x190808082b2b0819, 0x190808082b2b1908, 0x1908081908080808, 0x190808190808082b, + 0x1908081908081919, 0x1908081908082b08, 0x1908081908190819, 0x1908081908191908, 0x190808190819192b, 0x1908081908192b19, 0x19080819082b0808, 0x19080819082b082b, + 0x19080819082b1919, 0x1908081919080819, 0x1908081919081908, 0x190808191908192b, 0x1908081919082b19, 0x1908081919190808, 0x190808191919082b, 0x1908081919191919, + 0x1908081919192b08, 0x19080819192b0819, 0x19080819192b1908, 0x190808192b080808, 0x190808192b08082b, 0x190808192b081919, 0x190808192b082b08, 0x190808192b190819, + 0x190808192b191908, 0x190808192b2b0808, 0x1908082b08080819, 0x1908082b08081908, 0x1908082b08190808, 0x1908082b0819082b, 0x1908082b08191919, 0x1908082b08192b08, + 0x1908082b082b1908, 0x1908082b19080808, 0x1908082b19081919, 0x1908082b19082b08, 0x1908082b19190819, 0x1908082b19191908, 0x1908082b192b0808, 0x1908082b2b080819, + 0x1908082b2b081908, 0x1908190808080808, 0x190819080808082b, 0x1908190808081919, 0x1908190808082b08, 0x1908190808082b2b, 0x1908190808190819, 0x1908190808191908, + 0x190819080819192b, 0x1908190808192b19, 0x19081908082b0808, 0x19081908082b082b, 0x19081908082b1919, 0x19081908082b2b08, 0x1908190819080819, 0x1908190819081908, + 0x190819081908192b, 0x1908190819082b19, 0x1908190819190808, 0x190819081919082b, 0x1908190819191919, 0x1908190819192b08, 0x19081908192b0819, 0x19081908192b1908, + 0x190819082b080808, 0x190819082b08082b, 0x190819082b081919, 0x190819082b082b08, 0x190819082b190819, 0x190819082b191908, 0x190819082b2b0808, 0x1908191908080819, + 0x1908191908081908, 0x190819190808192b, 0x1908191908082b19, 0x1908191908190808, 0x190819190819082b, 0x1908191908191919, 0x1908191908192b08, 0x19081919082b0819, + 0x19081919082b1908, 0x1908191919080808, 0x190819191908082b, 0x1908191919081919, 0x1908191919082b08, 0x1908191919190819, 0x1908191919191908, 0x19081919192b0808, + 0x19081919192b2b2b, 0x190819192b080819, 0x190819192b081908, 0x190819192b190808, 0x1908192b08080808, 0x1908192b0808082b, 0x1908192b08081919, 0x1908192b08082b08, + 0x1908192b08190819, 0x1908192b08191908, 0x1908192b082b0808, 0x1908192b19080819, 0x1908192b19081908, 0x1908192b19190808, 0x1908192b2b080808, 0x1908192b2b2b1919, + 0x19082b0808080819, 0x19082b0808081908, 0x19082b0808082b19, 0x19082b0808190808, 0x19082b080819082b, 0x19082b0808191919, 0x19082b0808192b08, 0x19082b08082b0819, + 0x19082b08082b1908, 0x19082b0819080808, 0x19082b081908082b, 0x19082b0819081919, 0x19082b0819082b08, 0x19082b0819190819, 0x19082b0819191908, 0x19082b08192b0808, + 0x19082b082b081908, 0x19082b082b190808, 0x19082b1908080808, 0x19082b190808082b, 0x19082b1908081919, 0x19082b1908082b08, 0x19082b1908190819, 0x19082b1908191908, + 0x19082b19082b0808, 0x19082b1919080819, 0x19082b1919081908, 0x19082b1919190808, 0x19082b192b080808, 0x19082b192b19192b, 0x19082b2b08080819, 0x19082b2b08081908, + 0x19082b2b08190808, 0x19082b2b19080808, 0x1919080808080808, 0x191908080808082b, 0x1919080808081919, 0x1919080808082b08, 0x1919080808190819, 0x1919080808191908, + 0x191908080819192b, 0x1919080808192b19, 0x19190808082b0808, 0x19190808082b082b, 0x19190808082b1919, 0x19190808082b2b08, 0x1919080819080819, 0x1919080819081908, + 0x191908081908192b, 0x1919080819082b19, 0x1919080819190808, 0x191908081919082b, 0x1919080819191919, 0x1919080819192b08, 0x19190808192b0819, 0x19190808192b1908, + 0x191908082b080808, 0x191908082b08082b, 0x191908082b081919, 0x191908082b082b08, 0x191908082b190819, 0x191908082b191908, 0x1919081908080819, 0x1919081908081908, + 0x191908190808192b, 0x1919081908082b19, 0x1919081908190808, 0x191908190819082b, 0x1919081908191919, 0x1919081908192b08, 0x19190819082b0819, 0x19190819082b1908, + 0x1919081919080808, 0x191908191908082b, 0x1919081919081919, 0x1919081919082b08, 0x1919081919190819, 0x1919081919191908, 0x19190819192b0808, 0x191908192b080819, + 0x191908192b081908, 0x191908192b190808, 0x1919082b08080808, 0x1919082b08081919, 0x1919082b08082b08, 0x1919082b08190819, 0x1919082b08191908, 0x1919082b082b0808, + 0x1919082b19080819, 0x1919082b19081908, 0x1919082b19190808, 0x1919082b192b2b19, 0x1919082b2b080808, 0x1919190808080819, 0x1919190808081908, 0x191919080808192b, + 0x1919190808082b19, 0x1919190808190808, 0x191919080819082b, 0x1919190808191919, 0x1919190808192b08, 0x19191908082b0819, 0x19191908082b1908, 0x1919190819080808, + 0x191919081908082b, 0x1919190819081919, 0x1919190819082b08, 0x1919190819190819, 0x1919190819191908, 0x19191908192b0808, 0x191919082b080819, 0x191919082b081908, + 0x191919082b190808, 0x1919191908080808, 0x191919190808082b, 0x1919191908081919, 0x1919191908082b08, 0x1919191908190819, 0x1919191908191908, 0x19191919082b0808, + 0x1919191919080819, 0x1919191919081908, 0x1919191919190808, 0x191919192b080808, 0x1919192b08080819, 0x1919192b08081908, 0x1919192b08190808, 0x1919192b082b192b, + 0x1919192b19080808, 0x19192b0808080808, 0x19192b080808082b, 0x19192b0808081919, 0x19192b0808082b08, 0x19192b0808190819, 0x19192b0808191908, 0x19192b08082b0808, + 0x19192b0819080819, 0x19192b0819081908, 0x19192b0819190808, 0x19192b0819192b2b, 0x19192b082b080808, 0x19192b1908080819, 0x19192b1908081908, 0x19192b1908190808, + 0x19192b1919080808, 0x19192b2b08080808, 0x19192b2b08192b19, 0x19192b2b2b081919, 0x19192b2b2b2b2b08, 0x192b080808080819, 0x192b080808081908, 0x192b08080808192b, + 0x192b080808190808, 0x192b08080819082b, 0x192b080808191919, 0x192b080808192b08, 0x192b0808082b0819, 0x192b0808082b1908, 0x192b080819080808, 0x192b080819081919, + 0x192b080819082b08, 0x192b080819190819, 0x192b080819191908, 0x192b0808192b0808, 0x192b08082b081908, 0x192b08082b190808, 0x192b081908080808, 0x192b08190808082b, + 0x192b081908081919, 0x192b081908082b08, 0x192b081908190819, 0x192b081908191908, 0x192b0819082b0808, 0x192b081919080819, 0x192b081919081908, 0x192b081919190808, + 0x192b08192b080808, 0x192b08192b192b19, 0x192b082b08081908, 0x192b082b08190808, 0x192b082b19080808, 0x192b082b1919192b, 0x192b082b2b2b0819, 0x192b190808080808, + 0x192b190808081919, 0x192b190808082b08, 0x192b190808190819, 0x192b190808191908, 0x192b1908082b0808, 0x192b190819080819, 0x192b190819081908, 0x192b190819190808, + 0x192b19082b080808, 0x192b191908080819, 0x192b191908081908, 0x192b191908190808, 0x192b191919080808, 0x192b191919082b2b, 0x192b1919192b2b08, 0x192b19192b19082b, + 0x192b192b08080808, 0x192b192b2b191908, 0x192b2b0808080819, 0x192b2b0808081908, 0x192b2b0808190808, 0x192b2b08192b1919, 0x192b2b082b192b08, 0x192b2b1908080808, + 0x192b2b19082b2b2b, 0x192b2b2b1908082b, 0x192b2b2b2b2b0819, 0x2b08080808080808, 0x2b0808080808082b, 0x2b08080808081919, 0x2b08080808082b08, 0x2b08080808190819, + 0x2b08080808191908, 0x2b08080808192b19, 0x2b080808082b0808, 0x2b080808082b1919, 0x2b08080819080819, 0x2b08080819081908, 0x2b08080819190808, 0x2b0808081919082b, + 0x2b08080819191919, 0x2b08080819192b08, 0x2b080808192b0819, 0x2b0808082b080808, 0x2b0808082b081919, 0x2b0808082b190819, 0x2b0808082b191908, 0x2b08081908080819, + 0x2b08081908081908, 0x2b08081908082b19, 0x2b08081908190808, 0x2b0808190819082b, 0x2b08081908191919, 0x2b08081908192b08, 0x2b080819082b0819, 0x2b080819082b1908, + 0x2b08081919080808, 0x2b0808191908082b, 0x2b08081919081919, 0x2b08081919082b08, 0x2b08081919190819, 0x2b08081919191908, 0x2b0808192b080819, 0x2b0808192b081908, + 0x2b0808192b190808, 0x2b0808192b2b2b19, 0x2b08082b08080808, 0x2b08082b08081919, 0x2b08082b08082b2b, 0x2b08082b08190819, 0x2b08082b08191908, 0x2b08082b19080819, + 0x2b08082b19081908, 0x2b08082b19190808, 0x2b08190808080819, 0x2b08190808081908, 0x2b0819080808192b, 0x2b08190808082b19, 0x2b08190808190808, 0x2b0819080819082b, + 0x2b08190808191919, 0x2b08190808192b08, 0x2b081908082b0819, 0x2b08190819080808, 0x2b0819081908082b, 0x2b08190819081919, 0x2b08190819082b08, 0x2b08190819190819, + 0x2b08190819191908, 0x2b081908192b0808, 0x2b0819082b080819, 0x2b0819082b081908, 0x2b0819082b190808, 0x2b08191908080808, 0x2b0819190808082b, 0x2b08191908081919, + 0x2b08191908082b08, 0x2b08191908190819, 0x2b08191908191908, 0x2b081919082b0808, 0x2b08191919080819, 0x2b08191919081908, 0x2b08191919190808, 0x2b0819192b080808, + 0x2b0819192b082b2b, 0x2b08192b08080819, 0x2b08192b08081908, 0x2b08192b08190808, 0x2b08192b082b2b19, 0x2b08192b19080808, 0x2b082b0808080808, 0x2b082b0808081919, + 0x2b082b0808190819, 0x2b082b0808191908, 0x2b082b0819080819, 0x2b082b0819081908, 0x2b082b0819190808, 0x2b082b082b2b082b, 0x2b082b1908080819, 0x2b082b1908081908, + 0x2b082b1919080808, 0x2b082b19192b1919, 0x2b082b2b082b082b, 0x2b082b2b19192b08, 0x2b082b2b19192b2b, 0x2b082b2b2b08082b, 0x2b082b2b2b2b082b, 0x2b19080808080819, + 0x2b19080808081908, 0x2b19080808082b19, 0x2b19080808190808, 0x2b1908080819082b, 0x2b19080808191919, 0x2b19080808192b08, 0x2b190808082b1908, 0x2b19080819080808, + 0x2b1908081908082b, 0x2b19080819081919, 0x2b19080819082b08, 0x2b19080819190819, 0x2b19080819191908, 0x2b190808192b0808, 0x2b1908082b080819, 0x2b1908082b081908, + 0x2b1908082b190808, 0x2b19081908080808, 0x2b19081908081919, 0x2b19081908190819, 0x2b19081908191908, 0x2b19081919080819, 0x2b19081919081908, 0x2b19081919190808, + 0x2b19081919192b2b, 0x2b19082b08080819, 0x2b19082b08081908, 0x2b19082b08190808, 0x2b19082b19080808, 0x2b19082b2b2b192b, 0x2b19190808080808, 0x2b1919080808082b, + 0x2b19190808081919, 0x2b19190808082b08, 0x2b19190808190819, 0x2b19190808191908, 0x2b191908082b0808, 0x2b19190819080819, 0x2b19190819081908, 0x2b19190819190808, + 0x2b1919082b080808, 0x2b1919082b19192b, 0x2b19191908080819, 0x2b19191908081908, 0x2b19191908190808, 0x2b19191919080808, 0x2b1919192b192b08, 0x2b1919192b2b0819, + 0x2b19192b08080808, 0x2b19192b1908192b, 0x2b19192b192b1908, 0x2b192b0808080819, 0x2b192b0808081908, 0x2b192b0808190808, 0x2b192b08082b192b, 0x2b192b0819080808, + 0x2b192b082b2b2b19, 0x2b192b1908080808, 0x2b192b1919082b19, 0x2b192b191919082b, 0x2b192b2b2b190808, 0x2b2b080808080808, 0x2b2b080808081919, 0x2b2b080808082b2b, + 0x2b2b080808191908, 0x2b2b0808082b082b, 0x2b2b0808082b2b2b, 0x2b2b080819080819, 0x2b2b080819081908, 0x2b2b080819190808, 0x2b2b08082b2b082b, 0x2b2b08082b2b2b2b, + 0x2b2b081919080808, 0x2b2b0819192b1919, 0x2b2b082b0808082b, 0x2b2b082b08082b2b, 0x2b2b082b082b082b, 0x2b2b082b082b2b08, 0x2b2b082b082b2b2b, 0x2b2b082b2b08082b, + 0x2b2b082b2b082b08, 0x2b2b082b2b082b2b, 0x2b2b082b2b2b2b08, 0x2b2b190808080819, 0x2b2b190808081908, 0x2b2b190808190808, 0x2b2b190819080808, 0x2b2b19082b082b19, + 0x2b2b19082b2b1908, 0x2b2b191908080808, 0x2b2b191908192b19, 0x2b2b192b19190819, 0x2b2b2b0808082b2b, 0x2b2b2b08082b2b08, 0x2b2b2b082b2b082b, 0x2b2b2b1919191908, + 0x2b2b2b192b08192b, 0x2b2b2b2b08082b08, 0x2b2b2b2b08082b2b, 0x2b2b2b2b082b0808, 0x2b2b2b2b082b082b, 0x2b2b2b2b082b2b08, 0x2b2b2b2b2b082b08, 0x2b2b2b2b2b2b2b2b, ]; +#[rustfmt::skip] pub(super) const IQ3XXS_GRID: [u32; 256] = [ - 0x04040404, 0x04040414, 0x04040424, 0x04040c0c, 0x04040c1c, 0x04040c3e, 0x04041404, 0x04041414, 0x04041c0c, - 0x04042414, 0x04043e1c, 0x04043e2c, 0x040c040c, 0x040c041c, 0x040c0c04, 0x040c0c14, 0x040c140c, 0x040c142c, - 0x040c1c04, 0x040c1c14, 0x040c240c, 0x040c2c24, 0x040c3e04, 0x04140404, 0x04140414, 0x04140424, 0x04140c0c, - 0x04141404, 0x04141414, 0x04141c0c, 0x04141c1c, 0x04141c3e, 0x04142c0c, 0x04142c3e, 0x04143e2c, 0x041c040c, - 0x041c043e, 0x041c0c04, 0x041c0c14, 0x041c142c, 0x041c3e04, 0x04240c1c, 0x04241c3e, 0x04242424, 0x04242c3e, - 0x04243e1c, 0x04243e2c, 0x042c040c, 0x042c043e, 0x042c1c14, 0x042c2c14, 0x04341c2c, 0x04343424, 0x043e0c04, - 0x043e0c24, 0x043e0c34, 0x043e241c, 0x043e340c, 0x0c04040c, 0x0c04041c, 0x0c040c04, 0x0c040c14, 0x0c04140c, - 0x0c04141c, 0x0c041c04, 0x0c041c14, 0x0c041c24, 0x0c04243e, 0x0c042c04, 0x0c0c0404, 0x0c0c0414, 0x0c0c0c0c, - 0x0c0c1404, 0x0c0c1414, 0x0c14040c, 0x0c14041c, 0x0c140c04, 0x0c140c14, 0x0c14140c, 0x0c141c04, 0x0c143e14, - 0x0c1c0404, 0x0c1c0414, 0x0c1c1404, 0x0c1c1c0c, 0x0c1c2434, 0x0c1c3434, 0x0c24040c, 0x0c24042c, 0x0c242c04, - 0x0c2c1404, 0x0c2c1424, 0x0c2c2434, 0x0c2c3e0c, 0x0c34042c, 0x0c3e1414, 0x0c3e2404, 0x14040404, 0x14040414, - 0x14040c0c, 0x14040c1c, 0x14041404, 0x14041414, 0x14041434, 0x14041c0c, 0x14042414, 0x140c040c, 0x140c041c, - 0x140c042c, 0x140c0c04, 0x140c0c14, 0x140c140c, 0x140c1c04, 0x140c341c, 0x140c343e, 0x140c3e04, 0x14140404, - 0x14140414, 0x14140c0c, 0x14140c3e, 0x14141404, 0x14141414, 0x14141c3e, 0x14142404, 0x14142c2c, 0x141c040c, - 0x141c0c04, 0x141c0c24, 0x141c3e04, 0x141c3e24, 0x14241c2c, 0x14242c1c, 0x142c041c, 0x142c143e, 0x142c240c, - 0x142c3e24, 0x143e040c, 0x143e041c, 0x143e0c34, 0x143e242c, 0x1c04040c, 0x1c040c04, 0x1c040c14, 0x1c04140c, - 0x1c04141c, 0x1c042c04, 0x1c04342c, 0x1c043e14, 0x1c0c0404, 0x1c0c0414, 0x1c0c1404, 0x1c0c1c0c, 0x1c0c2424, - 0x1c0c2434, 0x1c14040c, 0x1c14041c, 0x1c140c04, 0x1c14142c, 0x1c142c14, 0x1c143e14, 0x1c1c0c0c, 0x1c1c1c1c, - 0x1c241c04, 0x1c24243e, 0x1c243e14, 0x1c2c0404, 0x1c2c0434, 0x1c2c1414, 0x1c2c2c2c, 0x1c340c24, 0x1c341c34, - 0x1c34341c, 0x1c3e1c1c, 0x1c3e3404, 0x24040424, 0x24040c3e, 0x24041c2c, 0x24041c3e, 0x24042c1c, 0x24042c3e, - 0x240c3e24, 0x24141404, 0x24141c3e, 0x24142404, 0x24143404, 0x24143434, 0x241c043e, 0x241c242c, 0x24240424, - 0x24242c0c, 0x24243424, 0x242c142c, 0x242c241c, 0x242c3e04, 0x243e042c, 0x243e0c04, 0x243e0c14, 0x243e1c04, - 0x2c040c14, 0x2c04240c, 0x2c043e04, 0x2c0c0404, 0x2c0c0434, 0x2c0c1434, 0x2c0c2c2c, 0x2c140c24, 0x2c141c14, - 0x2c143e14, 0x2c1c0414, 0x2c1c2c1c, 0x2c240c04, 0x2c24141c, 0x2c24143e, 0x2c243e14, 0x2c2c0414, 0x2c2c1c0c, - 0x2c342c04, 0x2c3e1424, 0x2c3e2414, 0x34041424, 0x34042424, 0x34042434, 0x34043424, 0x340c140c, 0x340c340c, - 0x34140c3e, 0x34143424, 0x341c1c04, 0x341c1c34, 0x34242424, 0x342c042c, 0x342c2c14, 0x34341c1c, 0x343e041c, - 0x343e140c, 0x3e04041c, 0x3e04042c, 0x3e04043e, 0x3e040c04, 0x3e041c14, 0x3e042c14, 0x3e0c1434, 0x3e0c2404, - 0x3e140c14, 0x3e14242c, 0x3e142c14, 0x3e1c0404, 0x3e1c0c2c, 0x3e1c1c1c, 0x3e1c3404, 0x3e24140c, 0x3e24240c, - 0x3e2c0404, 0x3e2c0414, 0x3e2c1424, 0x3e341c04, + 0x04040404, 0x04040414, 0x04040424, 0x04040c0c, 0x04040c1c, 0x04040c3e, 0x04041404, 0x04041414, + 0x04041c0c, 0x04042414, 0x04043e1c, 0x04043e2c, 0x040c040c, 0x040c041c, 0x040c0c04, 0x040c0c14, + 0x040c140c, 0x040c142c, 0x040c1c04, 0x040c1c14, 0x040c240c, 0x040c2c24, 0x040c3e04, 0x04140404, + 0x04140414, 0x04140424, 0x04140c0c, 0x04141404, 0x04141414, 0x04141c0c, 0x04141c1c, 0x04141c3e, + 0x04142c0c, 0x04142c3e, 0x04143e2c, 0x041c040c, 0x041c043e, 0x041c0c04, 0x041c0c14, 0x041c142c, + 0x041c3e04, 0x04240c1c, 0x04241c3e, 0x04242424, 0x04242c3e, 0x04243e1c, 0x04243e2c, 0x042c040c, + 0x042c043e, 0x042c1c14, 0x042c2c14, 0x04341c2c, 0x04343424, 0x043e0c04, 0x043e0c24, 0x043e0c34, + 0x043e241c, 0x043e340c, 0x0c04040c, 0x0c04041c, 0x0c040c04, 0x0c040c14, 0x0c04140c, 0x0c04141c, + 0x0c041c04, 0x0c041c14, 0x0c041c24, 0x0c04243e, 0x0c042c04, 0x0c0c0404, 0x0c0c0414, 0x0c0c0c0c, + 0x0c0c1404, 0x0c0c1414, 0x0c14040c, 0x0c14041c, 0x0c140c04, 0x0c140c14, 0x0c14140c, 0x0c141c04, + 0x0c143e14, 0x0c1c0404, 0x0c1c0414, 0x0c1c1404, 0x0c1c1c0c, 0x0c1c2434, 0x0c1c3434, 0x0c24040c, + 0x0c24042c, 0x0c242c04, 0x0c2c1404, 0x0c2c1424, 0x0c2c2434, 0x0c2c3e0c, 0x0c34042c, 0x0c3e1414, + 0x0c3e2404, 0x14040404, 0x14040414, 0x14040c0c, 0x14040c1c, 0x14041404, 0x14041414, 0x14041434, + 0x14041c0c, 0x14042414, 0x140c040c, 0x140c041c, 0x140c042c, 0x140c0c04, 0x140c0c14, 0x140c140c, + 0x140c1c04, 0x140c341c, 0x140c343e, 0x140c3e04, 0x14140404, 0x14140414, 0x14140c0c, 0x14140c3e, + 0x14141404, 0x14141414, 0x14141c3e, 0x14142404, 0x14142c2c, 0x141c040c, 0x141c0c04, 0x141c0c24, + 0x141c3e04, 0x141c3e24, 0x14241c2c, 0x14242c1c, 0x142c041c, 0x142c143e, 0x142c240c, 0x142c3e24, + 0x143e040c, 0x143e041c, 0x143e0c34, 0x143e242c, 0x1c04040c, 0x1c040c04, 0x1c040c14, 0x1c04140c, + 0x1c04141c, 0x1c042c04, 0x1c04342c, 0x1c043e14, 0x1c0c0404, 0x1c0c0414, 0x1c0c1404, 0x1c0c1c0c, + 0x1c0c2424, 0x1c0c2434, 0x1c14040c, 0x1c14041c, 0x1c140c04, 0x1c14142c, 0x1c142c14, 0x1c143e14, + 0x1c1c0c0c, 0x1c1c1c1c, 0x1c241c04, 0x1c24243e, 0x1c243e14, 0x1c2c0404, 0x1c2c0434, 0x1c2c1414, + 0x1c2c2c2c, 0x1c340c24, 0x1c341c34, 0x1c34341c, 0x1c3e1c1c, 0x1c3e3404, 0x24040424, 0x24040c3e, + 0x24041c2c, 0x24041c3e, 0x24042c1c, 0x24042c3e, 0x240c3e24, 0x24141404, 0x24141c3e, 0x24142404, + 0x24143404, 0x24143434, 0x241c043e, 0x241c242c, 0x24240424, 0x24242c0c, 0x24243424, 0x242c142c, + 0x242c241c, 0x242c3e04, 0x243e042c, 0x243e0c04, 0x243e0c14, 0x243e1c04, 0x2c040c14, 0x2c04240c, + 0x2c043e04, 0x2c0c0404, 0x2c0c0434, 0x2c0c1434, 0x2c0c2c2c, 0x2c140c24, 0x2c141c14, 0x2c143e14, + 0x2c1c0414, 0x2c1c2c1c, 0x2c240c04, 0x2c24141c, 0x2c24143e, 0x2c243e14, 0x2c2c0414, 0x2c2c1c0c, + 0x2c342c04, 0x2c3e1424, 0x2c3e2414, 0x34041424, 0x34042424, 0x34042434, 0x34043424, 0x340c140c, + 0x340c340c, 0x34140c3e, 0x34143424, 0x341c1c04, 0x341c1c34, 0x34242424, 0x342c042c, 0x342c2c14, + 0x34341c1c, 0x343e041c, 0x343e140c, 0x3e04041c, 0x3e04042c, 0x3e04043e, 0x3e040c04, 0x3e041c14, + 0x3e042c14, 0x3e0c1434, 0x3e0c2404, 0x3e140c14, 0x3e14242c, 0x3e142c14, 0x3e1c0404, 0x3e1c0c2c, + 0x3e1c1c1c, 0x3e1c3404, 0x3e24140c, 0x3e24240c, 0x3e2c0404, 0x3e2c0414, 0x3e2c1424, 0x3e341c04, ]; +#[rustfmt::skip] pub(super) const IQ3S_GRID: [u32; 512] = [ - 0x01010101, 0x01010103, 0x01010105, 0x0101010b, 0x0101010f, 0x01010301, 0x01010303, 0x01010305, 0x01010309, - 0x0101030d, 0x01010501, 0x01010503, 0x0101050b, 0x01010707, 0x01010901, 0x01010905, 0x0101090b, 0x0101090f, - 0x01010b03, 0x01010b07, 0x01010d01, 0x01010d05, 0x01010f03, 0x01010f09, 0x01010f0f, 0x01030101, 0x01030103, - 0x01030105, 0x01030109, 0x01030301, 0x01030303, 0x0103030b, 0x01030501, 0x01030507, 0x0103050f, 0x01030703, - 0x0103070b, 0x01030909, 0x01030d03, 0x01030d0b, 0x01030f05, 0x01050101, 0x01050103, 0x0105010b, 0x0105010f, - 0x01050301, 0x01050307, 0x0105030d, 0x01050503, 0x0105050b, 0x01050701, 0x01050709, 0x01050905, 0x0105090b, - 0x0105090f, 0x01050b03, 0x01050b07, 0x01050f01, 0x01050f07, 0x01070107, 0x01070303, 0x0107030b, 0x01070501, - 0x01070505, 0x01070703, 0x01070707, 0x0107070d, 0x01070909, 0x01070b01, 0x01070b05, 0x01070d0f, 0x01070f03, - 0x01070f0b, 0x01090101, 0x01090307, 0x0109030f, 0x01090503, 0x01090509, 0x01090705, 0x01090901, 0x01090907, - 0x01090b03, 0x01090f01, 0x010b0105, 0x010b0109, 0x010b0501, 0x010b0505, 0x010b050d, 0x010b0707, 0x010b0903, - 0x010b090b, 0x010b090f, 0x010b0d0d, 0x010b0f07, 0x010d010d, 0x010d0303, 0x010d0307, 0x010d0703, 0x010d0b05, - 0x010d0f03, 0x010f0101, 0x010f0105, 0x010f0109, 0x010f0501, 0x010f0505, 0x010f050d, 0x010f0707, 0x010f0b01, - 0x010f0b09, 0x03010101, 0x03010103, 0x03010105, 0x03010109, 0x03010301, 0x03010303, 0x03010307, 0x0301030b, - 0x0301030f, 0x03010501, 0x03010505, 0x03010703, 0x03010709, 0x0301070d, 0x03010b09, 0x03010b0d, 0x03010d03, - 0x03010f05, 0x03030101, 0x03030103, 0x03030107, 0x0303010d, 0x03030301, 0x03030309, 0x03030503, 0x03030701, - 0x03030707, 0x03030903, 0x03030b01, 0x03030b05, 0x03030f01, 0x03030f0d, 0x03050101, 0x03050305, 0x0305030b, - 0x0305030f, 0x03050501, 0x03050509, 0x03050705, 0x03050901, 0x03050907, 0x03050b0b, 0x03050d01, 0x03050f05, - 0x03070103, 0x03070109, 0x0307010f, 0x03070301, 0x03070307, 0x03070503, 0x0307050f, 0x03070701, 0x03070709, - 0x03070903, 0x03070d05, 0x03070f01, 0x03090107, 0x0309010b, 0x03090305, 0x03090309, 0x03090703, 0x03090707, - 0x03090905, 0x0309090d, 0x03090b01, 0x03090b09, 0x030b0103, 0x030b0301, 0x030b0307, 0x030b0503, 0x030b0701, - 0x030b0705, 0x030b0b03, 0x030d0501, 0x030d0509, 0x030d050f, 0x030d0909, 0x030d090d, 0x030f0103, 0x030f0107, - 0x030f0301, 0x030f0305, 0x030f0503, 0x030f070b, 0x030f0903, 0x030f0d05, 0x030f0f01, 0x05010101, 0x05010103, - 0x05010107, 0x0501010b, 0x0501010f, 0x05010301, 0x05010305, 0x05010309, 0x0501030d, 0x05010503, 0x05010507, - 0x0501050f, 0x05010701, 0x05010705, 0x05010903, 0x05010907, 0x0501090b, 0x05010b01, 0x05010b05, 0x05010d0f, - 0x05010f01, 0x05010f07, 0x05010f0b, 0x05030101, 0x05030105, 0x05030301, 0x05030307, 0x0503030f, 0x05030505, - 0x0503050b, 0x05030703, 0x05030709, 0x05030905, 0x05030b03, 0x05050103, 0x05050109, 0x0505010f, 0x05050503, - 0x05050507, 0x05050701, 0x0505070f, 0x05050903, 0x05050b07, 0x05050b0f, 0x05050f03, 0x05050f09, 0x05070101, - 0x05070105, 0x0507010b, 0x05070303, 0x05070505, 0x05070509, 0x05070703, 0x05070707, 0x05070905, 0x05070b01, - 0x05070d0d, 0x05090103, 0x0509010f, 0x05090501, 0x05090507, 0x05090705, 0x0509070b, 0x05090903, 0x05090f05, - 0x05090f0b, 0x050b0109, 0x050b0303, 0x050b0505, 0x050b070f, 0x050b0901, 0x050b0b07, 0x050b0f01, 0x050d0101, - 0x050d0105, 0x050d010f, 0x050d0503, 0x050d0b0b, 0x050d0d03, 0x050f010b, 0x050f0303, 0x050f050d, 0x050f0701, - 0x050f0907, 0x050f0b01, 0x07010105, 0x07010303, 0x07010307, 0x0701030b, 0x0701030f, 0x07010505, 0x07010703, - 0x07010707, 0x0701070b, 0x07010905, 0x07010909, 0x0701090f, 0x07010b03, 0x07010d07, 0x07010f03, 0x07030103, - 0x07030107, 0x0703010b, 0x07030309, 0x07030503, 0x07030507, 0x07030901, 0x07030d01, 0x07030f05, 0x07030f0d, - 0x07050101, 0x07050305, 0x07050501, 0x07050705, 0x07050709, 0x07050b01, 0x07070103, 0x07070301, 0x07070309, - 0x07070503, 0x07070507, 0x0707050f, 0x07070701, 0x07070903, 0x07070907, 0x0707090f, 0x07070b0b, 0x07070f07, - 0x07090107, 0x07090303, 0x0709030d, 0x07090505, 0x07090703, 0x07090b05, 0x07090d01, 0x07090d09, 0x070b0103, - 0x070b0301, 0x070b0305, 0x070b050b, 0x070b0705, 0x070b0909, 0x070b0b0d, 0x070b0f07, 0x070d030d, 0x070d0903, - 0x070f0103, 0x070f0107, 0x070f0501, 0x070f0505, 0x070f070b, 0x09010101, 0x09010109, 0x09010305, 0x09010501, - 0x09010509, 0x0901050f, 0x09010705, 0x09010903, 0x09010b01, 0x09010f01, 0x09030105, 0x0903010f, 0x09030303, - 0x09030307, 0x09030505, 0x09030701, 0x0903070b, 0x09030907, 0x09030b03, 0x09030b0b, 0x09050103, 0x09050107, - 0x09050301, 0x0905030b, 0x09050503, 0x09050707, 0x09050901, 0x09050b0f, 0x09050d05, 0x09050f01, 0x09070109, - 0x09070303, 0x09070307, 0x09070501, 0x09070505, 0x09070703, 0x0907070b, 0x09090101, 0x09090105, 0x09090509, - 0x0909070f, 0x09090901, 0x09090f03, 0x090b010b, 0x090b010f, 0x090b0503, 0x090b0d05, 0x090d0307, 0x090d0709, - 0x090d0d01, 0x090f0301, 0x090f030b, 0x090f0701, 0x090f0907, 0x090f0b03, 0x0b010105, 0x0b010301, 0x0b010309, - 0x0b010505, 0x0b010901, 0x0b010909, 0x0b01090f, 0x0b010b05, 0x0b010d0d, 0x0b010f09, 0x0b030103, 0x0b030107, - 0x0b03010b, 0x0b030305, 0x0b030503, 0x0b030705, 0x0b030f05, 0x0b050101, 0x0b050303, 0x0b050507, 0x0b050701, - 0x0b05070d, 0x0b050b07, 0x0b070105, 0x0b07010f, 0x0b070301, 0x0b07050f, 0x0b070909, 0x0b070b03, 0x0b070d0b, - 0x0b070f07, 0x0b090103, 0x0b090109, 0x0b090501, 0x0b090705, 0x0b09090d, 0x0b0b0305, 0x0b0b050d, 0x0b0b0b03, - 0x0b0b0b07, 0x0b0d0905, 0x0b0f0105, 0x0b0f0109, 0x0b0f0505, 0x0d010303, 0x0d010307, 0x0d01030b, 0x0d010703, - 0x0d010707, 0x0d010d01, 0x0d030101, 0x0d030501, 0x0d03050f, 0x0d030d09, 0x0d050305, 0x0d050709, 0x0d050905, - 0x0d050b0b, 0x0d050d05, 0x0d050f01, 0x0d070101, 0x0d070309, 0x0d070503, 0x0d070901, 0x0d09050b, 0x0d090907, - 0x0d090d05, 0x0d0b0101, 0x0d0b0107, 0x0d0b0709, 0x0d0b0d01, 0x0d0d010b, 0x0d0d0901, 0x0d0f0303, 0x0d0f0307, - 0x0f010101, 0x0f010109, 0x0f01010f, 0x0f010501, 0x0f010505, 0x0f01070d, 0x0f010901, 0x0f010b09, 0x0f010d05, - 0x0f030105, 0x0f030303, 0x0f030509, 0x0f030907, 0x0f03090b, 0x0f050103, 0x0f050109, 0x0f050301, 0x0f05030d, - 0x0f050503, 0x0f050701, 0x0f050b03, 0x0f070105, 0x0f070705, 0x0f07070b, 0x0f070b07, 0x0f090103, 0x0f09010b, + 0x01010101, 0x01010103, 0x01010105, 0x0101010b, 0x0101010f, 0x01010301, 0x01010303, 0x01010305, + 0x01010309, 0x0101030d, 0x01010501, 0x01010503, 0x0101050b, 0x01010707, 0x01010901, 0x01010905, + 0x0101090b, 0x0101090f, 0x01010b03, 0x01010b07, 0x01010d01, 0x01010d05, 0x01010f03, 0x01010f09, + 0x01010f0f, 0x01030101, 0x01030103, 0x01030105, 0x01030109, 0x01030301, 0x01030303, 0x0103030b, + 0x01030501, 0x01030507, 0x0103050f, 0x01030703, 0x0103070b, 0x01030909, 0x01030d03, 0x01030d0b, + 0x01030f05, 0x01050101, 0x01050103, 0x0105010b, 0x0105010f, 0x01050301, 0x01050307, 0x0105030d, + 0x01050503, 0x0105050b, 0x01050701, 0x01050709, 0x01050905, 0x0105090b, 0x0105090f, 0x01050b03, + 0x01050b07, 0x01050f01, 0x01050f07, 0x01070107, 0x01070303, 0x0107030b, 0x01070501, 0x01070505, + 0x01070703, 0x01070707, 0x0107070d, 0x01070909, 0x01070b01, 0x01070b05, 0x01070d0f, 0x01070f03, + 0x01070f0b, 0x01090101, 0x01090307, 0x0109030f, 0x01090503, 0x01090509, 0x01090705, 0x01090901, + 0x01090907, 0x01090b03, 0x01090f01, 0x010b0105, 0x010b0109, 0x010b0501, 0x010b0505, 0x010b050d, + 0x010b0707, 0x010b0903, 0x010b090b, 0x010b090f, 0x010b0d0d, 0x010b0f07, 0x010d010d, 0x010d0303, + 0x010d0307, 0x010d0703, 0x010d0b05, 0x010d0f03, 0x010f0101, 0x010f0105, 0x010f0109, 0x010f0501, + 0x010f0505, 0x010f050d, 0x010f0707, 0x010f0b01, 0x010f0b09, 0x03010101, 0x03010103, 0x03010105, + 0x03010109, 0x03010301, 0x03010303, 0x03010307, 0x0301030b, 0x0301030f, 0x03010501, 0x03010505, + 0x03010703, 0x03010709, 0x0301070d, 0x03010b09, 0x03010b0d, 0x03010d03, 0x03010f05, 0x03030101, + 0x03030103, 0x03030107, 0x0303010d, 0x03030301, 0x03030309, 0x03030503, 0x03030701, 0x03030707, + 0x03030903, 0x03030b01, 0x03030b05, 0x03030f01, 0x03030f0d, 0x03050101, 0x03050305, 0x0305030b, + 0x0305030f, 0x03050501, 0x03050509, 0x03050705, 0x03050901, 0x03050907, 0x03050b0b, 0x03050d01, + 0x03050f05, 0x03070103, 0x03070109, 0x0307010f, 0x03070301, 0x03070307, 0x03070503, 0x0307050f, + 0x03070701, 0x03070709, 0x03070903, 0x03070d05, 0x03070f01, 0x03090107, 0x0309010b, 0x03090305, + 0x03090309, 0x03090703, 0x03090707, 0x03090905, 0x0309090d, 0x03090b01, 0x03090b09, 0x030b0103, + 0x030b0301, 0x030b0307, 0x030b0503, 0x030b0701, 0x030b0705, 0x030b0b03, 0x030d0501, 0x030d0509, + 0x030d050f, 0x030d0909, 0x030d090d, 0x030f0103, 0x030f0107, 0x030f0301, 0x030f0305, 0x030f0503, + 0x030f070b, 0x030f0903, 0x030f0d05, 0x030f0f01, 0x05010101, 0x05010103, 0x05010107, 0x0501010b, + 0x0501010f, 0x05010301, 0x05010305, 0x05010309, 0x0501030d, 0x05010503, 0x05010507, 0x0501050f, + 0x05010701, 0x05010705, 0x05010903, 0x05010907, 0x0501090b, 0x05010b01, 0x05010b05, 0x05010d0f, + 0x05010f01, 0x05010f07, 0x05010f0b, 0x05030101, 0x05030105, 0x05030301, 0x05030307, 0x0503030f, + 0x05030505, 0x0503050b, 0x05030703, 0x05030709, 0x05030905, 0x05030b03, 0x05050103, 0x05050109, + 0x0505010f, 0x05050503, 0x05050507, 0x05050701, 0x0505070f, 0x05050903, 0x05050b07, 0x05050b0f, + 0x05050f03, 0x05050f09, 0x05070101, 0x05070105, 0x0507010b, 0x05070303, 0x05070505, 0x05070509, + 0x05070703, 0x05070707, 0x05070905, 0x05070b01, 0x05070d0d, 0x05090103, 0x0509010f, 0x05090501, + 0x05090507, 0x05090705, 0x0509070b, 0x05090903, 0x05090f05, 0x05090f0b, 0x050b0109, 0x050b0303, + 0x050b0505, 0x050b070f, 0x050b0901, 0x050b0b07, 0x050b0f01, 0x050d0101, 0x050d0105, 0x050d010f, + 0x050d0503, 0x050d0b0b, 0x050d0d03, 0x050f010b, 0x050f0303, 0x050f050d, 0x050f0701, 0x050f0907, + 0x050f0b01, 0x07010105, 0x07010303, 0x07010307, 0x0701030b, 0x0701030f, 0x07010505, 0x07010703, + 0x07010707, 0x0701070b, 0x07010905, 0x07010909, 0x0701090f, 0x07010b03, 0x07010d07, 0x07010f03, + 0x07030103, 0x07030107, 0x0703010b, 0x07030309, 0x07030503, 0x07030507, 0x07030901, 0x07030d01, + 0x07030f05, 0x07030f0d, 0x07050101, 0x07050305, 0x07050501, 0x07050705, 0x07050709, 0x07050b01, + 0x07070103, 0x07070301, 0x07070309, 0x07070503, 0x07070507, 0x0707050f, 0x07070701, 0x07070903, + 0x07070907, 0x0707090f, 0x07070b0b, 0x07070f07, 0x07090107, 0x07090303, 0x0709030d, 0x07090505, + 0x07090703, 0x07090b05, 0x07090d01, 0x07090d09, 0x070b0103, 0x070b0301, 0x070b0305, 0x070b050b, + 0x070b0705, 0x070b0909, 0x070b0b0d, 0x070b0f07, 0x070d030d, 0x070d0903, 0x070f0103, 0x070f0107, + 0x070f0501, 0x070f0505, 0x070f070b, 0x09010101, 0x09010109, 0x09010305, 0x09010501, 0x09010509, + 0x0901050f, 0x09010705, 0x09010903, 0x09010b01, 0x09010f01, 0x09030105, 0x0903010f, 0x09030303, + 0x09030307, 0x09030505, 0x09030701, 0x0903070b, 0x09030907, 0x09030b03, 0x09030b0b, 0x09050103, + 0x09050107, 0x09050301, 0x0905030b, 0x09050503, 0x09050707, 0x09050901, 0x09050b0f, 0x09050d05, + 0x09050f01, 0x09070109, 0x09070303, 0x09070307, 0x09070501, 0x09070505, 0x09070703, 0x0907070b, + 0x09090101, 0x09090105, 0x09090509, 0x0909070f, 0x09090901, 0x09090f03, 0x090b010b, 0x090b010f, + 0x090b0503, 0x090b0d05, 0x090d0307, 0x090d0709, 0x090d0d01, 0x090f0301, 0x090f030b, 0x090f0701, + 0x090f0907, 0x090f0b03, 0x0b010105, 0x0b010301, 0x0b010309, 0x0b010505, 0x0b010901, 0x0b010909, + 0x0b01090f, 0x0b010b05, 0x0b010d0d, 0x0b010f09, 0x0b030103, 0x0b030107, 0x0b03010b, 0x0b030305, + 0x0b030503, 0x0b030705, 0x0b030f05, 0x0b050101, 0x0b050303, 0x0b050507, 0x0b050701, 0x0b05070d, + 0x0b050b07, 0x0b070105, 0x0b07010f, 0x0b070301, 0x0b07050f, 0x0b070909, 0x0b070b03, 0x0b070d0b, + 0x0b070f07, 0x0b090103, 0x0b090109, 0x0b090501, 0x0b090705, 0x0b09090d, 0x0b0b0305, 0x0b0b050d, + 0x0b0b0b03, 0x0b0b0b07, 0x0b0d0905, 0x0b0f0105, 0x0b0f0109, 0x0b0f0505, 0x0d010303, 0x0d010307, + 0x0d01030b, 0x0d010703, 0x0d010707, 0x0d010d01, 0x0d030101, 0x0d030501, 0x0d03050f, 0x0d030d09, + 0x0d050305, 0x0d050709, 0x0d050905, 0x0d050b0b, 0x0d050d05, 0x0d050f01, 0x0d070101, 0x0d070309, + 0x0d070503, 0x0d070901, 0x0d09050b, 0x0d090907, 0x0d090d05, 0x0d0b0101, 0x0d0b0107, 0x0d0b0709, + 0x0d0b0d01, 0x0d0d010b, 0x0d0d0901, 0x0d0f0303, 0x0d0f0307, 0x0f010101, 0x0f010109, 0x0f01010f, + 0x0f010501, 0x0f010505, 0x0f01070d, 0x0f010901, 0x0f010b09, 0x0f010d05, 0x0f030105, 0x0f030303, + 0x0f030509, 0x0f030907, 0x0f03090b, 0x0f050103, 0x0f050109, 0x0f050301, 0x0f05030d, 0x0f050503, + 0x0f050701, 0x0f050b03, 0x0f070105, 0x0f070705, 0x0f07070b, 0x0f070b07, 0x0f090103, 0x0f09010b, 0x0f090307, 0x0f090501, 0x0f090b01, 0x0f0b0505, 0x0f0b0905, 0x0f0d0105, 0x0f0d0703, 0x0f0f0101, ]; -pub(super) const KVALUES_IQ4NL: [i8; 16] = [-127, -104, -83, -65, -49, -35, -22, -10, 1, 13, 25, 38, 53, 69, 89, 113]; +#[rustfmt::skip] +pub(super) const KVALUES_IQ4NL: [i8; 16] = [ + -127, -104, -83, -65, -49, -35, -22, -10, + 1, 13, 25, 38, 53, 69, 89, 113, +]; diff --git a/crates/native-cpu-expert/src/rust_iq1_grid.rs b/crates/native-cpu-expert/src/rust_iq1_grid.rs index c850266b..ac5852aa 100644 --- a/crates/native-cpu-expert/src/rust_iq1_grid.rs +++ b/crates/native-cpu-expert/src/rust_iq1_grid.rs @@ -1,2051 +1,260 @@ //! Literal pinned GGML IQ1 grid; see LICENSE.ggml. -pub(super) const GRID: [u64; 2048] = [ - 0xffffffffffffffff, - 0xffffffffffffff01, - 0xffffffffffff0000, - 0xffffffffffff01ff, - 0xffffffffffff0101, - 0xffffffffff00ff00, - 0xffffffffff000000, - 0xffffffffff01ffff, - 0xffffffffff01ff01, - 0xffffffffff0101ff, - 0xffffffffff010101, - 0xffffffff00ff0000, - 0xffffffff0000ff00, - 0xffffffff000000ff, - 0xffffffff00000001, - 0xffffffff00010000, - 0xffffffff01ffffff, - 0xffffffff01ffff01, - 0xffffffff01ff01ff, - 0xffffffff01ff0101, - 0xffffffff01000000, - 0xffffffff0101ffff, - 0xffffffff0101ff01, - 0xffffffff010101ff, - 0xffffffff01010101, - 0xffffff00ffff00ff, - 0xffffff00ffff0000, - 0xffffff00ff00ff00, - 0xffffff00ff0000ff, - 0xffffff00ff000001, - 0xffffff00ff000100, - 0xffffff00ff000101, - 0xffffff00ff010000, - 0xffffff0000ffff00, - 0xffffff0000ff0001, - 0xffffff0000ff0100, - 0xffffff000000ff01, - 0xffffff0000000000, - 0xffffff0000000101, - 0xffffff000001ff00, - 0xffffff00000100ff, - 0xffffff0000010001, - 0xffffff00000101ff, - 0xffffff0001ff0000, - 0xffffff000100ff00, - 0xffffff00010000ff, - 0xffffff0001000001, - 0xffffff0001010000, - 0xffffff01ffffffff, - 0xffffff01ffffff01, - 0xffffff01ffff01ff, - 0xffffff01ffff0101, - 0xffffff01ff000000, - 0xffffff01ff01ffff, - 0xffffff01ff01ff01, - 0xffffff01ff0101ff, - 0xffffff01ff010101, - 0xffffff0100ff0000, - 0xffffff010000ff00, - 0xffffff0100000100, - 0xffffff01000100ff, - 0xffffff0100010100, - 0xffffff0101ffffff, - 0xffffff0101ffff01, - 0xffffff0101ff01ff, - 0xffffff0101ff0101, - 0xffffff010100ff00, - 0xffffff0101000000, - 0xffffff0101000100, - 0xffffff010101ffff, - 0xffffff010101ff01, - 0xffffff01010101ff, - 0xffffff0101010101, - 0xffff00ffff00ff00, - 0xffff00ffff0000ff, - 0xffff00ffff000001, - 0xffff00ffff010000, - 0xffff00ff00ffff00, - 0xffff00ff00ff0100, - 0xffff00ff00000000, - 0xffff00ff00000101, - 0xffff00ff000100ff, - 0xffff00ff00010000, - 0xffff00ff0100ff00, - 0xffff00ff01000100, - 0xffff00ff01010000, - 0xffff0000ffffff00, - 0xffff0000ffff00ff, - 0xffff0000ffff0000, - 0xffff0000ffff0001, - 0xffff0000ff000000, - 0xffff0000ff0001ff, - 0xffff0000ff000101, - 0xffff0000ff010100, - 0xffff000000ffffff, - 0xffff000000ff0000, - 0xffff000000ff0101, - 0xffff00000000ffff, - 0xffff00000000ff00, - 0xffff0000000000ff, - 0xffff000000000000, - 0xffff000000000001, - 0xffff000000000100, - 0xffff00000001ffff, - 0xffff00000001ff01, - 0xffff000000010000, - 0xffff0000000101ff, - 0xffff000000010101, - 0xffff000001ffff00, - 0xffff00000100ff00, - 0xffff000001000000, - 0xffff0000010001ff, - 0xffff000001000101, - 0xffff00000101ff00, - 0xffff0000010100ff, - 0xffff000001010000, - 0xffff000001010001, - 0xffff000001010100, - 0xffff0001ff0000ff, - 0xffff0001ff000100, - 0xffff000100ffff00, - 0xffff000100ff00ff, - 0xffff00010000ffff, - 0xffff00010000ff01, - 0xffff000100000000, - 0xffff0001000001ff, - 0xffff00010001ffff, - 0xffff00010001ff00, - 0xffff000100010001, - 0xffff000100010100, - 0xffff000101ff0000, - 0xffff00010100ff00, - 0xffff0001010000ff, - 0xffff000101000100, - 0xffff01ffffffffff, - 0xffff01ffffffff01, - 0xffff01ffffff01ff, - 0xffff01ffffff0101, - 0xffff01ffff000000, - 0xffff01ffff01ffff, - 0xffff01ffff01ff01, - 0xffff01ffff0101ff, - 0xffff01ffff010101, - 0xffff01ff00ff0000, - 0xffff01ff0000ff00, - 0xffff01ff00000001, - 0xffff01ff00010000, - 0xffff01ff01ffffff, - 0xffff01ff01ffff01, - 0xffff01ff01ff01ff, - 0xffff01ff01ff0101, - 0xffff01ff01000000, - 0xffff01ff0101ffff, - 0xffff01ff0101ff01, - 0xffff01ff010101ff, - 0xffff01ff01010101, - 0xffff0100ffff0000, - 0xffff0100ff00ff00, - 0xffff0100ff0000ff, - 0xffff0100ff000100, - 0xffff0100ff0100ff, - 0xffff0100ff010000, - 0xffff010000ffff00, - 0xffff01000000ffff, - 0xffff01000000ff00, - 0xffff010000000000, - 0xffff01000001ff00, - 0xffff0100000100ff, - 0xffff010000010100, - 0xffff01000100ff00, - 0xffff0100010000ff, - 0xffff010001000001, - 0xffff010001000100, - 0xffff010001010000, - 0xffff0101ffffffff, - 0xffff0101ffffff01, - 0xffff0101ffff01ff, - 0xffff0101ffff0101, - 0xffff0101ff000000, - 0xffff0101ff01ffff, - 0xffff0101ff01ff01, - 0xffff0101ff0101ff, - 0xffff0101ff010101, - 0xffff010100ff0000, - 0xffff01010000ff00, - 0xffff010100000100, - 0xffff01010001ff00, - 0xffff010100010000, - 0xffff010101ffffff, - 0xffff010101ffff01, - 0xffff010101ff0000, - 0xffff010101ff01ff, - 0xffff010101ff0101, - 0xffff010101000000, - 0xffff01010101ffff, - 0xffff01010101ff01, - 0xffff0101010101ff, - 0xffff010101010101, - 0xff00ffffff00ffff, - 0xff00ffffff00ff00, - 0xff00ffffff0000ff, - 0xff00ffffff000100, - 0xff00ffffff0100ff, - 0xff00ffffff010000, - 0xff00ffff00ffff00, - 0xff00ffff00ff00ff, - 0xff00ffff0000ffff, - 0xff00ffff00000000, - 0xff00ffff000001ff, - 0xff00ffff0001ff00, - 0xff00ffff000100ff, - 0xff00ffff00010000, - 0xff00ffff00010100, - 0xff00ffff0100ff00, - 0xff00ffff010000ff, - 0xff00ffff01000001, - 0xff00ffff0101ff00, - 0xff00ffff01010000, - 0xff00ff00ffffff00, - 0xff00ff00ffff00ff, - 0xff00ff00ffff0001, - 0xff00ff00ffff0100, - 0xff00ff00ff00ffff, - 0xff00ff00ff00ff01, - 0xff00ff00ff000000, - 0xff00ff00ff0001ff, - 0xff00ff00ff01ff00, - 0xff00ff00ff0100ff, - 0xff00ff00ff010100, - 0xff00ff0000ff0000, - 0xff00ff0000ff0101, - 0xff00ff000000ffff, - 0xff00ff000000ff00, - 0xff00ff000000ff01, - 0xff00ff00000000ff, - 0xff00ff0000000000, - 0xff00ff0000000001, - 0xff00ff0000000100, - 0xff00ff000001ffff, - 0xff00ff0000010000, - 0xff00ff0001ff00ff, - 0xff00ff000100ff01, - 0xff00ff0001000000, - 0xff00ff000101ff00, - 0xff00ff00010100ff, - 0xff00ff01ff00ff00, - 0xff00ff01ff0000ff, - 0xff00ff01ff000001, - 0xff00ff01ff010000, - 0xff00ff0100ffffff, - 0xff00ff0100ff0001, - 0xff00ff0100ff0100, - 0xff00ff010000ff01, - 0xff00ff0100000000, - 0xff00ff01000001ff, - 0xff00ff0100000101, - 0xff00ff01000100ff, - 0xff00ff0100010001, - 0xff00ff0101ff0000, - 0xff00ff010100ff00, - 0xff00ff01010000ff, - 0xff00ff0101000001, - 0xff00ff0101010000, - 0xff0000ffffffff00, - 0xff0000ffffff0001, - 0xff0000ffffff0100, - 0xff0000ffff0000ff, - 0xff0000ffff000000, - 0xff0000ffff0001ff, - 0xff0000ffff000100, - 0xff0000ffff01ff00, - 0xff0000ffff010001, - 0xff0000ff00ffff00, - 0xff0000ff00ff0000, - 0xff0000ff00ff0001, - 0xff0000ff00ff01ff, - 0xff0000ff00ff0101, - 0xff0000ff0000ff00, - 0xff0000ff000000ff, - 0xff0000ff00000000, - 0xff0000ff00000001, - 0xff0000ff00000100, - 0xff0000ff0001ff01, - 0xff0000ff00010000, - 0xff0000ff000101ff, - 0xff0000ff01ff00ff, - 0xff0000ff01ff0100, - 0xff0000ff0100ffff, - 0xff0000ff010000ff, - 0xff0000ff01000000, - 0xff0000ff010001ff, - 0xff0000ff01000100, - 0xff0000ff01000101, - 0xff0000ff0101ff00, - 0xff0000ff010100ff, - 0xff0000ff01010000, - 0xff0000ff01010100, - 0xff000000ffffff01, - 0xff000000ffff0000, - 0xff000000ffff0101, - 0xff000000ff00ff00, - 0xff000000ff0000ff, - 0xff000000ff000000, - 0xff000000ff000001, - 0xff000000ff000100, - 0xff000000ff01ffff, - 0xff000000ff01ff01, - 0xff000000ff010000, - 0xff000000ff0101ff, - 0xff000000ff010101, - 0xff00000000ffff00, - 0xff00000000ff00ff, - 0xff00000000ff0000, - 0xff00000000ff0001, - 0xff0000000000ff00, - 0xff0000000000ff01, - 0xff000000000000ff, - 0xff00000000000000, - 0xff00000000000001, - 0xff00000000000100, - 0xff00000000000101, - 0xff0000000001ff00, - 0xff000000000100ff, - 0xff00000000010000, - 0xff00000000010001, - 0xff00000000010100, - 0xff00000001ffffff, - 0xff00000001ffff01, - 0xff00000001ff00ff, - 0xff00000001ff0000, - 0xff00000001ff01ff, - 0xff00000001ff0101, - 0xff0000000100ffff, - 0xff0000000100ff00, - 0xff000000010000ff, - 0xff00000001000000, - 0xff00000001000001, - 0xff00000001000100, - 0xff00000001000101, - 0xff0000000101ffff, - 0xff0000000101ff01, - 0xff00000001010000, - 0xff000001ffffff00, - 0xff000001ffff00ff, - 0xff000001ffff0000, - 0xff000001ffff0001, - 0xff000001ff000000, - 0xff000001ff000001, - 0xff000001ff0001ff, - 0xff000001ff000101, - 0xff000001ff01ff00, - 0xff000001ff010001, - 0xff00000100ffffff, - 0xff00000100ffff01, - 0xff00000100ff00ff, - 0xff00000100ff0000, - 0xff00000100ff01ff, - 0xff00000100ff0101, - 0xff0000010000ff00, - 0xff00000100000000, - 0xff00000100000001, - 0xff000001000001ff, - 0xff00000100000100, - 0xff0000010001ff00, - 0xff000001000100ff, - 0xff00000100010000, - 0xff000001000101ff, - 0xff00000100010100, - 0xff00000100010101, - 0xff00000101ff0001, - 0xff00000101ff0101, - 0xff0000010100ff01, - 0xff00000101000000, - 0xff000001010100ff, - 0xff00000101010100, - 0xff0001ffff00ff00, - 0xff0001ffff000001, - 0xff0001ffff010000, - 0xff0001ff00ffff00, - 0xff0001ff00ff00ff, - 0xff0001ff00ff0001, - 0xff0001ff00ff0100, - 0xff0001ff0000ffff, - 0xff0001ff00000000, - 0xff0001ff000001ff, - 0xff0001ff00000101, - 0xff0001ff0001ffff, - 0xff0001ff0001ff00, - 0xff0001ff000100ff, - 0xff0001ff00010001, - 0xff0001ff00010100, - 0xff0001ff01ff0000, - 0xff0001ff0100ff00, - 0xff0001ff010000ff, - 0xff0001ff01010000, - 0xff000100ff00ffff, - 0xff000100ff00ff01, - 0xff000100ff000000, - 0xff000100ff000101, - 0xff000100ff01ff00, - 0xff000100ff010000, - 0xff00010000ffff01, - 0xff00010000ff00ff, - 0xff00010000ff0000, - 0xff00010000ff01ff, - 0xff0001000000ff00, - 0xff000100000000ff, - 0xff00010000000000, - 0xff00010000000001, - 0xff00010000000100, - 0xff00010000000101, - 0xff0001000001ffff, - 0xff00010000010000, - 0xff00010000010101, - 0xff00010001ff0100, - 0xff0001000100ff00, - 0xff0001000100ff01, - 0xff00010001000000, - 0xff000100010001ff, - 0xff0001000101ff00, - 0xff00010001010001, - 0xff00010001010100, - 0xff000101ffff0100, - 0xff000101ff000001, - 0xff000101ff0100ff, - 0xff000101ff010001, - 0xff00010100ff00ff, - 0xff00010100ff0001, - 0xff00010100ff0100, - 0xff0001010000ffff, - 0xff0001010000ff01, - 0xff00010100000000, - 0xff000101000001ff, - 0xff0001010001ff00, - 0xff00010100010001, - 0xff00010100010100, - 0xff00010101ff0000, - 0xff0001010100ff00, - 0xff00010101000001, - 0xff00010101000101, - 0xff01ffffffffffff, - 0xff01ffffffffff01, - 0xff01ffffffff01ff, - 0xff01ffffffff0101, - 0xff01ffffff000000, - 0xff01ffffff01ffff, - 0xff01ffffff01ff01, - 0xff01ffffff010000, - 0xff01ffffff0101ff, - 0xff01ffffff010101, - 0xff01ffff00ff0000, - 0xff01ffff0000ff00, - 0xff01ffff00000100, - 0xff01ffff0001ff00, - 0xff01ffff00010000, - 0xff01ffff01ffffff, - 0xff01ffff01ffff01, - 0xff01ffff01ff01ff, - 0xff01ffff01ff0101, - 0xff01ffff01000000, - 0xff01ffff0101ffff, - 0xff01ffff0101ff01, - 0xff01ffff01010000, - 0xff01ffff010101ff, - 0xff01ffff01010101, - 0xff01ff00ffff0000, - 0xff01ff00ff00ff00, - 0xff01ff00ff0000ff, - 0xff01ff00ff000100, - 0xff01ff00ff010000, - 0xff01ff0000ffff01, - 0xff01ff0000ff00ff, - 0xff01ff0000ff0100, - 0xff01ff0000000000, - 0xff01ff00000001ff, - 0xff01ff0000000101, - 0xff01ff000001ff00, - 0xff01ff00000100ff, - 0xff01ff0000010000, - 0xff01ff0000010001, - 0xff01ff0001ff0000, - 0xff01ff000100ffff, - 0xff01ff0001000001, - 0xff01ff0001000100, - 0xff01ff0001010000, - 0xff01ff01ffffff00, - 0xff01ff01ffff01ff, - 0xff01ff01ffff0101, - 0xff01ff01ff00ff00, - 0xff01ff01ff000000, - 0xff01ff01ff01ffff, - 0xff01ff01ff01ff01, - 0xff01ff01ff0101ff, - 0xff01ff01ff010101, - 0xff01ff0100ff0000, - 0xff01ff010000ff00, - 0xff01ff0100000001, - 0xff01ff0100000100, - 0xff01ff0100010000, - 0xff01ff0101ffff00, - 0xff01ff0101ff01ff, - 0xff01ff0101ff0101, - 0xff01ff010100ff00, - 0xff01ff0101000000, - 0xff01ff010101ffff, - 0xff01ff010101ff01, - 0xff01ff01010101ff, - 0xff01ff0101010101, - 0xff0100ffffff0000, - 0xff0100ffff0000ff, - 0xff0100ffff000001, - 0xff0100ffff000100, - 0xff0100ffff010000, - 0xff0100ff00ff00ff, - 0xff0100ff00ff0000, - 0xff0100ff00ff0001, - 0xff0100ff00ff0100, - 0xff0100ff0000ff01, - 0xff0100ff00000000, - 0xff0100ff000001ff, - 0xff0100ff00000101, - 0xff0100ff00010001, - 0xff0100ff01ff0000, - 0xff0100ff0100ff00, - 0xff0100ff010000ff, - 0xff0100ff01000100, - 0xff0100ff0101ff00, - 0xff0100ff01010000, - 0xff010000ffff0100, - 0xff010000ff000000, - 0xff010000ff01ff00, - 0xff010000ff010100, - 0xff01000000ffffff, - 0xff01000000ff0000, - 0xff01000000ff01ff, - 0xff0100000000ff00, - 0xff010000000000ff, - 0xff01000000000000, - 0xff01000000000100, - 0xff0100000001ff01, - 0xff01000000010000, - 0xff010000000101ff, - 0xff01000001ff0100, - 0xff0100000100ffff, - 0xff010000010000ff, - 0xff01000001000000, - 0xff010000010001ff, - 0xff01000001000101, - 0xff0100000101ff00, - 0xff010000010100ff, - 0xff01000001010001, - 0xff01000001010100, - 0xff010001ffff0000, - 0xff010001ff00ffff, - 0xff010001ff00ff01, - 0xff010001ff000100, - 0xff010001ff010000, - 0xff01000100ffff00, - 0xff01000100ff0100, - 0xff01000100000000, - 0xff0100010001ffff, - 0xff0100010001ff00, - 0xff01000100010100, - 0xff01000101ff00ff, - 0xff01000101ff0001, - 0xff0100010100ffff, - 0xff01000101000101, - 0xff0101ffffffffff, - 0xff0101ffffffff01, - 0xff0101ffffff01ff, - 0xff0101ffffff0101, - 0xff0101ffff000000, - 0xff0101ffff01ffff, - 0xff0101ffff01ff01, - 0xff0101ffff0101ff, - 0xff0101ffff010101, - 0xff0101ff00ff0000, - 0xff0101ff0000ff00, - 0xff0101ff000000ff, - 0xff0101ff00010000, - 0xff0101ff01ffffff, - 0xff0101ff01ffff01, - 0xff0101ff01ff01ff, - 0xff0101ff01ff0101, - 0xff0101ff0101ffff, - 0xff0101ff0101ff01, - 0xff0101ff010101ff, - 0xff0101ff01010101, - 0xff010100ffff0100, - 0xff010100ff00ff00, - 0xff010100ff0000ff, - 0xff010100ff000100, - 0xff010100ff010000, - 0xff01010000ff0001, - 0xff01010000ff0100, - 0xff0101000000ff01, - 0xff01010000000000, - 0xff0101000001ff00, - 0xff010100000100ff, - 0xff01010000010001, - 0xff01010000010100, - 0xff01010001ff0000, - 0xff0101000100ffff, - 0xff01010001000001, - 0xff01010001000100, - 0xff010100010100ff, - 0xff01010001010000, - 0xff010101ffffffff, - 0xff010101ffffff01, - 0xff010101ffff01ff, - 0xff010101ffff0101, - 0xff010101ff01ffff, - 0xff010101ff01ff01, - 0xff010101ff0101ff, - 0xff010101ff010101, - 0xff01010100ff0000, - 0xff0101010000ff00, - 0xff01010100000001, - 0xff01010100000100, - 0xff01010100010000, - 0xff01010101ffffff, - 0xff01010101ffff01, - 0xff01010101ff01ff, - 0xff01010101ff0101, - 0xff01010101000000, - 0xff0101010101ffff, - 0xff0101010101ff01, - 0xff010101010101ff, - 0xff01010101010101, - 0x00ffffffffff0000, - 0x00ffffffff00ff00, - 0x00ffffffff000001, - 0x00ffffffff010000, - 0x00ffffff00ff0100, - 0x00ffffff0000ff01, - 0x00ffffff00000000, - 0x00ffffff000001ff, - 0x00ffffff00000101, - 0x00ffffff0001ff00, - 0x00ffffff000100ff, - 0x00ffffff00010001, - 0x00ffffff010000ff, - 0x00ffffff01000100, - 0x00ffffff0101ff00, - 0x00ffffff01010001, - 0x00ffff00ffffffff, - 0x00ffff00ffffff00, - 0x00ffff00ffff00ff, - 0x00ffff00ffff0001, - 0x00ffff00ffff0100, - 0x00ffff00ff00ff01, - 0x00ffff00ff000000, - 0x00ffff00ff000001, - 0x00ffff00ff0001ff, - 0x00ffff00ff000101, - 0x00ffff00ff01ff00, - 0x00ffff00ff010001, - 0x00ffff00ff010100, - 0x00ffff0000ff0000, - 0x00ffff0000ff01ff, - 0x00ffff0000ff0101, - 0x00ffff000000ff00, - 0x00ffff00000000ff, - 0x00ffff0000000000, - 0x00ffff0000000001, - 0x00ffff0000000100, - 0x00ffff0000000101, - 0x00ffff0000010000, - 0x00ffff00000101ff, - 0x00ffff0000010101, - 0x00ffff0001ffff00, - 0x00ffff0001ff00ff, - 0x00ffff0001ff0001, - 0x00ffff000100ffff, - 0x00ffff000100ff01, - 0x00ffff0001000000, - 0x00ffff000101ffff, - 0x00ffff000101ff00, - 0x00ffff000101ff01, - 0x00ffff01ffff0000, - 0x00ffff01ff00ff00, - 0x00ffff01ff0000ff, - 0x00ffff01ff000001, - 0x00ffff01ff010000, - 0x00ffff0100ffff00, - 0x00ffff010000ff01, - 0x00ffff0100000000, - 0x00ffff0100000101, - 0x00ffff01000100ff, - 0x00ffff0100010100, - 0x00ffff0101ff0100, - 0x00ffff01010000ff, - 0x00ffff0101010000, - 0x00ff00ffffffff00, - 0x00ff00ffff000000, - 0x00ff00ffff000100, - 0x00ff00ffff010100, - 0x00ff00ff00ff0000, - 0x00ff00ff00ff01ff, - 0x00ff00ff00ff0101, - 0x00ff00ff0000ff00, - 0x00ff00ff000000ff, - 0x00ff00ff00000000, - 0x00ff00ff00000001, - 0x00ff00ff0001ff00, - 0x00ff00ff0001ff01, - 0x00ff00ff00010000, - 0x00ff00ff000101ff, - 0x00ff00ff00010101, - 0x00ff00ff01ffff00, - 0x00ff00ff01ff0001, - 0x00ff00ff01ff0100, - 0x00ff00ff0100ffff, - 0x00ff00ff0100ff01, - 0x00ff00ff01000000, - 0x00ff00ff0101ffff, - 0x00ff00ff0101ff00, - 0x00ff00ff01010100, - 0x00ff0000ffffff00, - 0x00ff0000ffffff01, - 0x00ff0000ffff0000, - 0x00ff0000ffff0101, - 0x00ff0000ff00ff00, - 0x00ff0000ff0000ff, - 0x00ff0000ff000000, - 0x00ff0000ff000001, - 0x00ff0000ff000100, - 0x00ff0000ff01ffff, - 0x00ff0000ff010000, - 0x00ff0000ff010101, - 0x00ff000000ffff00, - 0x00ff000000ff00ff, - 0x00ff000000ff0000, - 0x00ff000000ff0001, - 0x00ff000000ff0100, - 0x00ff00000000ffff, - 0x00ff00000000ff00, - 0x00ff0000000000ff, - 0x00ff000000000000, - 0x00ff000000000001, - 0x00ff0000000001ff, - 0x00ff000000000100, - 0x00ff00000001ff00, - 0x00ff0000000100ff, - 0x00ff000000010000, - 0x00ff000000010001, - 0x00ff000000010100, - 0x00ff000001ffff01, - 0x00ff000001ff00ff, - 0x00ff000001ff0000, - 0x00ff000001ff01ff, - 0x00ff00000100ff00, - 0x00ff0000010000ff, - 0x00ff000001000000, - 0x00ff000001000001, - 0x00ff000001000100, - 0x00ff000001000101, - 0x00ff000001010000, - 0x00ff0000010101ff, - 0x00ff000001010101, - 0x00ff0001ffffff00, - 0x00ff0001ffff0000, - 0x00ff0001ffff0100, - 0x00ff0001ff0000ff, - 0x00ff0001ff000000, - 0x00ff0001ff0001ff, - 0x00ff0001ff000101, - 0x00ff0001ff01ff00, - 0x00ff0001ff0100ff, - 0x00ff0001ff010100, - 0x00ff000100ffffff, - 0x00ff000100ffff01, - 0x00ff000100ff0000, - 0x00ff000100ff01ff, - 0x00ff00010000ffff, - 0x00ff00010000ff00, - 0x00ff00010000ff01, - 0x00ff000100000000, - 0x00ff000100000001, - 0x00ff000100000100, - 0x00ff00010001ff01, - 0x00ff000100010000, - 0x00ff0001000101ff, - 0x00ff000101ffff00, - 0x00ff000101ff0000, - 0x00ff000101ff0101, - 0x00ff0001010000ff, - 0x00ff000101000000, - 0x00ff00010101ff00, - 0x00ff0001010100ff, - 0x00ff000101010001, - 0x00ff01ffffff0000, - 0x00ff01ffff00ff00, - 0x00ff01ffff000000, - 0x00ff01ffff000101, - 0x00ff01ffff010000, - 0x00ff01ff00ffff01, - 0x00ff01ff00ff0100, - 0x00ff01ff0000ffff, - 0x00ff01ff00000000, - 0x00ff01ff000001ff, - 0x00ff01ff0001ff00, - 0x00ff01ff000100ff, - 0x00ff01ff00010001, - 0x00ff01ff00010100, - 0x00ff01ff01ff0000, - 0x00ff01ff0100ff00, - 0x00ff01ff010000ff, - 0x00ff01ff01000001, - 0x00ff01ff01000100, - 0x00ff01ff01010000, - 0x00ff0100ffffff00, - 0x00ff0100ffff0000, - 0x00ff0100ffff0001, - 0x00ff0100ffff0101, - 0x00ff0100ff00ffff, - 0x00ff0100ff0000ff, - 0x00ff0100ff000000, - 0x00ff0100ff0001ff, - 0x00ff0100ff01ff00, - 0x00ff0100ff0100ff, - 0x00ff0100ff010001, - 0x00ff010000ffffff, - 0x00ff010000ff0000, - 0x00ff010000ff0101, - 0x00ff01000000ff00, - 0x00ff01000000ff01, - 0x00ff0100000000ff, - 0x00ff010000000000, - 0x00ff010000000001, - 0x00ff010000000100, - 0x00ff01000001ffff, - 0x00ff01000001ff01, - 0x00ff010000010000, - 0x00ff010000010001, - 0x00ff010000010101, - 0x00ff010001ff0001, - 0x00ff010001ff0100, - 0x00ff01000100ff01, - 0x00ff010001000000, - 0x00ff010001000001, - 0x00ff0100010001ff, - 0x00ff01000101ff00, - 0x00ff0100010100ff, - 0x00ff010001010001, - 0x00ff010001010100, - 0x00ff0101ff000001, - 0x00ff010100ff00ff, - 0x00ff010100ff0001, - 0x00ff010100ff0100, - 0x00ff010100000000, - 0x00ff0101000001ff, - 0x00ff010100000101, - 0x00ff0101000100ff, - 0x00ff010100010100, - 0x00ff0101010000ff, - 0x00ff010101010000, - 0x0000ffffffffff00, - 0x0000ffffffff00ff, - 0x0000ffffffff0000, - 0x0000ffffffff0001, - 0x0000ffffffff0100, - 0x0000ffffff00ff01, - 0x0000ffffff000000, - 0x0000ffffff000101, - 0x0000ffffff01ff00, - 0x0000ffffff0100ff, - 0x0000ffffff010100, - 0x0000ffff00ffffff, - 0x0000ffff00ff0000, - 0x0000ffff00ff01ff, - 0x0000ffff0000ff00, - 0x0000ffff000000ff, - 0x0000ffff00000000, - 0x0000ffff00000001, - 0x0000ffff00000100, - 0x0000ffff00010000, - 0x0000ffff000101ff, - 0x0000ffff01ff0001, - 0x0000ffff01ff0100, - 0x0000ffff01000000, - 0x0000ffff010001ff, - 0x0000ffff0101ffff, - 0x0000ffff0101ff00, - 0x0000ffff01010001, - 0x0000ffff01010100, - 0x0000ff00ffff0000, - 0x0000ff00ffff01ff, - 0x0000ff00ffff0100, - 0x0000ff00ffff0101, - 0x0000ff00ff00ff00, - 0x0000ff00ff0000ff, - 0x0000ff00ff000000, - 0x0000ff00ff000001, - 0x0000ff00ff0001ff, - 0x0000ff00ff000100, - 0x0000ff00ff01ffff, - 0x0000ff00ff010000, - 0x0000ff00ff010001, - 0x0000ff00ff0101ff, - 0x0000ff00ff010101, - 0x0000ff0000ffff00, - 0x0000ff0000ff00ff, - 0x0000ff0000ff0000, - 0x0000ff0000ff0001, - 0x0000ff0000ff0100, - 0x0000ff000000ffff, - 0x0000ff000000ff00, - 0x0000ff000000ff01, - 0x0000ff00000000ff, - 0x0000ff0000000000, - 0x0000ff0000000001, - 0x0000ff00000001ff, - 0x0000ff0000000100, - 0x0000ff0000000101, - 0x0000ff000001ff00, - 0x0000ff00000100ff, - 0x0000ff0000010000, - 0x0000ff0000010001, - 0x0000ff0000010100, - 0x0000ff0001ffff01, - 0x0000ff0001ff0000, - 0x0000ff000100ff00, - 0x0000ff00010000ff, - 0x0000ff0001000000, - 0x0000ff0001000001, - 0x0000ff0001000100, - 0x0000ff000101ffff, - 0x0000ff0001010000, - 0x0000ff0001010101, - 0x0000ff01ffffff00, - 0x0000ff01ffff0001, - 0x0000ff01ff00ff01, - 0x0000ff01ff000000, - 0x0000ff01ff000101, - 0x0000ff01ff01ff00, - 0x0000ff01ff0100ff, - 0x0000ff0100ffff01, - 0x0000ff0100ff0000, - 0x0000ff0100ff0101, - 0x0000ff010000ff00, - 0x0000ff01000000ff, - 0x0000ff0100000000, - 0x0000ff0100000001, - 0x0000ff0100000100, - 0x0000ff010001ff01, - 0x0000ff0100010000, - 0x0000ff0101ff0000, - 0x0000ff010100ffff, - 0x0000ff010100ff01, - 0x0000ff0101000000, - 0x0000ff0101000100, - 0x0000ff0101000101, - 0x0000ff01010100ff, - 0x000000ffffff00ff, - 0x000000ffffff0000, - 0x000000ffff00ff00, - 0x000000ffff0000ff, - 0x000000ffff000000, - 0x000000ffff000001, - 0x000000ffff0001ff, - 0x000000ffff000100, - 0x000000ffff01ff00, - 0x000000ffff010000, - 0x000000ffff0101ff, - 0x000000ffff010101, - 0x000000ff00ffff00, - 0x000000ff00ff00ff, - 0x000000ff00ff0000, - 0x000000ff00ff0001, - 0x000000ff00ff0100, - 0x000000ff00ff0101, - 0x000000ff0000ffff, - 0x000000ff0000ff00, - 0x000000ff000000ff, - 0x000000ff00000000, - 0x000000ff00000001, - 0x000000ff000001ff, - 0x000000ff00000100, - 0x000000ff00000101, - 0x000000ff0001ff00, - 0x000000ff0001ff01, - 0x000000ff000100ff, - 0x000000ff00010000, - 0x000000ff00010001, - 0x000000ff00010100, - 0x000000ff01ffffff, - 0x000000ff01ff01ff, - 0x000000ff01ff0101, - 0x000000ff0100ff00, - 0x000000ff010000ff, - 0x000000ff01000000, - 0x000000ff01000001, - 0x000000ff01000100, - 0x000000ff0101ff00, - 0x000000ff010100ff, - 0x000000ff01010000, - 0x000000ff01010101, - 0x00000000ffffff00, - 0x00000000ffffff01, - 0x00000000ffff00ff, - 0x00000000ffff0000, - 0x00000000ffff0001, - 0x00000000ffff0100, - 0x00000000ff00ffff, - 0x00000000ff00ff00, - 0x00000000ff00ff01, - 0x00000000ff0000ff, - 0x00000000ff000000, - 0x00000000ff000001, - 0x00000000ff000100, - 0x00000000ff000101, - 0x00000000ff01ff00, - 0x00000000ff0100ff, - 0x00000000ff010000, - 0x00000000ff010001, - 0x00000000ff010100, - 0x0000000000ffffff, - 0x0000000000ffff00, - 0x0000000000ffff01, - 0x0000000000ff00ff, - 0x0000000000ff0000, - 0x0000000000ff0001, - 0x0000000000ff01ff, - 0x0000000000ff0100, - 0x000000000000ffff, - 0x000000000000ff00, - 0x000000000000ff01, - 0x00000000000000ff, - 0x0000000000000000, - 0x0000000000000001, - 0x00000000000001ff, - 0x0000000000000100, - 0x0000000000000101, - 0x000000000001ffff, - 0x000000000001ff00, - 0x00000000000100ff, - 0x0000000000010000, - 0x0000000000010001, - 0x00000000000101ff, - 0x0000000000010100, - 0x0000000000010101, - 0x0000000001ffff00, - 0x0000000001ff00ff, - 0x0000000001ff0000, - 0x0000000001ff0100, - 0x0000000001ff0101, - 0x000000000100ffff, - 0x000000000100ff00, - 0x00000000010000ff, - 0x0000000001000000, - 0x0000000001000001, - 0x00000000010001ff, - 0x0000000001000100, - 0x000000000101ff00, - 0x00000000010100ff, - 0x0000000001010000, - 0x0000000001010001, - 0x0000000001010100, - 0x00000001ffffffff, - 0x00000001ffffff00, - 0x00000001ffffff01, - 0x00000001ffff00ff, - 0x00000001ffff0001, - 0x00000001ffff01ff, - 0x00000001ffff0100, - 0x00000001ff00ff00, - 0x00000001ff0000ff, - 0x00000001ff000000, - 0x00000001ff0001ff, - 0x00000001ff000100, - 0x00000001ff01ffff, - 0x00000001ff01ff00, - 0x00000001ff01ff01, - 0x00000001ff0100ff, - 0x00000001ff010000, - 0x00000001ff010001, - 0x00000001ff0101ff, - 0x00000001ff010100, - 0x0000000100ffff00, - 0x0000000100ff0000, - 0x0000000100ff0001, - 0x0000000100ff01ff, - 0x0000000100ff0100, - 0x0000000100ff0101, - 0x000000010000ffff, - 0x000000010000ff00, - 0x000000010000ff01, - 0x00000001000000ff, - 0x0000000100000000, - 0x0000000100000001, - 0x00000001000001ff, - 0x0000000100000100, - 0x0000000100000101, - 0x000000010001ff00, - 0x00000001000100ff, - 0x0000000100010000, - 0x0000000100010100, - 0x0000000101ffff01, - 0x0000000101ff0000, - 0x0000000101ff0001, - 0x0000000101ff01ff, - 0x0000000101ff0100, - 0x0000000101ff0101, - 0x000000010100ff00, - 0x0000000101000000, - 0x0000000101000101, - 0x000000010101ff01, - 0x0000000101010000, - 0x0000000101010001, - 0x00000001010101ff, - 0x0000000101010100, - 0x000001ffffff00ff, - 0x000001ffffff0000, - 0x000001ffffff0001, - 0x000001ffffff0100, - 0x000001ffff00ffff, - 0x000001ffff000000, - 0x000001ffff0001ff, - 0x000001ffff01ff00, - 0x000001ffff010101, - 0x000001ff00ff0000, - 0x000001ff00ff01ff, - 0x000001ff00ff0101, - 0x000001ff0000ff00, - 0x000001ff000000ff, - 0x000001ff00000000, - 0x000001ff00000001, - 0x000001ff000001ff, - 0x000001ff00000100, - 0x000001ff0001ffff, - 0x000001ff0001ff01, - 0x000001ff000100ff, - 0x000001ff00010000, - 0x000001ff01ffff01, - 0x000001ff01ff0100, - 0x000001ff0100ffff, - 0x000001ff0100ff01, - 0x000001ff01000000, - 0x000001ff010001ff, - 0x000001ff0101ff00, - 0x000001ff01010100, - 0x00000100ffffff00, - 0x00000100ffffff01, - 0x00000100ffff0000, - 0x00000100ffff0101, - 0x00000100ff00ff00, - 0x00000100ff0000ff, - 0x00000100ff000000, - 0x00000100ff000001, - 0x00000100ff000100, - 0x00000100ff010000, - 0x0000010000ffff00, - 0x0000010000ff00ff, - 0x0000010000ff0000, - 0x0000010000ff0001, - 0x0000010000ff0100, - 0x000001000000ffff, - 0x000001000000ff00, - 0x000001000000ff01, - 0x00000100000000ff, - 0x0000010000000000, - 0x0000010000000001, - 0x00000100000001ff, - 0x0000010000000100, - 0x0000010000000101, - 0x000001000001ff00, - 0x00000100000100ff, - 0x0000010000010000, - 0x0000010000010001, - 0x0000010000010100, - 0x0000010001ffff00, - 0x0000010001ff0000, - 0x0000010001ff0100, - 0x000001000100ff00, - 0x00000100010000ff, - 0x0000010001000000, - 0x0000010001000001, - 0x00000100010001ff, - 0x0000010001000100, - 0x0000010001010000, - 0x00000101ffff00ff, - 0x00000101ffff01ff, - 0x00000101ff000000, - 0x00000101ff000101, - 0x00000101ff01ffff, - 0x00000101ff010000, - 0x00000101ff010001, - 0x00000101ff010100, - 0x0000010100ff0000, - 0x0000010100ff01ff, - 0x0000010100ff0100, - 0x000001010000ff00, - 0x0000010100000000, - 0x0000010100000001, - 0x00000101000001ff, - 0x0000010100000100, - 0x000001010001ff01, - 0x0000010100010000, - 0x00000101000101ff, - 0x0000010100010101, - 0x0000010101ffff00, - 0x0000010101ff0101, - 0x000001010100ff01, - 0x0000010101000000, - 0x0000010101000001, - 0x00000101010001ff, - 0x0000010101000101, - 0x000001010101ff00, - 0x0001ffffffff0000, - 0x0001ffffff0000ff, - 0x0001ffffff000001, - 0x0001ffffff000100, - 0x0001ffffff010000, - 0x0001ffff00ff00ff, - 0x0001ffff0000ffff, - 0x0001ffff00000000, - 0x0001ffff00000001, - 0x0001ffff000001ff, - 0x0001ffff00000101, - 0x0001ffff0001ff00, - 0x0001ffff000100ff, - 0x0001ffff00010001, - 0x0001ffff00010100, - 0x0001ffff01ffff00, - 0x0001ffff01000001, - 0x0001ffff01010000, - 0x0001ff00ffffff00, - 0x0001ff00ffff00ff, - 0x0001ff00ffff0001, - 0x0001ff00ffff0100, - 0x0001ff00ff00ff01, - 0x0001ff00ff000000, - 0x0001ff00ff01ff00, - 0x0001ff00ff01ff01, - 0x0001ff00ff010001, - 0x0001ff00ff010100, - 0x0001ff0000ff0000, - 0x0001ff0000ff0100, - 0x0001ff000000ff00, - 0x0001ff0000000000, - 0x0001ff0000000001, - 0x0001ff0000000100, - 0x0001ff0000010000, - 0x0001ff0000010001, - 0x0001ff0000010101, - 0x0001ff0001ff00ff, - 0x0001ff0001ff0101, - 0x0001ff000100ff01, - 0x0001ff0001000000, - 0x0001ff000101ff00, - 0x0001ff0001010001, - 0x0001ff0001010100, - 0x0001ff01ff00ff00, - 0x0001ff01ff000001, - 0x0001ff01ff000100, - 0x0001ff0100ffffff, - 0x0001ff0100ffff00, - 0x0001ff0100ff0001, - 0x0001ff0100000000, - 0x0001ff0100000001, - 0x0001ff01000001ff, - 0x0001ff010001ffff, - 0x0001ff0101ff0000, - 0x0001ff010100ff00, - 0x0001ff0101000001, - 0x0001ff0101010000, - 0x000100ffff00ff00, - 0x000100ffff00ff01, - 0x000100ffff000000, - 0x000100ffff000001, - 0x000100ffff000101, - 0x000100ffff01ff00, - 0x000100ffff010001, - 0x000100ffff010100, - 0x000100ff00ffffff, - 0x000100ff00ffff01, - 0x000100ff00ff0000, - 0x000100ff00ff01ff, - 0x000100ff00ff0101, - 0x000100ff0000ff00, - 0x000100ff000000ff, - 0x000100ff00000000, - 0x000100ff00000001, - 0x000100ff00000100, - 0x000100ff00000101, - 0x000100ff0001ffff, - 0x000100ff0001ff01, - 0x000100ff00010000, - 0x000100ff01ff00ff, - 0x000100ff01ff0000, - 0x000100ff01ff0100, - 0x000100ff0100ffff, - 0x000100ff0100ff01, - 0x000100ff010000ff, - 0x000100ff01000000, - 0x000100ff01000001, - 0x000100ff010001ff, - 0x000100ff01000101, - 0x000100ff0101ff00, - 0x000100ff010100ff, - 0x000100ff01010100, - 0x00010000ffff0000, - 0x00010000ffff01ff, - 0x00010000ffff0101, - 0x00010000ff00ff00, - 0x00010000ff000000, - 0x00010000ff000001, - 0x00010000ff000100, - 0x0001000000ff00ff, - 0x0001000000ff0000, - 0x0001000000ff0001, - 0x0001000000ff0100, - 0x000100000000ffff, - 0x000100000000ff00, - 0x00010000000000ff, - 0x0001000000000000, - 0x0001000000000001, - 0x0001000000000100, - 0x000100000001ff00, - 0x00010000000100ff, - 0x0001000000010000, - 0x0001000000010001, - 0x0001000000010100, - 0x0001000001ff0001, - 0x0001000001ff0100, - 0x0001000001ff0101, - 0x000100000100ff00, - 0x0001000001000000, - 0x0001000001000001, - 0x0001000001000100, - 0x0001000001000101, - 0x000100000101ff01, - 0x0001000001010000, - 0x0001000001010001, - 0x00010000010101ff, - 0x00010001ffffff01, - 0x00010001ffff0100, - 0x00010001ff000000, - 0x00010001ff01ffff, - 0x00010001ff010001, - 0x00010001ff0101ff, - 0x00010001ff010100, - 0x0001000100ffffff, - 0x0001000100ff0000, - 0x0001000100ff01ff, - 0x0001000100ff0101, - 0x000100010000ff00, - 0x00010001000000ff, - 0x0001000100000000, - 0x0001000100000001, - 0x00010001000001ff, - 0x0001000100000101, - 0x000100010001ffff, - 0x0001000100010000, - 0x00010001000101ff, - 0x0001000101ffffff, - 0x0001000101ffff01, - 0x0001000101ff0000, - 0x0001000101ff0101, - 0x00010001010000ff, - 0x0001000101000001, - 0x00010001010001ff, - 0x0001000101000100, - 0x000100010101ffff, - 0x00010001010100ff, - 0x0001000101010001, - 0x0001000101010101, - 0x000101ffff000001, - 0x000101ffff000100, - 0x000101ffff010000, - 0x000101ff00ffff00, - 0x000101ff0000ff01, - 0x000101ff00000000, - 0x000101ff00000101, - 0x000101ff0001ff00, - 0x000101ff00010100, - 0x000101ff01ff0000, - 0x000101ff0100ff00, - 0x000101ff010001ff, - 0x000101ff01010001, - 0x00010100ffffff00, - 0x00010100ffff00ff, - 0x00010100ff00ffff, - 0x00010100ff000000, - 0x00010100ff01ff00, - 0x00010100ff0100ff, - 0x00010100ff010001, - 0x00010100ff010100, - 0x0001010000ffffff, - 0x0001010000ffff00, - 0x0001010000ff0000, - 0x0001010000ff0001, - 0x0001010000ff01ff, - 0x000101000000ff00, - 0x00010100000000ff, - 0x0001010000000000, - 0x0001010000000001, - 0x0001010000000100, - 0x000101000001ffff, - 0x0001010000010000, - 0x0001010000010101, - 0x0001010001ffff01, - 0x0001010001ff00ff, - 0x0001010001ff0101, - 0x0001010001000000, - 0x000101000101ff00, - 0x00010100010100ff, - 0x0001010001010000, - 0x0001010001010100, - 0x00010101ff00ff00, - 0x00010101ff000001, - 0x00010101ff0001ff, - 0x0001010100ffff00, - 0x0001010100ff00ff, - 0x0001010100ff0100, - 0x000101010000ffff, - 0x0001010100000000, - 0x00010101000001ff, - 0x0001010100000101, - 0x00010101000100ff, - 0x0001010100010000, - 0x0001010100010100, - 0x0001010101ff0001, - 0x00010101010000ff, - 0x00010101010001ff, - 0x0001010101000101, - 0x0001010101010001, - 0x01ffffffffffffff, - 0x01ffffffffffff01, - 0x01ffffffffff01ff, - 0x01ffffffffff0101, - 0x01ffffffff01ffff, - 0x01ffffffff01ff01, - 0x01ffffffff0101ff, - 0x01ffffffff010101, - 0x01ffffff00ff0000, - 0x01ffffff0000ffff, - 0x01ffffff0000ff00, - 0x01ffffff000000ff, - 0x01ffffff00000001, - 0x01ffffff00000100, - 0x01ffffff00010000, - 0x01ffffff01ffffff, - 0x01ffffff01ffff01, - 0x01ffffff01ff01ff, - 0x01ffffff01ff0101, - 0x01ffffff01000000, - 0x01ffffff0101ffff, - 0x01ffffff0101ff01, - 0x01ffffff010101ff, - 0x01ffffff01010101, - 0x01ffff00ffff0000, - 0x01ffff00ff00ff00, - 0x01ffff00ff0000ff, - 0x01ffff00ff000001, - 0x01ffff00ff000100, - 0x01ffff00ff010000, - 0x01ffff0000ffff00, - 0x01ffff0000ff00ff, - 0x01ffff0000ff0100, - 0x01ffff000000ffff, - 0x01ffff000000ff01, - 0x01ffff0000000000, - 0x01ffff0000000001, - 0x01ffff00000001ff, - 0x01ffff0000000100, - 0x01ffff00000100ff, - 0x01ffff0000010001, - 0x01ffff0000010100, - 0x01ffff0001ff0000, - 0x01ffff0001ff0100, - 0x01ffff00010000ff, - 0x01ffff0001000001, - 0x01ffff0001000100, - 0x01ffff0001010000, - 0x01ffff01ffffffff, - 0x01ffff01ffffff01, - 0x01ffff01ffff01ff, - 0x01ffff01ffff0101, - 0x01ffff01ff000000, - 0x01ffff01ff01ffff, - 0x01ffff01ff01ff01, - 0x01ffff01ff0101ff, - 0x01ffff01ff010101, - 0x01ffff010000ff00, - 0x01ffff01000000ff, - 0x01ffff0100000100, - 0x01ffff0100010000, - 0x01ffff0101ffffff, - 0x01ffff0101ffff01, - 0x01ffff0101ff01ff, - 0x01ffff0101ff0101, - 0x01ffff0101000000, - 0x01ffff010101ffff, - 0x01ffff010101ff01, - 0x01ffff01010101ff, - 0x01ffff0101010101, - 0x01ff00ffff0000ff, - 0x01ff00ffff000100, - 0x01ff00ff00ffff00, - 0x01ff00ff00ff00ff, - 0x01ff00ff0000ff00, - 0x01ff00ff00000000, - 0x01ff00ff00000101, - 0x01ff00ff0001ff00, - 0x01ff00ff000100ff, - 0x01ff00ff00010100, - 0x01ff00ff010000ff, - 0x01ff00ff01000100, - 0x01ff0000ffffff00, - 0x01ff0000ffff0100, - 0x01ff0000ff00ff01, - 0x01ff0000ff000000, - 0x01ff0000ff000101, - 0x01ff0000ff010001, - 0x01ff0000ff010100, - 0x01ff000000ffffff, - 0x01ff000000ffff00, - 0x01ff000000ff0000, - 0x01ff000000ff01ff, - 0x01ff00000000ff00, - 0x01ff0000000000ff, - 0x01ff000000000000, - 0x01ff000000000001, - 0x01ff000000000100, - 0x01ff000000000101, - 0x01ff000000010000, - 0x01ff000000010001, - 0x01ff0000000101ff, - 0x01ff000000010101, - 0x01ff000001ffff00, - 0x01ff000001ff00ff, - 0x01ff000001ff0001, - 0x01ff000001ff0100, - 0x01ff00000100ffff, - 0x01ff00000100ff01, - 0x01ff000001000000, - 0x01ff0000010001ff, - 0x01ff000001010001, - 0x01ff0001ff00ff00, - 0x01ff0001ff000001, - 0x01ff0001ff000100, - 0x01ff0001ff010000, - 0x01ff000100ffff00, - 0x01ff000100ff00ff, - 0x01ff000100ff0100, - 0x01ff000100ff0101, - 0x01ff00010000ffff, - 0x01ff000100000000, - 0x01ff000100000100, - 0x01ff000100000101, - 0x01ff00010001ff00, - 0x01ff000100010001, - 0x01ff000100010101, - 0x01ff000101ff0000, - 0x01ff00010100ff00, - 0x01ff000101000101, - 0x01ff0001010100ff, - 0x01ff01ffffffffff, - 0x01ff01ffffffff01, - 0x01ff01ffffff01ff, - 0x01ff01ffffff0101, - 0x01ff01ffff000000, - 0x01ff01ffff01ffff, - 0x01ff01ffff01ff01, - 0x01ff01ffff0101ff, - 0x01ff01ffff010101, - 0x01ff01ff00ffff00, - 0x01ff01ff00ff0000, - 0x01ff01ff0000ff00, - 0x01ff01ff000000ff, - 0x01ff01ff00000100, - 0x01ff01ff00010000, - 0x01ff01ff00010100, - 0x01ff01ff01ffffff, - 0x01ff01ff01ffff01, - 0x01ff01ff01ff01ff, - 0x01ff01ff01ff0101, - 0x01ff01ff01000000, - 0x01ff01ff0101ffff, - 0x01ff01ff0101ff01, - 0x01ff01ff010101ff, - 0x01ff01ff01010101, - 0x01ff0100ffff0000, - 0x01ff0100ffff0001, - 0x01ff0100ff00ff00, - 0x01ff0100ff0000ff, - 0x01ff0100ff000001, - 0x01ff0100ff010000, - 0x01ff010000ffff00, - 0x01ff010000ff00ff, - 0x01ff010000ff0001, - 0x01ff010000ff0100, - 0x01ff01000000ffff, - 0x01ff01000000ff01, - 0x01ff010000000000, - 0x01ff010000000101, - 0x01ff01000001ff00, - 0x01ff0100000100ff, - 0x01ff010001ff0000, - 0x01ff010001000001, - 0x01ff010001000100, - 0x01ff010001010000, - 0x01ff0101ffffffff, - 0x01ff0101ffffff01, - 0x01ff0101ffff01ff, - 0x01ff0101ffff0101, - 0x01ff0101ff000000, - 0x01ff0101ff01ffff, - 0x01ff0101ff01ff01, - 0x01ff0101ff0101ff, - 0x01ff0101ff010101, - 0x01ff010100ff0000, - 0x01ff01010000ff00, - 0x01ff0101000000ff, - 0x01ff010100000001, - 0x01ff010101ffffff, - 0x01ff010101ffff01, - 0x01ff010101ff01ff, - 0x01ff010101ff0101, - 0x01ff010101000000, - 0x01ff01010101ffff, - 0x01ff01010101ff01, - 0x01ff0101010101ff, - 0x01ff010101010101, - 0x0100ffffffff0000, - 0x0100ffffff00ff00, - 0x0100ffffff000001, - 0x0100ffffff0001ff, - 0x0100ffffff000100, - 0x0100ffffff010000, - 0x0100ffff00ffff00, - 0x0100ffff00ff0001, - 0x0100ffff00ff0100, - 0x0100ffff00000000, - 0x0100ffff000001ff, - 0x0100ffff00000101, - 0x0100ffff00010100, - 0x0100ffff00010101, - 0x0100ffff01ff0000, - 0x0100ffff0100ff00, - 0x0100ffff010000ff, - 0x0100ffff01000001, - 0x0100ffff01000100, - 0x0100ffff01010000, - 0x0100ff00ffffff00, - 0x0100ff00ffff00ff, - 0x0100ff00ffff0001, - 0x0100ff00ffff0100, - 0x0100ff00ff00ffff, - 0x0100ff00ff000000, - 0x0100ff00ff0001ff, - 0x0100ff00ff000101, - 0x0100ff00ff01ff00, - 0x0100ff00ff0100ff, - 0x0100ff00ff010001, - 0x0100ff00ff010100, - 0x0100ff0000ffffff, - 0x0100ff0000ff0000, - 0x0100ff000000ffff, - 0x0100ff000000ff00, - 0x0100ff00000000ff, - 0x0100ff0000000000, - 0x0100ff0000000001, - 0x0100ff0000000100, - 0x0100ff000001ff01, - 0x0100ff0000010000, - 0x0100ff0001ff00ff, - 0x0100ff0001ff0001, - 0x0100ff000100ff01, - 0x0100ff0001000000, - 0x0100ff00010001ff, - 0x0100ff000101ff00, - 0x0100ff00010100ff, - 0x0100ff0001010001, - 0x0100ff0001010100, - 0x0100ff01ffff0000, - 0x0100ff01ff00ff00, - 0x0100ff01ff0000ff, - 0x0100ff01ff000100, - 0x0100ff01ff010000, - 0x0100ff0100ff00ff, - 0x0100ff0100ff0001, - 0x0100ff0100ff0100, - 0x0100ff010000ffff, - 0x0100ff010000ff01, - 0x0100ff0100000000, - 0x0100ff01000001ff, - 0x0100ff0100010001, - 0x0100ff0100010100, - 0x0100ff0101ff0000, - 0x0100ff01010000ff, - 0x0100ff0101000001, - 0x0100ff0101010100, - 0x010000ffffffff00, - 0x010000ffffff00ff, - 0x010000ffffff0001, - 0x010000ffff00ffff, - 0x010000ffff000000, - 0x010000ffff0001ff, - 0x010000ffff010001, - 0x010000ff00ffffff, - 0x010000ff00ff0101, - 0x010000ff0000ff00, - 0x010000ff000000ff, - 0x010000ff00000000, - 0x010000ff00000001, - 0x010000ff000001ff, - 0x010000ff00000100, - 0x010000ff0001ffff, - 0x010000ff0001ff00, - 0x010000ff0001ff01, - 0x010000ff00010000, - 0x010000ff01ff00ff, - 0x010000ff01ff0001, - 0x010000ff0100ff01, - 0x010000ff010000ff, - 0x010000ff01000000, - 0x010000ff010001ff, - 0x010000ff0101ff00, - 0x010000ff01010100, - 0x01000000ffffffff, - 0x01000000ffff0000, - 0x01000000ffff01ff, - 0x01000000ffff0101, - 0x01000000ff00ffff, - 0x01000000ff00ff00, - 0x01000000ff0000ff, - 0x01000000ff000000, - 0x01000000ff000001, - 0x01000000ff000100, - 0x01000000ff01ff00, - 0x01000000ff010000, - 0x01000000ff010100, - 0x01000000ff010101, - 0x0100000000ffff00, - 0x0100000000ff00ff, - 0x0100000000ff0000, - 0x0100000000ff0001, - 0x0100000000ff0100, - 0x010000000000ffff, - 0x010000000000ff00, - 0x010000000000ff01, - 0x01000000000000ff, - 0x0100000000000000, - 0x0100000000000001, - 0x01000000000001ff, - 0x0100000000000100, - 0x0100000000000101, - 0x010000000001ff00, - 0x01000000000100ff, - 0x0100000000010000, - 0x0100000000010001, - 0x0100000000010100, - 0x0100000001ffff00, - 0x0100000001ff0000, - 0x0100000001ff01ff, - 0x010000000100ff00, - 0x010000000100ff01, - 0x01000000010000ff, - 0x0100000001000000, - 0x0100000001000001, - 0x0100000001000100, - 0x0100000001000101, - 0x010000000101ffff, - 0x010000000101ff01, - 0x0100000001010000, - 0x01000000010101ff, - 0x0100000001010101, - 0x01000001ffffff00, - 0x01000001ffff00ff, - 0x01000001ff00ffff, - 0x01000001ff000000, - 0x01000001ff000100, - 0x01000001ff01ffff, - 0x01000001ff010001, - 0x01000001ff010100, - 0x0100000100ff0000, - 0x0100000100ff01ff, - 0x0100000100ff0100, - 0x010000010000ff00, - 0x010000010000ff01, - 0x0100000100000000, - 0x0100000100000001, - 0x0100000100000100, - 0x0100000100010000, - 0x01000001000101ff, - 0x0100000101ffff01, - 0x0100000101ff00ff, - 0x0100000101ff0100, - 0x0100000101ff0101, - 0x010000010100ff01, - 0x01000001010000ff, - 0x0100000101000000, - 0x01000001010100ff, - 0x0100000101010001, - 0x0100000101010100, - 0x010001ffffff0000, - 0x010001ffff000001, - 0x010001ffff000100, - 0x010001ffff010000, - 0x010001ff00ffff00, - 0x010001ff00ff0001, - 0x010001ff0000ffff, - 0x010001ff0000ff01, - 0x010001ff00000000, - 0x010001ff00000001, - 0x010001ff00000101, - 0x010001ff000100ff, - 0x010001ff00010000, - 0x010001ff01ff0000, - 0x010001ff0100ff00, - 0x010001ff01000001, - 0x010001ff01000100, - 0x010001ff01010000, - 0x01000100ffff00ff, - 0x01000100ffff0001, - 0x01000100ffff0100, - 0x01000100ff00ffff, - 0x01000100ff00ff01, - 0x01000100ff000000, - 0x01000100ff0001ff, - 0x01000100ff000101, - 0x01000100ff01ffff, - 0x01000100ff01ff00, - 0x01000100ff0100ff, - 0x01000100ff010001, - 0x0100010000ffffff, - 0x0100010000ffff01, - 0x0100010000ff0000, - 0x0100010000ff01ff, - 0x0100010000ff0101, - 0x010001000000ff00, - 0x01000100000000ff, - 0x0100010000000000, - 0x0100010000000001, - 0x0100010000000100, - 0x010001000001ff01, - 0x0100010000010000, - 0x0100010000010001, - 0x0100010000010101, - 0x0100010001ffff00, - 0x0100010001ff00ff, - 0x010001000100ffff, - 0x010001000100ff01, - 0x0100010001000000, - 0x0100010001000101, - 0x010001000101ff00, - 0x0100010001010001, - 0x01000101ffff0000, - 0x01000101ff000000, - 0x01000101ff010000, - 0x0100010100ff00ff, - 0x0100010100ff0001, - 0x0100010100ff0100, - 0x010001010000ffff, - 0x0100010100000000, - 0x01000101000001ff, - 0x010001010001ff00, - 0x0100010101ff0000, - 0x010001010100ff00, - 0x01000101010000ff, - 0x0100010101000000, - 0x0100010101000001, - 0x0101ffffffffffff, - 0x0101ffffffffff01, - 0x0101ffffffff01ff, - 0x0101ffffffff0101, - 0x0101ffffff000000, - 0x0101ffffff01ffff, - 0x0101ffffff01ff01, - 0x0101ffffff0101ff, - 0x0101ffffff010101, - 0x0101ffff00ff0000, - 0x0101ffff0000ff00, - 0x0101ffff000000ff, - 0x0101ffff00000001, - 0x0101ffff00000100, - 0x0101ffff01ffffff, - 0x0101ffff01ffff01, - 0x0101ffff01ff01ff, - 0x0101ffff01ff0101, - 0x0101ffff01000000, - 0x0101ffff0101ffff, - 0x0101ffff0101ff01, - 0x0101ffff010101ff, - 0x0101ffff01010101, - 0x0101ff00ffff0000, - 0x0101ff00ffff0100, - 0x0101ff00ff00ff00, - 0x0101ff00ff0000ff, - 0x0101ff00ff000001, - 0x0101ff00ff000100, - 0x0101ff00ff000101, - 0x0101ff0000ff0001, - 0x0101ff0000ff0100, - 0x0101ff000000ff00, - 0x0101ff0000000000, - 0x0101ff00000001ff, - 0x0101ff0000000101, - 0x0101ff000001ff00, - 0x0101ff00000100ff, - 0x0101ff0001ff0000, - 0x0101ff000100ffff, - 0x0101ff000100ff01, - 0x0101ff0001000001, - 0x0101ff0001000100, - 0x0101ff01ffffff01, - 0x0101ff01ffff01ff, - 0x0101ff01ffff0101, - 0x0101ff01ff00ffff, - 0x0101ff01ff000100, - 0x0101ff01ff01ff01, - 0x0101ff01ff0101ff, - 0x0101ff01ff010101, - 0x0101ff0100ff0000, - 0x0101ff010000ff00, - 0x0101ff0100000001, - 0x0101ff0100000100, - 0x0101ff0100010000, - 0x0101ff0101ffffff, - 0x0101ff0101ffff01, - 0x0101ff0101ff01ff, - 0x0101ff0101ff0101, - 0x0101ff0101000000, - 0x0101ff010101ffff, - 0x0101ff010101ff01, - 0x0101ff01010101ff, - 0x0101ff0101010101, - 0x010100ffff000100, - 0x010100ffff010000, - 0x010100ff00ffff00, - 0x010100ff00ff00ff, - 0x010100ff0000ffff, - 0x010100ff000000ff, - 0x010100ff00000000, - 0x010100ff000001ff, - 0x010100ff00000101, - 0x010100ff0001ff00, - 0x010100ff00010000, - 0x010100ff00010001, - 0x010100ff000101ff, - 0x010100ff00010100, - 0x010100ff01ff0000, - 0x01010000ffff0001, - 0x01010000ffff0100, - 0x01010000ff00ffff, - 0x01010000ff00ff01, - 0x01010000ff000000, - 0x01010000ff0001ff, - 0x01010000ff010001, - 0x01010000ff010100, - 0x0101000000ffff01, - 0x0101000000ff0000, - 0x010100000000ff00, - 0x01010000000000ff, - 0x0101000000000000, - 0x0101000000000001, - 0x0101000000000100, - 0x0101000000010000, - 0x0101000000010101, - 0x0101000001ffff00, - 0x0101000001ff00ff, - 0x0101000001ff0000, - 0x0101000001ff0001, - 0x0101000001ff0100, - 0x010100000100ff01, - 0x0101000001000000, - 0x01010000010001ff, - 0x01010001ffff0000, - 0x01010001ff00ff00, - 0x01010001ff000001, - 0x01010001ff000101, - 0x01010001ff01ff00, - 0x01010001ff010000, - 0x0101000100ff00ff, - 0x0101000100ff0001, - 0x0101000100ff0101, - 0x010100010000ff01, - 0x0101000100000000, - 0x0101000100000001, - 0x01010001000001ff, - 0x010100010001ffff, - 0x010100010001ff01, - 0x0101000101ff0001, - 0x010100010100ffff, - 0x0101000101000000, - 0x0101000101000001, - 0x0101000101000100, - 0x010100010101ff00, - 0x01010001010100ff, - 0x0101000101010001, - 0x010101ffffffffff, - 0x010101ffffffff01, - 0x010101ffffff01ff, - 0x010101ffffff0101, - 0x010101ffff01ffff, - 0x010101ffff01ff01, - 0x010101ffff0101ff, - 0x010101ffff010101, - 0x010101ff0000ff00, - 0x010101ff000000ff, - 0x010101ff00000001, - 0x010101ff00000100, - 0x010101ff01ffffff, - 0x010101ff01ffff01, - 0x010101ff01ff01ff, - 0x010101ff01ff0101, - 0x010101ff01000000, - 0x010101ff0101ffff, - 0x010101ff0101ff01, - 0x010101ff010101ff, - 0x010101ff01010101, - 0x01010100ffff0000, - 0x01010100ff0000ff, - 0x01010100ff000100, - 0x01010100ff01ff00, - 0x01010100ff010000, - 0x0101010000ffff00, - 0x010101000000ffff, - 0x0101010000000000, - 0x0101010000000101, - 0x010101000001ff00, - 0x0101010000010001, - 0x0101010000010100, - 0x010101000100ffff, - 0x0101010001000001, - 0x01010101ffffffff, - 0x01010101ffffff01, - 0x01010101ffff01ff, - 0x01010101ffff0101, - 0x01010101ff01ffff, - 0x01010101ff01ff01, - 0x01010101ff0101ff, - 0x01010101ff010101, - 0x010101010000ff00, - 0x01010101000000ff, - 0x0101010100000001, - 0x0101010101ffffff, - 0x0101010101ffff01, - 0x0101010101ff01ff, - 0x0101010101ff0101, - 0x0101010101000000, - 0x010101010101ffff, - 0x010101010101ff01, - 0x01010101010101ff, - 0x0101010101010101, +#[rustfmt::skip] +pub(super) const GRID:[u64;2048]=[ +0xffffffffffffffff,0xffffffffffffff01,0xffffffffffff0000,0xffffffffffff01ff,0xffffffffffff0101,0xffffffffff00ff00,0xffffffffff000000,0xffffffffff01ffff, +0xffffffffff01ff01,0xffffffffff0101ff,0xffffffffff010101,0xffffffff00ff0000,0xffffffff0000ff00,0xffffffff000000ff,0xffffffff00000001,0xffffffff00010000, +0xffffffff01ffffff,0xffffffff01ffff01,0xffffffff01ff01ff,0xffffffff01ff0101,0xffffffff01000000,0xffffffff0101ffff,0xffffffff0101ff01,0xffffffff010101ff, +0xffffffff01010101,0xffffff00ffff00ff,0xffffff00ffff0000,0xffffff00ff00ff00,0xffffff00ff0000ff,0xffffff00ff000001,0xffffff00ff000100,0xffffff00ff000101, +0xffffff00ff010000,0xffffff0000ffff00,0xffffff0000ff0001,0xffffff0000ff0100,0xffffff000000ff01,0xffffff0000000000,0xffffff0000000101,0xffffff000001ff00, +0xffffff00000100ff,0xffffff0000010001,0xffffff00000101ff,0xffffff0001ff0000,0xffffff000100ff00,0xffffff00010000ff,0xffffff0001000001,0xffffff0001010000, +0xffffff01ffffffff,0xffffff01ffffff01,0xffffff01ffff01ff,0xffffff01ffff0101,0xffffff01ff000000,0xffffff01ff01ffff,0xffffff01ff01ff01,0xffffff01ff0101ff, +0xffffff01ff010101,0xffffff0100ff0000,0xffffff010000ff00,0xffffff0100000100,0xffffff01000100ff,0xffffff0100010100,0xffffff0101ffffff,0xffffff0101ffff01, +0xffffff0101ff01ff,0xffffff0101ff0101,0xffffff010100ff00,0xffffff0101000000,0xffffff0101000100,0xffffff010101ffff,0xffffff010101ff01,0xffffff01010101ff, +0xffffff0101010101,0xffff00ffff00ff00,0xffff00ffff0000ff,0xffff00ffff000001,0xffff00ffff010000,0xffff00ff00ffff00,0xffff00ff00ff0100,0xffff00ff00000000, +0xffff00ff00000101,0xffff00ff000100ff,0xffff00ff00010000,0xffff00ff0100ff00,0xffff00ff01000100,0xffff00ff01010000,0xffff0000ffffff00,0xffff0000ffff00ff, +0xffff0000ffff0000,0xffff0000ffff0001,0xffff0000ff000000,0xffff0000ff0001ff,0xffff0000ff000101,0xffff0000ff010100,0xffff000000ffffff,0xffff000000ff0000, +0xffff000000ff0101,0xffff00000000ffff,0xffff00000000ff00,0xffff0000000000ff,0xffff000000000000,0xffff000000000001,0xffff000000000100,0xffff00000001ffff, +0xffff00000001ff01,0xffff000000010000,0xffff0000000101ff,0xffff000000010101,0xffff000001ffff00,0xffff00000100ff00,0xffff000001000000,0xffff0000010001ff, +0xffff000001000101,0xffff00000101ff00,0xffff0000010100ff,0xffff000001010000,0xffff000001010001,0xffff000001010100,0xffff0001ff0000ff,0xffff0001ff000100, +0xffff000100ffff00,0xffff000100ff00ff,0xffff00010000ffff,0xffff00010000ff01,0xffff000100000000,0xffff0001000001ff,0xffff00010001ffff,0xffff00010001ff00, +0xffff000100010001,0xffff000100010100,0xffff000101ff0000,0xffff00010100ff00,0xffff0001010000ff,0xffff000101000100,0xffff01ffffffffff,0xffff01ffffffff01, +0xffff01ffffff01ff,0xffff01ffffff0101,0xffff01ffff000000,0xffff01ffff01ffff,0xffff01ffff01ff01,0xffff01ffff0101ff,0xffff01ffff010101,0xffff01ff00ff0000, +0xffff01ff0000ff00,0xffff01ff00000001,0xffff01ff00010000,0xffff01ff01ffffff,0xffff01ff01ffff01,0xffff01ff01ff01ff,0xffff01ff01ff0101,0xffff01ff01000000, +0xffff01ff0101ffff,0xffff01ff0101ff01,0xffff01ff010101ff,0xffff01ff01010101,0xffff0100ffff0000,0xffff0100ff00ff00,0xffff0100ff0000ff,0xffff0100ff000100, +0xffff0100ff0100ff,0xffff0100ff010000,0xffff010000ffff00,0xffff01000000ffff,0xffff01000000ff00,0xffff010000000000,0xffff01000001ff00,0xffff0100000100ff, +0xffff010000010100,0xffff01000100ff00,0xffff0100010000ff,0xffff010001000001,0xffff010001000100,0xffff010001010000,0xffff0101ffffffff,0xffff0101ffffff01, +0xffff0101ffff01ff,0xffff0101ffff0101,0xffff0101ff000000,0xffff0101ff01ffff,0xffff0101ff01ff01,0xffff0101ff0101ff,0xffff0101ff010101,0xffff010100ff0000, +0xffff01010000ff00,0xffff010100000100,0xffff01010001ff00,0xffff010100010000,0xffff010101ffffff,0xffff010101ffff01,0xffff010101ff0000,0xffff010101ff01ff, +0xffff010101ff0101,0xffff010101000000,0xffff01010101ffff,0xffff01010101ff01,0xffff0101010101ff,0xffff010101010101,0xff00ffffff00ffff,0xff00ffffff00ff00, +0xff00ffffff0000ff,0xff00ffffff000100,0xff00ffffff0100ff,0xff00ffffff010000,0xff00ffff00ffff00,0xff00ffff00ff00ff,0xff00ffff0000ffff,0xff00ffff00000000, +0xff00ffff000001ff,0xff00ffff0001ff00,0xff00ffff000100ff,0xff00ffff00010000,0xff00ffff00010100,0xff00ffff0100ff00,0xff00ffff010000ff,0xff00ffff01000001, +0xff00ffff0101ff00,0xff00ffff01010000,0xff00ff00ffffff00,0xff00ff00ffff00ff,0xff00ff00ffff0001,0xff00ff00ffff0100,0xff00ff00ff00ffff,0xff00ff00ff00ff01, +0xff00ff00ff000000,0xff00ff00ff0001ff,0xff00ff00ff01ff00,0xff00ff00ff0100ff,0xff00ff00ff010100,0xff00ff0000ff0000,0xff00ff0000ff0101,0xff00ff000000ffff, +0xff00ff000000ff00,0xff00ff000000ff01,0xff00ff00000000ff,0xff00ff0000000000,0xff00ff0000000001,0xff00ff0000000100,0xff00ff000001ffff,0xff00ff0000010000, +0xff00ff0001ff00ff,0xff00ff000100ff01,0xff00ff0001000000,0xff00ff000101ff00,0xff00ff00010100ff,0xff00ff01ff00ff00,0xff00ff01ff0000ff,0xff00ff01ff000001, +0xff00ff01ff010000,0xff00ff0100ffffff,0xff00ff0100ff0001,0xff00ff0100ff0100,0xff00ff010000ff01,0xff00ff0100000000,0xff00ff01000001ff,0xff00ff0100000101, +0xff00ff01000100ff,0xff00ff0100010001,0xff00ff0101ff0000,0xff00ff010100ff00,0xff00ff01010000ff,0xff00ff0101000001,0xff00ff0101010000,0xff0000ffffffff00, +0xff0000ffffff0001,0xff0000ffffff0100,0xff0000ffff0000ff,0xff0000ffff000000,0xff0000ffff0001ff,0xff0000ffff000100,0xff0000ffff01ff00,0xff0000ffff010001, +0xff0000ff00ffff00,0xff0000ff00ff0000,0xff0000ff00ff0001,0xff0000ff00ff01ff,0xff0000ff00ff0101,0xff0000ff0000ff00,0xff0000ff000000ff,0xff0000ff00000000, +0xff0000ff00000001,0xff0000ff00000100,0xff0000ff0001ff01,0xff0000ff00010000,0xff0000ff000101ff,0xff0000ff01ff00ff,0xff0000ff01ff0100,0xff0000ff0100ffff, +0xff0000ff010000ff,0xff0000ff01000000,0xff0000ff010001ff,0xff0000ff01000100,0xff0000ff01000101,0xff0000ff0101ff00,0xff0000ff010100ff,0xff0000ff01010000, +0xff0000ff01010100,0xff000000ffffff01,0xff000000ffff0000,0xff000000ffff0101,0xff000000ff00ff00,0xff000000ff0000ff,0xff000000ff000000,0xff000000ff000001, +0xff000000ff000100,0xff000000ff01ffff,0xff000000ff01ff01,0xff000000ff010000,0xff000000ff0101ff,0xff000000ff010101,0xff00000000ffff00,0xff00000000ff00ff, +0xff00000000ff0000,0xff00000000ff0001,0xff0000000000ff00,0xff0000000000ff01,0xff000000000000ff,0xff00000000000000,0xff00000000000001,0xff00000000000100, +0xff00000000000101,0xff0000000001ff00,0xff000000000100ff,0xff00000000010000,0xff00000000010001,0xff00000000010100,0xff00000001ffffff,0xff00000001ffff01, +0xff00000001ff00ff,0xff00000001ff0000,0xff00000001ff01ff,0xff00000001ff0101,0xff0000000100ffff,0xff0000000100ff00,0xff000000010000ff,0xff00000001000000, +0xff00000001000001,0xff00000001000100,0xff00000001000101,0xff0000000101ffff,0xff0000000101ff01,0xff00000001010000,0xff000001ffffff00,0xff000001ffff00ff, +0xff000001ffff0000,0xff000001ffff0001,0xff000001ff000000,0xff000001ff000001,0xff000001ff0001ff,0xff000001ff000101,0xff000001ff01ff00,0xff000001ff010001, +0xff00000100ffffff,0xff00000100ffff01,0xff00000100ff00ff,0xff00000100ff0000,0xff00000100ff01ff,0xff00000100ff0101,0xff0000010000ff00,0xff00000100000000, +0xff00000100000001,0xff000001000001ff,0xff00000100000100,0xff0000010001ff00,0xff000001000100ff,0xff00000100010000,0xff000001000101ff,0xff00000100010100, +0xff00000100010101,0xff00000101ff0001,0xff00000101ff0101,0xff0000010100ff01,0xff00000101000000,0xff000001010100ff,0xff00000101010100,0xff0001ffff00ff00, +0xff0001ffff000001,0xff0001ffff010000,0xff0001ff00ffff00,0xff0001ff00ff00ff,0xff0001ff00ff0001,0xff0001ff00ff0100,0xff0001ff0000ffff,0xff0001ff00000000, +0xff0001ff000001ff,0xff0001ff00000101,0xff0001ff0001ffff,0xff0001ff0001ff00,0xff0001ff000100ff,0xff0001ff00010001,0xff0001ff00010100,0xff0001ff01ff0000, +0xff0001ff0100ff00,0xff0001ff010000ff,0xff0001ff01010000,0xff000100ff00ffff,0xff000100ff00ff01,0xff000100ff000000,0xff000100ff000101,0xff000100ff01ff00, +0xff000100ff010000,0xff00010000ffff01,0xff00010000ff00ff,0xff00010000ff0000,0xff00010000ff01ff,0xff0001000000ff00,0xff000100000000ff,0xff00010000000000, +0xff00010000000001,0xff00010000000100,0xff00010000000101,0xff0001000001ffff,0xff00010000010000,0xff00010000010101,0xff00010001ff0100,0xff0001000100ff00, +0xff0001000100ff01,0xff00010001000000,0xff000100010001ff,0xff0001000101ff00,0xff00010001010001,0xff00010001010100,0xff000101ffff0100,0xff000101ff000001, +0xff000101ff0100ff,0xff000101ff010001,0xff00010100ff00ff,0xff00010100ff0001,0xff00010100ff0100,0xff0001010000ffff,0xff0001010000ff01,0xff00010100000000, +0xff000101000001ff,0xff0001010001ff00,0xff00010100010001,0xff00010100010100,0xff00010101ff0000,0xff0001010100ff00,0xff00010101000001,0xff00010101000101, +0xff01ffffffffffff,0xff01ffffffffff01,0xff01ffffffff01ff,0xff01ffffffff0101,0xff01ffffff000000,0xff01ffffff01ffff,0xff01ffffff01ff01,0xff01ffffff010000, +0xff01ffffff0101ff,0xff01ffffff010101,0xff01ffff00ff0000,0xff01ffff0000ff00,0xff01ffff00000100,0xff01ffff0001ff00,0xff01ffff00010000,0xff01ffff01ffffff, +0xff01ffff01ffff01,0xff01ffff01ff01ff,0xff01ffff01ff0101,0xff01ffff01000000,0xff01ffff0101ffff,0xff01ffff0101ff01,0xff01ffff01010000,0xff01ffff010101ff, +0xff01ffff01010101,0xff01ff00ffff0000,0xff01ff00ff00ff00,0xff01ff00ff0000ff,0xff01ff00ff000100,0xff01ff00ff010000,0xff01ff0000ffff01,0xff01ff0000ff00ff, +0xff01ff0000ff0100,0xff01ff0000000000,0xff01ff00000001ff,0xff01ff0000000101,0xff01ff000001ff00,0xff01ff00000100ff,0xff01ff0000010000,0xff01ff0000010001, +0xff01ff0001ff0000,0xff01ff000100ffff,0xff01ff0001000001,0xff01ff0001000100,0xff01ff0001010000,0xff01ff01ffffff00,0xff01ff01ffff01ff,0xff01ff01ffff0101, +0xff01ff01ff00ff00,0xff01ff01ff000000,0xff01ff01ff01ffff,0xff01ff01ff01ff01,0xff01ff01ff0101ff,0xff01ff01ff010101,0xff01ff0100ff0000,0xff01ff010000ff00, +0xff01ff0100000001,0xff01ff0100000100,0xff01ff0100010000,0xff01ff0101ffff00,0xff01ff0101ff01ff,0xff01ff0101ff0101,0xff01ff010100ff00,0xff01ff0101000000, +0xff01ff010101ffff,0xff01ff010101ff01,0xff01ff01010101ff,0xff01ff0101010101,0xff0100ffffff0000,0xff0100ffff0000ff,0xff0100ffff000001,0xff0100ffff000100, +0xff0100ffff010000,0xff0100ff00ff00ff,0xff0100ff00ff0000,0xff0100ff00ff0001,0xff0100ff00ff0100,0xff0100ff0000ff01,0xff0100ff00000000,0xff0100ff000001ff, +0xff0100ff00000101,0xff0100ff00010001,0xff0100ff01ff0000,0xff0100ff0100ff00,0xff0100ff010000ff,0xff0100ff01000100,0xff0100ff0101ff00,0xff0100ff01010000, +0xff010000ffff0100,0xff010000ff000000,0xff010000ff01ff00,0xff010000ff010100,0xff01000000ffffff,0xff01000000ff0000,0xff01000000ff01ff,0xff0100000000ff00, +0xff010000000000ff,0xff01000000000000,0xff01000000000100,0xff0100000001ff01,0xff01000000010000,0xff010000000101ff,0xff01000001ff0100,0xff0100000100ffff, +0xff010000010000ff,0xff01000001000000,0xff010000010001ff,0xff01000001000101,0xff0100000101ff00,0xff010000010100ff,0xff01000001010001,0xff01000001010100, +0xff010001ffff0000,0xff010001ff00ffff,0xff010001ff00ff01,0xff010001ff000100,0xff010001ff010000,0xff01000100ffff00,0xff01000100ff0100,0xff01000100000000, +0xff0100010001ffff,0xff0100010001ff00,0xff01000100010100,0xff01000101ff00ff,0xff01000101ff0001,0xff0100010100ffff,0xff01000101000101,0xff0101ffffffffff, +0xff0101ffffffff01,0xff0101ffffff01ff,0xff0101ffffff0101,0xff0101ffff000000,0xff0101ffff01ffff,0xff0101ffff01ff01,0xff0101ffff0101ff,0xff0101ffff010101, +0xff0101ff00ff0000,0xff0101ff0000ff00,0xff0101ff000000ff,0xff0101ff00010000,0xff0101ff01ffffff,0xff0101ff01ffff01,0xff0101ff01ff01ff,0xff0101ff01ff0101, +0xff0101ff0101ffff,0xff0101ff0101ff01,0xff0101ff010101ff,0xff0101ff01010101,0xff010100ffff0100,0xff010100ff00ff00,0xff010100ff0000ff,0xff010100ff000100, +0xff010100ff010000,0xff01010000ff0001,0xff01010000ff0100,0xff0101000000ff01,0xff01010000000000,0xff0101000001ff00,0xff010100000100ff,0xff01010000010001, +0xff01010000010100,0xff01010001ff0000,0xff0101000100ffff,0xff01010001000001,0xff01010001000100,0xff010100010100ff,0xff01010001010000,0xff010101ffffffff, +0xff010101ffffff01,0xff010101ffff01ff,0xff010101ffff0101,0xff010101ff01ffff,0xff010101ff01ff01,0xff010101ff0101ff,0xff010101ff010101,0xff01010100ff0000, +0xff0101010000ff00,0xff01010100000001,0xff01010100000100,0xff01010100010000,0xff01010101ffffff,0xff01010101ffff01,0xff01010101ff01ff,0xff01010101ff0101, +0xff01010101000000,0xff0101010101ffff,0xff0101010101ff01,0xff010101010101ff,0xff01010101010101,0x00ffffffffff0000,0x00ffffffff00ff00,0x00ffffffff000001, +0x00ffffffff010000,0x00ffffff00ff0100,0x00ffffff0000ff01,0x00ffffff00000000,0x00ffffff000001ff,0x00ffffff00000101,0x00ffffff0001ff00,0x00ffffff000100ff, +0x00ffffff00010001,0x00ffffff010000ff,0x00ffffff01000100,0x00ffffff0101ff00,0x00ffffff01010001,0x00ffff00ffffffff,0x00ffff00ffffff00,0x00ffff00ffff00ff, +0x00ffff00ffff0001,0x00ffff00ffff0100,0x00ffff00ff00ff01,0x00ffff00ff000000,0x00ffff00ff000001,0x00ffff00ff0001ff,0x00ffff00ff000101,0x00ffff00ff01ff00, +0x00ffff00ff010001,0x00ffff00ff010100,0x00ffff0000ff0000,0x00ffff0000ff01ff,0x00ffff0000ff0101,0x00ffff000000ff00,0x00ffff00000000ff,0x00ffff0000000000, +0x00ffff0000000001,0x00ffff0000000100,0x00ffff0000000101,0x00ffff0000010000,0x00ffff00000101ff,0x00ffff0000010101,0x00ffff0001ffff00,0x00ffff0001ff00ff, +0x00ffff0001ff0001,0x00ffff000100ffff,0x00ffff000100ff01,0x00ffff0001000000,0x00ffff000101ffff,0x00ffff000101ff00,0x00ffff000101ff01,0x00ffff01ffff0000, +0x00ffff01ff00ff00,0x00ffff01ff0000ff,0x00ffff01ff000001,0x00ffff01ff010000,0x00ffff0100ffff00,0x00ffff010000ff01,0x00ffff0100000000,0x00ffff0100000101, +0x00ffff01000100ff,0x00ffff0100010100,0x00ffff0101ff0100,0x00ffff01010000ff,0x00ffff0101010000,0x00ff00ffffffff00,0x00ff00ffff000000,0x00ff00ffff000100, +0x00ff00ffff010100,0x00ff00ff00ff0000,0x00ff00ff00ff01ff,0x00ff00ff00ff0101,0x00ff00ff0000ff00,0x00ff00ff000000ff,0x00ff00ff00000000,0x00ff00ff00000001, +0x00ff00ff0001ff00,0x00ff00ff0001ff01,0x00ff00ff00010000,0x00ff00ff000101ff,0x00ff00ff00010101,0x00ff00ff01ffff00,0x00ff00ff01ff0001,0x00ff00ff01ff0100, +0x00ff00ff0100ffff,0x00ff00ff0100ff01,0x00ff00ff01000000,0x00ff00ff0101ffff,0x00ff00ff0101ff00,0x00ff00ff01010100,0x00ff0000ffffff00,0x00ff0000ffffff01, +0x00ff0000ffff0000,0x00ff0000ffff0101,0x00ff0000ff00ff00,0x00ff0000ff0000ff,0x00ff0000ff000000,0x00ff0000ff000001,0x00ff0000ff000100,0x00ff0000ff01ffff, +0x00ff0000ff010000,0x00ff0000ff010101,0x00ff000000ffff00,0x00ff000000ff00ff,0x00ff000000ff0000,0x00ff000000ff0001,0x00ff000000ff0100,0x00ff00000000ffff, +0x00ff00000000ff00,0x00ff0000000000ff,0x00ff000000000000,0x00ff000000000001,0x00ff0000000001ff,0x00ff000000000100,0x00ff00000001ff00,0x00ff0000000100ff, +0x00ff000000010000,0x00ff000000010001,0x00ff000000010100,0x00ff000001ffff01,0x00ff000001ff00ff,0x00ff000001ff0000,0x00ff000001ff01ff,0x00ff00000100ff00, +0x00ff0000010000ff,0x00ff000001000000,0x00ff000001000001,0x00ff000001000100,0x00ff000001000101,0x00ff000001010000,0x00ff0000010101ff,0x00ff000001010101, +0x00ff0001ffffff00,0x00ff0001ffff0000,0x00ff0001ffff0100,0x00ff0001ff0000ff,0x00ff0001ff000000,0x00ff0001ff0001ff,0x00ff0001ff000101,0x00ff0001ff01ff00, +0x00ff0001ff0100ff,0x00ff0001ff010100,0x00ff000100ffffff,0x00ff000100ffff01,0x00ff000100ff0000,0x00ff000100ff01ff,0x00ff00010000ffff,0x00ff00010000ff00, +0x00ff00010000ff01,0x00ff000100000000,0x00ff000100000001,0x00ff000100000100,0x00ff00010001ff01,0x00ff000100010000,0x00ff0001000101ff,0x00ff000101ffff00, +0x00ff000101ff0000,0x00ff000101ff0101,0x00ff0001010000ff,0x00ff000101000000,0x00ff00010101ff00,0x00ff0001010100ff,0x00ff000101010001,0x00ff01ffffff0000, +0x00ff01ffff00ff00,0x00ff01ffff000000,0x00ff01ffff000101,0x00ff01ffff010000,0x00ff01ff00ffff01,0x00ff01ff00ff0100,0x00ff01ff0000ffff,0x00ff01ff00000000, +0x00ff01ff000001ff,0x00ff01ff0001ff00,0x00ff01ff000100ff,0x00ff01ff00010001,0x00ff01ff00010100,0x00ff01ff01ff0000,0x00ff01ff0100ff00,0x00ff01ff010000ff, +0x00ff01ff01000001,0x00ff01ff01000100,0x00ff01ff01010000,0x00ff0100ffffff00,0x00ff0100ffff0000,0x00ff0100ffff0001,0x00ff0100ffff0101,0x00ff0100ff00ffff, +0x00ff0100ff0000ff,0x00ff0100ff000000,0x00ff0100ff0001ff,0x00ff0100ff01ff00,0x00ff0100ff0100ff,0x00ff0100ff010001,0x00ff010000ffffff,0x00ff010000ff0000, +0x00ff010000ff0101,0x00ff01000000ff00,0x00ff01000000ff01,0x00ff0100000000ff,0x00ff010000000000,0x00ff010000000001,0x00ff010000000100,0x00ff01000001ffff, +0x00ff01000001ff01,0x00ff010000010000,0x00ff010000010001,0x00ff010000010101,0x00ff010001ff0001,0x00ff010001ff0100,0x00ff01000100ff01,0x00ff010001000000, +0x00ff010001000001,0x00ff0100010001ff,0x00ff01000101ff00,0x00ff0100010100ff,0x00ff010001010001,0x00ff010001010100,0x00ff0101ff000001,0x00ff010100ff00ff, +0x00ff010100ff0001,0x00ff010100ff0100,0x00ff010100000000,0x00ff0101000001ff,0x00ff010100000101,0x00ff0101000100ff,0x00ff010100010100,0x00ff0101010000ff, +0x00ff010101010000,0x0000ffffffffff00,0x0000ffffffff00ff,0x0000ffffffff0000,0x0000ffffffff0001,0x0000ffffffff0100,0x0000ffffff00ff01,0x0000ffffff000000, +0x0000ffffff000101,0x0000ffffff01ff00,0x0000ffffff0100ff,0x0000ffffff010100,0x0000ffff00ffffff,0x0000ffff00ff0000,0x0000ffff00ff01ff,0x0000ffff0000ff00, +0x0000ffff000000ff,0x0000ffff00000000,0x0000ffff00000001,0x0000ffff00000100,0x0000ffff00010000,0x0000ffff000101ff,0x0000ffff01ff0001,0x0000ffff01ff0100, +0x0000ffff01000000,0x0000ffff010001ff,0x0000ffff0101ffff,0x0000ffff0101ff00,0x0000ffff01010001,0x0000ffff01010100,0x0000ff00ffff0000,0x0000ff00ffff01ff, +0x0000ff00ffff0100,0x0000ff00ffff0101,0x0000ff00ff00ff00,0x0000ff00ff0000ff,0x0000ff00ff000000,0x0000ff00ff000001,0x0000ff00ff0001ff,0x0000ff00ff000100, +0x0000ff00ff01ffff,0x0000ff00ff010000,0x0000ff00ff010001,0x0000ff00ff0101ff,0x0000ff00ff010101,0x0000ff0000ffff00,0x0000ff0000ff00ff,0x0000ff0000ff0000, +0x0000ff0000ff0001,0x0000ff0000ff0100,0x0000ff000000ffff,0x0000ff000000ff00,0x0000ff000000ff01,0x0000ff00000000ff,0x0000ff0000000000,0x0000ff0000000001, +0x0000ff00000001ff,0x0000ff0000000100,0x0000ff0000000101,0x0000ff000001ff00,0x0000ff00000100ff,0x0000ff0000010000,0x0000ff0000010001,0x0000ff0000010100, +0x0000ff0001ffff01,0x0000ff0001ff0000,0x0000ff000100ff00,0x0000ff00010000ff,0x0000ff0001000000,0x0000ff0001000001,0x0000ff0001000100,0x0000ff000101ffff, +0x0000ff0001010000,0x0000ff0001010101,0x0000ff01ffffff00,0x0000ff01ffff0001,0x0000ff01ff00ff01,0x0000ff01ff000000,0x0000ff01ff000101,0x0000ff01ff01ff00, +0x0000ff01ff0100ff,0x0000ff0100ffff01,0x0000ff0100ff0000,0x0000ff0100ff0101,0x0000ff010000ff00,0x0000ff01000000ff,0x0000ff0100000000,0x0000ff0100000001, +0x0000ff0100000100,0x0000ff010001ff01,0x0000ff0100010000,0x0000ff0101ff0000,0x0000ff010100ffff,0x0000ff010100ff01,0x0000ff0101000000,0x0000ff0101000100, +0x0000ff0101000101,0x0000ff01010100ff,0x000000ffffff00ff,0x000000ffffff0000,0x000000ffff00ff00,0x000000ffff0000ff,0x000000ffff000000,0x000000ffff000001, +0x000000ffff0001ff,0x000000ffff000100,0x000000ffff01ff00,0x000000ffff010000,0x000000ffff0101ff,0x000000ffff010101,0x000000ff00ffff00,0x000000ff00ff00ff, +0x000000ff00ff0000,0x000000ff00ff0001,0x000000ff00ff0100,0x000000ff00ff0101,0x000000ff0000ffff,0x000000ff0000ff00,0x000000ff000000ff,0x000000ff00000000, +0x000000ff00000001,0x000000ff000001ff,0x000000ff00000100,0x000000ff00000101,0x000000ff0001ff00,0x000000ff0001ff01,0x000000ff000100ff,0x000000ff00010000, +0x000000ff00010001,0x000000ff00010100,0x000000ff01ffffff,0x000000ff01ff01ff,0x000000ff01ff0101,0x000000ff0100ff00,0x000000ff010000ff,0x000000ff01000000, +0x000000ff01000001,0x000000ff01000100,0x000000ff0101ff00,0x000000ff010100ff,0x000000ff01010000,0x000000ff01010101,0x00000000ffffff00,0x00000000ffffff01, +0x00000000ffff00ff,0x00000000ffff0000,0x00000000ffff0001,0x00000000ffff0100,0x00000000ff00ffff,0x00000000ff00ff00,0x00000000ff00ff01,0x00000000ff0000ff, +0x00000000ff000000,0x00000000ff000001,0x00000000ff000100,0x00000000ff000101,0x00000000ff01ff00,0x00000000ff0100ff,0x00000000ff010000,0x00000000ff010001, +0x00000000ff010100,0x0000000000ffffff,0x0000000000ffff00,0x0000000000ffff01,0x0000000000ff00ff,0x0000000000ff0000,0x0000000000ff0001,0x0000000000ff01ff, +0x0000000000ff0100,0x000000000000ffff,0x000000000000ff00,0x000000000000ff01,0x00000000000000ff,0x0000000000000000,0x0000000000000001,0x00000000000001ff, +0x0000000000000100,0x0000000000000101,0x000000000001ffff,0x000000000001ff00,0x00000000000100ff,0x0000000000010000,0x0000000000010001,0x00000000000101ff, +0x0000000000010100,0x0000000000010101,0x0000000001ffff00,0x0000000001ff00ff,0x0000000001ff0000,0x0000000001ff0100,0x0000000001ff0101,0x000000000100ffff, +0x000000000100ff00,0x00000000010000ff,0x0000000001000000,0x0000000001000001,0x00000000010001ff,0x0000000001000100,0x000000000101ff00,0x00000000010100ff, +0x0000000001010000,0x0000000001010001,0x0000000001010100,0x00000001ffffffff,0x00000001ffffff00,0x00000001ffffff01,0x00000001ffff00ff,0x00000001ffff0001, +0x00000001ffff01ff,0x00000001ffff0100,0x00000001ff00ff00,0x00000001ff0000ff,0x00000001ff000000,0x00000001ff0001ff,0x00000001ff000100,0x00000001ff01ffff, +0x00000001ff01ff00,0x00000001ff01ff01,0x00000001ff0100ff,0x00000001ff010000,0x00000001ff010001,0x00000001ff0101ff,0x00000001ff010100,0x0000000100ffff00, +0x0000000100ff0000,0x0000000100ff0001,0x0000000100ff01ff,0x0000000100ff0100,0x0000000100ff0101,0x000000010000ffff,0x000000010000ff00,0x000000010000ff01, +0x00000001000000ff,0x0000000100000000,0x0000000100000001,0x00000001000001ff,0x0000000100000100,0x0000000100000101,0x000000010001ff00,0x00000001000100ff, +0x0000000100010000,0x0000000100010100,0x0000000101ffff01,0x0000000101ff0000,0x0000000101ff0001,0x0000000101ff01ff,0x0000000101ff0100,0x0000000101ff0101, +0x000000010100ff00,0x0000000101000000,0x0000000101000101,0x000000010101ff01,0x0000000101010000,0x0000000101010001,0x00000001010101ff,0x0000000101010100, +0x000001ffffff00ff,0x000001ffffff0000,0x000001ffffff0001,0x000001ffffff0100,0x000001ffff00ffff,0x000001ffff000000,0x000001ffff0001ff,0x000001ffff01ff00, +0x000001ffff010101,0x000001ff00ff0000,0x000001ff00ff01ff,0x000001ff00ff0101,0x000001ff0000ff00,0x000001ff000000ff,0x000001ff00000000,0x000001ff00000001, +0x000001ff000001ff,0x000001ff00000100,0x000001ff0001ffff,0x000001ff0001ff01,0x000001ff000100ff,0x000001ff00010000,0x000001ff01ffff01,0x000001ff01ff0100, +0x000001ff0100ffff,0x000001ff0100ff01,0x000001ff01000000,0x000001ff010001ff,0x000001ff0101ff00,0x000001ff01010100,0x00000100ffffff00,0x00000100ffffff01, +0x00000100ffff0000,0x00000100ffff0101,0x00000100ff00ff00,0x00000100ff0000ff,0x00000100ff000000,0x00000100ff000001,0x00000100ff000100,0x00000100ff010000, +0x0000010000ffff00,0x0000010000ff00ff,0x0000010000ff0000,0x0000010000ff0001,0x0000010000ff0100,0x000001000000ffff,0x000001000000ff00,0x000001000000ff01, +0x00000100000000ff,0x0000010000000000,0x0000010000000001,0x00000100000001ff,0x0000010000000100,0x0000010000000101,0x000001000001ff00,0x00000100000100ff, +0x0000010000010000,0x0000010000010001,0x0000010000010100,0x0000010001ffff00,0x0000010001ff0000,0x0000010001ff0100,0x000001000100ff00,0x00000100010000ff, +0x0000010001000000,0x0000010001000001,0x00000100010001ff,0x0000010001000100,0x0000010001010000,0x00000101ffff00ff,0x00000101ffff01ff,0x00000101ff000000, +0x00000101ff000101,0x00000101ff01ffff,0x00000101ff010000,0x00000101ff010001,0x00000101ff010100,0x0000010100ff0000,0x0000010100ff01ff,0x0000010100ff0100, +0x000001010000ff00,0x0000010100000000,0x0000010100000001,0x00000101000001ff,0x0000010100000100,0x000001010001ff01,0x0000010100010000,0x00000101000101ff, +0x0000010100010101,0x0000010101ffff00,0x0000010101ff0101,0x000001010100ff01,0x0000010101000000,0x0000010101000001,0x00000101010001ff,0x0000010101000101, +0x000001010101ff00,0x0001ffffffff0000,0x0001ffffff0000ff,0x0001ffffff000001,0x0001ffffff000100,0x0001ffffff010000,0x0001ffff00ff00ff,0x0001ffff0000ffff, +0x0001ffff00000000,0x0001ffff00000001,0x0001ffff000001ff,0x0001ffff00000101,0x0001ffff0001ff00,0x0001ffff000100ff,0x0001ffff00010001,0x0001ffff00010100, +0x0001ffff01ffff00,0x0001ffff01000001,0x0001ffff01010000,0x0001ff00ffffff00,0x0001ff00ffff00ff,0x0001ff00ffff0001,0x0001ff00ffff0100,0x0001ff00ff00ff01, +0x0001ff00ff000000,0x0001ff00ff01ff00,0x0001ff00ff01ff01,0x0001ff00ff010001,0x0001ff00ff010100,0x0001ff0000ff0000,0x0001ff0000ff0100,0x0001ff000000ff00, +0x0001ff0000000000,0x0001ff0000000001,0x0001ff0000000100,0x0001ff0000010000,0x0001ff0000010001,0x0001ff0000010101,0x0001ff0001ff00ff,0x0001ff0001ff0101, +0x0001ff000100ff01,0x0001ff0001000000,0x0001ff000101ff00,0x0001ff0001010001,0x0001ff0001010100,0x0001ff01ff00ff00,0x0001ff01ff000001,0x0001ff01ff000100, +0x0001ff0100ffffff,0x0001ff0100ffff00,0x0001ff0100ff0001,0x0001ff0100000000,0x0001ff0100000001,0x0001ff01000001ff,0x0001ff010001ffff,0x0001ff0101ff0000, +0x0001ff010100ff00,0x0001ff0101000001,0x0001ff0101010000,0x000100ffff00ff00,0x000100ffff00ff01,0x000100ffff000000,0x000100ffff000001,0x000100ffff000101, +0x000100ffff01ff00,0x000100ffff010001,0x000100ffff010100,0x000100ff00ffffff,0x000100ff00ffff01,0x000100ff00ff0000,0x000100ff00ff01ff,0x000100ff00ff0101, +0x000100ff0000ff00,0x000100ff000000ff,0x000100ff00000000,0x000100ff00000001,0x000100ff00000100,0x000100ff00000101,0x000100ff0001ffff,0x000100ff0001ff01, +0x000100ff00010000,0x000100ff01ff00ff,0x000100ff01ff0000,0x000100ff01ff0100,0x000100ff0100ffff,0x000100ff0100ff01,0x000100ff010000ff,0x000100ff01000000, +0x000100ff01000001,0x000100ff010001ff,0x000100ff01000101,0x000100ff0101ff00,0x000100ff010100ff,0x000100ff01010100,0x00010000ffff0000,0x00010000ffff01ff, +0x00010000ffff0101,0x00010000ff00ff00,0x00010000ff000000,0x00010000ff000001,0x00010000ff000100,0x0001000000ff00ff,0x0001000000ff0000,0x0001000000ff0001, +0x0001000000ff0100,0x000100000000ffff,0x000100000000ff00,0x00010000000000ff,0x0001000000000000,0x0001000000000001,0x0001000000000100,0x000100000001ff00, +0x00010000000100ff,0x0001000000010000,0x0001000000010001,0x0001000000010100,0x0001000001ff0001,0x0001000001ff0100,0x0001000001ff0101,0x000100000100ff00, +0x0001000001000000,0x0001000001000001,0x0001000001000100,0x0001000001000101,0x000100000101ff01,0x0001000001010000,0x0001000001010001,0x00010000010101ff, +0x00010001ffffff01,0x00010001ffff0100,0x00010001ff000000,0x00010001ff01ffff,0x00010001ff010001,0x00010001ff0101ff,0x00010001ff010100,0x0001000100ffffff, +0x0001000100ff0000,0x0001000100ff01ff,0x0001000100ff0101,0x000100010000ff00,0x00010001000000ff,0x0001000100000000,0x0001000100000001,0x00010001000001ff, +0x0001000100000101,0x000100010001ffff,0x0001000100010000,0x00010001000101ff,0x0001000101ffffff,0x0001000101ffff01,0x0001000101ff0000,0x0001000101ff0101, +0x00010001010000ff,0x0001000101000001,0x00010001010001ff,0x0001000101000100,0x000100010101ffff,0x00010001010100ff,0x0001000101010001,0x0001000101010101, +0x000101ffff000001,0x000101ffff000100,0x000101ffff010000,0x000101ff00ffff00,0x000101ff0000ff01,0x000101ff00000000,0x000101ff00000101,0x000101ff0001ff00, +0x000101ff00010100,0x000101ff01ff0000,0x000101ff0100ff00,0x000101ff010001ff,0x000101ff01010001,0x00010100ffffff00,0x00010100ffff00ff,0x00010100ff00ffff, +0x00010100ff000000,0x00010100ff01ff00,0x00010100ff0100ff,0x00010100ff010001,0x00010100ff010100,0x0001010000ffffff,0x0001010000ffff00,0x0001010000ff0000, +0x0001010000ff0001,0x0001010000ff01ff,0x000101000000ff00,0x00010100000000ff,0x0001010000000000,0x0001010000000001,0x0001010000000100,0x000101000001ffff, +0x0001010000010000,0x0001010000010101,0x0001010001ffff01,0x0001010001ff00ff,0x0001010001ff0101,0x0001010001000000,0x000101000101ff00,0x00010100010100ff, +0x0001010001010000,0x0001010001010100,0x00010101ff00ff00,0x00010101ff000001,0x00010101ff0001ff,0x0001010100ffff00,0x0001010100ff00ff,0x0001010100ff0100, +0x000101010000ffff,0x0001010100000000,0x00010101000001ff,0x0001010100000101,0x00010101000100ff,0x0001010100010000,0x0001010100010100,0x0001010101ff0001, +0x00010101010000ff,0x00010101010001ff,0x0001010101000101,0x0001010101010001,0x01ffffffffffffff,0x01ffffffffffff01,0x01ffffffffff01ff,0x01ffffffffff0101, +0x01ffffffff01ffff,0x01ffffffff01ff01,0x01ffffffff0101ff,0x01ffffffff010101,0x01ffffff00ff0000,0x01ffffff0000ffff,0x01ffffff0000ff00,0x01ffffff000000ff, +0x01ffffff00000001,0x01ffffff00000100,0x01ffffff00010000,0x01ffffff01ffffff,0x01ffffff01ffff01,0x01ffffff01ff01ff,0x01ffffff01ff0101,0x01ffffff01000000, +0x01ffffff0101ffff,0x01ffffff0101ff01,0x01ffffff010101ff,0x01ffffff01010101,0x01ffff00ffff0000,0x01ffff00ff00ff00,0x01ffff00ff0000ff,0x01ffff00ff000001, +0x01ffff00ff000100,0x01ffff00ff010000,0x01ffff0000ffff00,0x01ffff0000ff00ff,0x01ffff0000ff0100,0x01ffff000000ffff,0x01ffff000000ff01,0x01ffff0000000000, +0x01ffff0000000001,0x01ffff00000001ff,0x01ffff0000000100,0x01ffff00000100ff,0x01ffff0000010001,0x01ffff0000010100,0x01ffff0001ff0000,0x01ffff0001ff0100, +0x01ffff00010000ff,0x01ffff0001000001,0x01ffff0001000100,0x01ffff0001010000,0x01ffff01ffffffff,0x01ffff01ffffff01,0x01ffff01ffff01ff,0x01ffff01ffff0101, +0x01ffff01ff000000,0x01ffff01ff01ffff,0x01ffff01ff01ff01,0x01ffff01ff0101ff,0x01ffff01ff010101,0x01ffff010000ff00,0x01ffff01000000ff,0x01ffff0100000100, +0x01ffff0100010000,0x01ffff0101ffffff,0x01ffff0101ffff01,0x01ffff0101ff01ff,0x01ffff0101ff0101,0x01ffff0101000000,0x01ffff010101ffff,0x01ffff010101ff01, +0x01ffff01010101ff,0x01ffff0101010101,0x01ff00ffff0000ff,0x01ff00ffff000100,0x01ff00ff00ffff00,0x01ff00ff00ff00ff,0x01ff00ff0000ff00,0x01ff00ff00000000, +0x01ff00ff00000101,0x01ff00ff0001ff00,0x01ff00ff000100ff,0x01ff00ff00010100,0x01ff00ff010000ff,0x01ff00ff01000100,0x01ff0000ffffff00,0x01ff0000ffff0100, +0x01ff0000ff00ff01,0x01ff0000ff000000,0x01ff0000ff000101,0x01ff0000ff010001,0x01ff0000ff010100,0x01ff000000ffffff,0x01ff000000ffff00,0x01ff000000ff0000, +0x01ff000000ff01ff,0x01ff00000000ff00,0x01ff0000000000ff,0x01ff000000000000,0x01ff000000000001,0x01ff000000000100,0x01ff000000000101,0x01ff000000010000, +0x01ff000000010001,0x01ff0000000101ff,0x01ff000000010101,0x01ff000001ffff00,0x01ff000001ff00ff,0x01ff000001ff0001,0x01ff000001ff0100,0x01ff00000100ffff, +0x01ff00000100ff01,0x01ff000001000000,0x01ff0000010001ff,0x01ff000001010001,0x01ff0001ff00ff00,0x01ff0001ff000001,0x01ff0001ff000100,0x01ff0001ff010000, +0x01ff000100ffff00,0x01ff000100ff00ff,0x01ff000100ff0100,0x01ff000100ff0101,0x01ff00010000ffff,0x01ff000100000000,0x01ff000100000100,0x01ff000100000101, +0x01ff00010001ff00,0x01ff000100010001,0x01ff000100010101,0x01ff000101ff0000,0x01ff00010100ff00,0x01ff000101000101,0x01ff0001010100ff,0x01ff01ffffffffff, +0x01ff01ffffffff01,0x01ff01ffffff01ff,0x01ff01ffffff0101,0x01ff01ffff000000,0x01ff01ffff01ffff,0x01ff01ffff01ff01,0x01ff01ffff0101ff,0x01ff01ffff010101, +0x01ff01ff00ffff00,0x01ff01ff00ff0000,0x01ff01ff0000ff00,0x01ff01ff000000ff,0x01ff01ff00000100,0x01ff01ff00010000,0x01ff01ff00010100,0x01ff01ff01ffffff, +0x01ff01ff01ffff01,0x01ff01ff01ff01ff,0x01ff01ff01ff0101,0x01ff01ff01000000,0x01ff01ff0101ffff,0x01ff01ff0101ff01,0x01ff01ff010101ff,0x01ff01ff01010101, +0x01ff0100ffff0000,0x01ff0100ffff0001,0x01ff0100ff00ff00,0x01ff0100ff0000ff,0x01ff0100ff000001,0x01ff0100ff010000,0x01ff010000ffff00,0x01ff010000ff00ff, +0x01ff010000ff0001,0x01ff010000ff0100,0x01ff01000000ffff,0x01ff01000000ff01,0x01ff010000000000,0x01ff010000000101,0x01ff01000001ff00,0x01ff0100000100ff, +0x01ff010001ff0000,0x01ff010001000001,0x01ff010001000100,0x01ff010001010000,0x01ff0101ffffffff,0x01ff0101ffffff01,0x01ff0101ffff01ff,0x01ff0101ffff0101, +0x01ff0101ff000000,0x01ff0101ff01ffff,0x01ff0101ff01ff01,0x01ff0101ff0101ff,0x01ff0101ff010101,0x01ff010100ff0000,0x01ff01010000ff00,0x01ff0101000000ff, +0x01ff010100000001,0x01ff010101ffffff,0x01ff010101ffff01,0x01ff010101ff01ff,0x01ff010101ff0101,0x01ff010101000000,0x01ff01010101ffff,0x01ff01010101ff01, +0x01ff0101010101ff,0x01ff010101010101,0x0100ffffffff0000,0x0100ffffff00ff00,0x0100ffffff000001,0x0100ffffff0001ff,0x0100ffffff000100,0x0100ffffff010000, +0x0100ffff00ffff00,0x0100ffff00ff0001,0x0100ffff00ff0100,0x0100ffff00000000,0x0100ffff000001ff,0x0100ffff00000101,0x0100ffff00010100,0x0100ffff00010101, +0x0100ffff01ff0000,0x0100ffff0100ff00,0x0100ffff010000ff,0x0100ffff01000001,0x0100ffff01000100,0x0100ffff01010000,0x0100ff00ffffff00,0x0100ff00ffff00ff, +0x0100ff00ffff0001,0x0100ff00ffff0100,0x0100ff00ff00ffff,0x0100ff00ff000000,0x0100ff00ff0001ff,0x0100ff00ff000101,0x0100ff00ff01ff00,0x0100ff00ff0100ff, +0x0100ff00ff010001,0x0100ff00ff010100,0x0100ff0000ffffff,0x0100ff0000ff0000,0x0100ff000000ffff,0x0100ff000000ff00,0x0100ff00000000ff,0x0100ff0000000000, +0x0100ff0000000001,0x0100ff0000000100,0x0100ff000001ff01,0x0100ff0000010000,0x0100ff0001ff00ff,0x0100ff0001ff0001,0x0100ff000100ff01,0x0100ff0001000000, +0x0100ff00010001ff,0x0100ff000101ff00,0x0100ff00010100ff,0x0100ff0001010001,0x0100ff0001010100,0x0100ff01ffff0000,0x0100ff01ff00ff00,0x0100ff01ff0000ff, +0x0100ff01ff000100,0x0100ff01ff010000,0x0100ff0100ff00ff,0x0100ff0100ff0001,0x0100ff0100ff0100,0x0100ff010000ffff,0x0100ff010000ff01,0x0100ff0100000000, +0x0100ff01000001ff,0x0100ff0100010001,0x0100ff0100010100,0x0100ff0101ff0000,0x0100ff01010000ff,0x0100ff0101000001,0x0100ff0101010100,0x010000ffffffff00, +0x010000ffffff00ff,0x010000ffffff0001,0x010000ffff00ffff,0x010000ffff000000,0x010000ffff0001ff,0x010000ffff010001,0x010000ff00ffffff,0x010000ff00ff0101, +0x010000ff0000ff00,0x010000ff000000ff,0x010000ff00000000,0x010000ff00000001,0x010000ff000001ff,0x010000ff00000100,0x010000ff0001ffff,0x010000ff0001ff00, +0x010000ff0001ff01,0x010000ff00010000,0x010000ff01ff00ff,0x010000ff01ff0001,0x010000ff0100ff01,0x010000ff010000ff,0x010000ff01000000,0x010000ff010001ff, +0x010000ff0101ff00,0x010000ff01010100,0x01000000ffffffff,0x01000000ffff0000,0x01000000ffff01ff,0x01000000ffff0101,0x01000000ff00ffff,0x01000000ff00ff00, +0x01000000ff0000ff,0x01000000ff000000,0x01000000ff000001,0x01000000ff000100,0x01000000ff01ff00,0x01000000ff010000,0x01000000ff010100,0x01000000ff010101, +0x0100000000ffff00,0x0100000000ff00ff,0x0100000000ff0000,0x0100000000ff0001,0x0100000000ff0100,0x010000000000ffff,0x010000000000ff00,0x010000000000ff01, +0x01000000000000ff,0x0100000000000000,0x0100000000000001,0x01000000000001ff,0x0100000000000100,0x0100000000000101,0x010000000001ff00,0x01000000000100ff, +0x0100000000010000,0x0100000000010001,0x0100000000010100,0x0100000001ffff00,0x0100000001ff0000,0x0100000001ff01ff,0x010000000100ff00,0x010000000100ff01, +0x01000000010000ff,0x0100000001000000,0x0100000001000001,0x0100000001000100,0x0100000001000101,0x010000000101ffff,0x010000000101ff01,0x0100000001010000, +0x01000000010101ff,0x0100000001010101,0x01000001ffffff00,0x01000001ffff00ff,0x01000001ff00ffff,0x01000001ff000000,0x01000001ff000100,0x01000001ff01ffff, +0x01000001ff010001,0x01000001ff010100,0x0100000100ff0000,0x0100000100ff01ff,0x0100000100ff0100,0x010000010000ff00,0x010000010000ff01,0x0100000100000000, +0x0100000100000001,0x0100000100000100,0x0100000100010000,0x01000001000101ff,0x0100000101ffff01,0x0100000101ff00ff,0x0100000101ff0100,0x0100000101ff0101, +0x010000010100ff01,0x01000001010000ff,0x0100000101000000,0x01000001010100ff,0x0100000101010001,0x0100000101010100,0x010001ffffff0000,0x010001ffff000001, +0x010001ffff000100,0x010001ffff010000,0x010001ff00ffff00,0x010001ff00ff0001,0x010001ff0000ffff,0x010001ff0000ff01,0x010001ff00000000,0x010001ff00000001, +0x010001ff00000101,0x010001ff000100ff,0x010001ff00010000,0x010001ff01ff0000,0x010001ff0100ff00,0x010001ff01000001,0x010001ff01000100,0x010001ff01010000, +0x01000100ffff00ff,0x01000100ffff0001,0x01000100ffff0100,0x01000100ff00ffff,0x01000100ff00ff01,0x01000100ff000000,0x01000100ff0001ff,0x01000100ff000101, +0x01000100ff01ffff,0x01000100ff01ff00,0x01000100ff0100ff,0x01000100ff010001,0x0100010000ffffff,0x0100010000ffff01,0x0100010000ff0000,0x0100010000ff01ff, +0x0100010000ff0101,0x010001000000ff00,0x01000100000000ff,0x0100010000000000,0x0100010000000001,0x0100010000000100,0x010001000001ff01,0x0100010000010000, +0x0100010000010001,0x0100010000010101,0x0100010001ffff00,0x0100010001ff00ff,0x010001000100ffff,0x010001000100ff01,0x0100010001000000,0x0100010001000101, +0x010001000101ff00,0x0100010001010001,0x01000101ffff0000,0x01000101ff000000,0x01000101ff010000,0x0100010100ff00ff,0x0100010100ff0001,0x0100010100ff0100, +0x010001010000ffff,0x0100010100000000,0x01000101000001ff,0x010001010001ff00,0x0100010101ff0000,0x010001010100ff00,0x01000101010000ff,0x0100010101000000, +0x0100010101000001,0x0101ffffffffffff,0x0101ffffffffff01,0x0101ffffffff01ff,0x0101ffffffff0101,0x0101ffffff000000,0x0101ffffff01ffff,0x0101ffffff01ff01, +0x0101ffffff0101ff,0x0101ffffff010101,0x0101ffff00ff0000,0x0101ffff0000ff00,0x0101ffff000000ff,0x0101ffff00000001,0x0101ffff00000100,0x0101ffff01ffffff, +0x0101ffff01ffff01,0x0101ffff01ff01ff,0x0101ffff01ff0101,0x0101ffff01000000,0x0101ffff0101ffff,0x0101ffff0101ff01,0x0101ffff010101ff,0x0101ffff01010101, +0x0101ff00ffff0000,0x0101ff00ffff0100,0x0101ff00ff00ff00,0x0101ff00ff0000ff,0x0101ff00ff000001,0x0101ff00ff000100,0x0101ff00ff000101,0x0101ff0000ff0001, +0x0101ff0000ff0100,0x0101ff000000ff00,0x0101ff0000000000,0x0101ff00000001ff,0x0101ff0000000101,0x0101ff000001ff00,0x0101ff00000100ff,0x0101ff0001ff0000, +0x0101ff000100ffff,0x0101ff000100ff01,0x0101ff0001000001,0x0101ff0001000100,0x0101ff01ffffff01,0x0101ff01ffff01ff,0x0101ff01ffff0101,0x0101ff01ff00ffff, +0x0101ff01ff000100,0x0101ff01ff01ff01,0x0101ff01ff0101ff,0x0101ff01ff010101,0x0101ff0100ff0000,0x0101ff010000ff00,0x0101ff0100000001,0x0101ff0100000100, +0x0101ff0100010000,0x0101ff0101ffffff,0x0101ff0101ffff01,0x0101ff0101ff01ff,0x0101ff0101ff0101,0x0101ff0101000000,0x0101ff010101ffff,0x0101ff010101ff01, +0x0101ff01010101ff,0x0101ff0101010101,0x010100ffff000100,0x010100ffff010000,0x010100ff00ffff00,0x010100ff00ff00ff,0x010100ff0000ffff,0x010100ff000000ff, +0x010100ff00000000,0x010100ff000001ff,0x010100ff00000101,0x010100ff0001ff00,0x010100ff00010000,0x010100ff00010001,0x010100ff000101ff,0x010100ff00010100, +0x010100ff01ff0000,0x01010000ffff0001,0x01010000ffff0100,0x01010000ff00ffff,0x01010000ff00ff01,0x01010000ff000000,0x01010000ff0001ff,0x01010000ff010001, +0x01010000ff010100,0x0101000000ffff01,0x0101000000ff0000,0x010100000000ff00,0x01010000000000ff,0x0101000000000000,0x0101000000000001,0x0101000000000100, +0x0101000000010000,0x0101000000010101,0x0101000001ffff00,0x0101000001ff00ff,0x0101000001ff0000,0x0101000001ff0001,0x0101000001ff0100,0x010100000100ff01, +0x0101000001000000,0x01010000010001ff,0x01010001ffff0000,0x01010001ff00ff00,0x01010001ff000001,0x01010001ff000101,0x01010001ff01ff00,0x01010001ff010000, +0x0101000100ff00ff,0x0101000100ff0001,0x0101000100ff0101,0x010100010000ff01,0x0101000100000000,0x0101000100000001,0x01010001000001ff,0x010100010001ffff, +0x010100010001ff01,0x0101000101ff0001,0x010100010100ffff,0x0101000101000000,0x0101000101000001,0x0101000101000100,0x010100010101ff00,0x01010001010100ff, +0x0101000101010001,0x010101ffffffffff,0x010101ffffffff01,0x010101ffffff01ff,0x010101ffffff0101,0x010101ffff01ffff,0x010101ffff01ff01,0x010101ffff0101ff, +0x010101ffff010101,0x010101ff0000ff00,0x010101ff000000ff,0x010101ff00000001,0x010101ff00000100,0x010101ff01ffffff,0x010101ff01ffff01,0x010101ff01ff01ff, +0x010101ff01ff0101,0x010101ff01000000,0x010101ff0101ffff,0x010101ff0101ff01,0x010101ff010101ff,0x010101ff01010101,0x01010100ffff0000,0x01010100ff0000ff, +0x01010100ff000100,0x01010100ff01ff00,0x01010100ff010000,0x0101010000ffff00,0x010101000000ffff,0x0101010000000000,0x0101010000000101,0x010101000001ff00, +0x0101010000010001,0x0101010000010100,0x010101000100ffff,0x0101010001000001,0x01010101ffffffff,0x01010101ffffff01,0x01010101ffff01ff,0x01010101ffff0101, +0x01010101ff01ffff,0x01010101ff01ff01,0x01010101ff0101ff,0x01010101ff010101,0x010101010000ff00,0x01010101000000ff,0x0101010100000001,0x0101010101ffffff, +0x0101010101ffff01,0x0101010101ff01ff,0x0101010101ff0101,0x0101010101000000,0x010101010101ffff,0x010101010101ff01,0x01010101010101ff,0x0101010101010101, ]; diff --git a/scripts/dev/split_module.py b/scripts/dev/split_module.py index 3d09f6b6..34462271 100644 --- a/scripts/dev/split_module.py +++ b/scripts/dev/split_module.py @@ -51,7 +51,7 @@ def path_targets(): def process(path, target, dry_run, loaded, allow_root=False): - if is_root(path) and not (allow_root and path.name == "lib.rs"): + if is_root(path) and not (allow_root and path.name in ("lib.rs", "main.rs") or "examples" in path.parts and path.name == "main.rs"): return "skipped", "crate root, bin or example" directory = child_dir(path) # a file loaded through `#[path]`, or an integration test crate root (tests/foo.rs): `mod x;` would look beside it diff --git a/tools/kernel-ab/README.md b/tools/kernel-ab/README.md index 452a8eb7..19499d94 100644 --- a/tools/kernel-ab/README.md +++ b/tools/kernel-ab/README.md @@ -17,7 +17,7 @@ production, and Python is used offline only (`verify_manifest.py`, standard libr | `time_smoke.sh` | STRA-317 acceptance in one command (time, verify, A/A); last line `TIME SMOKE OK` | The `time` mode (resident / streamed regimes, clock calibration, A/A control) is STRA-317 (S0.8a2): section "Timing" below. -The Rust half (`examples/kernel_ab.rs`, reader, comparison, alternation) is STRA-289. +The Rust half (`examples/kernel_ab/main.rs`, reader, comparison, alternation) is STRA-289. ## Why a Makefile and not CMake