Skip to content

Bug: Qwen3-8B integration issue #2

Description

@918822019

incoh_rotate=true degrades W4 PPL on Qwen3-8B (opposite to paper findings on Llama-2)

Summary

When applying KronQ W4 quantization to Qwen3-8B, enabling incoh_rotate=true consistently increases PPL degradation compared to incoh_rotate=false (1.22x–1.41x vs 1.11x), which is the opposite of the expected behavior demonstrated on Llama-2-7B in the paper.

I verified that the same pipeline correctly reproduces the paper's conclusion on Llama-2-7B (1.02x with rotation vs 1.27x without), so the issue appears to be architecture-specific rather than a bug in the implementation.

Environment

  • Python 3.12.9
  • PyTorch 2.6.0+cu124
  • CUDA 12.4
  • 2× NVIDIA A100 80GB
  • transformers 5.13.1
  • fast-hadamard-transform 1.1.0

Model Details

Property Value
Model Qwen3-8B
hidden_size 4096 (power of 2 ✓)
intermediate_size 12288 (12×1024, Hadamard-compatible ✓)
num_hidden_layers 36
Architecture notes Uses QK-Norm (RMSNorm on Q/K before attention)

Reproduction

Gradient Precomputation

# Dual-GPU parallel, layers split at 18
CUDA_VISIBLE_DEVICES=0 python -m algorithms.quantization.kronq._vendor.precompute_gradients \
  --model pretrained/Qwen3-8B \
  --output outputs/kronq_grads_qwen3_8b_wikitext \
  --calib_data datasets/wikitext_calib/data.jsonl \
  --nsamples 128 --seqlen 512 --fisher_samples 1 --batch_size 8 \
  --layer_start 0 --layer_end 18 &

CUDA_VISIBLE_DEVICES=1 python -m algorithms.quantization.kronq._vendor.precompute_gradients \
  --model pretrained/Qwen3-8B \
  --output outputs/kronq_grads_qwen3_8b_wikitext \
  --calib_data datasets/wikitext_calib/data.jsonl \
  --nsamples 128 --seqlen 512 --fisher_samples 1 --batch_size 8 \
  --layer_start 18 --layer_end 36 &
wait

PPL Evaluation

# incoh_rotate=false (best result)
python scripts/eval_kronq_ppl.py \
  --model pretrained/Qwen3-8B \
  --calib datasets/wikitext_calib/data.jsonl \
  --test data/wikitext_salesforce/wikitext-2-raw-v1/test-00000-of-00001.parquet \
  --grad_dir outputs/kronq_grads_qwen3_8b_wikitext \
  --w_bits 4 --alpha 0.1 --nsamples 64 --seqlen 512 \
  --eval_seqlen 2048 --batch_size 8

# incoh_rotate=true
python scripts/eval_kronq_ppl.py \
  --model pretrained/Qwen3-8B \
  --calib datasets/wikitext_calib/data.jsonl \
  --test data/wikitext_salesforce/wikitext-2-raw-v1/test-00000-of-00001.parquet \
  --grad_dir outputs/kronq_grads_qwen3_8b_wikitext \
  --w_bits 4 --alpha 0.25 --nsamples 64 --seqlen 512 --incoh_rotate \
  --eval_seqlen 2048 --batch_size 8

Results

Evaluation: wikitext-2 test full data, eval_seqlen=2048, 145 samples.

Config w_bits incoh_rotate alpha FP16 PPL Quantized PPL Degradation
A 4 false 0.1 9.72 10.83 1.11x
B 4 true 0.0 9.72 13.67 1.41x
C 4 true 0.1 9.72 12.62 1.30x
D 4 true 0.25 9.72 11.84 1.22x
E 4 true (grad v2) 0.25 9.72 12.41 1.28x

Config E uses higher-quality gradients (nsamples=128, seqlen=512, batch_size=8, dual-GPU parallel), but PPL did not improve.

Comparison with Llama-2-7B (same pipeline, same codebase)

Model incoh_rotate=true incoh_rotate=false Paper conclusion reproduced?
Llama-2-7B 5.61 (1.02x) 6.99 (1.27x) ✅ Yes
Qwen3-8B 11.84 (1.22x, best) 10.83 (1.11x) ❌ No (reversed)

Analysis & Hypothesis

The key architectural difference between Llama-2 and Qwen3 is that Qwen3 uses QK-Norm (RMSNorm applied to Q and K projections before attention computation). My hypothesis:

  1. The incoherent rotation (Hadamard transform) applied to weight matrices assumes that the activation distribution benefits from being "spread out" across dimensions.
  2. QK-Norm already normalizes the query/key representations, potentially making the activation distribution more uniform in attention layers.
  3. When BiIP's rotation is applied on top of QK-Norm's normalization, the combined effect may distort the learned representation geometry rather than improve quantization-friendliness.
  4. This could explain why higher alpha (more H_G influence) partially recovers performance (Config D: 1.22x vs Config B: 1.41x at alpha=0) — the gradient covariance helps compensate, but cannot fully overcome the architectural mismatch.

Questions

  1. Has KronQ been tested on Qwen-family models (especially those with QK-Norm)? Are there known compatibility considerations?
  2. Would it be possible to selectively disable incoherent rotation for attention layers (where QK-Norm is active) while keeping it for MLP layers?
  3. Is there a recommended approach to tune BiIP behavior for architectures with built-in normalization on Q/K?

Additional Context

  • I also tested Qwen3-0.6B (hidden_size=1024, no QK-Norm issue at this scale), where incoh_rotate=true works well (1.04x vs 1.15x for false). This suggests the interaction with QK-Norm may become more pronounced at larger scales.
  • Gradient quality (nsamples/seqlen) does not appear to be the bottleneck — Config E with 2x more calibration data showed no improvement.
  • No NaN issues were observed on Qwen3-8B (unlike Qwen3-0.6B at alpha=0.25, which required reducing to 0.1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions