caiovicentino1/Qwen3.5-9B-PolarQuant-MLX-4bit

Model

5

stars

14

commits

4

linked in READMEs

Apr 13, 2026

updated

4-bit
apple-silicon
conversational
hlwq
llm-compression
mac
mlx
quantization
qwen3.5
qwen3_5
safetensors
text-generation
Browse cluster: MLX and Apple Silicon ML Models β†’

README

[!IMPORTANT] Naming notice (2026-04-10). The "HLWQ" technique used in this model is being rebranded to HLWQ (Hadamard-Lloyd Weight Quantization). The change is only the name; the algorithm and the weights in this repository are unchanged.

The rebrand resolves a name collision with an unrelated, earlier KV cache quantization method also named HLWQ (Han et al., arXiv:2502.02617, 2025). HLWQ addresses weight quantization with a deterministic Walsh-Hadamard rotation and Lloyd-Max scalar codebook; Han et al.'s HLWQ addresses KV cache quantization with a random polar rotation. The two methods are technically distinct.

Existing loaders that load this repository by ID continue to work without changes. Future model uploads will use the HLWQ name.

Reference paper for this technique: arXiv:2603.29078 (v2 in preparation; v1 still uses the old name).

🍎 HLWQ MLX 4-bit -- Qwen3.5-9B

Run Qwen3.5-9B on your Mac with HLWQ quality -- 19.7 tok/s at only 4.8 GB memory.

HLWQ MLX brings the benefits of Hadamard rotation + Lloyd-Max optimal quantization to Apple Silicon via the MLX framework. Get better-than-naive-Q4 quality with native Metal acceleration.


🎯 Key Results

MetricValue
MethodHLWQ Q4 (MLX)
Perplexity (WikiText-2)6.90
Throughput19.7 tok/s
Memory4.8 GB
PlatformMac mini M4
Quantization4-bit with Hadamard rotation

πŸ“Š Cross-Platform Comparison

Speed vs VRAM

PPL Comparison

Methodtok/sMemoryPPLPlatform
FP16 baseline45.717.9 GB6.37RTX PRO 6000
HLWQ Q5 + torchao43.16.5 GB6.56RTX PRO 6000
torchao INT4 (absmax)43.36.3 GB6.68RTX PRO 6000
HLWQ MLX Q419.74.8 GB6.90Mac mini M4

Runs comfortably on any Mac with 8 GB+ unified memory. No GPU required -- Metal handles everything.


πŸš€ Quick Start

Option 1: mlx-lm (Easiest)

pip install mlx-lm
from mlx_lm import load, generate

model, tokenizer = load("caiovicentino1/Qwen3.5-9B-HLWQ-MLX-4bit")

response = generate(
    model, tokenizer,
    prompt="Explain the theory of relativity in simple terms:",
    max_tokens=200,
    verbose=True  # Shows tok/s
)
print(response)

Option 2: Command Line

mlx_lm.generate \
    --model caiovicentino1/Qwen3.5-9B-HLWQ-MLX-4bit \
    --prompt "Write a Python function to sort a list:" \
    --max-tokens 300

Option 3: Chat Mode

mlx_lm.chat \
    --model caiovicentino1/Qwen3.5-9B-HLWQ-MLX-4bit \
    --max-tokens 500

πŸ”¬ Why HLWQ on MLX?

Standard MLX quantization uses simple absmax rounding. HLWQ improves on this by:

  1. Hadamard Rotation: Transforms weight blocks to follow a Gaussian distribution using a deterministic 128x128 Walsh-Hadamard matrix
  2. Lloyd-Max Centroids: Uses MSE-optimal quantization levels for Gaussian data instead of uniform spacing

This combination reduces quantization error by up to 54% compared to absmax at the same bit width.

Original Weights --> Normalize --> Hadamard Rotate --> Lloyd-Max Q4 --> MLX Format
                                                                         |
                       Metal Acceleration <-- MLX Inference <-- Dequant --+

πŸ”§ Technical Details

ComponentDetails
FrameworkMLX (Apple's ML framework for Apple Silicon)
QuantizationHLWQ Q4 (4-bit, block_size=128)
Rotation128x128 Walsh-Hadamard (self-inverse, deterministic)
CentroidsPre-computed MSE-optimal for N(0,1)
AccelerationMetal Performance Shaders (MPS)
CompatibilityMac M1/M2/M3/M4 (8 GB+ unified memory)

πŸ’» System Requirements

RequirementMinimumRecommended
macOS13.5+ (Ventura)14.0+ (Sonoma)
Apple SiliconM1M4
Unified Memory8 GB16 GB
Python3.10+3.11+
mlx0.5.0+Latest


πŸ“– Citation

@article{vicentino2026polarquant,
  title={HLWQ: Optimal Gaussian Weight Quantization via Hadamard Rotation for LLM Compression},
  author={Vicentino, Caio},
  journal={arXiv preprint arXiv:2603.7424577},
  year={2026}
}

πŸ™ Acknowledgements

Built with MLX by Apple, mlx-lm, and the Qwen team's open-weight models.

Contributors

caiovicentino1

14 commits

caiovicentino1/Qwen3.5-9B-PolarQuant-MLX-4bit

Model

5

stars

14

commits

4

linked in READMEs

Apr 13, 2026

updated

4-bit
apple-silicon
conversational
hlwq
llm-compression
mac
mlx
quantization
qwen3.5
qwen3_5
safetensors
text-generation
Browse cluster: MLX and Apple Silicon ML Models β†’

README

[!IMPORTANT] Naming notice (2026-04-10). The "HLWQ" technique used in this model is being rebranded to HLWQ (Hadamard-Lloyd Weight Quantization). The change is only the name; the algorithm and the weights in this repository are unchanged.

The rebrand resolves a name collision with an unrelated, earlier KV cache quantization method also named HLWQ (Han et al., arXiv:2502.02617, 2025). HLWQ addresses weight quantization with a deterministic Walsh-Hadamard rotation and Lloyd-Max scalar codebook; Han et al.'s HLWQ addresses KV cache quantization with a random polar rotation. The two methods are technically distinct.

Existing loaders that load this repository by ID continue to work without changes. Future model uploads will use the HLWQ name.

Reference paper for this technique: arXiv:2603.29078 (v2 in preparation; v1 still uses the old name).

🍎 HLWQ MLX 4-bit -- Qwen3.5-9B

Run Qwen3.5-9B on your Mac with HLWQ quality -- 19.7 tok/s at only 4.8 GB memory.

HLWQ MLX brings the benefits of Hadamard rotation + Lloyd-Max optimal quantization to Apple Silicon via the MLX framework. Get better-than-naive-Q4 quality with native Metal acceleration.


🎯 Key Results

MetricValue
MethodHLWQ Q4 (MLX)
Perplexity (WikiText-2)6.90
Throughput19.7 tok/s
Memory4.8 GB
PlatformMac mini M4
Quantization4-bit with Hadamard rotation

πŸ“Š Cross-Platform Comparison

Speed vs VRAM

PPL Comparison

Methodtok/sMemoryPPLPlatform
FP16 baseline45.717.9 GB6.37RTX PRO 6000
HLWQ Q5 + torchao43.16.5 GB6.56RTX PRO 6000
torchao INT4 (absmax)43.36.3 GB6.68RTX PRO 6000
HLWQ MLX Q419.74.8 GB6.90Mac mini M4

Runs comfortably on any Mac with 8 GB+ unified memory. No GPU required -- Metal handles everything.


πŸš€ Quick Start

Option 1: mlx-lm (Easiest)

pip install mlx-lm
from mlx_lm import load, generate

model, tokenizer = load("caiovicentino1/Qwen3.5-9B-HLWQ-MLX-4bit")

response = generate(
    model, tokenizer,
    prompt="Explain the theory of relativity in simple terms:",
    max_tokens=200,
    verbose=True  # Shows tok/s
)
print(response)

Option 2: Command Line

mlx_lm.generate \
    --model caiovicentino1/Qwen3.5-9B-HLWQ-MLX-4bit \
    --prompt "Write a Python function to sort a list:" \
    --max-tokens 300

Option 3: Chat Mode

mlx_lm.chat \
    --model caiovicentino1/Qwen3.5-9B-HLWQ-MLX-4bit \
    --max-tokens 500

πŸ”¬ Why HLWQ on MLX?

Standard MLX quantization uses simple absmax rounding. HLWQ improves on this by:

  1. Hadamard Rotation: Transforms weight blocks to follow a Gaussian distribution using a deterministic 128x128 Walsh-Hadamard matrix
  2. Lloyd-Max Centroids: Uses MSE-optimal quantization levels for Gaussian data instead of uniform spacing

This combination reduces quantization error by up to 54% compared to absmax at the same bit width.

Original Weights --> Normalize --> Hadamard Rotate --> Lloyd-Max Q4 --> MLX Format
                                                                         |
                       Metal Acceleration <-- MLX Inference <-- Dequant --+

πŸ”§ Technical Details

ComponentDetails
FrameworkMLX (Apple's ML framework for Apple Silicon)
QuantizationHLWQ Q4 (4-bit, block_size=128)
Rotation128x128 Walsh-Hadamard (self-inverse, deterministic)
CentroidsPre-computed MSE-optimal for N(0,1)
AccelerationMetal Performance Shaders (MPS)
CompatibilityMac M1/M2/M3/M4 (8 GB+ unified memory)

πŸ’» System Requirements

RequirementMinimumRecommended
macOS13.5+ (Ventura)14.0+ (Sonoma)
Apple SiliconM1M4
Unified Memory8 GB16 GB
Python3.10+3.11+
mlx0.5.0+Latest


πŸ“– Citation

@article{vicentino2026polarquant,
  title={HLWQ: Optimal Gaussian Weight Quantization via Hadamard Rotation for LLM Compression},
  author={Vicentino, Caio},
  journal={arXiv preprint arXiv:2603.7424577},
  year={2026}
}

πŸ™ Acknowledgements

Built with MLX by Apple, mlx-lm, and the Qwen team's open-weight models.

Contributors

caiovicentino1

14 commits