Views
No views yet
1# NOTE: HF cache stores safetensors under snapshots/<hash>/, NOT at the model root!
2# Find the correct path with: ls /root/.cache/huggingface/hub/models--deepseek-ai--DeepSeek-V3.2/snapshots/
3export HF_FP8_CKPT="/root/.cache/huggingface/hub/models--deepseek-ai--DeepSeek-V3.2/snapshots/a7e62ac04ecb2c0a54d736dc46601c5606cf10a6"
4export DS_CKPT="/sgl-workspace/sglang/Model-Optimizer/examples/deepseek/out/deepseek-v3.2-fp8"
5export FP4_QUANT_PATH="/sgl-workspace/sglang/Model-Optimizer/examples/deepseek/out/deepseek-v3.2-fp4-calib"
6export HF_FP4_PATH="/sgl-workspace/sglang/Model-Optimizer/examples/deepseek/out/deepseek-v3.2-fp4-hf"
7export MP=4 # must match --nproc-per-node in PTQ step
8export EXPERTS=2561# work from the Model-Optimizer example directory so paths below match
2cd /sgl-workspace/sglang/Model-Optimizer/examples/deepseek
3
4# clone the official V3.2 inference repo without pulling LFS (avoids safetensors download)
5GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/deepseek-ai/DeepSeek-V3.2 && cd DeepSeek-V3.2
6
7# we install FHT from src. see setup.py in FHT repo to see the more step / end var.
8pip install git+https://github.com/Dao-AILab/fast-hadamard-transform.git
9# install inference dependencies from the official repo
10pip install -r inference/requirements.txt1cd DeepSeek-V3.2/inference
2python convert.py \
3 --hf-ckpt-path $HF_FP8_CKPT \
4 --save-path $DS_CKPT \
5 --n-experts $EXPERTS \
6 --model-parallel $MP1cd /sgl-workspace/sglang/Model-Optimizer/examples/deepseek
2# --nproc-per-node MUST match --model-parallel used in convert.py (i.e. $MP)
3CUDA_VISIBLE_DEVICES=4,5,6,7 torchrun --nproc-per-node $MP --master_port=12346 ptq.py \
4 --model_path $DS_CKPT \
5 --config DeepSeek-V3.2/inference/config_671B_v3.2.json \
6 --quant_cfg NVFP4_DEFAULT_CFG \
7 --output_path $FP4_QUANT_PATH1./quantize_fp8_to_nvfp4.sh \
2 --amax_path $FP4_QUANT_PATH \
3 --fp4_output_path $HF_FP4_PATH \
4 --fp8_hf_path $HF_FP8_CKPT \
5 --world_size $MP1cd DeepSeek-V3.2/inference
2export CONFIG=config_671B_v3.2.json
3torchrun --nproc-per-node $MP generate.py --ckpt-path $DS_CKPT --config $CONFIG --interactive