Skip to content

Conversation

@RuibinCheung
Copy link
Contributor

Copilot AI review requested due to automatic review settings January 6, 2026 02:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for MXFP4 quantization in the Megatron-LM backend by extending the existing FP8 infrastructure to handle FP4 formats. The implementation allows users to enable MXFP4 by setting fp4: mxfp4 and fp4_recipe: mxfp4 in configuration files.

Key changes:

  • Created new FP4 utilities and patches mirroring the FP8 implementation pattern
  • Refactored quantization configuration to support both FP8 and FP4 through a unified PrimusTurboQuantConfig class
  • Updated Primus-Turbo dependency to a newer commit that includes MXFP4 support

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
primus/modules/trainer/megatron/utils.py Added FP4 validation and made validation code paths configurable via kwargs
primus/modules/trainer/megatron/trainer.py Added conditional FP4 validation path and made ori_code/new_code explicit parameters
primus/backends/megatron/patches/fp4_patches.py New file implementing FP4-specific patches for enums and context functions
primus/backends/megatron/core/fp8_utils.py Refactored FP8 utilities to extract recipe/config creation and updated context managers
primus/backends/megatron/core/fp4_utils.py New file implementing FP4 context managers and recipe handling
primus/backends/megatron/core/extensions/primus_turbo.py Unified FP8/FP4 configuration and added FP4 support across all linear operations
primus/backends/megatron/core/enums.py New file defining FP4 recipe enumeration
.github/workflows/ci.yaml Updated Primus-Turbo commit reference to include MXFP4 support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 6, 2026 03:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RuibinCheung RuibinCheung merged commit 8e94cec into main Jan 6, 2026
5 checks passed
@RuibinCheung RuibinCheung deleted the dev/support_mxfp4 branch January 6, 2026 08:17
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.

4 participants