Views
No views yet

Qwen3-1.7B model using the calibrated version of SINQ (Sinkhorn-Normalized Quantization) method.Qwen3-1.7B-4bit-ASINQ Qwen/Qwen3-1.7Bsinq1from transformers import AutoTokenizer
2from sinq.patch_model import AutoSINQHFModel
3import torch
4
5model_name = "huawei-csl/Qwen3-1.7B-4bit-ASINQ"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7sinq_model = AutoSINQHFModel.from_quantized_safetensors(
8 model_name,
9 device="cuda:0",
10 compute_dtype=torch.bfloat16
11)
12
13prompt = "Explain neural network quantization in one sentence."
14inputs = tokenizer(prompt, return_tensors="pt").to("cuda:0")
15with torch.inference_mode():
16 out_ids = sinq_model.generate(**inputs, max_new_tokens=32, do_sample=False)
17print(tokenizer.decode(out_ids[0], skip_special_tokens=True))
181from transformers import AutoModelForCausalLM, AutoTokenizer
2from sinq.patch_model import AutoSINQHFModel
3from sinq.sinqlinear import BaseQuantizeConfig
4import torch
5
6# Load base model
7base_model_name = "Qwen/Qwen3-1.7B"
8model = AutoModelForCausalLM.from_pretrained(base_model_name, torch_dtype="float16")
9tokenizer = AutoTokenizer.from_pretrained(base_model_name)
10
11# Apply 4-bit SINQ quantization
12quant_cfg = BaseQuantizeConfig(
13 nbits=4, # quantization bit-width
14 group_size=64, # group size
15 tiling_mode="1D", # tiling strategy
16 method="asinq" # quantization method ("asinq" for the calibrated version)
17)
18
19qmodel = AutoSINQHFModel.quantize_model(
20 model,
21 tokenizer=tokenizer,
22 quant_config=quant_cfg,
23 compute_dtype=torch.bfloat16,
24 device="cuda:0"
25)1@misc{muller2025sinq,
2 title={SINQ: Sinkhorn-Normalized Quantization for Calibration-Free Low-Precision LLM Weights},
3 author={Lorenz K. Muller and Philippe Bich and Jiawei Zhuang and Ahmet Celik and Luca Benfenati and Lukas Cavigelli},
4 year={2025},
5 eprint={2509.22944},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={http://arxiv.org/abs/2509.22944}
9}