okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
60d431e2a
main
1"""The picture reader's GPU gate reads our tower against the float32 reference (VitRef), not against llama.cpp's reader. 2 3tools/vision/own/gate_gpu.py: rule 1 = cosine(own GPU, float32) >= 0.999, rule 2 = no further from float32 than mtmd's GPU reader (1e-4 slack, or >= 0.9999). 4The numbers are code4217.png at 1,024 picture tokens, measured on 11-14 (RTX PRO 5000 and a Zen 3 CPU, Qwen3.8 BF16 mmproj). 5""" 6 7import importlib .util 8import unittest 9from pathlib import Path 10 11GATE = Path (__file__ ).resolve ().parents [2 ]/ "tools" / "vision" / "own" / "gate_gpu.py" 12 13 14def load_gate (): 15spec = importlib .util .spec_from_file_location ("gate_gpu" ,GATE ) 16mod = importlib .util .module_from_spec (spec ) 17spec .loader .exec_module (mod ) 18return mod 19 20 21class VisionGateRuleTest (unittest .TestCase ): 22def setUp (self ): 23self .g = load_gate () 24 25def test_code4217_float32_is_the_reference (self ): 26mtmd_gpu = 0.999029 # mtmd's GPU reader against float32 on code4217 (the floor) 27self .assertTrue (self .g .gate_pass (1.000000 ,mtmd_gpu ))# our tower without input rounding equals float32 28self .assertFalse (self .g .gate_pass (0.998392 ,mtmd_gpu ))# our CUDA tower with BF16 inputs: under rule 1 against float32 29self .assertFalse (self .g .gate_pass (0.998312 ,mtmd_gpu ))# our CPU tower with the old BF16 rounding default: under rule 1 30 31def test_rule_two_against_the_mtmd_floor (self ): 32self .assertTrue (self .g .gate_pass (0.99920 ,0.99925 ))# inside the 1e-4 slack 33self .assertFalse (self .g .gate_pass (0.99920 ,0.99940 ))# further from float32 than mtmd's GPU reader 34self .assertTrue (self .g .gate_pass (0.99990 ,1.0 ))# 0.9999 passes whatever the floor 35 36def test_largest_pictures_compare_the_gpu_readers (self ): 37self .assertTrue (self .g .gate_pass (0.995 ,1.0 ,skip_cpu = True )) 38self .assertFalse (self .g .gate_pass (0.985 ,1.0 ,skip_cpu = True )) 39 40def test_mtmd_is_information_only (self ): 41src = GATE .read_text (encoding = "utf-8" ) 42self .assertIn ('"STRATA_VIT_CPU": "ref"' ,src )# the reference reader the gate starts where --ref-dir lacks a picture 43self .assertIn ("own/mtmdC" ,src )# mtmd's CPU path stays a printed column 44 45 46if __name__ == "__main__" : 47unittest .main ()