-
Notifications
You must be signed in to change notification settings - Fork 294
Optimize LLVM JIT for large circuits #1261
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
Conversation
This makes a big difference for large UCCSD cicruits when using llvm::CodeGenOpt::None
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find 👍
This makes a big difference for large UCCSD circuits when using
llvm::CodeGenOpt::None, which we do in multiple places.For example, the JIT time for one of @marwafar's benchmark circuits went from ~260 seconds to ~45 seconds. (Most of the remaining time is spent in our Canonicalizer pass.)
Additional info: prior to this PR, we were spending a large amount of time in https://github.com/llvm/llvm-project/blob/llvmorg-16.0.6/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp#L1581 for large circuits. This change remedies that by disabling
-fast-isel. The "fast" instruction selection was supposed to be faster than the alternatives, but for us, it is actually slower for large circuits where it matters.Also note that I believe https://github.com/llvm/llvm-project/blob/llvmorg-16.0.6/llvm/lib/CodeGen/TargetPassConfig.cpp#L997 is preventing us from doing this in cleaner way where we specify this option via
TargetMachine::setFastISel(false)andTargetMachine::setO0WantsFastISel(false).