Skip to content

FP8 support for tokamax gmm kernel - #2706

Merged
copybara-service[bot] merged 1 commit into
mainfrom
mohit/tokamax_quant_gmm
Nov 20, 2025
Merged

FP8 support for tokamax gmm kernel#2706
copybara-service[bot] merged 1 commit into
mainfrom
mohit/tokamax_quant_gmm

Conversation

@khatwanimohit

@khatwanimohit khatwanimohit commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR calls tokamax_api.gmm in megablox/ops.py for supporting FP8 quantization using tokamax's gmm kernel. It also extends the tiling configs to 18 values, 9 for wi-* and 9 for wo tensors.

If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/458461066

Notice 1: Once all tests pass, the "pull ready" label will automatically be assigned.
This label is used for administrative purposes. Please do not add it manually.

Notice 2: For external contributions, our settings currently require an approval from a MaxText maintainer to trigger CI tests.

Tests

Command to repro: https://paste.googleplex.com/6669707558125568
Xprof: http://shortn/_HoU0Xj2IZ9

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@khatwanimohit
khatwanimohit force-pushed the mohit/tokamax_quant_gmm branch 2 times, most recently from 9d50c6a to 33cddf8 Compare November 17, 2025 22:33
@khatwanimohit khatwanimohit changed the title quantization with tokamax gmm FP8 support for tokamax gmm kernel Nov 17, 2025
@khatwanimohit
khatwanimohit marked this pull request as ready for review November 17, 2025 22:41
@khatwanimohit
khatwanimohit force-pushed the mohit/tokamax_quant_gmm branch from 33cddf8 to 64268d9 Compare November 17, 2025 22:47
Comment thread src/MaxText/layers/moe.py
Comment thread src/MaxText/configs/base.yml Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This pull request adds support for FP8 quantization using the tokamax GMM kernel. The changes are well-structured and introduce fine-grained configuration for tiling dimensions. The core logic is updated to switch between the existing megablox backend and the new tokamax backend.

🔍 General Feedback

  • The introduction of specific tiling configurations for forward and backward passes is a good improvement for tunability.
  • The changes in moe.py to support the tokamax backend are well-integrated.
  • I've left a few minor suggestions for improving code clarity and fixing a potential typo. There is also a question about a change in implementation detail that might affect performance.

Comment thread src/MaxText/configs/types.py Outdated
Comment thread src/MaxText/kernels/megablox/ops.py
Comment thread src/MaxText/configs/types.py Outdated
Comment thread src/MaxText/configs/types.py Outdated
Comment thread src/MaxText/configs/types.py Outdated
Comment thread src/MaxText/kernels/megablox/ops.py
Comment thread src/MaxText/kernels/megablox/ops.py
Comment thread src/MaxText/layers/moe.py
Comment thread src/MaxText/layers/moe.py Outdated
@khatwanimohit
khatwanimohit force-pushed the mohit/tokamax_quant_gmm branch from 64268d9 to 1bc7561 Compare November 18, 2025 00:30

@RissyRan RissyRan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Just one comment to move proper assertion in moe.py to the pyconfig file

@khatwanimohit
khatwanimohit force-pushed the mohit/tokamax_quant_gmm branch from 1bc7561 to e9d47c6 Compare November 18, 2025 02:45
Comment thread src/MaxText/layers/moe.py Outdated
Comment thread src/MaxText/kernels/megablox/backend.py
@khatwanimohit
khatwanimohit force-pushed the mohit/tokamax_quant_gmm branch 4 times, most recently from 7cf0bc9 to 4f761e0 Compare November 19, 2025 01:05
Comment thread src/MaxText/configs/base.yml
@khatwanimohit
khatwanimohit force-pushed the mohit/tokamax_quant_gmm branch from ffda110 to 67dc1f3 Compare November 19, 2025 18:37
@copybara-service
copybara-service Bot merged commit 05abc90 into main Nov 20, 2025
34 of 40 checks passed
@copybara-service
copybara-service Bot deleted the mohit/tokamax_quant_gmm branch November 20, 2025 06:58
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.

4 participants