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

Is it possible to restrict the dependencies of 'mlx.metallib' at compile time? #163

Open
tqtifnypmb opened this issue Dec 14, 2023 · 6 comments
Labels
question Further information is requested

Comments

@tqtifnypmb
Copy link

I think that would be nice for embed devices

@awni
Copy link
Member

awni commented Dec 16, 2023

What dependencies are you trying to remove? You can build without metal -DMLX_BUILD_METAL=OFF when you run cmake if that's what you mean.

@awni awni added the question Further information is requested label Dec 16, 2023
@tqtifnypmb
Copy link
Author

tqtifnypmb commented Dec 18, 2023

My main use case is tensor manipulation, but I need to leverage the advantages of universal memory to reduce the cost of memory copying. I wonder are there ways to avoid bundling mlx.metallib with the compiled binary?

@jagrit06
Copy link
Member

Thinking about possible methods, an option is to just bundle the metal source code and have the metal framework compile everything on the fly from the source - this might add some runtime overhead though (but also you will only have compiled versions of the kernels that you are using, so that might be a benefit depending on the device)

Beyond that, it will have to depend on your use case and what dependancies you want to avoid

@tqtifnypmb
Copy link
Author

tqtifnypmb commented Jan 4, 2024

Thinking about possible methods, an option is to just bundle the metal source code and have the metal framework compile everything on the fly from the source - this might add some runtime overhead though (but also you will only have compiled versions of the kernels that you are using, so that might be a benefit depending on the device)

Beyond that, it will have to depend on your use case and what dependancies you want to avoid

I primarily want to use it for iOS/macOS apps. If I include mlx.metallib in the binary, it will make the installation package too large. I'm wondering if it's possible to specify the operations to be used during compilation and then generate mlx.metallib based on these operations.

@akuz
Copy link

akuz commented Jul 25, 2024

@tqtifnypmb -- how were you able to include mlx.metallib into the app? I cannot do it. Please see my bug report here: #1286

P.S. You can make the binary much smaller if you don't pre-compile the shaders. See "Binary Size Minimization" here: https://ml-explore.github.io/mlx/build/html/install.html

@tqtifnypmb
Copy link
Author

tqtifnypmb commented Jul 26, 2024

@akuz

I can't recall what I did.

I just copy mlx.metallib next to the compiled executable file, not to framework nor resources dir as you mentioned in #1286.

and

I maybe (maybe not) changed METAL_PATH while compiling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants