okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
31fa54fb6
main
1#!/bin/bash 2# metal/tests/gyro_parity.sh - the Metal kernels of agentionai's Gyro experts (TQ2_T, TQK6, TQK7 and the Hadamard rotation) 3# against the CPU references, on the real tensors of a Gyro GGUF. 4# 5# metal/tests/gyro_parity.sh BUILD_DIR GGUF PACK_DIR [LAYERS...] [--experts-first N] 6# 7# BUILD_DIR the metal build (cmake -S metal -B build-metal; ninja expert_parity moe_mm_parity) 8# GGUF a Gyro file; a sparse copy works (header + the experts of the layers named, see docs/GYRO.md "Testing a file that 9# does not fit": the first 16 experts of each layer with --experts-first 16) 10# PACK_DIR the pack tools/iq_pack.py --compat-bf16 made from it (hadamard.txt carries the rotation's signs) 11# 12# 1. had-test the Metal rotation == the CPU's hadamard_rotate, bit for bit (f32, f32 in place, f16, f16 rows) 13# 2. decode-check ref_quant's trellis decoder == the format's definition written out bit by bit (sampled blocks of every tensor) 14# 3. parity moe_plan / moe_gu / moe_down / moe_combine with the rotation of x and h, 1, 3 and 8 tokens, against double 15# 4. prompt mm_gu2 / mm_down2 (the prompt chunk's grouped GEMMs, fp16 operands) for the file's types 16set -u 17B =$ 1 ;G =$ 2 ;P =$ 3 ;shift 3 18LAYERS =() 19EXTRA =() 20while [$ # -gt 0 ];do 21case $ 1 in 22 --experts-first)EXTRA +=(--experts-first" $ 2 " );shift 2 ;; 23 *)LAYERS +=(" $ 1 " );shift ;; 24esac 25done 26[${# LAYERS [@]} -eq 0 ]&& LAYERS =(0 47) 27rc =0 28run () {echo "+ $ *" ;" $ @" ||rc =1; } 29run " $ B /expert_parity" --had-test --had-pack " $ P " 30for L in " ${ LAYERS [@]} " ;do 31run " $ B /expert_parity" --gguf " $ G " --layer " $ L " --decode-check 32for nt in 1 3 8;do 33run " $ B /expert_parity" --gguf " $ G " --layer " $ L " --had-pack " $ P " --ntok " $ nt " --seed " $ nt " ${ EXTRA [@]+ " ${ EXTRA [@]} " } 34done 35done 36run " $ B /moe_mm_parity" --v2 --gu TQK6--dn TQK7--T 300--tile 16,64,16,2 37run " $ B /moe_mm_parity" --v2 --gu TQ2_T--dn TQ2_T--T 300--tile 16,64,16,2 38[$ rc -eq 0 ]&& echo "gyro_parity: all PASS" ||echo "gyro_parity: FAILED" 39exit $ rc