pytorch - ✅(Solved) Fix [MPS] Mixtral-8x7B fails on MPS with NotImplementedError: "histogram_mps" not implemented for 'Int' [1 pull requests, 4 comments, 2 participants]

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…
GitHub stats
pytorch/pytorch#176879Fetched 2026-04-08 00:24:01
View on GitHub
Comments
4
Participants
2
Timeline
70
Reactions
0
Participants
Assignees
Timeline (top)
mentioned ×22subscribed ×22labeled ×9referenced ×5

Error Message

import torch x = torch.tensor([0, 1, 2, 1, 0], dtype=torch.int32, device="mps") torch.histc(x, bins=3, min=0, max=2)

NotImplementedError: 'histogram_mps' not implemented for 'Int'

Fix Action

Fixed

PR fix notes

PR #176913: [EZ][MPS] Extend histogram to float/bfloat

Description (problem / solution / changelog)

Stack from ghstack (oldest at bottom):

  • -> #176913

The code was there for a while, at least for half, but dispatch was misconfigured. Though restrict histogram/histogramdd to support only float32, to match OpInfo definition. Also, switch to DispatchV2

Related to https://github.com/pytorch/pytorch/issues/176879

Changed files

  • aten/src/ATen/native/mps/kernels/HistogramKernel.metal (modified, +2/-1)
  • aten/src/ATen/native/mps/operations/HistogramKernel.mm (modified, +11/-5)
  • torch/testing/_internal/common_methods_invocations.py (modified, +0/-2)
  • torch/testing/_internal/common_mps.py (modified, +0/-1)

Code Example

import torch
 x = torch.tensor([0, 1, 2, 1, 0], dtype=torch.int32, device="mps")
 torch.histc(x, bins=3, min=0, max=2)
 # NotImplementedError: 'histogram_mps' not implemented for 'Int'
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

torch.histc on MPS only supports fp16 and fp32; passing integer tensors raises NotImplementedError. This surfaces in HuggingFace Transformers ≥ 5.1.0 Mixtral MoE routing.

 import torch
 x = torch.tensor([0, 1, 2, 1, 0], dtype=torch.int32, device="mps")
 torch.histc(x, bins=3, min=0, max=2)
 # NotImplementedError: 'histogram_mps' not implemented for 'Int'

Versions

PyTorch version: 2.10.0 Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A

OS: macOS 26.3 (arm64) GCC version: Could not collect Clang version: Could not collect CMake version: Could not collect Libc version: N/A

Python version: 3.11.13 (main, Jun 5 2025, 08:21:08) [Clang 14.0.6 ] (64-bit runtime) Python platform: macOS-26.3-arm64-arm-64bit Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA Is XPU available: False HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True Caching allocator config: N/A

CPU: Apple M3 Ultra

Versions of relevant libraries: [pip3] numpy==1.26.4 [pip3] torch==2.10.0 [conda] numpy 1.26.4 [conda] torch 2.10.0

cc @ezyang @gchanan @kadeng @msaroufim @kulinseth @malfet @DenisVieriu97 @jhavukainen @aditvenk

extent analysis

Fix Plan

Workaround: Convert Integer Tensor to Float Tensor

To fix the issue, we can convert the integer tensor to a float tensor before passing it to torch.histc. This is because torch.histc on MPS only supports fp16 and fp32.

Code Snippet

import torch

x = torch.tensor([0, 1, 2, 1, 0], dtype=torch.int32, device="mps")
x_float = x.float()  # Convert integer tensor to float tensor
torch.histc(x_float, bins=3, min=0, max=2)

Alternatively, you can also use torch.histc with the dtype argument set to torch.float32:

torch.histc(x, bins=3, min=0, max=2, dtype=torch.float32)

Update Code in HuggingFace Transformers

If you are using HuggingFace Transformers, you can update the code in moe.py to convert the integer tensor to a float tensor before passing it to torch.histc.

# Before
torch.histc(x, bins=3, min=0, max=2)

# After
x_float = x.float()
torch.histc(x_float, bins=3, min=0, max=2)

Verify the Fix

To verify that the fix worked, you can run the code again and check if the NotImplementedError is raised. If the fix is successful, the code should run without errors.

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 - ✅(Solved) Fix [MPS] Mixtral-8x7B fails on MPS with NotImplementedError: "histogram_mps" not implemented for 'Int' [1 pull requests, 4 comments, 2 participants]