v0.12.0: débitos r-43 quitados com prova (r-44/r-45) — escala por amostra certificável A.2 (contração real 1,246→0,948), A/B bug v011-1 (decorrel 47×, perda 4,8× melhor no corrigido), estimador TC por discriminador B.2, RE-3 prefixos NCM (busca binária + verificação direta; 99,7% dos bits do banco economizados, 0 rollbacks), gate em held-out V-3, checkpoints safetensors S-1 (pico de RAM 4,25× menor), autoajuste λ_vc por TC (T-ADJ) — 21/21 gates, 146/146 cargo
2ceda9d verified Download scripts/77_suite_v012.py from PowerMachine/khtst-rust: direct link, hf CLI and curl.
- Browser
- Download file 5.08 kB
-
https://huggingface.co/PowerMachine/khtst-rust/resolve/main/scripts/77_suite_v012.py
- Command line
-
hf download hf://PowerMachine/khtst-rust/scripts/77_suite_v012.py
-
curl -L -o 77_suite_v012.py https://huggingface.co/PowerMachine/khtst-rust/resolve/main/scripts/77_suite_v012.py
5.08 kB
| #!/usr/bin/env python3 | |
| """77_suite_v012.py — VEREDITO CONSOLIDADO v0.12 (r-44/r-45). | |
| Gates: | |
| 1. cargo test (lib + bins) — 3 execuções consecutivas; | |
| 2. unwraps do lib.rs = 0 (regressão v0.11); | |
| 3. gates REAIS do script 76 (resultados/treino_v012.json): | |
| escala por amostra, A/B v011-1, safetensors (RAM), RE-3, V-3, T-ADJ, | |
| elástico sound, SOM, H-SOM, fases; | |
| 4. telemetria: painel SIMD + ASSEMBLY. | |
| """ | |
| import json, os, re, subprocess, sys | |
| def main(): | |
| pasta = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, pasta) | |
| gates = {} | |
| # ---------------- 1. cargo (3x) ---------------- | |
| print("=== CARGO TEST (3 execuções) ===", flush=True) | |
| ok_cargo = 0 | |
| for i in range(3): | |
| cargo = os.path.expanduser("~/.cargo/bin/cargo") | |
| if not os.path.exists(cargo): | |
| cargo = "cargo" | |
| r = subprocess.run( | |
| [cargo, "test", "--release"], cwd=pasta, | |
| capture_output=True, text=True, timeout=1800) | |
| m = re.findall(r"test result: ok\. (\d+) passed", r.stdout) | |
| total = sum(int(x) for x in m) | |
| falhas = re.findall(r"test result: FAILED\. (\d+) failed", r.stdout) | |
| n_falhas = sum(int(x) for x in falhas) | |
| print(f" corrida {i+1}: {total} passaram, {n_falhas} falharam", flush=True) | |
| if r.returncode == 0 and n_falhas == 0 and total >= 146: | |
| ok_cargo += 1 | |
| gates["cargo_3x_146"] = ok_cargo == 3 | |
| # ---------------- 2. unwraps no lib.rs ---------------- | |
| src = open(os.path.join(pasta, "src", "lib.rs")).read() | |
| n_unwrap = len(re.findall(r"\.unwrap\(\)", src)) | |
| gates["lib_rs_zero_unwrap"] = n_unwrap == 0 | |
| print(f"=== UNWRAPS lib.rs: {n_unwrap} (esperado 0) ===", flush=True) | |
| # ---------------- 3. gates reais (script 76) ---------------- | |
| print("=== GATES REAIS (resultados/treino_v012.json) ===", flush=True) | |
| d = json.load(open(os.path.join(pasta, "resultados", "treino_v012.json"))) | |
| el = d["elastico_real"] | |
| q = el["quantizador"] | |
| es = q["escala_por_amostra"] | |
| r3 = el["elasticas"]["re3_prefixos"] | |
| ab = d["ab_v011_1"]["resumo"] | |
| ram = d["ram_s1"] | |
| tad = d["ab_v011_1"]["tad"] | |
| gates["a2_escala_melhorou"] = ( | |
| es["melhorou"] and es["fracao_m_negativo"] < 0.01 | |
| and es["contracao_medida_amostra"] <= q["contracao_cota_garantida"] + 0.05) | |
| gates["a2_contracao_abaixo_1"] = es["contracao_medida_amostra"] < 1.0 | |
| gates["ab_v011_1_decorrel_10x"] = ( | |
| ab["decorrel_bug"]["media"] > 10.0 * ab["decorrel_corrigido"]["media"]) | |
| gates["ab_v011_1_perda_nao_piora"] = ( | |
| ab["perda_pred_corrigido"]["media"] <= ab["perda_pred_bug"]["media"] * 1.05) | |
| gates["s1_ram_2x"] = (ram["razao_pico"] or 0) >= 2.0 | |
| gates["s1_safetensors_menor"] = ( | |
| ram["tamanho_mb"]["safetensors"] < ram["tamanho_mb"]["json"]) | |
| gates["re3_emitidos"] = r3["emitidos"] >= 5 | |
| gates["re3_sem_rollback_entregue"] = r3["rollbacks"] == 0 | |
| gates["re3_compressao_90"] = r3["compressao_frac"] < 0.10 | |
| gates["v3_curvas_completas"] = ( | |
| len(el["elasticas"]["curva_gate_conf_calibracao"]) == 5 | |
| and len(el["elasticas"]["curva_gate_conf_teste"]) == 5) | |
| gates["tad_lambda_dir_correta"] = tad["lambda_final"] < tad["lambda_inicial"] | |
| gates["elastico_sounds"] = ( | |
| el["elasticas"]["respostas_entregues_sounds"] == 24 | |
| and el["gates"]["gate_respostas_sounds"]) | |
| gates["elastico_aceite_min"] = el["elasticas"]["aceites"] >= 6 | |
| gates["fase_a_aprende"] = d["fases"]["a"]["perda_final"] < d["fases"]["a"]["perda_inicial"] | |
| gates["fase_b_aprende"] = d["fases"]["b"]["perda_final"] < d["fases"]["b"]["perda_inicial"] | |
| gates["fase_c_aprende"] = d["fases"]["c"]["ce_final"] < d["fases"]["c"]["ce_inicial"] | |
| gates["som_mediana_monotona"] = d["som_real"]["qe_mediana_monotono"] | |
| gates["som_mediana_melhora"] = ( | |
| d["som_real"]["mediana_dura"]["qe_final"] < d["som_real"]["media_suave"]["qe_final"]) | |
| gates["hsom_pin_teorema"] = d["hsom_real"]["pin_teorema_respeitado"] | |
| # telemetria: painel | |
| try: | |
| import khtst_rust as K | |
| painel = {"simd": K.simd_relatorio(), "asm": K.asm_relatorio()} | |
| except Exception as e: | |
| painel = {"erro": str(e)} | |
| n_ok = sum(1 for v in gates.values() if v) | |
| print(json.dumps(gates, indent=1, ensure_ascii=False), flush=True) | |
| print(f"painel: simd={painel.get('simd', {}).get('despacho', painel.get('simd'))} " | |
| f"asm={painel.get('asm')}", flush=True) | |
| print(f"VEREDITO v0.12: {n_ok}/{len(gates)} gates", flush=True) | |
| saida = { | |
| "versao": "0.12.0", | |
| "gates": gates, | |
| "n_ok": n_ok, | |
| "n_total": len(gates), | |
| "cargo_3x": ok_cargo, | |
| "unwraps_lib_rs": n_unwrap, | |
| "painel": painel, | |
| } | |
| with open(os.path.join(pasta, "resultados", "suite_v012_final.json"), "w") as f: | |
| json.dump(saida, f, indent=1, ensure_ascii=False) | |
| print("salvo: resultados/suite_v012_final.json", flush=True) | |
| if n_ok != len(gates): | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() | |