unum-cloud / usearch

Fast Open-Source Search & Clustering engine Ɨ for Vectors & šŸ”œ Strings Ɨ in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram šŸ”
https://unum-cloud.github.io/usearch/
Apache License 2.0
1.92k stars 109 forks source link

Bug: Arm64 versions starting at v10.0 and up give the error Fatal Python error: Illegal instruction #416

Closed lmerchant closed 1 month ago

lmerchant commented 1 month ago

Describe the bug

For the python pypi releases of v2.10.0 and onward, the wheels tagged with 'manylinux' and 'Arm64' give errors of 'Fatal Python error: Illegal instruction' when adding anything to an Index or running pytests on the python test scripts (test_index.py in python/scripts).

Steps to reproduce

I'm running the pytests in a Docker container on a MacBook Pro M1 Max using the Docker base image python:3.12.3 and a Linux Arm64 emulator profile using the program Colima (https://github.com/abiosoft/colima). I've also built and run the Docker image with Docker Desktop for Mac and it still fails the pytests and errors when an item is added to an Index. The command I'm using to build the Docker image is "docker buildx build --platform=linux/arm64". In the Dockerfile, I pip install pytest and usearch and curl download the corresponding repo zip to run the pytests on. I've also built it using a base Docker image of Ubuntu 24.04 but it still fails.

I pip installed usearch for v10.0 and up and ran the pytests in the repository python folder for the corresponding version on "python/scripts/test_index.py". The tests fail with the error "Illegal instruction". Even the simple example on the python Readme fails at 'index.add(42, vector)' with 'Illegal Instruction'. The releases before v10.0 that I've used have passed the pytests.

Expected behavior

Building the same Dockerfile using a Linux x86_64 emulator profile with Colima results in the pytests passing for v2.10.0 and up. There is no error if I build and install usearch with "docker buildx build --platform=linux/amd64".

USearch version

v2.10.0

Operating System

Ubuntu 24.04 in a Dockerfile for Arm64 run on a Mac M1

Hardware architecture

Arm

Which interface are you using?

Python bindings

Contact Details

lmerchant@ucsd.edu

Are you open to being tagged as a contributor?

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 1 month ago

Hi @lmerchant! Can you replicate this on real hardware? Emulators often cause issues with SIMD instructions.

lmerchant commented 1 month ago

You're right. The emulator caused the issue with the failing error. I found my old Linux laptop and installed Ubuntu 20 on it. Then I ran the images I made on my Mac M1 for AMD64 in Ubuntu docker, and the pytests passed. I also created Docker images using the same Dockerfiles I used on my Mac M1 for AMD64 and they run perfectly. Thank you for pointing out the emulator issue. In the future, it looks like I'll have to use a Linux machine to create and run my docker images rather than rely on my Silicon Mac M1.

It had just confused me that usearch worked before version 2.10.0 fine in my Docker images. Thank you for your suggestion to try and replicate things on a Linux machine.

ashvardanian commented 1 month ago

No worries, cross-platform builds are a nightmare! Check out our CI pipeline if you are getting too much sleep šŸ˜