Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Part of #13046: create the
n_local
function and port the internals to Rust. This will include other parts of theNLocal
family, such asTwoLocal
,EfficientSU2
,RealAmplitudes
etc.EvolvedOperatorAnsatz
is potentially a bit more involved and might be done in a follow-up.Details and comments
The new code is particularly fast when dealing with gates we already have in Rust and that don't need any special re-parameterization. In this case:
the new code is ~22x faster for 100 qubits, full entanglement and 10 reps
But if custom gates or special parameterizations are used (e.g.
RXGate(x + 3 * y)
) we need to go back to Python space to correctly handle the parameter logic. This slows down the code and in this case:the new code is ~3.5x faster for 100 qubits, linear entanglement (full took too long) and 10 reps
To do
entanglement
handling rust-side a bit better to understand instead of a 4-times nested vecUseThis might not be possible sincen_local
inNLocal
(i.e. fast path for Python code)NLocal
works withQuantumCircuit
s as blocks, butn_local
needs gates. Functionally it'd be the same but the circuits are nested differently, which is not backward compatible. We could add a fast-path in case the inputs are not circuits but gates.efficient_su2
etc.