KEMBAR78
Optimize LLVM JIT for large circuits by bmhowe23 · Pull Request #1261 · NVIDIA/cuda-quantum · GitHub
Skip to content

Conversation

@bmhowe23
Copy link
Collaborator

@bmhowe23 bmhowe23 commented Feb 20, 2024

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) and TargetMachine::setO0WantsFastISel(false).

This makes a big difference for large UCCSD cicruits when using
llvm::CodeGenOpt::None
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 22, 2024
@bmhowe23 bmhowe23 changed the title [DRAFT] Optimize LLVM JIT for large circuits Optimize LLVM JIT for large circuits Feb 22, 2024
@bmhowe23 bmhowe23 marked this pull request as ready for review February 22, 2024 02:25
@bmhowe23 bmhowe23 requested a review from 1tnguyen February 22, 2024 02:25
Copy link
Collaborator

@1tnguyen 1tnguyen left a comment

Choose a reason for hiding this comment

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

Nice find 👍

@bmhowe23 bmhowe23 enabled auto-merge (squash) February 22, 2024 15:23
@bmhowe23 bmhowe23 added this to the release 0.7.0 milestone Feb 22, 2024
@bmhowe23 bmhowe23 merged commit a946a0a into NVIDIA:main Feb 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 22, 2024
@bmhowe23 bmhowe23 deleted the pr-jit-opt-large-circuits branch February 22, 2024 17:10
@bettinaheim bettinaheim added the enhancement New feature or request label Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants