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

ML-DSA: AVX2 target feature #642

Merged
merged 25 commits into from
Nov 8, 2024
Merged

Conversation

jschneider-bensch
Copy link
Collaborator

@jschneider-bensch jschneider-bensch commented Oct 21, 2024

This PR performs the same kind of restructuring to ML-DSA as #636 does to ML-KEM, i.e. once we know we're running on an AVX2 machine, manually enable AVX2 specific optimizations using #[target_feature(enable = "avx2")] and then inline most functions that are further down in the call-tree.
Doing this should get us close to compiling the whole crate using RUSTFLAGS="-C target-feature=+avx2" in terms of performance.

Base automatically changed from jonas/ml-kem-target-feature to main October 21, 2024 21:19
@jschneider-bensch jschneider-bensch force-pushed the jonas/ml-dsa-target-feature branch from 3c5b96d to 61f72fd Compare November 4, 2024 14:12
@jschneider-bensch jschneider-bensch changed the base branch from main to ml-dsa-lax November 4, 2024 14:13
Base automatically changed from ml-dsa-lax to main November 5, 2024 11:42
@jschneider-bensch
Copy link
Collaborator Author

jschneider-bensch commented Nov 6, 2024

The F* lax checking changes regressed performance again. Looking into why this happened.

It seems 0703c5ba349bf587e1cfb3f9628fc61693e61119 was the commit that originally regressed performance before rebasing onto the lax checking branch.

@jschneider-bensch
Copy link
Collaborator Author

I have another version of this branch at https://github.com/cryspen/libcrux/tree/jonas/ml-dsa-target-feature-backup which is pre-rebase on top of the laxing changes. There, reverting the above commit containing SHA-3 changes fully restores performance, but leads to a stack overflow. Reverting the commit on this branch does not seem to help performance.

@franziskuskiefer @karthikbhargavan Shall we try and get this PR in with somewhat degraded performance (e.g. for me the difference between the overflowing performant code and the laxing, non-overflowing code is ~10x), and look into fully restoring performance in a follow-up?

Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in and then investigate the performance regression.

@franziskuskiefer franziskuskiefer added this pull request to the merge queue Nov 8, 2024
Merged via the queue into main with commit d4b585d Nov 8, 2024
52 checks passed
@franziskuskiefer franziskuskiefer deleted the jonas/ml-dsa-target-feature branch November 8, 2024 11:37
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