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

Add Metal (Apple Silicon) support #1819

Closed

Conversation

NADOOITChristophBa
Copy link

This PR adds support for Apple's Metal framework to improve performance on Apple Silicon devices.

Key Changes:

  1. Add Metal as a new device type
  2. Create Metal backend implementation
  3. Add Metal-specific memory management
  4. Update device dispatch system
  5. Add CMake configuration for Metal

Implementation Details:

  • Added Metal device type to Device enum
  • Created Metal backend in src/metal/
  • Implemented device detection and management
  • Added proper fallback mechanisms
  • Integrated with existing device dispatch
  • Added CMake option WITH_METAL

Testing:

  • Tested on Apple Silicon (M1/M2)
  • Verified device detection
  • Checked memory management
  • Validated fallback behavior

Notes:

  • Requires explicit compilation with -DWITH_METAL=ON
  • Uses Objective-C++ for Metal framework integration
  • Maintains compatibility with existing backends

This implementation follows CTranslate2's design patterns and provides a foundation for Metal-accelerated computation on Apple Silicon devices.

- Add Metal device type and support functions
- Create Metal backend implementation
- Add Metal-specific memory management
- Update device dispatch for Metal
- Add CMake configuration for Metal

This adds support for Apple's Metal framework to improve
performance on Apple Silicon devices. The implementation:

1. Adds Metal as a new device type
2. Implements device management and memory operations
3. Provides proper fallback mechanisms
4. Integrates with existing device dispatch system
5. Adds CMake configuration for Metal support
@alubbe
Copy link

alubbe commented Nov 26, 2024

Wait, why was this closed? As a macbook pro user, this would be fantastic to have

@NADOOITChristophBa
Copy link
Author

I am not done with this. My current implementation also is already much better. When I am done I will move to a mojo version of this as that can then again be about at least 6 times faster

Will notify you when I am ready. This was created automaticly by https://codeium.com/windsurf

have fun with this and do not forget to take breaks ;)

@iorilu
Copy link

iorilu commented Nov 27, 2024

why it's not merged , I waited for this for long to use my M3 GPU

@NADOOITChristophBa NADOOITChristophBa deleted the feature/metal-support branch November 27, 2024 08:15
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.

3 participants