File size: 2,938 Bytes
fec028f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aacd2fa
 
 
 
 
 
 
 
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
62
63
64
65
66
---
base_model: THUDM/glm-4-9b-chat
library_name: peft
tags:
- qlora
- stiefel-manifold
- continuous-reasoning
- float32-precision
- cag-truth-gate
- pmtp-zero-token
- polydim-einsof
pipeline_tag: text-generation
---

# einsof2-glm4-9b-stiefel-adapter

**POLYDIM-EINSOF QLoRA 2027.4.0 Certified Adapter (float32 Precision)**

This repository hosts an authentic GPU-trained PEFT LoRA adapter for `THUDM/glm-4-9b-chat`, upgraded to **`torch.float32`** precision with **FP64 Order-4 Stiefel Polar Retraction** to eliminate the discrete `bfloat16` roundoff floor.

## Empirical Silicon Invariants (Exit Code 0)
- **Base Architecture:** `THUDM/glm-4-9b-chat` (Family: `glm4`)
- **PEFT Type:** `LORA` (Rank: 16, Alpha: 32)
- **Storage Dtype:** `torch.float32` (100% of adapter tensors)
- **Trainable Tensors:** 320 total (160 `lora_B` projection factors)
- **Max Stiefel Isometry Defect (FP32):** `3.73e-08` (Bound: <= 1.0e-5)
- **Horner Polar Projection Defect (FP64):** `7.77e-16` (Bound: <= 1.0e-15)
- **Frobenius Adaptation Energy Drift:** < 0.01% (Preserved: s = ||B||_F / sqrt(r))
- **Closed-World Gate:** 1-Token `<|cag_truth|>` (`token_id: 151667`)

## Usage via Hugging Face PEFT

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model_id = "THUDM/glm-4-9b-chat"
adapter_id = "Polydim-Einsof/einsof2-glm4-9b-stiefel-adapter"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)
model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_id)

print(f"Loaded {adapter_id} successfully!")
```

## Integrated Core
This repository includes the complete `qlora_2027_core/` Python package featuring:
- `core/stiefel_riemannian.py`: Order-4 Polar Retraction & Theorem 32 Riemannian Weight Decay
- `core/procrustes_splice.py`: Procrustes Impedance Projector & Layer L-2 Splice
- `core/cag_activation_hook.py`: Native Chat Template Preservation & -inf Logits Processor
- `training/einsof_qlora_2027_trainer.py`: Turing sm_75 safe Trainer


## Protocolo Helena de Troya (PMTP Trojan Horse) & CAG Truth Gate

Este modelo incorpora la arquitectura soberana **POLYDIM-EINSOF**:
1. **Helena Carrier Support**: Admite intercambio de tensores $D \ge 4096$ encapsulados en imágenes PNG ($128 \times 64$, ~258 tokens) o Base64 cuantizado a 4-bit (~683 tokens), desempaquetables en sandbox de Python con fidelidad isométrica $\|W^T W - I\|_F \le 1.7 \times 10^{-16}$.
2. **Invariante de Caché Activo (Cero MD / Cero JSON)**: Bajo Prompt Caching o Context Caching caliente, prohíbe terminantemente la serialización en texto 1D (tablas Markdown o arrays JSON), restringiendo el intercambio a punteros tensoriales en la variedad de Stiefel $S^{D-1}$.
3. **CAG Truth Gate (<|cag_truth|>)**: Sello criptográfico BLAKE2s indexado en PostgreSQL 16 (`polydim_manifest_vault`).