Portuguese
mamba
mamba-3
ssm
muon
muonclip
qk-clip
adamw
optimizer
nope
hybrid-architecture
activation-checkpointing
3d-vision-language
depth-perception
point-cloud
diffusion
stable-diffusion
mixture-of-experts
kohonen
som-attention
random-forest
deep-neural-network
knowledge-distillation
bidirectional-distillation
engram-memory
multimodal
multi-token-prediction
dpo
rlhf
hh-rlhf
pcgrad
long-context
lra-qvit
engineer-agent
integral-state
cython
jev-classifiers
gumbel-softmax
quantization
riemannian-optimization
stiefel-manifold
cython-kernels
gradient-accumulation
vector-quantization
grayscale-detection
joint-perception
self-regulation
signal-table
abmo
ciar
growing-som
pt-br
KHTST v19 — acoplamento JEPA↔encoders de produção (vistas de tokens com pesos compartilhados, gradiente exato no encoder real Teo 31.2, conselho renormalizado 31.3, alvo EMA pós-step com guarda 31.6) + SonicMoE no tronco opt-in (dispatch agrupado+tiles, equivalência sônico≡vetorial Δy≤7.1e-8 Teo 31.4, roofline honesto 31.5, pilha evitada 2.21MB/forward) + A/B/C PAREADO em dados reais 1015 registros com pareamento exato por RNG dedicado (Teo 31.7; ΔCE monótono em λ; JEPA acoplada −74%) + doc 31 (Teos 31.1–31.7) + suíte v19 34/34 + regressão v1–v18 zero; sem estados de treino; sem segredos
546119a verified Download scripts/26_publicar_v19.py from PowerMachine/khtst-multimodal-ptbr: direct link, hf CLI and curl.
- Browser
- Download file 7.82 kB
-
https://huggingface.co/PowerMachine/khtst-multimodal-ptbr/resolve/main/scripts/26_publicar_v19.py
- Command line
-
hf download hf://PowerMachine/khtst-multimodal-ptbr/scripts/26_publicar_v19.py
-
curl -L -o 26_publicar_v19.py https://huggingface.co/PowerMachine/khtst-multimodal-ptbr/resolve/main/scripts/26_publicar_v19.py
7.82 kB
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """Publica o KHTST v19 no HuggingFace — UM ÚNICO COMMIT COMPLETO | |
| (anti-bloqueio do Hub: `upload_folder` + `delete_patterns=["*"]` | |
| substitui ATOMICAMENTE todo o conteúdo; nunca há uploads parciais em | |
| sequência curta). | |
| INCLUI: README (card v19) · LICENSE · requirements · configs/ · src/khtst/ | |
| (COM jepa_familia/acoplamento.py NOVO, moe.py com forward_sonico, | |
| treinador com conselho acoplado, ipc/, kernels .pyx/.c/.so) · scripts/ · | |
| docs/matematica/ (provas 00–31) · tests/ (v1–v19) · patches/ · | |
| PLANO_KHMAMBAJEPA.md · RELATORIO_KHTST.md · graficos/v19. | |
| EXCLUI: venv/ · __pycache__ · cache_dados · telemetria_out · | |
| cache_hub_tmp · .git · build · estados*/ · stage*/ · qualquer | |
| `.pt/.pth/.ckpt/.safetensors` (REQUISITO: nenhum estado de treino no | |
| Hub) · qualquer arquivo com padrão de token. | |
| SEGURANÇA: token EXCLUSIVAMENTE da variável de ambiente HF_TOKEN — | |
| nunca gravado em arquivo, log, repo ou remote URL. | |
| Uso: HF_TOKEN=hf_... python3 scripts/26_publicar_v19.py [--repo ...] | |
| """ | |
| import argparse | |
| import os | |
| import re | |
| import shutil | |
| import sys | |
| RAIZ = "/home/z/my-project/khtst" | |
| STAGE = "/home/z/my-project/khtst/stage_publicar_v19" | |
| IGNORAR_DIRS = {"__pycache__", "cache_dados", "telemetria_out", | |
| "cache_hub_tmp", ".git", "build", "venv", ".venv", | |
| "estados_local", "estados_local_teste", "estados", | |
| "stage_publicar", "stage_publicar_v17", | |
| "stage_publicar_v18", "stage_publicar_v19", "hf_stage", | |
| "download", "upload", "node_modules"} | |
| IGNORAR_EXT = (".pt", ".pth", ".ckpt", ".safetensors", ".pyc", ".pt.tmp", | |
| ".bin") | |
| PADRAO_TOKEN = re.compile(r"hf_[A-Za-z0-9]{30,}") | |
| RESIDUOS_PROIBIDOS = ("bugwatch",) | |
| def preparar_stage() -> int: | |
| if os.path.exists(STAGE): | |
| shutil.rmtree(STAGE) | |
| n = 0 | |
| for raiz, dirs, arquivos in os.walk(RAIZ): | |
| dirs[:] = [d for d in dirs if d not in IGNORAR_DIRS] | |
| rel = os.path.relpath(raiz, RAIZ) | |
| alvo_raiz = os.path.join(STAGE, rel) if rel != "." else STAGE | |
| os.makedirs(alvo_raiz, exist_ok=True) | |
| for a in arquivos: | |
| if a.endswith(IGNORAR_EXT) or a.startswith("."): | |
| continue | |
| if any(r in a.lower() for r in RESIDUOS_PROIBIDOS): | |
| print(f" [RESÍDUO] ignorado: {a}") | |
| continue | |
| origem = os.path.join(raiz, a) | |
| destino = os.path.join(alvo_raiz, a) | |
| shutil.copy2(origem, destino) | |
| n += 1 | |
| return n | |
| def auditar_stage(n: int) -> list[str]: | |
| problemas = [] | |
| for raiz, dirs, arquivos in os.walk(STAGE): | |
| for a in arquivos: | |
| caminho = os.path.join(raiz, a) | |
| try: | |
| if PADRAO_TOKEN.search(open(caminho, "rb").read() | |
| .decode("utf-8", "ignore") or ""): | |
| problemas.append(f"TOKEN em {caminho}") | |
| except Exception: | |
| pass | |
| if a.endswith((".pt", ".pth", ".ckpt", ".safetensors", ".bin")): | |
| problemas.append(f"ESTADO em {caminho}") | |
| chaves = [ | |
| # v19 — acoplamento + SonicMoE tronco | |
| "src/khtst/jepa_familia/acoplamento.py", | |
| "src/khtst/percepcao/moe.py", | |
| "src/khtst/config.py", | |
| "configs/base.json", | |
| "scripts/24_teste_v19.py", | |
| "scripts/25_graficos_v19.py", | |
| "graficos/v19/v19_evidencias.png", | |
| "docs/matematica/31-v19-acoplamento-jepa-sonicmoe.md", | |
| "tests/test_khtst_v19.py", | |
| # regressão de conteúdo (v18/v17/v16) | |
| "src/khtst/jepa_familia/variantes.py", | |
| "src/khtst/jepa_familia/sonicmoe.py", | |
| "src/khtst/ipc/khtst_ipc.pyx", | |
| "src/khtst/ipc/khtst_ipc.cpython-312-x86_64-linux-gnu.so", | |
| "src/khtst/acelerado/mc_jepa.pyx", | |
| "src/khtst/treino/treinador.py", | |
| "docs/matematica/30-v18-robustez-ipc-familia-jepa.md", | |
| "docs/matematica/29-autorregulacao-hibrida-aprimoramentos.md", | |
| "patches/jepa.py", | |
| "PLANO_KHMAMBAJEPA.md", "RELATORIO_KHTST.md", "README.md", | |
| ] | |
| for c in chaves: | |
| if not os.path.exists(os.path.join(STAGE, c)): | |
| problemas.append(f"FALTA chave: {c}") | |
| if n < 150: | |
| problemas.append(f"stage pequeno demais: {n} arquivos") | |
| return problemas | |
| def publicar(repo_id: str) -> None: | |
| from huggingface_hub import HfApi | |
| token = os.environ.get("HF_TOKEN") | |
| if not token: | |
| print("ERRO: HF_TOKEN ausente no ambiente") | |
| sys.exit(1) | |
| api = HfApi(token=token) | |
| # UM commit completo e atômico (anti-bloqueio — nada parcial em sequência) | |
| api.upload_folder( | |
| folder_path=STAGE, | |
| repo_id=repo_id, | |
| repo_type="model", | |
| commit_message=("KHTST v19 — acoplamento JEPA↔encoders de produção " | |
| "(vistas de tokens com pesos compartilhados, " | |
| "gradiente exato no encoder real Teo 31.2, conselho " | |
| "renormalizado 31.3, alvo EMA pós-step com guarda " | |
| "31.6) + SonicMoE no tronco opt-in (dispatch " | |
| "agrupado+tiles, equivalência sônico≡vetorial " | |
| "Δy≤7.1e-8 Teo 31.4, roofline honesto 31.5, pilha " | |
| "evitada 2.21MB/forward) + A/B/C PAREADO em dados " | |
| "reais 1015 registros com pareamento exato por RNG " | |
| "dedicado (Teo 31.7; ΔCE monótono em λ; JEPA " | |
| "acoplada −74%) + doc 31 (Teos 31.1–31.7) + suíte " | |
| "v19 34/34 + regressão v1–v18 zero; sem estados de " | |
| "treino; sem segredos"), | |
| delete_patterns=["*"], | |
| ) | |
| print(f"upload concluído → https://huggingface.co/{repo_id}") | |
| def auditar_hub(repo_id: str) -> None: | |
| from huggingface_hub import HfApi | |
| api = HfApi(token=os.environ.get("HF_TOKEN")) | |
| arquivos = api.list_repo_files(repo_id, repo_type="model") | |
| print(f"arquivos no Hub: {len(arquivos)}") | |
| estados = [a for a in arquivos if a.endswith( | |
| (".pt", ".pth", ".ckpt", ".safetensors", ".bin"))] | |
| print("estados de treino no Hub:", len(estados), estados[:5]) | |
| chaves = ["src/khtst/jepa_familia/acoplamento.py", | |
| "src/khtst/percepcao/moe.py", | |
| "scripts/24_teste_v19.py", | |
| "scripts/25_graficos_v19.py", | |
| "graficos/v19/v19_evidencias.png", | |
| "docs/matematica/31-v19-acoplamento-jepa-sonicmoe.md", | |
| "tests/test_khtst_v19.py", | |
| "src/khtst/jepa_familia/variantes.py", | |
| "src/khtst/ipc/khtst_ipc.pyx", | |
| "PLANO_KHMAMBAJEPA.md", "README.md"] | |
| for c in chaves: | |
| print((" ✓ " if c in arquivos else " ✗ FALTA ") + c) | |
| residuos = [a for a in arquivos if "bugwatch" in a.lower()] | |
| print("resíduos:", len(residuos)) | |
| deprecados = [a for a in arquivos if "stage_publicar" in a | |
| or "/fase-v" in a] | |
| print("deprecados/estados antigos:", len(deprecados), deprecados[:5]) | |
| ok = (len(estados) == 0 and not residuos and not deprecados | |
| and all(c in arquivos for c in chaves)) | |
| print("AUDITORIA DO HUB:", "APROVADA" if ok else "FALHOU") | |
| return 0 if ok else 1 | |
| if __name__ == "__main__": | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--repo", default="PowerMachine/khtst-multimodal-ptbr") | |
| args = ap.parse_args() | |
| n = preparar_stage() | |
| print(f"stage: {n} arquivos") | |
| problemas = auditar_stage(n) | |
| if problemas: | |
| print("AUDITORIA DO STAGE FALHOU:") | |
| for p in problemas: | |
| print(" -", p) | |
| sys.exit(1) | |
| print("stage OK") | |
| publicar(args.repo) | |
| raise SystemExit(auditar_hub(args.repo)) | |