Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ See `examples/` for more examples including tiled copy (`02-tiledCopy.py`), tile
| **Blockscale GEMM** | `test_blockscale_preshuffle_gemm.py` | Blockscale preshuffle GEMM |
| **HGEMM Split-K** | `test_hgemm_splitk.py` | FP16 GEMM split-K |
| **MoE GEMM** | `test_moe_gemm.py` | MoE 2-stage (gate/up + reduce) |
| **MoE Blockscale** | `test_moe_blockscale.py` | MoE blockscale 2-stage |
| **MoE Reduce** | `test_moe_reduce.py` | MoE reduce kernel |
| **PagedAttention** | `test_pa.py` | Paged attention decode (FP8) — *WIP perf tuning* |
| **FlashAttention** | `test_flash_attn_fwd.py` | Flash attention — *WIP perf tuning* |
Expand Down
3 changes: 1 addition & 2 deletions docs/api/kernels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ MoE (Mixture-of-Experts) Kernels
- ``kernels.moe.moe_gemm_2stage`` -- MoE GEMM with 2-stage pipeline (stage1 + stage2). Also
provides the MoE reduction (sum over the topk dimension, ``Y[t, d] = sum(X[t, :, d])``),
compiled via ``compile_moe_reduction()``.
- ``kernels.moe.mixed_moe_gemm_2stage`` -- Mixed-precision MoE GEMM
- ``kernels.moe.moe_blockscale_2stage`` -- MoE with block-scale quantization (MXFP4)
- ``kernels.moe.mxfp_moe`` -- Fused a4w4 / a8w4 MoE 2-stage GEMM (device-side fp4 re-quant)

Paged Attention
----------------
Expand Down
3 changes: 1 addition & 2 deletions docs/architecture_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ FlyDSL/
│ │ └── fused_rope_cache_kernel.py # Fused RoPE + KV cache
│ ├── moe/ # Mixture-of-experts kernels
│ │ ├── moe_gemm_2stage.py # MoE GEMM (2-stage gate/up + reduce)
│ │ ├── moe_blockscale_2stage.py # MoE Blockscale GEMM
│ │ ├── mixed_moe_gemm_2stage.py # Mixed-precision MoE GEMM
│ │ ├── mxfp_moe/ # Fused a4w4/a8w4 MoE 2-stage (device fp4 re-quant)
│ │ ├── moe_sorting_kernel.py # MoE token sorting
│ │ └── topk_gating_softmax_kernel.py # Top-k gating softmax
│ ├── mma/ # Shared MMA pipeline helpers
Expand Down
5 changes: 1 addition & 4 deletions docs/prebuilt_kernels_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ What operation do you need?
├── MoE (Mixture of Experts)
│ ├── Blockscale MoE (gate+up+reduce)
│ │ └── → kernels/moe/moe_blockscale_2stage.py
│ └── Standard MoE (fp8/f16/bf16/int8/int4)
│ └── → kernels/moe/moe_gemm_2stage.py
Expand All @@ -368,8 +367,7 @@ What operation do you need?
| `kernels/gemm/blockscale_preshuffle_gemm.py` | Blockscale GEMM |
| `kernels/gemm/hgemm_splitk.py` | FP16 GEMM split-K |
| `kernels/moe/moe_gemm_2stage.py` | MoE GEMM 2-stage (gate/up + reduce) |
| `kernels/moe/moe_blockscale_2stage.py` | MoE Blockscale 2-stage |
| `kernels/moe/mixed_moe_gemm_2stage.py` | Mixed-precision MoE GEMM |
| `kernels/moe/mxfp_moe/` | Fused a4w4/a8w4 MoE 2-stage GEMM (device fp4 re-quant) |
| `kernels/attention/pa_decode_fp8.py` | Paged attention decode (FP8) |
| `kernels/attention/flash_attn_generic.py` | FlashAttention generic fallback |
| `kernels/attention/flash_attn_gfx950.py` | FlashAttention gfx950 bf16/f16 fast path |
Expand Down Expand Up @@ -398,7 +396,6 @@ What operation do you need?
| `tests/kernels/test_blockscale_preshuffle_gemm.py` | Blockscale GEMM |
| `tests/kernels/test_hgemm_splitk.py` | FP16 GEMM split-K |
| `tests/kernels/test_moe_gemm.py` | MoE GEMM |
| `tests/kernels/test_moe_blockscale.py` | MoE Blockscale GEMM |
| `tests/kernels/test_moe_reduce.py` | MoE reduce kernel |
| `tests/kernels/test_pa.py` | Paged attention decode |
| `tests/kernels/test_flash_attn_fwd.py` | FlashAttention |
Expand Down
1 change: 0 additions & 1 deletion docs/testing_benchmarking_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Full end-to-end tests: compile FlyDSL kernels, execute on GPU, validate against
| `test_preshuffle_gemm.py` | GEMM | Preshuffle MFMA GEMM (fp8/int8/fp16/bf16) |
| `test_blockscale_preshuffle_gemm.py` | GEMM | Block-scale (MXFP4) preshuffle GEMM |
| `test_moe_gemm.py` | MoE GEMM | Mixture-of-Experts GEMM |
| `test_moe_blockscale.py` | MoE | MoE with block-scale quantization |
| `test_moe_reduce.py` | MoE Reduce | MoE reduction kernel |
| `test_pa.py` | Paged Attn | Paged attention decode |
| `test_quant.py` | Quantization | Quantization ops |
Expand Down
18 changes: 14 additions & 4 deletions kernels/common/tensor_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@
def _run_compiled(exe, *args):
"""First call: ``flyc.compile(exe, *args)`` compiles **and** executes the kernel.
Subsequent calls: fast dispatch via the cached ``CompiledFunction``.

A failed cold compile can leave an MLIR ``Context`` open on the stack; unwind
it before re-raising so the next attempt starts clean.
"""
cf = getattr(exe, "_cf", None)
if cf is None:
cf = flyc.compile(exe, *args)
exe._cf = cf
else:
if cf is not None:
cf(*args)
return
try:
exe._cf = flyc.compile(exe, *args)
except Exception:
try:
while ir.Context.current is not None:
ir.Context.current.__exit__(None, None, None)
except Exception:
pass
raise


def _to_raw(v):
Expand Down
15 changes: 0 additions & 15 deletions kernels/moe/mixed_moe_gemm_2stage/__init__.py

This file was deleted.

46 changes: 0 additions & 46 deletions kernels/moe/mixed_moe_gemm_2stage/common.py

This file was deleted.

Loading
Loading