Skip to content

Conversation

@davidomanovic
Copy link
Contributor

@davidomanovic davidomanovic commented Nov 1, 2025

Description

Multithreading in Rayon for faster JW map by parallelizing processes in Rust.

Results

On N2 in cc-pvdz:

1 thread: 14.098538247868419 s
4 threads: 5.772801402956247 s
16 threads: 3.734854843467474 s
48 threads: 3.3065379448235035 s
64 threads: 3.1618218813091516 s

Closes issue #496

@kevinsung
Copy link
Collaborator

Just to be sure, this is more performant than your original Python multiprocessing implementation, right?

@davidomanovic
Copy link
Contributor Author

Just to be sure, this is more performant than your original Python multiprocessing implementation, right?

Yes, even the non-parallelized Rust implementation was faster than the original Python multiprocessing implementation.

@kevinsung
Copy link
Collaborator

On N2 in cc-pvdz, 48 threads:

Non-parallel: 13 seconds
Parallel: 3 seconds

Hmm so we only get a ~4x speedup with 48 threads. Do we get the same performance with just 4 threads? Does the performance improvement level off after 4 or so threads?

@davidomanovic
Copy link
Contributor Author

davidomanovic commented Nov 1, 2025

On N2 in cc-pvdz, 48 threads:

Non-parallel: 13 seconds
Parallel: 3 seconds

Hmm so we only get a ~4x speedup with 48 threads. Do we get the same performance with just 4 threads? Does the performance improvement level off after 4 or so threads?

I tried with different threads:
1 thread: 14.098538247868419 s
4 threads: 5.772801402956247 s
16 threads: 3.734854843467474 s
48 threads: 3.3065379448235035 s
64 threads: 3.1618218813091516 s

I assume this is due to memory bandwidth and serial work that every thread must do, so throwing more threads at it dont help since it anyways just plateus. It actually seems to agree well with Amdahl's law. There is room for tiny improvements (maybe like 20%) with faster hashers, but we are pretty much at the limit here 😄

Copy link
Collaborator

@kevinsung kevinsung left a comment

Choose a reason for hiding this comment

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

Thank you!

@kevinsung kevinsung merged commit eb88c7a into qiskit-community:main Nov 3, 2025
21 checks passed
@davidomanovic
Copy link
Contributor Author

Thank you!

Enjoy! 😄

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.

2 participants