Text Generation
Transformers
Safetensors
English
Chinese
deepseek_v4
nvfp4
ocp-mx
quantization
amd-quark
Mixture of Experts
deepseek
8-bit precision
quark
Instructions to use amd/DeepSeek-V4-Pro-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/DeepSeek-V4-Pro-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amd/DeepSeek-V4-Pro-NVFP4")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("amd/DeepSeek-V4-Pro-NVFP4") model = AutoModelForCausalLM.from_pretrained("amd/DeepSeek-V4-Pro-NVFP4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use amd/DeepSeek-V4-Pro-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/DeepSeek-V4-Pro-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-V4-Pro-NVFP4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/amd/DeepSeek-V4-Pro-NVFP4
- SGLang
How to use amd/DeepSeek-V4-Pro-NVFP4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "amd/DeepSeek-V4-Pro-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-V4-Pro-NVFP4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "amd/DeepSeek-V4-Pro-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-V4-Pro-NVFP4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use amd/DeepSeek-V4-Pro-NVFP4 with Docker Model Runner:
docker model run hf.co/amd/DeepSeek-V4-Pro-NVFP4
updated quantized model
#2
by huidongji - opened
- assets/dsv4_performance.png +3 -0
- config.json +0 -0
- inference/__pycache__/model.cpython-312.pyc +0 -0
- inference/kernel.py +1 -1
- inference/model.py +1 -2
- input_scale.safetensors +2 -2
- model-00064-of-00064.safetensors +2 -2
- model.safetensors.index.json +2 -2
assets/dsv4_performance.png
ADDED
|
Git LFS Details
|
config.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
inference/__pycache__/model.cpython-312.pyc
CHANGED
|
Binary files a/inference/__pycache__/model.cpython-312.pyc and b/inference/__pycache__/model.cpython-312.pyc differ
|
|
|
inference/kernel.py
CHANGED
|
@@ -85,7 +85,7 @@ def act_quant_kernel(
|
|
| 85 |
for i, j in T.Parallel(blk_m, group_size):
|
| 86 |
y_local[i, j] = T.Cast(
|
| 87 |
out_dtype,
|
| 88 |
-
T.Cast(compute_dtype, T.Cast(
|
| 89 |
x_local[i, j] / s_local[i], fp8_min, fp8_max
|
| 90 |
))) * s_local[i],
|
| 91 |
)
|
|
|
|
| 85 |
for i, j in T.Parallel(blk_m, group_size):
|
| 86 |
y_local[i, j] = T.Cast(
|
| 87 |
out_dtype,
|
| 88 |
+
T.Cast(compute_dtype, T.Cast(FP8, T.clamp(
|
| 89 |
x_local[i, j] / s_local[i], fp8_min, fp8_max
|
| 90 |
))) * s_local[i],
|
| 91 |
)
|
inference/model.py
CHANGED
|
@@ -624,8 +624,7 @@ class MoE(nn.Module):
|
|
| 624 |
self.experts = nn.ModuleList([Expert(args.dim, args.moe_inter_dim, dtype=expert_dtype, swiglu_limit=args.swiglu_limit) if self.experts_start_idx <= i < self.experts_end_idx else None
|
| 625 |
for i in range(self.n_routed_experts)])
|
| 626 |
assert args.n_shared_experts == 1
|
| 627 |
-
|
| 628 |
-
self.shared_experts = Expert(args.dim, args.moe_inter_dim)
|
| 629 |
|
| 630 |
def forward(self, x: torch.Tensor, input_ids: torch.Tensor) -> torch.Tensor:
|
| 631 |
shape = x.size()
|
|
|
|
| 624 |
self.experts = nn.ModuleList([Expert(args.dim, args.moe_inter_dim, dtype=expert_dtype, swiglu_limit=args.swiglu_limit) if self.experts_start_idx <= i < self.experts_end_idx else None
|
| 625 |
for i in range(self.n_routed_experts)])
|
| 626 |
assert args.n_shared_experts == 1
|
| 627 |
+
self.shared_experts = Expert(args.dim, args.moe_inter_dim, swiglu_limit=args.swiglu_limit)
|
|
|
|
| 628 |
|
| 629 |
def forward(self, x: torch.Tensor, input_ids: torch.Tensor) -> torch.Tensor:
|
| 630 |
shape = x.size()
|
input_scale.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1df615aed5669b3bde5a8766298f12df4669a3a3baa883dda05fb0fc25a0eca9
|
| 3 |
+
size 7311108
|
model-00064-of-00064.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46fa7b6b16fc1f56b28be0424a34cc6f06ca2c4a550d2741c5efdd28e623bbb1
|
| 3 |
+
size 13964140292
|
model.safetensors.index.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c3658a0ac088136056edb8652e9c53aa4e76d0e0b808e10806a72c2cf4dfad2
|
| 3 |
+
size 23762560
|