Instructions to use tiny-random/deepseek-v4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/deepseek-v4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/deepseek-v4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiny-random/deepseek-v4") model = AutoModelForCausalLM.from_pretrained("tiny-random/deepseek-v4", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/deepseek-v4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/deepseek-v4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/deepseek-v4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/deepseek-v4
- SGLang
How to use tiny-random/deepseek-v4 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 "tiny-random/deepseek-v4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/deepseek-v4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "tiny-random/deepseek-v4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/deepseek-v4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/deepseek-v4 with Docker Model Runner:
docker model run hf.co/tiny-random/deepseek-v4
Upload folder using huggingface_hub
Browse files- .meta.json +1 -1
- README.md +38 -6
- config.json +3 -3
- generation_config.json +1 -1
- model.safetensors +2 -2
.meta.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"safetensors": "0.8.0",
|
| 3 |
"torch": "2.11.0+cu128",
|
| 4 |
-
"transformers": "5.
|
| 5 |
"vllm": "0.24.0+cu129"
|
| 6 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"safetensors": "0.8.0",
|
| 3 |
"torch": "2.11.0+cu128",
|
| 4 |
+
"transformers": "5.15.0.dev0",
|
| 5 |
"vllm": "0.24.0+cu129"
|
| 6 |
}
|
README.md
CHANGED
|
@@ -12,7 +12,7 @@ Note:
|
|
| 12 |
|
| 13 |
| File path | Size |
|
| 14 |
|------|------|
|
| 15 |
-
| model.safetensors |
|
| 16 |
|
| 17 |
|
| 18 |
### Example usage:
|
|
@@ -20,7 +20,7 @@ Note:
|
|
| 20 |
- vLLM
|
| 21 |
|
| 22 |
```bash
|
| 23 |
-
# Not fully tested, please
|
| 24 |
model_id=tiny-random/deepseek-v4
|
| 25 |
vllm serve $model_id \
|
| 26 |
--trust-remote-code \
|
|
@@ -35,6 +35,33 @@ vllm serve $model_id \
|
|
| 35 |
--speculative-config '{"method":"mtp","num_speculative_tokens":2}'
|
| 36 |
```
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
### Codes to create this repo:
|
| 39 |
|
| 40 |
<details><summary>Click to expand</summary>
|
|
@@ -64,11 +91,16 @@ config = {
|
|
| 64 |
"hc_eps": 1e-06,
|
| 65 |
"hc_mult": 4,
|
| 66 |
"hc_sinkhorn_iters": 20,
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
"hidden_act": "silu",
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
| 70 |
"index_head_dim": 128,
|
| 71 |
-
"index_n_heads":
|
| 72 |
"index_topk": 1024,
|
| 73 |
"initializer_range": 0.02,
|
| 74 |
"max_position_embeddings": 1048576,
|
|
@@ -437,5 +469,5 @@ main()
|
|
| 437 |
|
| 438 |
- safetensors: 0.8.0
|
| 439 |
- torch: 2.11.0+cu128
|
| 440 |
-
- transformers: 5.
|
| 441 |
- vllm: 0.24.0+cu129
|
|
|
|
| 12 |
|
| 13 |
| File path | Size |
|
| 14 |
|------|------|
|
| 15 |
+
| model.safetensors | 277.3MB |
|
| 16 |
|
| 17 |
|
| 18 |
### Example usage:
|
|
|
|
| 20 |
- vLLM
|
| 21 |
|
| 22 |
```bash
|
| 23 |
+
# Not fully tested, please report any issues if you find any problems.
|
| 24 |
model_id=tiny-random/deepseek-v4
|
| 25 |
vllm serve $model_id \
|
| 26 |
--trust-remote-code \
|
|
|
|
| 35 |
--speculative-config '{"method":"mtp","num_speculative_tokens":2}'
|
| 36 |
```
|
| 37 |
|
| 38 |
+
- SGLang
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
# Tested on H20. Please report any issues if you find any problems.
|
| 42 |
+
export NVCC_PREPEND_FLAGS=-allow-unsupported-compiler
|
| 43 |
+
export NVCC_APPEND_FLAGS=-allow-unsupported-compiler
|
| 44 |
+
export SGLANG_OPT_USE_TILELANG_MHC_PRE=0
|
| 45 |
+
export SGLANG_OPT_USE_TILELANG_MHC_POST=0
|
| 46 |
+
export SGLANG_OPT_DEEPGEMM_HC_PRENORM=0
|
| 47 |
+
export SGLANG_OPT_USE_TILELANG_INDEXER=1
|
| 48 |
+
|
| 49 |
+
model_id=tiny-random/deepseek-v4
|
| 50 |
+
sglang serve \
|
| 51 |
+
--trust-remote-code \
|
| 52 |
+
--model-path $model_id \
|
| 53 |
+
--tp 2 \
|
| 54 |
+
--moe-runner-backend marlin \
|
| 55 |
+
--fp8-gemm-backend triton \
|
| 56 |
+
--speculative-algorithm EAGLE \
|
| 57 |
+
--speculative-num-steps 3 \
|
| 58 |
+
--speculative-eagle-topk 1 \
|
| 59 |
+
--speculative-num-draft-tokens 4 \
|
| 60 |
+
--mem-fraction-static 0.6 \
|
| 61 |
+
--disable-cuda-graph \
|
| 62 |
+
--disable-custom-all-reduce
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
### Codes to create this repo:
|
| 66 |
|
| 67 |
<details><summary>Click to expand</summary>
|
|
|
|
| 91 |
"hc_eps": 1e-06,
|
| 92 |
"hc_mult": 4,
|
| 93 |
"hc_sinkhorn_iters": 20,
|
| 94 |
+
# SGLang's DSV4 KV-cache layout fixes the non-RoPE portion at 448
|
| 95 |
+
# elements; together with qk_rope_head_dim=64 this must be 512.
|
| 96 |
+
"head_dim": 512,
|
| 97 |
"hidden_act": "silu",
|
| 98 |
+
# SGLang's Hopper MXFP4 Marlin path pads hidden_size to 256. Keeping
|
| 99 |
+
# the checkpoint at 128 leaves its per-32 scales at width 4 while the
|
| 100 |
+
# runtime allocates width 8, so make the checkpoint natively compatible.
|
| 101 |
+
"hidden_size": 256,
|
| 102 |
"index_head_dim": 128,
|
| 103 |
+
"index_n_heads": 32,
|
| 104 |
"index_topk": 1024,
|
| 105 |
"initializer_range": 0.02,
|
| 106 |
"max_position_embeddings": 1048576,
|
|
|
|
| 469 |
|
| 470 |
- safetensors: 0.8.0
|
| 471 |
- torch: 2.11.0+cu128
|
| 472 |
+
- transformers: 5.15.0.dev0
|
| 473 |
- vllm: 0.24.0+cu129
|
config.json
CHANGED
|
@@ -10,11 +10,11 @@
|
|
| 10 |
"hc_eps": 1e-06,
|
| 11 |
"hc_mult": 4,
|
| 12 |
"hc_sinkhorn_iters": 20,
|
| 13 |
-
"head_dim":
|
| 14 |
"hidden_act": "silu",
|
| 15 |
-
"hidden_size":
|
| 16 |
"index_head_dim": 128,
|
| 17 |
-
"index_n_heads":
|
| 18 |
"index_topk": 1024,
|
| 19 |
"initializer_range": 0.02,
|
| 20 |
"max_position_embeddings": 1048576,
|
|
|
|
| 10 |
"hc_eps": 1e-06,
|
| 11 |
"hc_mult": 4,
|
| 12 |
"hc_sinkhorn_iters": 20,
|
| 13 |
+
"head_dim": 512,
|
| 14 |
"hidden_act": "silu",
|
| 15 |
+
"hidden_size": 256,
|
| 16 |
"index_head_dim": 128,
|
| 17 |
+
"index_n_heads": 32,
|
| 18 |
"index_topk": 1024,
|
| 19 |
"initializer_range": 0.02,
|
| 20 |
"max_position_embeddings": 1048576,
|
generation_config.json
CHANGED
|
@@ -5,5 +5,5 @@
|
|
| 5 |
"eos_token_id": 1,
|
| 6 |
"temperature": 1.0,
|
| 7 |
"top_p": 1.0,
|
| 8 |
-
"transformers_version": "5.
|
| 9 |
}
|
|
|
|
| 5 |
"eos_token_id": 1,
|
| 6 |
"temperature": 1.0,
|
| 7 |
"top_p": 1.0,
|
| 8 |
+
"transformers_version": "5.15.0.dev0"
|
| 9 |
}
|
model.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:bb9a57398e8d94236a97a8fe6dedec046971166dd8b7db108850c9466eaafec4
|
| 3 |
+
size 277297456
|