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
File size: 2,464 Bytes
5e2c860 20672ab 5e2c860 20672ab 5e2c860 20672ab 5e2c860 20672ab 5e2c860 20672ab 5e2c860 20672ab 5e2c860 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # -*- coding: utf-8 -*-
"""KHTST IPC — comunicação Modelo→Modelo (v18, doc 30 §4; v21 doc 33 §1).
Cython PRIORITÁRIO: `khtst_ipc.KHTSTCanal` (compilado, atomics C11/GCC,
nogil) — fallback puro-Python honesto (`_fallback.KHTSTCanal`) quando o
.so não está compilado.
v21 (doc 33 §1, Teos 33.1/33.2 — requisito de refatoração 1): o crate Rust
foi REMOVIDO (3ª implementação redundante do mesmo ABI — DRY) e o layout
ganhou FONTE ÚNICA (`khtst/ipc/layout.py`) com DUAS camadas de verificação:
1. compile-time — `_Static_assert`s da struct espelho no .pyx (não
compila se o layout diverge);
2. import-time — a auditoria abaixo compara o binário com a fonte
única; um .so velho falha com erro explícito em vez de corromper
frames silenciosamente.
Uso mínimo (mesmo processo):
from khtst.ipc import KHTSTCanal
c1 = KHTSTCanal(b"demo", 4 * 1024 * 1024)
c2 = KHTSTCanal.anexar(c1.fd, 4 * 1024 * 1024)
c1.escrever(b"olá"); print(c2.ler())
Entre processos: `enviar_fd`/`receber_fd` (SCM_RIGHTS) — ver
scripts/21_teste_ipc.py (demo completo servidor×cliente com frames).
"""
from __future__ import annotations
import os
__all__ = ["KHTSTCanal", "MOTOR_IPC", "framing", "layout"]
MOTOR_IPC = "fallback"
try: # Cython prioritário (requisito)
try:
from khtst.ipc import khtst_ipc as _ext # build como pacote
except ImportError:
import khtst_ipc as _ext # build top-level
# v21 Teo 33.2 — auditoria FONTE ÚNICA ↔ binário (fatal no import)
from khtst.ipc import layout as _layout
_layout.auditar_ext(_ext)
KHTSTCanal = _ext.KHTSTCanal
MOTOR_IPC = "cython"
except Exception as e: # pragma: no cover — clone frio
_erro_cython = repr(e)
try:
from khtst.ipc._fallback import KHTSTCanal # noqa: F401
except Exception:
raise ImportError(
"khtst.ipc: nem o módulo Cython (khtst_ipc.so) nem o fallback "
"estão disponíveis — compile com: python setup.py build_ext "
f"--inplace (erro original: {_erro_cython})")
from khtst.ipc import framing # noqa: E402,F401
from khtst.ipc import layout # noqa: E402,F401
# FD exposto p/ o padrão de uso anexar(c1.fd, ...)
try:
KHTSTCanal.fd = property(lambda self: self._fd)
except Exception: # pragma: no cover
pass
|