Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix backend/mlx/core and backend/common/dtypes for MLX + Improve integration_tests/numerical_test.py #19619

Open
wants to merge 66 commits into
base: mlx
Choose a base branch
from

Conversation

Faisal-Alsrheed
Copy link
Contributor

@Faisal-Alsrheed Faisal-Alsrheed commented Apr 26, 2024

MLX Backend Specific Failures:

Missing Operations: The MLX backend lack implementations for specific operations, including:

  • mod
  • rand
  • rmatmul
  • ror
  • rpow
  • rxor
  • xor
 KERAS_BACKEND=mlx pytest keras/src/backend/
=================================================================================================================== short test summary info ====================================================================================================================
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__mod__ - AssertionError: 
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__rand__ - AttributeError: 'mlx.core.array' object has no attribute '__rand__'. Did you mean: '__and__'?
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__rmatmul__ - AttributeError: 'mlx.core.array' object has no attribute '__rmatmul__'. Did you mean: '__imatmul__'?
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__ror__ - AttributeError: 'mlx.core.array' object has no attribute '__ror__'. Did you mean: '__ior__'?
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__rpow__ - AttributeError: 'mlx.core.array' object has no attribute '__rpow__'. Did you mean: '__ipow__'?
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__rxor__ - AttributeError: 'mlx.core.array' object has no attribute '__rxor__'. Did you mean: '__ior__'?
FAILED keras/src/backend/common/variables_test.py::VariableOperationsTest::test__xor__ - AttributeError: 'mlx.core.array' object has no attribute '__xor__'. Did you mean: '__ior__'?
========================================================================================================== 7 failed, 413 passed, 91 skipped in 7.92s ===========================================================================================================

@Faisal-Alsrheed Faisal-Alsrheed changed the title [WIP] Implement convolution operation for MLX backend [WIP] Implement backend/mlx/nn.py:conv Apr 26, 2024
@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2024

Codecov Report

Attention: Patch coverage is 46.15385% with 7 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (mlx@722883a). Click here to learn what that means.

Files Patch % Lines
keras/src/backend/mlx/core.py 0.00% 5 Missing ⚠️
keras/src/backend/common/variables.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             mlx   #19619   +/-   ##
======================================
  Coverage       ?   69.12%           
======================================
  Files          ?      506           
  Lines          ?    45944           
  Branches       ?     8499           
======================================
  Hits           ?    31757           
  Misses         ?    12534           
  Partials       ?     1653           
Flag Coverage Δ
keras 69.04% <46.15%> (?)
keras-jax 59.51% <46.15%> (?)
keras-numpy 53.85% <46.15%> (?)
keras-tensorflow 60.65% <46.15%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…t and channels_last data formats consistently
…irst and channels_last data formats consistently
@Faisal-Alsrheed Faisal-Alsrheed changed the title [WIP] Implement backend/mlx/nn.py:conv [WIP] Fix backend/mlx/core file and backend/common/dtypes for MLX Apr 30, 2024
@Faisal-Alsrheed Faisal-Alsrheed changed the title [WIP] Fix backend/mlx/core file and backend/common/dtypes for MLX [WIP] Fix backend/mlx/core and backend/common/dtypes for MLX Apr 30, 2024
@Faisal-Alsrheed Faisal-Alsrheed changed the title [WIP] Fix backend/mlx/core and backend/common/dtypes for MLX [WIP] Fix backend/mlx/core and backend/common/dtypes for MLX + Improve integration_tests/numerical_test.py May 1, 2024
@Faisal-Alsrheed Faisal-Alsrheed marked this pull request as ready for review May 3, 2024 06:08
@Faisal-Alsrheed Faisal-Alsrheed changed the title [WIP] Fix backend/mlx/core and backend/common/dtypes for MLX + Improve integration_tests/numerical_test.py Fix backend/mlx/core and backend/common/dtypes for MLX + Improve integration_tests/numerical_test.py May 3, 2024
if isinstance(x, mx.array):
if x.dtype == mx.int64:
x = x.astype(mx.int32)
elif x.dtype == mx.float64:
Copy link
Contributor

@lkarthee lkarthee May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no mx.float64 ?

@@ -70,9 +70,11 @@ def convert_to_tensor(x, dtype=None, sparse=None):
return x.value.astype(mlx_dtype)
return x.value

if isinstance(x, np.ndarray):
Copy link
Contributor

@lkarthee lkarthee May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove this cast, mlx crashes when running some test cases on my local machine. I logged a bug on mlx repo (see mlx backend issue).

It did not crash on CI tests on this pr because it is not being run on macOS ? Am really confused as I thought mlx runs only on macOS.

https://github.com/keras-team/keras/actions/runs/8907542811/job/24461598952#step:1:2

2024-05-01T09:07:10.5470064Z Current runner version: '2.316.0'
2024-05-01T09:07:10.5494922Z ##[group]Operating System
2024-05-01T09:07:10.5495654Z Ubuntu
2024-05-01T09:07:10.5496034Z 22.04.4
2024-05-01T09:07:10.5496669Z LTS
2024-05-01T09:07:10.5497089Z ##[endgroup]
2024-05-01T09:07:10.5497521Z ##[group]Runner Image
2024-05-01T09:07:10.5498174Z Image: ubuntu-22.04
2024-05-01T09:07:10.5498671Z Version: 20240422.1.0
2024-05-01T09:07:10.5499877Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240422.1/images/ubuntu/Ubuntu2204-Readme.md
2024-05-01T09:07:10.5501763Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240422.1

@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
PR Queue
Assigned Reviewer
Development

Successfully merging this pull request may close these issues.

None yet

4 participants