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/22_publicar_v17.py from PowerMachine/khtst-multimodal-ptbr: direct link, hf CLI and curl.
- Browser
- Download file 6.61 kB
-
https://huggingface.co/PowerMachine/khtst-multimodal-ptbr/resolve/main/scripts/22_publicar_v17.py
- Command line
-
hf download hf://PowerMachine/khtst-multimodal-ptbr/scripts/22_publicar_v17.py
-
curl -L -o 22_publicar_v17.py https://huggingface.co/PowerMachine/khtst-multimodal-ptbr/resolve/main/scripts/22_publicar_v17.py
6.61 kB
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """Publica o KHTST v17 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 v17) · LICENSE · requirements · configs/ · | |
| src/khtst/ (COM o pacote NOVO aprimoramento/ e os kernels Cython | |
| .pyx/.c/.so) · scripts/ · docs/matematica/ (provas 00–29) · tests/ | |
| (v1–v17) · patches/ · PLANO_KHMAMBAJEPA.md · RELATORIO_KHTST.md · | |
| graficos/ (evidências do card). | |
| 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 o 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/22_publicar_v17.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_v17" | |
| 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", "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 v17 presentes | |
| chaves = ["src/khtst/aprimoramento/__init__.py", | |
| "src/khtst/aprimoramento/controlador_hibrido.py", | |
| "src/khtst/aprimoramento/autorregulacao_estendida.py", | |
| "src/khtst/aprimoramento/difusao_gradiente.py", | |
| "src/khtst/aprimoramento/metricas_qe_ct.py", | |
| "src/khtst/aprimoramento/lambda_c_unificado.py", | |
| "src/khtst/aprimoramento/tradeoff_k.py", | |
| "src/khtst/aprimoramento/jepa.py", | |
| "src/khtst/aprimoramento/config.py", | |
| "docs/matematica/29-autorregulacao-hibrida-aprimoramentos.md", | |
| "tests/test_khtst_v17.py", | |
| "PLANO_KHMAMBAJEPA.md", "RELATORIO_KHTST.md", "README.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 | |
| api.upload_folder( | |
| folder_path=STAGE, | |
| repo_id=repo_id, | |
| repo_type="model", | |
| commit_message=("KHTST v17 — pacote aprimoramento (6 módulos " | |
| "refatorados, defeitos D1–D14 provados doc 29) + " | |
| "controlador HÍBRIDO RM+PI+bisseção + tabela de 18 " | |
| "sinais (AdamW/Muon/PRS/pesos/ABMO/CIAR/crescimento) " | |
| "com nascimento neutro e TelemetryHub total; suíte " | |
| "v17 56✓; regressão v1–v16 zero; Cython prioritário " | |
| "(VICReg delega ao kernel compilado); 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/aprimoramento/controlador_hibrido.py", | |
| "docs/matematica/29-autorregulacao-hibrida-aprimoramentos.md", | |
| "tests/test_khtst_v17.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() | |
| or a.endswith((".pyc",))] | |
| print("resíduos:", len(residuos)) | |
| 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") | |
| problemas = auditar_stage(n) | |
| if problemas: | |
| print("AUDITORIA FALHOU:") | |
| for p in problemas: | |
| print(" ✗", p) | |
| sys.exit(1) | |
| print("auditoria do stage OK (sem segredos, sem estados, chaves v17)") | |
| publicar(args.repo) | |
| auditar_hub(args.repo) | |