============================================================================================== DEVICE: NVIDIA GeForce RTX 5090 (sm_120, 170 SMs) UUID=GPU-9910bc89-2f86-4c0e-2108-c2872beeb239 Mainstream Open-Source Quantiser `lop3.b32` Superoptimization & Benchmark ============================================================================================== [Candidate 1] llama.cpp Q2_K Unsigned 2-Bit Extract `(qs >> s) & 0x03030303`: -> VERDICT: HONEST KILL (Already PTX/SASS-Optimal at `nvcc -O3`: 1 SHR + 1 AND = 1 logic gate). Moved immediately to Candidate 2 (BitNet b1.58 I2_S / TQ2_0) & Candidate 3 (llama.cpp Q3_K)! [Superoptimizer Search] Exhaustive GPU 3-LUT Search over (ia, ib, ic, imm8): BitNet I2_S Output p0 (trit0 pos MAC) (TT=0x44441111): min_E=0 in 1 lop3.b32 gate! (solutions=6, witness imm8=0x09, inputs=(0,1,4)) BitNet I2_S Output n0 (trit0 neg MAC) (TT=0x11114444): min_E=0 in 1 lop3.b32 gate! (solutions=6, witness imm8=0x06, inputs=(0,1,4)) BitNet I2_S Output p1 (trit1 pos MAC) (TT=0x0f00000f): min_E=0 in 1 lop3.b32 gate! (solutions=6, witness imm8=0x09, inputs=(2,3,4)) BitNet I2_S Output n1 (trit1 neg MAC) (TT=0x000f0f00): min_E=0 in 1 lop3.b32 gate! (solutions=6, witness imm8=0x06, inputs=(2,3,4)) llama.cpp Q3_K Out mag0 (|w| bit 0) (TT=0xaaaa) : min_E=0 in 1 lop3.b32 gate! (solutions=370, witness imm8=0x80, inputs=(0,0,0)) llama.cpp Q3_K Out mag1 (|w| bit 1) (TT=0x6c6c) : min_E=0 in 1 lop3.b32 gate! (solutions=6, witness imm8=0x6A, inputs=(0,2,1)) llama.cpp Q3_K Out mag2 (|w| bit 2 == 4) (TT=0x0101) : min_E=0 in 1 lop3.b32 gate! (solutions=6, witness imm8=0x01, inputs=(0,1,2)) llama.cpp Q3_K Out s_neg (h ^ act) (TT=0x0ff0) : min_E=0 in 1 lop3.b32 gate! (solutions=108, witness imm8=0x18, inputs=(2,3,3)) [Exhaustive Bit-Exact Check] PASS (0 mismatches across 32 BitNet 5-input states, 81 BitNet int8x4 states, and 4,096 Q3_K int8x4 states)! [Isolated SM Cycle Microbenchmark (clock64(), 50 trials x 1024 loop iterations)]: 1. BitNet b1.58 I2_S Dual-Trit Bit-Sliced MAC (14-op 2-input vs 4-lop3.b32): Incumbent (14 gates) : 34.21 +/- 0.00 cycles/iter Superopt ( 4 lop3) : 27.22 +/- 0.00 cycles/iter | +20.44% cycle reduction (1.26x faster)! 2. BitNet b1.58 I2_S / TQ2_0 int8x4 __dp4a Unpacker (__vsub4 vs 2-lop3 + IMAD, 16 weights/iter): Incumbent (__vsub4) : 54.22 +/- 0.00 cycles/iter Superopt (2-lop3) : 54.24 +/- 0.00 cycles/iter | -0.04% cycle reduction (1.00x faster)! 3. llama.cpp Q3_K 3-Bit Signed int8x4 __dp4a Unpacker (__vsub4 vs 2-lop3 0x40/0xEC + IMAD, 16 weights/iter): Incumbent (__vsub4) : 54.25 +/- 0.00 cycles/iter Superopt (2-lop3) : 51.24 +/- 0.00 cycles/iter | +5.54% cycle reduction (1.06x faster)! [End-to-End Mainstream Quantiser GEMV Kernel Benchmarks (nvcc -O3, B=4 & B=16)]: [BitNet b1.58 I2_S / TQ2_0 Bit-Sliced GEMV 4096x14336 B=4] mismatches=0/16384 Incumbent (14-gate two-stage unpack+MAC) : 0.0148 +/- 0.0004 ms | 997.3 GB/s Superopt (4-lop3.b32 @ imm8=0x41/0x14) : 0.0148 +/- 0.0007 ms | 992.9 GB/s | -0.44% faster (0.996x)! [BitNet b1.58 I2_S / TQ2_0 int8x4 __dp4a GEMV 4096x14336 B=4] mismatches=0/16384 Incumbent (__vsub4, 7-inst/4w) : 0.0151 +/- 0.0008 ms | 973.5 GB/s Superopt (lop3 0xEA + bias-XOR, 3-inst) : 0.0155 +/- 0.0002 ms | 951.9 GB/s | -2.27% faster (0.978x)! [llama.cpp Q3_K 3-Bit Signed GEMV 4096x14336 B=4] mismatches=0/16384 Incumbent (__vsub4, 9-inst/4w) : 0.0155 +/- 0.0004 ms | 1894.9 GB/s Superopt (2-lop3 0xEA/0x30 + bias-XOR) : 0.0175 +/- 0.0006 ms | 1677.7 GB/s | -12.95% faster (0.885x)! [BitNet b1.58 I2_S / TQ2_0 Bit-Sliced GEMV 8192x8192 B=4] mismatches=0/32768 Incumbent (14-gate two-stage unpack+MAC) : 0.0149 +/- 0.0004 ms | 1125.7 GB/s Superopt (4-lop3.b32 @ imm8=0x41/0x14) : 0.0149 +/- 0.0001 ms | 1129.1 GB/s | +0.30% faster (1.003x)! [BitNet b1.58 I2_S / TQ2_0 int8x4 __dp4a GEMV 8192x8192 B=4] mismatches=0/32768 Incumbent (__vsub4, 7-inst/4w) : 0.0150 +/- 0.0005 ms | 1116.9 GB/s Superopt (lop3 0xEA + bias-XOR, 3-inst) : 0.0155 +/- 0.0001 ms | 1084.0 GB/s | -3.04% faster (0.970x)! [llama.cpp Q3_K 3-Bit Signed GEMV 8192x8192 B=4] mismatches=0/32768 Incumbent (__vsub4, 9-inst/4w) : 0.0156 +/- 0.0005 ms | 2149.3 GB/s Superopt (2-lop3 0xEA/0x30 + bias-XOR) : 0.0176 +/- 0.0004 ms | 1910.4 GB/s | -12.50% faster (0.889x)! [BitNet b1.58 I2_S / TQ2_0 Bit-Sliced GEMV 4096x14336 B=16] mismatches=0/65536 Incumbent (14-gate two-stage unpack+MAC) : 0.0496 +/- 0.0009 ms | 300.9 GB/s Superopt (4-lop3.b32 @ imm8=0x41/0x14) : 0.0485 +/- 0.0006 ms | 307.5 GB/s | +2.16% faster (1.022x)! [BitNet b1.58 I2_S / TQ2_0 int8x4 __dp4a GEMV 4096x14336 B=16] mismatches=0/65536 Incumbent (__vsub4, 7-inst/4w) : 0.0320 +/- 0.0003 ms | 466.3 GB/s Superopt (lop3 0xEA + bias-XOR, 3-inst) : 0.0320 +/- 0.0006 ms | 465.9 GB/s | -0.08% faster (0.999x)! [llama.cpp Q3_K 3-Bit Signed GEMV 4096x14336 B=16] mismatches=0/65536 Incumbent (__vsub4, 9-inst/4w) : 0.0322 +/- 0.0007 ms | 919.5 GB/s Superopt (2-lop3 0xEA/0x30 + bias-XOR) : 0.0279 +/- 0.0002 ms | 1061.4 GB/s | +13.37% faster (1.154x)! ============================================================================================== ALL MAINSTREAM QUANTISER LOP3 BENCHMARKS PASSED (0 MISMATCHES)