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

update: Update to revamped c binding #147

Merged
merged 60 commits into from
Dec 11, 2024
Merged

update: Update to revamped c binding #147

merged 60 commits into from
Dec 11, 2024

Conversation

minghuaw
Copy link
Collaborator

@minghuaw minghuaw commented Nov 18, 2024

@minghuaw minghuaw marked this pull request as draft November 18, 2024 22:56
@minghuaw minghuaw assigned minghuaw and unassigned minghuaw Nov 18, 2024
mlx-rs/src/array/mod.rs Outdated Show resolved Hide resolved
mlx-rs/src/macros/internal.rs Outdated Show resolved Hide resolved
@dcvz
Copy link
Contributor

dcvz commented Nov 20, 2024

@minghuaw Feels great and quite clean ✨

mlx-rs/src/error.rs Outdated Show resolved Hide resolved
@minghuaw minghuaw marked this pull request as ready for review December 11, 2024 05:11
@minghuaw
Copy link
Collaborator Author

@dcvz somehow it's requiring metal3.2 and only macos 15 is supported. Would there be macos 15 support in blaze soon?

@dcvz
Copy link
Contributor

dcvz commented Dec 11, 2024

@minghuaw set it to blaze/macos-15 :)

@minghuaw
Copy link
Collaborator Author

minghuaw commented Dec 11, 2024

@minghuaw set it to blaze/macos-15 :)

Didn't realize this is already available since it was not shown on your website lol

@minghuaw minghuaw merged commit f5e413b into main Dec 11, 2024
3 checks passed
@minghuaw minghuaw deleted the update/revamped-c-api branch December 11, 2024 08:24
minghuaw added a commit that referenced this pull request Dec 11, 2024
* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 11, 2024
* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 11, 2024
* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 11, 2024
* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 11, 2024
* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 13, 2024
* add InstanceNorm

* fix wrong reduction_axes

* add LayerNorm

* added RmsNorm

* add GroupNorm

* partial impl batch norm

* change forward to take &mut self

* add BatchNorm

* clippy and fmt

* Revamp internal macro `generate_builder!{}` (#150)

* initial impl of Buildable macro

* test generate_builder and Buildable macro on AdaDelta

* clippy

* update adafactor

* fix missing doc in generated code

* update current use of generate_builder macro

* always auto impl Builder when derive Builder

* added impl Into for new() args

* update mod linear

* clippy and fmt

* update docs

* update doc for generated builder

* Add generic type `Args` in `Module` trait to allow binary modules (#146)

* add unary module

* update module_value_and_grad impl

* update doc for UnaryModule and BinaryModule

* clippy and fmt

* change trait bound to ModuleParameters

* added marker trait TernaryModule

* fixed typo

* remove two unused marker traits

* added associated type Output in trait Module

* update norm to use Builder and Buildable macros

* update: Update to revamped c binding (#147)

* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>

* fix error handling

* clippy and fmt

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 14, 2024
* add ConvTranspose1d

* add ConvTranspose*

* feat: Allow recursive freeze/unfreeze (#143)

* clippy and fmt

* rename to test_optimizers

* update Parameter and ModuleParameter traits

* add test cases for recursive freeze/unfreeze

* fix error in unit test

* fix: Fix error with checking if parameter is frozen on empty module (#144)

* fix *_frozen() error with empty module

* clippy and fmt

* add freeze/unfreeze test cases for empty module

* feat: Change `Module::forward` to take `&mut self` (#145)

* change Module::forward to take &mut self

* clippy  and fmt

* update Module impl

* update to latest Builder and Buildable macros

* update: Update to revamped c binding (#147)

* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>

* clippy and fmt

* rename conv_transposed to conv_transpose

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Dec 14, 2024
* add MultiHeadAttention

* add more conversion into Input

* encoder layer requires layernorm

* replace deep_clone with regular clone

* impl transformer encoder layer

* impl transformer encoder

* impl TransformerDecoderLayer

* impl TransformerDecoder

* impl Transformer

* clippy and fmt

* clippy and fmt

* update: Update to revamped c binding (#147)

* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>

* replace placefolder with actual LayerNorm

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Jan 2, 2025
* add QuantizedEmbedding

* add QuantizedLinear

* clippy and fmt

* feat: Allow recursive freeze/unfreeze (#143)

* clippy and fmt

* rename to test_optimizers

* update Parameter and ModuleParameter traits

* add test cases for recursive freeze/unfreeze

* fix error in unit test

* update to latest change in ModuleParameter

* fix: Fix error with checking if parameter is frozen on empty module (#144)

* fix *_frozen() error with empty module

* clippy and fmt

* add freeze/unfreeze test cases for empty module

* feat: Change `Module::forward` to take `&mut self` (#145)

* change Module::forward to take &mut self

* clippy  and fmt

* update Module impl

* update quantized to use Bulider and Buildable macro

* update: Update to revamped c binding (#147)

* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>

* derive Clone for Embedding

* derive Clone

---------

Co-authored-by: David Chavez <[email protected]>
minghuaw added a commit that referenced this pull request Jan 7, 2025
* impl pooling

* clippy and fmt

* feat: Change `Module::forward` to take `&mut self` (#145)

* change Module::forward to take &mut self

* clippy  and fmt

* update Module impl

* update pooling

* update: Update to revamped c binding (#147)

* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>

* fix errror handling

* cargo fmt

* replace Arc with DynClone

* clippy and fmt

---------

Co-authored-by: David Chavez <[email protected]>
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.

2 participants