---
title: HAGI-DeepSeek-V4-Flash-0731-2M
canonical_url: "https://www.modelscope.ai/models/svyatoblood/HAGI-DeepSeek-V4-Flash-0731-2M"
md_url: "https://www.modelscope.ai/models/svyatoblood/HAGI-DeepSeek-V4-Flash-0731-2M.md"
repository: svyatoblood/HAGI-DeepSeek-V4-Flash-0731-2M
last_updated: 2026-09-11
license: mit
model_type:
  - deepseek_v4
architectures:
  - DeepseekV4ForCausalLM
base_model:
  - deepseek-ai/DeepSeek-V4-Flash-0731
base_model_relation: quantized
parameters: 93.9B
tensor_type:
  - U8
  - F32
  - F16
  - I64
  - F8_E8M0
  - BF16
library_name:
  - safetensors
downloads: 184
stars: 0
tags:
  - moe
  - quantization
  - ternary-weights
  - gptq
  - telescopic-calibration
---

# HAGI-DeepSeek-V4-Flash-0731-2M

> HAGI-DeepSeek-V4-Flash-0731-2M - An open-source model by svyatoblood on ModelScope. HAGI terni4-v2: DeepSeek-V4-Flash

svyatoblood/HAGI-DeepSeek-V4-Flash-0731-2M is a 93.9B-parameter machine learning model on ModelScope. licensed under mit. derived from deepseek-ai/DeepSeek-V4-Flash-0731.

- **Repository**: svyatoblood/HAGI-DeepSeek-V4-Flash-0731-2M
- **License**: mit
- **Parameters**: 93.9B
- **Base model**: deepseek-ai/DeepSeek-V4-Flash-0731
- **Tags**: moe, quantization, ternary-weights, gptq, telescopic-calibration
- **Downloads**: 184
- **Stars**: 0
- **Last updated**: 2026-09-11

Source: https://www.modelscope.ai/models/svyatoblood/HAGI-DeepSeek-V4-Flash-0731-2M

---

# HAGI terni4-v2: DeepSeek-V4-Flash

Bit-exact-evaluated ternary compression of DeepSeek-V4-Flash-0731 MoE
experts: 43 layers × 256 routed experts, ternary W1/W3 (5 trits/byte,
g128 scales) + int4 W2 (g128), with coherent end-to-end generation validated on the full stack.

**Every routed expert was fitted on activations drifted through the
already-compressed prefix (telescopic calibration)** — layer-1 drift-fit
measured 0.73% vs 13.46% clean-fit (18×). Honest 20% held-out residual
in every expert file; dead experts (zero routed rows) are
SVD-self-synthesized from their own W1 subspaces, not pool-distilled.

## Layout

```
skeleton/            attention + embeddings + LM head (original bf16)
routers.safetensors  per-layer MoE router tables (from the original)
layers/layer{L}.safetensors  43 × ~2.0 GB:
    w13t  u8 [256,4096,820]  ternary W1|W3 (5 trits/byte)
    s13   f32 [256,4096,32]  per-(row,group) scales g128
    b13   f32 [256,4096]     biases
    w2a   u8 [256,4096,1024] int4 packed W2
    s2    f32 [256,4096,16]  W2 scales
    P f16 [4096,4096], mu f32[4096]   per-layer POD rotation/centering
    n_real/n_val u8[256], resid f32[256]  per-expert provenance
tokenizer/           DeepSeek tokenizer (MIT, from the original snapshot)
hagi_load.py         self-contained loader — no other code needed
kv_int8_scales.pt    optional: per-channel int8 KV scales (compressed stack)
```

## Quick start

```python
from hagi_load import load_compressed_model, generate, install_int8_kv
model, tok = load_compressed_model(".")          # this directory
text = generate(model, tok, "The capital of France is Paris.", 60)
# optional: HAGI_KV_INT8=1 env → install_int8_kv(model) for 2× KV memory
```

GPU memory: banks stream with LRU eviction (HAGI_BANK_BUDGET, default
60 GB — stable on a 107 GB APU; raise on bigger GPUs, ~92 GB holds the
whole stack). The first token takes ~3 min (model load + banks); decode
is launch-bound on consumer GPUs (~0.2 tok/s on the reference box).

## Validation summary

- Full-stack e2e: coherent factual generation (EN/RU capital chains).
- Per-expert honest val residual: median 0.8% (L18) → ~24% (L36+);
  the residual stream absorbs per-expert error at generation time.
- Decode quality is quality-neutral wrt bf16 KV cache (int8 KV A/B).
- Rejected by measurement (do not retry): whitening, frozen scales,
  h/y rotations (QuIP#), sign branches, k-means codebooks, channel
  rescaling W3↔W2 (provably invariant), KL-Root-Kron, act_order,
  POD-KV (KV is near full-rank).

## License

Weights derivative of DeepSeek-V4-Flash-0731 (MIT). This packaging:
MIT. The compression recipe and loader: see the HAGI project repo https://github.com/ShmidtS/HAGI_v2
