Skip to content

[KMCompiler][Ascend][Hygon] fix fused_h_aggregate_backward operator. - #145

Open
wuhansky wants to merge 1 commit into
flagos-ai:mainfrom
wuhansky:fused_h_aggregate_backward_fixed
Open

wuhansky wants to merge 1 commit into
flagos-ai:mainfrom
wuhansky:fused_h_aggregate_backward_fixed

Conversation

@wuhansky

Copy link
Copy Markdown
Contributor

count every live tile in the UB budget

Two Ascend configs failed to lower: with n=8/C=4096 the row block was forced to one row while the column tile stayed full width (a 16384-lane operand tile, 205 KiB), and the budget ignored the [BLOCK_M, BLOCK_C] gradient tile that is live beside the operand (n=1, fp32, 320 bytes over). Cap the column tile by the operand budget and size the row block from a 12288-lane operand-plus- gradient budget; measured, 12288 lanes compile and 16384 do not.

@wuhansky wuhansky changed the title [KMCompiler] fix fused_h_aggregate_backward. [KMCompiler][Ascend][Hygon] fix fused_h_aggregate_backward operator. Nov 27, 2026
@wuhansky
wuhansky force-pushed the fused_h_aggregate_backward_fixed branch from 4d817cd to d26ffbd Compare November 27, 2026 06:43
@github-actions github-actions Bot added the tests label Nov 27, 2026
@wuhansky
wuhansky force-pushed the fused_h_aggregate_backward_fixed branch from d26ffbd to 7b7d7f0 Compare November 27, 2026 08:14
@wuhansky
wuhansky force-pushed the fused_h_aggregate_backward_fixed branch 3 times, most recently from 38aad0f to be5b6eb Compare December 1, 2026 06:19
@Caeruleann

Copy link
Copy Markdown
Collaborator

…fused_h_aggregate_backward

The generic tile config forced one row while the column tile stayed full width
and ignored the [BLOCK_M, BLOCK_C] gradient tile that is live beside the
operand, so two Ascend configs failed to lower (200 KiB, and 320 bytes over
the 192 KiB UB). Cap the column tile first and size the row block from a
measured 12288-lane operand-plus-gradient budget.

Hygon: override the backward so a runtime 1.0 keeps the fp32 grad_x product
materialized, defeating the HCU FMA contraction that rounded the exact product
straight to the output dtype (one ULP on fp16 midpoints).

Ascend: override with a core-bounded row-block walk and a mask-free body when
every extent is exact (widest column tile first, up to four rows filling a
40960-lane budget); 1.33x geomean over the portable launch across the 20
benchmark rows, with grad_x bit-identical.

Tests: floor the gradient comparisons at sqrt(reduced length) * RMS(terms), so
a cancellation-collapsed result RMS cannot make the tolerance unachievable.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@wuhansky
wuhansky force-pushed the fused_h_aggregate_backward_fixed branch from 44df3af to a7e9909 Compare December 1, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants