Skip to content

fix: convert weight scale shape[N, K/128] to [ceil(N/128), ceil(K/128)]#1353

Open
JiaoliangYu wants to merge 1 commit into
ROCm:mainfrom
JiaoliangYu:fix/post_training_fix
Open

fix: convert weight scale shape[N, K/128] to [ceil(N/128), ceil(K/128)]#1353
JiaoliangYu wants to merge 1 commit into
ROCm:mainfrom
JiaoliangYu:fix/post_training_fix

Conversation

@JiaoliangYu

Copy link
Copy Markdown
Contributor

Motivation

per_block_fp8 online quantization in ATOM can produce degenerate generation (all-f outputs or immediate EOS) because the weight-scale layout emitted by the online quant path does not match the layout expected by the existing linear FP8 blockscale GEMM backend.

Technical Details

In LinearBase.online_quantize_weight for online_quant_type == QuantType.per_1x128, we no longer
use the generic per-group quant output directly (weight_scale shaped like [N, K/128]). Instead,
we explicitly quantize weights into 128x128 blockscale format and emit:

  • q_weight: shape [N, K] (same logical weight shape),
  • weight_scale: shape [ceil(N/128), ceil(K/128)].

This aligns online-quantized weights with the current linear compute path
(gemm_a8w8_blockscale*), which consumes 128x128 block scales.

Additional fix included:
Added float8_e4m3fnuz compatibility in online quant dtype checks and avoided redundant normalize
marking when quant output is already fnuz (relevant on gfx942).

Test Plan

Test Result

Submission Checklist

@zufayu zufayu requested review from valarLip and removed request for valarLip June 26, 2026 06:12
@JiaoliangYu JiaoliangYu force-pushed the fix/post_training_fix branch from 69851cb to 83f5f09 Compare June 29, 2026 03:41
@JiaoliangYu JiaoliangYu marked this pull request as ready for review June 29, 2026 05:47
@JiaoliangYu JiaoliangYu force-pushed the fix/post_training_fix branch 2 times, most recently from 3792a55 to e544a8c Compare June 29, 2026 09:56

@lihaoyang-amd lihaoyang-amd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JiaoliangYu JiaoliangYu force-pushed the fix/post_training_fix branch from e544a8c to ecbd295 Compare June 29, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants