Instructions to use amd/DeepSeek-R1-0528-BF16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/DeepSeek-R1-0528-BF16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amd/DeepSeek-R1-0528-BF16", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("amd/DeepSeek-R1-0528-BF16", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("amd/DeepSeek-R1-0528-BF16", trust_remote_code=True) 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
- vLLM
How to use amd/DeepSeek-R1-0528-BF16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/DeepSeek-R1-0528-BF16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-R1-0528-BF16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/amd/DeepSeek-R1-0528-BF16
- SGLang
How to use amd/DeepSeek-R1-0528-BF16 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-R1-0528-BF16" \ --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": "amd/DeepSeek-R1-0528-BF16", "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 "amd/DeepSeek-R1-0528-BF16" \ --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": "amd/DeepSeek-R1-0528-BF16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use amd/DeepSeek-R1-0528-BF16 with Docker Model Runner:
docker model run hf.co/amd/DeepSeek-R1-0528-BF16
Model Overview
- Model Architecture: DeepSeek-R1-0528
- Input: Text
- Output: Text
- Supported Hardware Microarchitecture: AMD MI350/MI355
- ROCm: 7.0
- PyTorch: 2.8.0
- Transformers: 4.56.1
- Operating System(s): Linux
- Inference Engine: SGLang/vLLM
Model Details
In the original modeling_deepseek.py file from the unsloth/DeepSeek-R1-0528-BF16 model, there is no definition or implementation of the MTP (Multi-Token-Predictor) layer. As a result, when you load the original model, there is no MTP layer included, and MTP-specific quantization cannot be performed.
To enable MTP layer loading and quantization, this model is adapted from unsloth/DeepSeek-R1-0528-BF16 by adding an MTP layer in the modeling_deepseek.py file. With this modification, it is possible to use AMD-Quark to quantize the DeepSeek-R1-0528 model with the MTP layer included.
Important Notes:
- When loading this model, you must set
trust_remote_code=Trueto ensure that changes related to the MTP layer inmodeling_deepseek.pytake effect. - After loading this model with
transformers, evaluation should NOT be performed directly. The reason is that the forward function for the added MTP layer inmodeling_deepseek.pyis implemented only for calibration during the quantization process, so computation is not guaranteed to be the same as the original DeepSeek-R1-0528. - Therefore, when quantizing with AMD-Quark, you must add the
--skip_evaluationoption to skip the evaluation step and only perform quantization. - To skip quantization for the MTP layers, set
exclude_layers="lm_head *self_attn* *mlp.gate *eh_proj *shared_head.head model.layers.61.*".
Below is an example of how to quantize this model:
cd Quark/examples/torch/language_modeling/llm_ptq/
exclude_layers="lm_head *self_attn* *mlp.gate *eh_proj *shared_head.head"
python3 quantize_quark.py --model_dir $MODEL_DIR \
--quant_scheme w_mxfp4_a_mxfp4 \
--num_calib_data 32 \
--output_dir $output_dir \
--exclude_layers $exclude_layers \
--dataset pileval \
--multi_gpu \
--model_export hf_format \
--trust_remote_code \
--skip_evaluation \
--seq_len 512
For further details or issues, please refer to the AMD-Quark documentation or contact the respective developers.
License
Modifications Copyright(c) 2025 Advanced Micro Devices, Inc. All rights reserved.
- Downloads last month
- 5
Model tree for amd/DeepSeek-R1-0528-BF16
Base model
deepseek-ai/DeepSeek-R1-0528