Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

MLX compatibility: operators and elementwise functions

未關閉
#465 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python
領域
data, testing-qa

研究方向

針對 array_api_tests/test_operators_and_elementwise_functions.py 執行已回報的 ARRAY_API_TESTS_MODULE=mlx.core pytest 命令。依缺少的函式、複數核心、純量處理和整數運算將失敗分組,然後判斷哪些需要進行相容性工作,以及哪些需要向 upstream 回報。完成的標準是受影響的測試通過,或剩餘的 MLX 限制已明確向 upstream 回報。

由索引模型根據 Issue 內容生成。

描述

Towards https://github.com/data-apis/array-api-compat/issues/450.

Running

$ ARRAY_API_TESTS_SKIP_DTYPES=float64,complex128 ARRAY_API_TESTS_MODULE=mlx.core pytest array_api_tests/test_operators_and_elementwise_functions.py -v
...
==================================================== short test summary info =====================================================
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_acos - ValueError: a=(nan+nanj) and b=(1.570796326562066-22.873856958478193j), but input must be non-NaN
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_acosh - RuntimeError: [metal::Device] Unable to load kernel v_ArcCoshcomplex64complex64
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_asin - AssertionError: out=infj, but should be roughly asin(x)=(0.7856422146397344+8.664583897600078j) [asin()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_asinh - RuntimeError: [metal::Device] Unable to load kernel v_ArcSinhcomplex64complex64
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_atan - ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_atanh - RuntimeError: [metal::Device] Unable to load kernel v_ArcTanhcomplex64complex64
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[bitwise_left_shift(x1, x2)] - AssertionError: out=1, but should be (x1 << x2)=0 [bitwise_left_shift()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__lshift__(x1, x2)] - AssertionError: out=1, but should be (x1 << x2)=0 [__lshift__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__ilshift__(x1, x2)] - AssertionError: x1=1, but should be (x1 << x2)=0 [__ilshift__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[bitwise_right_shift(x1, x2)] - AssertionError: out=1, but should be (x1 >> x2)=0 [bitwise_right_shift()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__rshift__(x1, x2)] - AssertionError: out=1, but should be (x1 >> x2)=0 [__rshift__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__irshift__(x1, x2)] - AssertionError: x1=1, but should be (x1 >> x2)=0 [__irshift__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_clip - TypeError: clip(): incompatible function arguments. The following argument types are supported:
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_copysign - AssertionError: copysign is not defined in mlx.core
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_divide[divide(x1, x2)] - ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_expm1 - ValueError: [expm1] Not supported for complex64.
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[floor_divide(x1, x2)] - AssertionError: out=0, but should be (x1 // x2)=-1 [floor_divide()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x1, x2)] - AssertionError: out=0, but should be (x1 // x2)=-1 [__floordiv__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x1, x2)] - AssertionError: x1=0, but should be (x1 // x2)=-1 [__ifloordiv__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_hypot - AssertionError: hypot is not defined in mlx.core
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_log - AssertionError: out=(inf+0.8922129273414612j), but should be roughly log(x)=(44.361419543366964+0.892212881624599j) [log()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_log1p - AssertionError: out=(inf+0.7905846238136292j), but should be roughly log1p(x)=(44.361419543239215+0.7905845671575851j) [log1p()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_log2 - AssertionError: out=(inf+1.2417556047439575j), but should be roughly log2(x)=(63.99999997183151+1.241755551201958j) [log2()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_log10 - AssertionError: out=(inf+0.47804269194602966j), but should be roughly log10(x)=(19.265919715434027+0.47804270750558625j) [log...
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_nextafter - AssertionError: nextafter is not defined in mlx.core
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_positive[__pos__] - AttributeError: 'mlx.core.array' object has no attribute '__pos__'. Did you mean: '__pow__'?
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_signbit - AssertionError: signbit is not defined in mlx.core
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_sqrt - AssertionError: out=(inf+infj), but should be roughly sqrt(x)=(3956798150.479092+1670476642.4809253j) [sqrt()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_binary_with_scalars_real[atan2] - TypeError: arctan2(): incompatible function arguments. The following argument types are supported:
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_binary_with_scalars_real[copysign] - AssertionError: copysign is not defined in mlx.core
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_binary_with_scalars_real[hypot] - AssertionError: hypot is not defined in mlx.core
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_binary_with_scalars_real[nextafter] - AssertionError: nextafter is not defined in mlx.core
===================================== 32 failed, 123 passed, 5 skipped in 126.21s (0:02:06) ======================================

Failures sort into several categories:

  • Functions missing in MLX: nextafter, hypot, copysign, signbit, __pos__:
    --Could be submitted to MLX as pure enhancements.
  • Functions exist in MLX but miss complex kernels: acosh, asinh, atanh, exmp1:
    --We could report them upstream.
  • Early overflow in the complex plane (likely, internal computations done in float32): acos, asin, log, log2, log10, log1p, sqrt:
    --Cross-ref https://github.com/numpy/numpy/issues/32234#issuecomment-5244752601, hopefully will get fixed at the source.
  • Functions only arrays and reject python scalars: mx.atan2( mx.asarray(1.0), 2.0) :
    --Looks to be a small omission (other binary functions accept scalars?), can submit a PR upstream.
  • Modular arithmetics / rounding modes for integers: __floordiv__(array(-1, dtype=int8), array(2, dtype=int8)), also shifts, bitwise_right_shift(array(1, dtype=int32), array(32, dtype=int16)):
    --These need investigation.
  • clip requires min, max arguments, while in the spec they are optional:
    --Also a simple omission, can submit a PR upstream.
主要語言
Python
星號
131
分支
49
平均合併
16 小時 2 分鐘
30 天內合併 PR
2

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

data-apis/array-api-compat 的其他 Issue

查看 data-apis/array-api-compat 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。