DeepSeek-R1-FP4 / README.md
zhiyucheng's picture
add model card
4daeb23
|
raw
history blame
5.1 kB
---
base_model:
- deepseek-ai/DeepSeek-R1
---
# Model Overview
## Description:
The NVIDIA DeepSeek R1 FP4 model is the quantized version of the DeepSeek AI's DeepSeek R1 model, which is an auto-regressive language model that uses an optimized transformer architecture. For more information, please check [here](https://huggingface.co/deepseek-ai/DeepSeek-R1). The NVIDIA DeepSeek R1 FP4 model is quantized with [TensorRT Model Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer).
This model is ready for commercial/non-commercial use. <br>
## Third-Party Community Consideration
This model is not owned or developed by NVIDIA. This model has been developed and built to a third-party’s requirements for this application and use case; see link to Non-NVIDIA [(DeepSeek R1) Model Card](https://huggingface.co/deepseek-ai/DeepSeek-R1).
### License/Terms of Use:
[nvidia-open-model-license](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/)
## Model Architecture:
**Architecture Type:** Transformers <br>
**Network Architecture:** DeepSeek R1 <br>
## Input:
**Input Type(s):** Text <br>
**Input Format(s):** String <br>
**Input Parameters:** 1D (One Dimensional): Sequences <br>
**Other Properties Related to Input:** Context length up to 128K <br>
## Output:
**Output Type(s):** Text <br>
**Output Format:** String <br>
**Output Parameters:** 1D (One Dimensional): Sequences <br>
**Other Properties Related to Output:** N/A <br>
## Software Integration:
**Supported Runtime Engine(s):** <br>
* Tensor(RT)-LLM <br>
**Supported Hardware Microarchitecture Compatibility:** <br>
* NVIDIA Blackwell <br>
**Preferred Operating System(s):** <br>
* Linux <br>
## Model Version(s):
The model is quantized with nvidia-modelopt **v0.23.0** <br>
## Datasets:
* Calibration Dataset: [cnn_dailymail](https://huggingface.co/datasets/abisee/cnn_dailymail) <br>
** Data collection method: Automated. <br>
** Labeling method: Unknown. <br>
* Evaluation Dataset: [MMLU](https://github.com/hendrycks/test) <br>
** Data collection method: Unknown. <br>
** Labeling method: N/A. <br>
## Inference:
**Engine:** Tensor(RT)-LLM <br>
**Test Hardware:** B200 <br>
## Post Training Quantization
This model was obtained by quantizing the weights and activations of DeepSeek R1 to FP4 data type, ready for inference with TensorRT-LLM. Only the weights and activations of the linear operators within transformers blocks are quantized. This optimization reduces the number of bits per parameter from 8 to 4, reducing the disk size and GPU memory requirements by approximately 1.6x.
## Usage
### Deploy with TensorRT-LLM
To deploy the quantized checkpoint with [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM) LLM API, follow the sample codes below:
* LLM API sample usage:
```
from tensorrt_llm import LLM, SamplingParams
def main():
prompts = [
"Hello, my name is",
"The president of the United States is",
"The capital of France is",
"The future of AI is",
]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
llm = LLM(model="nvidia/DeepSeek-R1-FP4")
outputs = llm.generate(prompts, sampling_params)
# Print the outputs.
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
# The entry point of the program need to be protected for spawning processes.
if __name__ == '__main__':
main()
```
* Accuracy evaluation:
1) Prepare the MMLU dataset:
```sh
mkdir data; wget https://people.eecs.berkeley.edu/~hendrycks/data.tar -O data/mmlu.tar
tar -xf data/mmlu.tar -C data && mv data/data data/mmlu
```
2) Measure MMLU:
```sh
python examples/mmlu_llmapi.py --data_dir data/mmlu --hf_model_dir nvidia/DeepSeek-R1-FP4 --backend=pytorch
```
* Throughputs evaluation:
Please refer to the [TensorRT-LLM benchmarking documentation](https://github.com/NVIDIA/TensorRT-LLM/tree/main/benchmarks) for details.
#### Evaluation
The accuracy (MMLU, 5-shot) benchmark results are presented in the table below:
<table>
<tr>
<td><strong>Precision</strong>
</td>
<td><strong>MMLU</strong>
</td>
</tr>
<tr>
<td>FP8
</td>
<td>90.8
</td>
</tr>
<tr>
<td>FP4
</td>
<td>86.9
</td>
</tr>
<tr>
</table>
## Ethical Considerations
NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).