Skip to content

[BUG] AWQ packed-format readers: 8-bit Marlin/Machete wrong un-interleave; dequantize_model scrambles AWQ channels #3974

Closed

Description

@Qubitium

Audit of main @ a16977e. Two places read AWQ packed tensors with the wrong column order and give silently wrong numerics.

1. AWQ 8-bit through Marlin (and Machete) un-interleaves data that was never interleaved

  • gptqmodel/utils/marlin.py:1115-1135 (awq_to_marlin_zero_points) undoes [0,2,1,3] when num_bits == 8.
  • gptqmodel_ext/marlin/awq_marlin_repack.cu:104 does the same (undo_pack[4] = {0,2,1,3}).
  • This repo's pack_awq only interleaves 4-bit; other widths use _pack_contiguous, and reverse_awq_order is a no-op for bits≠4. AwqTorch and AllSpark read 8-bit as natural order.
  • So AwqMarlinLinear (SUPPORTS_BITS=[4,8]) swaps columns 1↔2 within every 32-bit word, for both weights and zeros.

Repro: same packed buffers, K=512, N=256, gs=128.

  • AwqTorch: max err 0.02. AwqMarlin: 52–106, with output magnitude ~71.
  • With gs=-1, AllSpark is 0.024 and Marlin is 125.
  • Re-packing the words with order [0,2,1,3] drops Marlin to 0.013.

nn_modules/qlinear/machete_awq.py:35-45,172,183 (_undo_awq_interleave) has the same 8-bit assumption. It wasn't run here (no SM90).

Fix: for bits==8, either re-interleave to [0,2,1,3] before awq_marlin_repack / awq_to_marlin_zero_points, or skip the 8-bit undo in both the Python and CUDA repack paths. Do the same for Machete.

2. model_dequant.convert_awq_file skips the AWQ nibble reverse-order and hardcodes 4-bit

gptqmodel/utils/model_dequant.py:1557-1569 unpacks qweight/qzeros with generic unpack_cols (nibble i → column i) and never applies AWQ_REVERSE_ORDER. bits = 4 is also hardcoded, ignoring the config.

dequantize_model on any AWQ GEMM checkpoint therefore writes a dense model with output channels permuted inside every group of 8.

Repro: 64×16, gs=32, 4-bit, packed with pack_awq.

  • dequantize_gemm: max err 0.004.
  • convert_awq_file: max err 23 (another shape: 0.256 vs ref max 0.133).

The existing test (tests/test_model_dequant_fp8.py:413) only covers ignored layers. GEMV/GEMV_FAST layouts are probably mis-decoded too (unverified).

Fix: reuse unpack_awq + reverse_awq_order (or dequantize_gemm) and read bits from the config.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 14, 2026
  2. Qubitium commented on Nov 14, 2026

    @Qubitium
    CollaboratorAuthor

    Follow-up review of the merged fix found remaining problems; see #4002.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions