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

"illegal hardware instruction" error when running MUSCLE v5.2 and above on Apple M series with subdir osx_64 #52034

Open
ori-scala opened this issue Nov 10, 2024 · 18 comments · May be fixed by #52616

Comments

@ori-scala
Copy link

After installing the latest MUSCLE version (5.2), I'm getting the following error when trying to run MUSCLE.

illegal hardware instruction

I assume it's related to the Apple M series chipset, I'm using Apple M1 Pro.

To reproduce:

conda install bioconda::muscle==5.2.0 -y

Then run muscle --help and get:

muscle --help
[1]    14859 illegal hardware instruction  muscle --help

Then, downgrade using:

conda install bioconda::muscle==5.1.0 -y

and muscle --help works again with the following output:

muscle --help

muscle 5.1.osx64 []  34.4Gb RAM, 10 cores
Built May 15 2023 21:29:02
(C) Copyright 2004-2021 Robert C. Edgar.
https://drive5.com

This is help.txt
@ori-scala
Copy link
Author

@apcamargo Thank you for the 5.3 build. Now both --version and --help are working well but running an actual alignment ends up with the same error:

[1]    42192 illegal hardware instruction  muscle -align  -output  -log

Maybe you can add that to the tests as well? Something like

muscle -align some_fasta_file.fasta -output output.fasta -log muscle_log.txt

@apcamargo
Copy link
Contributor

Does -super5 work? It is included in the tests.

@ori-scala
Copy link
Author

Nope, same error

[1]    42600 illegal hardware instruction  muscle -super5  -output  -log

@apcamargo
Copy link
Contributor

Ok, so the problem might be on your end. Is your Mac a M series? Because the output of your muscle --help shows osx64, which is Intel. Maybe the binary of the wrong architecture is being installed.

How are you installing muscle?

@ori-scala
Copy link
Author

ori-scala commented Nov 11, 2024

The mac indeed has an M series chipset (M1 Pro) but I'm setting the conda env to osx64 using conda config --env --set subdir osx-64 as other packages I'm using aren't built for M series and I'm forced to do that.

I'm installing using an env.yml file or by conda install -c bioconda muscle==5.3.0 -y

@apcamargo
Copy link
Contributor

apcamargo commented Nov 11, 2024

I guess the other binaries are being executed through Rosetta? If so, I don't know why muscle isn't (assuming the issue is that the issue is that the binary is not compatible with the processor's architecture).

Do you have the same issue if you try to install other packages with ARM builds (e.g. diamond, mmseqs2, or hhsuite)?

I don't think I know enough about this to help you. If you're using Pixi, you can try to ask for help in their Discord (people there are very helpful). Otherwise, maybe @bioconda/osx can help?

@ori-scala
Copy link
Author

You're correct, the other binaries are being executed through Rosetta. It doesn't happen with other packages nor with any muscle version prior to 5.2

@apcamargo
Copy link
Contributor

apcamargo commented Nov 11, 2024

In this case, I don't know what is going on. It could be something with the macOS ARM CI (as the build runs correctly there), but the core team would know better than me.

@ori-scala
Copy link
Author

Ok, thank you anyway Antônio!

@apcamargo
Copy link
Contributor

If you create an environment only for muscle and install the ARM version, does it work?

@ori-scala
Copy link
Author

Yep, that works as expected.

@apcamargo
Copy link
Contributor

This explains why the tests didn't catch this. From my understanding, the only major difference between the Bioconda build and Robert's build is that he is using GCC and Bioconda uses clang. As far as I know, there's no way for us to use GCC to build for macOS, but I don't really know our building system that well.

As you said, version 5.1 worked in Rosetta and it seems he used Clang back then (I'm inferring this from his CI). But the code changed a lot since then...

@apcamargo
Copy link
Contributor

Can you update the issue title to something that reflects better the info we gathered?

@ori-scala ori-scala changed the title "illegal hardware instruction" error "illegal hardware instruction" error when running MUSCLE v5.2 and above on Apple M series with subdir osx_64 Nov 12, 2024
@ori-scala
Copy link
Author

@apcamargo updated the title as requested

@milot-mirdita
Copy link
Contributor

Seems muscle is using AVX(2/512/...) in version 5.2. Rosetta does not emulate AVX.
Here is likely the issue:
https://github.com/bioconda/bioconda-recipes/blob/b310cef61eebed800970d596e79e059c8d9b91d5/recipes/muscle/vcxproj_make.py#L74C1-L75C43

Its probably not a good idea to use march native for conda packages.

For MMseqs2 I was explicitly setting to use up to SSE4_1 in comda, with the latest release 16 I made MMseqs2 use AVX2 in conda, so the same issue would likely happen now if someone were to use it in a Rosetta emulated environment.

@apcamargo
Copy link
Contributor

Thanks, @milot-mirdita! I had no idea Rosetta doesn't emulate AVX.

I guess this is. Matter of how much MUSCLE benefits from AVX. If the performance increase is substantial, it might be worth it to leave as is. Perhaps @rcedgar has a thought about this

@milot-mirdita
Copy link
Contributor

No matter what, conda recipes shouldn't be compiled with march native, since this will result in binaries that use the instruction set of whatever GitHub runner happens to compile the binary. Most likely recent intel machines with avx512.

Conda's default is I think nocona, which is ancient. A good compromise might be using the new x86-64-v3 psABI specifier.

@rcedgar
Copy link

rcedgar commented Dec 5, 2024

I don't think muscle has any explicit SIMD code, if I'm not forgetting something then any AVX instructions are compiler optimizations.

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 a pull request may close this issue.

4 participants