# 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]:]))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
# 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)