Views
No views yet
1uv venv --python 3.12
2
3# vllm is needed to load w4a16 quant scheme
4uv pip install "vllm>=0.8.5"
5
6# use patched sglang from git
7uv pip install "git+https://github.com/nytopop/sglang.git@qwen-30b-a3b#subdirectory=python[all]" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer-python
8
9# run
10uv run python -m sglang.launch_server --model-path nytopop/Qwen3-30B-A3B-abliterated.w4a16 --reasoning-parser qwen3 --dtype float161from transformers import AutoModelForCausalLM
2from llmcompressor import oneshot
3from llmcompressor.modifiers.quantization import QuantizationModifier
4from llmcompressor.transformers.compression.helpers import calculate_offload_device_map
5
6model_id = "mlabonne/Qwen3-30B-A3B-abliterated"
7model_out = model_id.split("/")[1] + ".w4a16"
8
9device_map = calculate_offload_device_map(
10 model_id, reserve_for_hessians=False, num_gpus=1, torch_dtype="bfloat16"
11)
12
13for k, v in device_map.items():
14 if v == 'disk':
15 device_map[k] = 'cpu'
16
17model = AutoModelForCausalLM.from_pretrained(
18 model_id,
19 device_map=device_map,
20 torch_dtype="bfloat16",
21)
22
23recipe = QuantizationModifier(targets="Linear", scheme="W4A16", ignore=["lm_head", "re:.*mlp.gate$"])
24
25oneshot(model=model, recipe=recipe, output_dir=model_out)