File size: 1,353 Bytes
e695de7 0ae75fd e695de7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #!/usr/bin/env bash
# Quantize Qwen/Qwen3-32B into 4 schemes, one at a time, upload each, then
# delete the local checkpoint. Disk is 500GB and two 97GB GPUs are available,
# so we shard the model across both GPUs (device_map="auto", no CPU offload)
# and run the full-quality calibration footprint. The base stays cached across
# schemes (no re-download).
MODEL="Qwen/Qwen3-32B"
PY="/home/vllm_env/bin/python"
CALIB_SAMPLES=512
CALIB_SEQLEN=2048
cd /home
# Make both GPUs visible for model sharding.
export CUDA_VISIBLE_DEVICES=0,1
# shellcheck disable=SC1091
source /home/vllm_env/bin/activate
# Reduce CUDA fragmentation during calibration. Auth uses the persisted HF
# credential file (~/.cache/huggingface/token), so no env token is required.
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
run() {
local scheme="$1"; shift
echo "===== START ${scheme} $(date) ====="
"${PY}" quantize_my_model.py \
--scheme "${scheme}" \
--model-id "${MODEL}" \
--num-calibration-samples "${CALIB_SAMPLES}" \
--max-seq-length "${CALIB_SEQLEN}" \
--upload-to-hub \
--delete-local-after-upload \
"$@" \
&& echo "===== OK ${scheme} $(date) =====" \
|| echo "!!!!! FAILED ${scheme} $(date) !!!!!"
echo "--- disk after ${scheme} ---"; df -h /home
}
run nvfp4
run mxfp4
run fp8
run mxfp8
echo "ALL DONE $(date)"
|