Skip to content

[CUDA] Add Triton Q4_K-to-FP8 prefill linear - #22192

Open
Gasoonjia wants to merge 1 commit into
codex/stack-d113-persistent-splitkfrom
codex/stack-q4k-fp8-prefill
Open

[CUDA] Add Triton Q4_K-to-FP8 prefill linear#22192
Gasoonjia wants to merge 1 commit into
codex/stack-d113-persistent-splitkfrom
codex/stack-q4k-fp8-prefill

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Stack dependency

Depends on #22190.

Summary

Add an SM90+ pure-Triton Q4_K-to-FP8 prefill linear path.

  • Dequantize Q4_K weights directly to FP8 and feed an FP8 matrix multiplication with BF16 output.
  • Retain the existing low-token decode kernel and BF16 prefill fallback for unsupported devices or shapes.
  • Add float8 dtype support to the slim AOT runtime shims.
  • Select the CUDA-target FP8 custom op during export even when export example tensors reside on CPU.

This change remains Triton-only and does not introduce CUDA or CuteDSL kernels.

Operator-level performance

RTX 5090, representative Muse MLP projection (N=39,936, K=6,656), Q4_K dequantization plus linear:

Prefill rows M BF16 dequant + linear Q4_K-to-FP8 path Speedup
128 5.033 ms 0.507 ms 9.93x
512 5.818 ms 0.945 ms 6.16x
2,048 9.182 ms 2.688 ms 3.42x

Test plan

  • lintrunner init && lintrunner -a (clean).
  • Int4 dispatch tests: 22 passed.
  • Verified that SM90+ export captures triton.q4k_fp8_linear.
  • Final PTE profile contains 208 FP8 matmul and 208 Q4_K-to-FP8 dequant kernel calls.
  • git diff --check.

@pytorch-bot

pytorch-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22192

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 26, 2026
@Gasoonjia
Gasoonjia force-pushed the codex/stack-q4k-fp8-prefill branch from 0088e51 to d11d0c6 Compare August 26, 2026 21:56
@Gasoonjia
Gasoonjia changed the base branch from codex/stack-online-splitk-tuning to codex/stack-d113-persistent-splitk August 26, 2026 21:56
@Gasoonjia
Gasoonjia force-pushed the codex/stack-d113-persistent-splitk branch from b8ef410 to 8c9f0cc Compare August 26, 2026 22:50
@Gasoonjia
Gasoonjia force-pushed the codex/stack-q4k-fp8-prefill branch from d11d0c6 to 28a5119 Compare August 26, 2026 22:50
@Gasoonjia
Gasoonjia force-pushed the codex/stack-d113-persistent-splitk branch from 8c9f0cc to cfd96e1 Compare August 26, 2026 23:03
@Gasoonjia
Gasoonjia force-pushed the codex/stack-q4k-fp8-prefill branch from 28a5119 to 37690cd Compare August 26, 2026 23:03
Add an SM90+ Triton path that dequantizes Q4_K weights directly to FP8 and feeds FP8 matrix multiplication during prefill. Extend the AOT slim dtype shims for float8 and make export-time dispatch select the CUDA target while tracing CPU example tensors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant