Skip to content

Comments

MXFP4 double buffer barrier fix #866

Open
adedespirlet wants to merge 16 commits intoiree-org:mainfrom
adedespirlet:mxfp4
Open

MXFP4 double buffer barrier fix #866
adedespirlet wants to merge 16 commits intoiree-org:mainfrom
adedespirlet:mxfp4

Conversation

@adedespirlet
Copy link
Contributor

This PR places barriers differently in the double buffered mfp4 gemm to reduce stalls observed in the trace.

The previous schedule utilized amdgpu.lds_barrier prior to the wavefront staggering branch. This forced an immediate s_waitcnt vmcnt(0), resulting in big stalls in the prologue. This "too early" LDS synchronization (vmcnt(0)) prevented the overlap of indexing logic with the in flight global memory loads.

To resolve this, I replaced the amdgpu.lds_barrier with a pure rocdl.s.barrier. And inside the loop I inserted a amdgpu.memory_counter_wait load(0) immediately before the first vector load from LDS.

Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
adedespirlet and others added 15 commits February 11, 2026 16:25
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
IE rather than extracting an i8 (and bitcasting to f8e8m0fnu) from a 4x vector (IE one VGPR) to use as mfma argument, use the extraction offset as the opsel argument for the mfma.
This should reduce register pressure.

Signed-off-by: William G Hatch <william@hatch.uno>
Signed-off-by: William G Hatch <william@hatch.uno>
Signed-off-by: William G Hatch <william@hatch.uno>
Signed-off-by: William G Hatch <william@hatch.uno>
The speculative_decoding.py tests change because the extra canonicalize pass optimizes some things away.  Eg. nested conditionals simplified to one conditional with a merged condition expression.

The pipelined_attention.py changes are similar, it looks like double canonicalization merged some things which moved bits around and changed some counts.

Signed-off-by: William G Hatch <william@hatch.uno>
Signed-off-by: William G Hatch <william@hatch.uno>
Signed-off-by: William G Hatch <william@hatch.uno>
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
Signed-off-by: Aurore De Spirlet <aurore.despirlet@amd.com>
):
"""Double-buffered MXFP4 GEMM, 8 waves, with stagger."""

mlir = """
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need to pass the MLIR text entirely?

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.

3 participants