pytorch - 💡(How to fix) Fix torch.nn.functional.scaled_grouped_mm doesn't support compile

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

I'm trying to migrate from the old private torch._scaled_grouped_mm api, to the new public torch.nn.functional.scaled_grouped_mm api in torchao here.

I am running into a composability issue with torch.compile:

Error Message

E NotImplementedError: aten::_scaled_grouped_mm_v2: attempted to run this operator with Meta tensors, but there was no fake impl or Meta kernel registered. You may have run into this message while using an operator with PT2 compilation APIs (torch.compile/torch.export); in order to use this operator with those APIs you'll need to add a fake impl. Please see the following for next steps: https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html

Root Cause

I'm trying to migrate from the old private torch._scaled_grouped_mm api, to the new public torch.nn.functional.scaled_grouped_mm api in torchao here.

I am running into a composability issue with torch.compile:

Fix Action

Fix / Workaround

While trying to debug this with various workarounds, I encountered other new errors:

Code Example

E               torch._dynamo.exc.Unsupported: Unexpected type in sourceless builder
E                 Higher Order Operator: autograd.Function
E                 Explanation: SourcelessBuilder.create does not know how to wrap <class 'torch.nn.functional._ScalingType'>
E                 Hint: This is likely to be a Dynamo bug. Please report an issue to PyTorch.
E               
E                 Developer debug context: torch.nn.functional._ScalingType
E               
E                For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0116.html
E               
E               from user code:
E                  File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 136, in _to_mxfp8_then_scaled_grouped_mm
E                   output = _MXFP8GroupedMM.apply(
E                 File "/home/dev/.conda/envs/torch/lib/python3.13/site-packages/torch/_functorch/autograd_function.py", line 880, in inner
E                   outs = orig_fwd(*args, **kwargs)
E                 File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 245, in forward
E                   output = _compute_fwd(
E                 File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 408, in _compute_fwd
E                   return _compute_fwd_sm100(
E                 File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 590, in _compute_fwd_sm100
E                   ScalingType.BlockWise1x32,

---

E       NotImplementedError: aten::_scaled_grouped_mm_v2: attempted to run this operator with Meta tensors, but there was no fake impl or Meta kernel registered. You may have run into this message while using an operator with PT2 compilation APIs (torch.compile/torch.export); in order to use this operator with those APIs you'll need to add a fake impl. Please see the following for next steps:  https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html

---

E                 Higher Order Operator: autograd.Function
E                 Explanation: Dynamo does not know how to trace the builtin `torch._VariableFunctionsClass._scaled_grouped_mm_v2.` This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind).
RAW_BUFFERClick to expand / collapse

Context

I'm trying to migrate from the old private torch._scaled_grouped_mm api, to the new public torch.nn.functional.scaled_grouped_mm api in torchao here.

I am running into a composability issue with torch.compile:

Error 1

E               torch._dynamo.exc.Unsupported: Unexpected type in sourceless builder
E                 Higher Order Operator: autograd.Function
E                 Explanation: SourcelessBuilder.create does not know how to wrap <class 'torch.nn.functional._ScalingType'>
E                 Hint: This is likely to be a Dynamo bug. Please report an issue to PyTorch.
E               
E                 Developer debug context: torch.nn.functional._ScalingType
E               
E                For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0116.html
E               
E               from user code:
E                  File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 136, in _to_mxfp8_then_scaled_grouped_mm
E                   output = _MXFP8GroupedMM.apply(
E                 File "/home/dev/.conda/envs/torch/lib/python3.13/site-packages/torch/_functorch/autograd_function.py", line 880, in inner
E                   outs = orig_fwd(*args, **kwargs)
E                 File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 245, in forward
E                   output = _compute_fwd(
E                 File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 408, in _compute_fwd
E                   return _compute_fwd_sm100(
E                 File "/home/dev/ao/torchao/prototype/moe_training/mxfp8_grouped_mm.py", line 590, in _compute_fwd_sm100
E                   ScalingType.BlockWise1x32,

While trying to debug this with various workarounds, I encountered other new errors:

Error 2

E       NotImplementedError: aten::_scaled_grouped_mm_v2: attempted to run this operator with Meta tensors, but there was no fake impl or Meta kernel registered. You may have run into this message while using an operator with PT2 compilation APIs (torch.compile/torch.export); in order to use this operator with those APIs you'll need to add a fake impl. Please see the following for next steps:  https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html

This seems to imply there's no fake/meta function registered for this aten op, and we need one implemented in core for torch.compile composability

Error 3

E                 Higher Order Operator: autograd.Function
E                 Explanation: Dynamo does not know how to trace the builtin `torch._VariableFunctionsClass._scaled_grouped_mm_v2.` This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind).

cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @chauhang @penguinwu @eellison @aorenste @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @amjames @jataylo @azahed98 @bdhirsh @bobrenjc93 @slayton58 @ngimel

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix torch.nn.functional.scaled_grouped_mm doesn't support compile