from transformers import AutoModelForCausalLM, AutoTokenizer
from llmcompressor import oneshot
from llmcompressor.modifiers.awq import AWQModifier
MODEL_ID = "Qwen/Qwen3-Coder-30B-A3B-Instruct"
SAVE_DIR = MODEL_ID.split("/")[-1] + "-W4A16-awq"# Configure the quantization algorithm to run.
recipe = [
AWQModifier(
duo_scaling=False,
ignore=[
"lm_head",
"re:.*mlp.gate$",
"re:.*mlp.shared_expert_gate$",
"re:visual.*",
],
scheme="W4A16",
targets=["Linear"],
),
]
# Select calibration dataset.
DATASET_ID = "codeparrot/self-instruct-starcoder"
DATASET_SPLIT = "curated"# Select number of samples. 256 samples is a good place to start.# Increasing the number of samples can improve accuracy.
NUM_CALIBRATION_SAMPLES = 256
MAX_SEQUENCE_LENGTH = 2048defget_calib_dataset(tokenizer):
from datasets import load_dataset
ds = load_dataset(
DATASET_ID,
split=f"{DATASET_SPLIT}[:{NUM_CALIBRATION_SAMPLES*10}]",
)
defpreprocess(example):
chat_messages = [
{"role": "user", "content": example["instruction"].strip()},
{"role": "assistant", "content": example["output"].strip()},
]
tokenized_messages = tokenizer.apply_chat_template(
chat_messages, tokenize=True
)
return {"input_ids": tokenized_messages}
ds = (
ds.shuffle(seed=42)
.map(preprocess, remove_columns=ds.column_names)
.select(range(NUM_CALIBRATION_SAMPLES))
)
return ds
if __name__ == "__main__":
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID, torch_dtype="auto", trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
###### Apply algorithms.###
oneshot(
model=model,
dataset=get_calib_dataset(tokenizer),
recipe=recipe,
max_seq_length=MAX_SEQUENCE_LENGTH,
num_calibration_samples=NUM_CALIBRATION_SAMPLES,
log_dir=None,
trust_remote_code_model=True,
)
model.save_pretrained(SAVE_DIR)
tokenizer.save_pretrained(SAVE_DIR)
Evaluation
The model was evaluated on HumanEval and HumanEval+ benchmark with the Neural Magic fork of the EvalPlus implementation of HumanEval+ and the vLLM engine, using the following commands:
Qwen3-Coder-30B-A3B-Instruct-W4A16-awq huggingface.co is an AI model on huggingface.co that provides Qwen3-Coder-30B-A3B-Instruct-W4A16-awq's model effect (), which can be used instantly with this nm-testing Qwen3-Coder-30B-A3B-Instruct-W4A16-awq model. huggingface.co supports a free trial of the Qwen3-Coder-30B-A3B-Instruct-W4A16-awq model, and also provides paid use of the Qwen3-Coder-30B-A3B-Instruct-W4A16-awq. Support call Qwen3-Coder-30B-A3B-Instruct-W4A16-awq model through api, including Node.js, Python, http.
Qwen3-Coder-30B-A3B-Instruct-W4A16-awq huggingface.co is an online trial and call api platform, which integrates Qwen3-Coder-30B-A3B-Instruct-W4A16-awq's modeling effects, including api services, and provides a free online trial of Qwen3-Coder-30B-A3B-Instruct-W4A16-awq, you can try Qwen3-Coder-30B-A3B-Instruct-W4A16-awq online for free by clicking the link below.
nm-testing Qwen3-Coder-30B-A3B-Instruct-W4A16-awq online free url in huggingface.co:
Qwen3-Coder-30B-A3B-Instruct-W4A16-awq is an open source model from GitHub that offers a free installation service, and any user can find Qwen3-Coder-30B-A3B-Instruct-W4A16-awq on GitHub to install. At the same time, huggingface.co provides the effect of Qwen3-Coder-30B-A3B-Instruct-W4A16-awq install, users can directly use Qwen3-Coder-30B-A3B-Instruct-W4A16-awq installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Qwen3-Coder-30B-A3B-Instruct-W4A16-awq install url in huggingface.co: