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

Evolved operator functions #13361

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

Evolved operator functions #13361

wants to merge 26 commits into from

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Oct 23, 2024

Summary

Part of #13046: The evolved_operator_ansatz and qaoa_ansatz functions.

This is based on #13295, so that PR will need merging first.

Details and comments

  • After Prepare PauliEvolutionGate for Rustiq & port it to Rust #13295, the EvolvedOperatorAnsatz is already pretty performant since it does the Pauli evolution in Rust. However, with these functions we still gain a speedup since we can do all evolution at once in Rust and don't need go back and forth.

    This benchmarks the construction of an evolved operator ansatz for an Ising Hamiltonian on a square grid with side length n
    (so n ** 2 qubits), which has 2 operators; the ZZ-interactions and the X-field. For 100 qubits we get a speedup of 1.33x,
    which is increasing with the number of qubits (e.g. we get 1.83x at 10'000 qubits).

    -- n = 10, speedup 1.33x
    main: 0.033 +- 0.014
    this: 0.025 +- 0.009
    
    -- n = 50, speedup 1.64x
    main: 6.218 +- 0.200
    this: 3.792 +- 0.105
    
    -- n = 100, speedup 1.83x
    main: 100.487 +- 2.275
    this: 55.007 +- 1.139
    
  • This also adds a new function called hamiltonian_variational_ansatz (HVA), which automatically splits an input Hamiltonian into commuting terms. This is slightly different to evolved_operator_ansatz, which requires you to manually do this split, but IMO the HVA is the form most users would be interested in. We could've changed the default behavior of evolved_operator_ansatz to do the splitting, but I didn't want to change behavior for a class that users are already used to.

@Cryoris Cryoris added performance Changelog: New Feature Include in the "Added" section of the changelog labels Oct 23, 2024
@Cryoris Cryoris added this to the 1.3.0 milestone Oct 23, 2024
@Cryoris Cryoris requested review from ShellyGarion and a team as code owners October 23, 2024 15:34
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11483287578

Details

  • 379 of 421 (90.02%) changed or added relevant lines in 16 files are covered.
  • 20 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-0.03%) to 88.653%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/synthesis/evolution/suzuki_trotter.py 18 20 90.0%
qiskit/circuit/library/n_local/evolved_operator_ansatz.py 69 73 94.52%
qiskit/synthesis/evolution/product_formula.py 41 45 91.11%
qiskit/synthesis/evolution/qdrift.py 14 18 77.78%
crates/circuit/src/operations.rs 1 6 16.67%
crates/accelerate/src/circuit_library/pauli_evolution.rs 179 185 96.76%
crates/accelerate/src/circuit_library/utils.rs 9 26 34.62%
Files with Coverage Reduction New Missed Lines %
qiskit/synthesis/evolution/product_formula.py 1 93.15%
crates/qasm2/src/expr.rs 1 94.02%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 2 61.59%
crates/qasm2/src/lex.rs 3 92.23%
crates/qasm2/src/parse.rs 6 97.62%
qiskit/synthesis/two_qubit/xx_decompose/decomposer.py 7 90.77%
Totals Coverage Status
Change from base Build 11481266566: -0.03%
Covered Lines: 75031
Relevant Lines: 84634

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog performance
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

3 participants