gptq_fused_kernel#

Fused Triton kernels for GPTQ blockwise weight-update.

A kernel for scalar (NVFP4) quantization with precomputed FP8 block scales. Fuses quantization + per-column GPTQ error propagation into one launch per GPTQ block, avoiding the Python-level per-column loop.

Architecture:
  • One Triton program per output row.

  • w_full [BLOCK_SIZE] register tensor holds working weights.

  • Per-column: calls nvfp4_scalar_quant() for FP4 QDQ with the column’s block scale, then propagates error via w_full -= err * h_inv_row.

Functions

gptq_fused_block_scalar

Run scalar GPTQ (NVFP4) column loop for one block in a single Triton kernel launch.

gptq_fused_block_scalar(w_block, block_scale, h_inv_cho_blk, quant_block_size, block_start)#

Run scalar GPTQ (NVFP4) column loop for one block in a single Triton kernel launch.

Performs NVFP4 fake quantization with the given FP8-quantized block scales and GPTQ error propagation per column.

Parameters:
  • w_block (Tensor) – Working weights [num_rows, block_size] (float32).

  • block_scale (Tensor) – FP8-quantized per-block scales [num_rows, n_scale_blocks] (float32).

  • h_inv_cho_blk (Tensor) – Block of upper-Cholesky inverse Hessian [block_size, block_size].

  • quant_block_size (int) – Number of elements sharing one scale factor.

  • block_start (int) – Column offset of this block in the full weight matrix.

Returns:

(qw_block, err_block) each [num_rows, block_size].

Return type:

tuple[Tensor, Tensor]