[BUG] mx.expm1 is wrong for complex inputs (discards imaginary part)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with the CPU backend implementation of mx.expm1 and compare its handling with the special cases already used by mx.log1p and mx.log2. Confirm that complex inputs preserve their imaginary part and that mx.expm1(z) matches mx.exp(z) - 1 for the reported example.
Written by the indexing model from the issue text.
Description
Describe the bug
mx.expm1 returns wrong results for complex inputs: it operates on the real part and discards the imaginary part. The CPU backend uses std::expm1, which has no complex overload.
import mlx.core as mx
z = mx.array([0.5 + 0.7j])
print(mx.expm1(z)) # [0.6487+0j] == expm1(0.5), wrong
print(mx.exp(z) - 1) # [0.261+1.062j] correct
mx.log1p and mx.log2 already special-case complex; expm1 was missed.
Expected behavior
mx.expm1(z) == mx.exp(z) - 1 for complex z.
Desktop
- OS: macOS
- Version: main (0.32.0.dev)
- Dominant language
- C++
- Stars
- 28.5k
- Forks
- 2.3k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 58
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ml-explore/mlx
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ml-explore/mlx#4536 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ml-explore/mlx#4534 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ml-explore/mlx#4533 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ml-explore/mlx#4503 · 1 comment ·
-
bug low priority
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ml-explore/mlx#4321 · 1 comment ·
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·