Downloads · 30 days
14
17% of all-time downloads
imbob798/deepseek-v4-toy-int4-ov
deepseek-v4-toy-int4-ov is a text generation model from imbob798. Use it when you need the model to write or continue text. It is set up for openvino. The card lists the license as mit.
WARNING — this is a TOY model with RANDOM weights, not real DeepSeek-V4-Flash. Architecturally it is the V4-Flash design (hybrid sparse attention, manifold-constrained Hyper-Connections, MoE, indexer-driven KV compres…
Downloads · 30 days
14
17% of all-time downloads
All-time downloads
82
Public
Repo size
6.2 MB
Likes
0
Public
Click a slice to open those files.
.bin6.2 MB · 65%
From the Hugging Face model README
WARNING — this is a TOY model with RANDOM weights, not real DeepSeek-V4-Flash.
Architecturally it is the V4-Flash design (hybrid sparse attention, manifold-constrained Hyper-Connections, MoE, indexer-driven KV compression), shrunk to 1.34M parameters with no training. It produces arbitrary tokens when run. The point of this repo is to validate the OpenVINO conversion path, not to do useful inference.
If you're looking for real V4-Flash inference, this is not it.
A working OpenVINO IR proof-of-concept for the DeepSeek-V4 architecture, built
on a 64 GB laptop. Includes both the FP32 IR and an INT4 weight-compressed IR
(via nncf.compress_weights). The same conversion code accepts the real
V4-Flash weights wherever there is enough RAM to host them.
Source repository: https://github.com/bob798/deepseek-v4-openvino
| What | RAM / VRAM |
|---|---|
| Run this toy IR (CPU, GPU, NPU) | < 100 MB |
| Convert from PyTorch (toy) | < 1 GB |
| Convert real V4-Flash from PyTorch | ~500 GB peak (BF16 dequant) |
| Run real V4-Flash IR (after dequant + INT4) | ~140 GB |
Tested on Intel Core Ultra 9 285H + Arc 140T iGPU with OpenVINO 2026.1.0.
from optimum.intel import OVModelForCausalLM
from transformers import AutoTokenizer
# trust_remote_code=True pulls the bundled configuration_/modeling_ source files.
# use_cache=False because the IR is prefill-only — no past_key_values input.
model = OVModelForCausalLM.from_pretrained(
"imbob798/deepseek-v4-toy-int4-ov",
trust_remote_code=True,
use_cache=False,
)
# No tokenizer is shipped with this toy. Pass random input_ids:
import torch
input_ids = torch.randint(0, 512, (1, 64))
out = model(input_ids=input_ids)
print(out.logits.shape) # torch.Size([1, 64, 512])
import openvino as ov
import numpy as np
core = ov.Core()
compiled = core.compile_model("openvino_model.xml", "CPU") # or "GPU", "NPU"
input_ids = np.random.randint(0, 512, (1, 64), dtype=np.int64)
logits = compiled([input_ids])[0]
print(logits.shape) # (1, 64, 512)
This toy implements every architectural feature of V4-Flash, just at a smaller scale:
| Field | Toy value | Real V4-Flash |
|---|---|---|
hidden_size | 128 | 4096 |
num_hidden_layers | 4 | 43 |
num_attention_heads | 4 | 64 |
num_key_value_heads | 1 (MQA) | 1 (MQA) |
head_dim | 32 | 512 |
q_lora_rank | 64 | 1024 |
n_routed_experts | 8 | 256 |
num_experts_per_tok | 2 | 6 |
n_shared_experts | 1 | 1 |
compress_ratios | [0, 0, 4, 128] | [0, 0, 4, 128, 4, 128, ...] |
hc_mult | 4 | 4 |
hc_sinkhorn_iters | 4 | 20 |
| total params | 1.34 M | ~284 B (~13 B active) |
Features exercised by the 4-layer toy:
| File | Size | Notes |
|---|---|---|
openvino_model.xml/.bin | 2.71 MB | INT4 weight-compressed IR (NNCF, INT4_ASYM, group_size=32) |
openvino_model_fp32.xml/.bin | 6.33 MB | FP32 baseline IR for comparison |
config.json | — | toy config with auto_map |
configuration_deepseek_v4.py | — | bundled for trust_remote_code |
modeling_deepseek_v4.py | — | bundled for trust_remote_code |
| IR | Size | Greedy next-token (B=1, seed=0) |
|---|---|---|
| FP32 | 6.33 MB | 78 |
| INT8 (not shipped here) | 3.03 MB | 78 |
| INT4 (shipped) | 2.71 MB | 78 |
INT4 vs FP32: max abs diff 2.9e-1, mean 4.3e-2 on the toy. Greedy token matches.
past_key_values input. Use use_cache=False
with OVModelForCausalLM.from_pretrained. Autoregressive decode will require
KV-cache plumbing that isn't done yet.num_nextn_predict_layers=0, num_hash_layers=0).optimum-intel 1.27.0, native
model_type="deepseek_v4" is not registered; this repo uses
trust_remote_code=True instead. See the upstream issue tracked at
https://github.com/bob798/deepseek-v4-openvino/blob/main/UPSTREAM_ISSUE.md.MIT. Architecture is derived from the deepseek-ai V4-Flash reference (also MIT) at https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash. The PyTorch port and the OpenVINO conversion code are original.
If you build on this work, please link https://github.com/bob798/deepseek-v4-openvino.