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 v18 — robustez provada (Teos 30.1–30.8: clamps Mamba-3, Muon wd espectral 1e-4, NS fp32 adaptativo, PCGrad normalizado por EMA, τ GSQ 0.5/400, guarda de ordem EMA, validar_config, telemetria com níveis+rotação) + treinador em 4 mixins+facade + IPC Modelo→Modelo Rust/Cython (memfd selável, ring SPSC lock-free, SCM_RIGHTS, CRC32; demo 2 processos) + família JEPA 10 variantes + ConselhoJepas multimodal + SonicMoE (IO/tiles) + ReplaySSM + hardware chinês NPU/MLU; suíte v18 46/46; regressão v1–v17 zero; sem estados de treino; sem segredos
5e2c860 verified Download scripts/23_publicar_v18.py from PowerMachine/khtst-multimodal-ptbr: direct link, hf CLI and curl.
- Browser
- Download file 8.97 kB
-
https://huggingface.co/PowerMachine/khtst-multimodal-ptbr/resolve/main/scripts/23_publicar_v18.py
- Command line
-
hf download hf://PowerMachine/khtst-multimodal-ptbr/scripts/23_publicar_v18.py
-
curl -L -o 23_publicar_v18.py https://huggingface.co/PowerMachine/khtst-multimodal-ptbr/resolve/main/scripts/23_publicar_v18.py
8.97 kB
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """Publica o KHTST v18 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 v18) · LICENSE · requirements · configs/ · | |
| src/khtst/ (COM ipc/ Rust+Cython e jepa_familia/ NOVOS, kernels | |
| .pyx/.c/.so) · scripts/ · docs/matematica/ (provas 00–30) · tests/ | |
| (v1–v18) · patches/ · PLANO_KHMAMBAJEPA.md · RELATORIO_KHTST.md. | |
| 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/23_publicar_v18.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_v18" | |
| 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", "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) | |
| # (i) segredos | |
| try: | |
| if PADRAO_TOKEN.search(open(caminho, "rb").read() | |
| .decode("utf-8", "ignore") or ""): | |
| problemas.append(f"TOKEN em {caminho}") | |
| except Exception: | |
| pass | |
| # (ii) estados de treino | |
| if a.endswith((".pt", ".pth", ".ckpt", ".safetensors", ".bin")): | |
| problemas.append(f"ESTADO em {caminho}") | |
| # (iii) arquivos-chave da v18 presentes | |
| chaves = [ | |
| # v18 — robustez | |
| "src/khtst/mamba3/kernel.py", | |
| "src/khtst/treino/otimizadores.py", | |
| "src/khtst/treino/cirurgia_grad.py", | |
| "src/khtst/treino/jepa.py", | |
| "src/khtst/nucleo/validacao.py", | |
| "src/khtst/telemetria/log_estruturado.py", | |
| "src/khtst/telemetria/hub.py", | |
| # v18 — refatoração | |
| "src/khtst/treino/treinador.py", | |
| "src/khtst/treino/treinador_lr.py", | |
| "src/khtst/treino/treinador_perdas.py", | |
| "src/khtst/treino/treinador_estado.py", | |
| "src/khtst/treino/treinador_fases.py", | |
| # v18 — IPC | |
| "src/khtst/ipc/__init__.py", | |
| "src/khtst/ipc/khtst_ipc.pyx", | |
| "src/khtst/ipc/khtst_ipc_abi.pxd", | |
| "src/khtst/ipc/framing.py", | |
| "src/khtst/ipc/_fallback.py", | |
| "src/khtst/ipc/setup.py", | |
| "src/khtst/ipc/khtst_ipc.cpython-312-x86_64-linux-gnu.so", | |
| "src/khtst/ipc/rust/Cargo.toml", | |
| "src/khtst/ipc/rust/src/lib.rs", | |
| "src/khtst/ipc/rust/src/ringbytes.rs", | |
| "src/khtst/ipc/rust/src/memfd.rs", | |
| "scripts/21_teste_ipc.py", | |
| # v18 — família JEPA | |
| "src/khtst/jepa_familia/__init__.py", | |
| "src/khtst/jepa_familia/base.py", | |
| "src/khtst/jepa_familia/variantes.py", | |
| "src/khtst/jepa_familia/conselho.py", | |
| "src/khtst/jepa_familia/sonicmoe.py", | |
| "src/khtst/jepa_familia/replayssm.py", | |
| "src/khtst/jepa_familia/dispositivo.py", | |
| # memória/provas/testes | |
| "docs/matematica/30-v18-robustez-ipc-familia-jepa.md", | |
| "tests/test_khtst_v18.py", | |
| "PLANO_KHMAMBAJEPA.md", "RELATORIO_KHTST.md", "README.md", | |
| # v17 (regressão de conteúdo) | |
| "src/khtst/aprimoramento/controlador_hibrido.py", | |
| "docs/matematica/29-autorregulacao-hibrida-aprimoramentos.md", | |
| "src/khtst/acelerado/mc_jepa.pyx", | |
| ] | |
| 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 v18 — robustez provada (Teos 30.1–30.8: " | |
| "clamps Mamba-3, Muon wd espectral 1e-4, NS fp32 " | |
| "adaptativo, PCGrad normalizado por EMA, τ GSQ " | |
| "0.5/400, guarda de ordem EMA, validar_config, " | |
| "telemetria com níveis+rotação) + treinador em 4 " | |
| "mixins+facade + IPC Modelo→Modelo Rust/Cython " | |
| "(memfd selável, ring SPSC lock-free, SCM_RIGHTS, " | |
| "CRC32; demo 2 processos) + família JEPA 10 " | |
| "variantes + ConselhoJepas multimodal + SonicMoE " | |
| "(IO/tiles) + ReplaySSM + hardware chinês " | |
| "NPU/MLU; suíte v18 46/46; regressão v1–v17 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/ipc/khtst_ipc.pyx", | |
| "src/khtst/ipc/rust/src/ringbytes.rs", | |
| "src/khtst/jepa_familia/variantes.py", | |
| "src/khtst/jepa_familia/sonicmoe.py", | |
| "src/khtst/jepa_familia/replayssm.py", | |
| "src/khtst/nucleo/validacao.py", | |
| "src/khtst/telemetria/log_estruturado.py", | |
| "src/khtst/treino/treinador_lr.py", | |
| "docs/matematica/30-v18-robustez-ipc-familia-jepa.md", | |
| "tests/test_khtst_v18.py", | |
| "scripts/21_teste_ipc.py", | |
| "PLANO_KHMAMBAJEPA.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 preparado: {n} arquivos") | |
| probs = auditar_stage(n) | |
| if probs: | |
| print("AUDITORIA DO STAGE FALHOU:") | |
| for p_ in probs: | |
| print(" -", p_) | |
| sys.exit(1) | |
| print("auditoria do stage OK (0 segredos, 0 estados, chaves v18 ✓)") | |
| publicar(args.repo) | |
| codigo = auditar_hub(args.repo) | |
| # limpeza do stage local (não fica resíduo) | |
| if os.path.exists(STAGE): | |
| shutil.rmtree(STAGE) | |
| print("stage local removido") | |
| sys.exit(codigo) | |