mlx-swift icon indicating copy to clipboard operation
mlx-swift copied to clipboard

Crash when initializing MLXArray

Open jjjjjeffrey opened this issue 3 months ago • 6 comments

Image

jjjjjeffrey avatar Sep 16 '25 06:09 jjjjjeffrey

Xcode 16.4 iOS 18.5 MacOS 15.6.1

jjjjjeffrey avatar Sep 16 '25 06:09 jjjjjeffrey

Can you see what the error it is aborting on shows (frame 5 perhaps)?

Do you only see this when running tests? Are these tests hosted in an application?

davidkoski avatar Sep 16 '25 16:09 davidkoski

FSRS-swift.zip

Just shared the project for debugging, thanks!

Step: Run the app in simulator, and tap the "Run test" button, it would happen. @davidkoski

jjjjjeffrey avatar Sep 17 '25 05:09 jjjjjeffrey

Ah, "Run the app in simulator" is the key.

  • https://swiftpackageindex.com/ml-explore/mlx-swift/main/documentation/mlx/running-on-ios#Developing-for-iOS

This doesn't support the right class of GPU and can't run there.

davidkoski avatar Sep 17 '25 16:09 davidkoski

Thank for helping me😜, I ran it on my device smoothly, but got another issue:

MLX error: float64 is not supported on the GPU at /Users/jeffrey/Library/Developer/Xcode/DerivedData/FSRS-swift-hdllzmbelgdqumagmcfkkezkpgrm/SourcePackages/checkouts/mlx-swift/Source/Cmlx/mlx-c/mlx/c/ops.cpp:643

jjjjjeffrey avatar Sep 19 '25 05:09 jjjjjeffrey

OK, I think you have two choices:

  • run the float64 part on the CPU
  • don't use float64, use float32 or float16

davidkoski avatar Sep 19 '25 05:09 davidkoski