Skip to content

Conversation

@ifsheldon
Copy link
Contributor

This resolves the issue in #295 (comment), adding a backend for MLX so that we can use einsum. Since MLX has very similar APIs to PyTorch and Numpy, the MLXBackend looks very similar to NumpyBackend and TorchBackend.

The tests passed on my Mac.

$ uv run einops/tests/run_tests.py mlx
running: ['python', '-m', 'pytest', '.']
=========================================================== test session starts ===========================================================
platform darwin -- Python 3.12.9, pytest-8.3.5, pluggy-1.5.0
rootdir: /Users/zhiqiu/offline_code/opensource/einops
configfile: pyproject.toml
collected 64 items                                                                                                                        

test_einsum.py ....                                                                                                                 [  6%]
test_examples.py .s                                                                                                                 [  9%]
test_layers.py ....ssss..                                                                                                           [ 25%]
test_ops.py ......................s.                                                                                                [ 62%]
test_other.py ............ss.s                                                                                                      [ 87%]
test_packing.py ....                                                                                                                [ 93%]
test_parsing.py ....                                                                                                                [100%]

============================================================ warnings summary =============================================================
einops/tests/test_layers.py::test_einmix_decomposition
  /Users/zhiqiu/offline_code/opensource/einops/einops/layers/_einmix.py:63: UserWarning: EinMix: weight has no dimensions (means multiplication by a number)
    self.initialize_einmix(

einops/tests/test_other.py::testmod
  /Users/zhiqiu/offline_code/opensource/einops/.venv/lib/python3.12/site-packages/_pytest/python.py:163: PytestReturnNotNoneWarning: Expected None, but einops/tests/test_other.py::testmod returned TestResults(failed=0, attempted=0), which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================ 55 passed, 9 skipped, 2 warnings in 0.18s ================================================

@ifsheldon
Copy link
Contributor Author

Probably we need to add new CI configurations for testing MLX as well.

@ifsheldon
Copy link
Contributor Author

@arogozhnikov Hi! Can you take a look at this PR? Thanks!

@Datamance
Copy link

Very excited for this! I prefer the MLX api and throwing einsum in the mix would be fabulous.

@ryang-max
Copy link

Any progress on this? Really looking forward to this feature 🚀

@Datamance
Copy link

When will this be merged?

@Datamance
Copy link

Ping 😄 @arogozhnikov can this be merged?

@arogozhnikov
Copy link
Owner

uh. Okok, let's make an exception for MLX.

@arogozhnikov arogozhnikov merged commit 3cdcbd5 into arogozhnikov:main Jan 22, 2026
7 checks passed
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