Skip to content

[mxpf8] Make mxfp8 dim1 cast kernel configurable #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 12 additions & 3 deletions torchtitan/components/quantization/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,20 @@ def __init__(self, job_config: JobConfig, parallel_dims: ParallelDims):
self.filter_fqns = mx_job_config.filter_fqns

# Configure MXFP8
from torchao.prototype.mx_formats.config import MXLinearConfig
from torchao.prototype.mx_formats.config import (
MXFP8CastKernelChoice,
MXLinearConfig,
)

config = MXLinearConfig.from_recipe_name(NAME_MAP[mx_job_config.recipe_name])
config.use_fp8_dim1_cast_triton_kernel = (
mx_job_config.use_fp8_dim1_cast_triton_kernel

dim1_cast_kernel_choice_str = (
mx_job_config.mxfp8_dim1_cast_kernel_choice.upper()
)
config.mxfp8_dim1_cast_kernel_choice = (
MXFP8CastKernelChoice[dim1_cast_kernel_choice_str]
if mx_job_config.mxfp8_dim1_cast_kernel_choice != "NONE"
else None
)
self.config = config

Expand Down
2 changes: 1 addition & 1 deletion torchtitan/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class Float8:

@dataclass
class MX:
use_fp8_dim1_cast_triton_kernel: bool = True
mxfp8_dim1_cast_kernel_choice: Literal["triton", "cuda", "none"] = "triton"
"""Temp work around for inductor performance gap"""

recipe_name: Literal["mxfp8"] = "mxfp8"
Expand Down
Loading