qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Improved MCXVChain with dirty auxiliary qubits

Open rafaella-vale opened this issue 2 years ago • 10 comments

Summary

Implementation of MCX with $k$ controls and $k - 2$ dirty auxiliary qubits following the optimizations described by Iten et al. in [1].

[1] http://arxiv.org/abs/1501.06911

Details and comments

The changes made to the MCXVChain class only affect the dirty_ancilla mode. This implementation produces MCX circuits with at most $8k - 6$ CNOTs with $k$ control qubits. It also addresses issue #5872 and is a necessary step to further improve PR #8710.

rafaella-vale avatar Mar 01 '23 03:03 rafaella-vale

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

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

qiskit-bot avatar Mar 01 '23 03:03 qiskit-bot

Pull Request Test Coverage Report for Build 4333363738

  • 51 of 52 (98.08%) changed or added relevant lines in 1 file are covered.
  • 168 unchanged lines in 12 files lost coverage.
  • Overall coverage increased (+0.02%) to 85.338%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/library/standard_gates/x.py 51 52 98.08%
<!-- Total: 51 52
Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passmanager_config.py 1 97.18%
src/vf2_layout.rs 1 86.44%
qiskit/circuit/bit.py 2 87.5%
qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py 2 98.08%
qiskit/pulse/library/waveform.py 3 91.67%
qiskit/quantum_info/synthesis/one_qubit_decompose.py 7 93.86%
qiskit/transpiler/instruction_durations.py 7 91.18%
qiskit/visualization/counts_visualization.py 12 79.87%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 14 95.04%
qiskit/visualization/circuit/circuit_visualization.py 16 69.64%
<!-- Total: 168
Totals Coverage Status
Change from base Build 4318901192: 0.02%
Covered Lines: 67922
Relevant Lines: 79592

💛 - Coveralls

coveralls avatar Mar 03 '23 02:03 coveralls

This PR solves issue #9740 .

from qiskit import transpile
from qiskit.circuit.library.standard_gates import MCXVChain

k = 10
qc = MCXVChain(k, True).definition
tqc = transpile(qc, basis_gates=['u', 'cx'])
tqc.count_ops()['cx']

Now the required number of cx gates is 8k-6.

PS. This PR was a task for the students of the quantum computing class at Centro de Informática - UFPE.

adjs avatar Mar 06 '23 18:03 adjs

@adjs @rafaella-vale - Following the recent discussion in #5872 I'm checking on the status of this PR. I believe that we are still waiting for a recent version following the @Cryoris review comments. If you still need any help from us, please let us know.

ShellyGarion avatar Feb 28 '24 07:02 ShellyGarion

Could you please merge your branch with the main branch, fix the conflicts and the lint and docs errors?

ShellyGarion avatar Mar 04 '24 07:03 ShellyGarion

Pull Request Test Coverage Report for Build 9702834241

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 54 of 55 (98.18%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 89.782%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/library/standard_gates/x.py 54 55 98.18%
<!-- Total: 54 55
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 93.38%
<!-- Total: 4
Totals Coverage Status
Change from base Build 9698604147: 0.02%
Covered Lines: 63877
Relevant Lines: 71147

💛 - Coveralls

coveralls avatar Mar 13 '24 14:03 coveralls

Could you please rebase your code on the current main branch of Qiskit and remove all redundant PRs? It's impossible to review the code this way (there are over 200 files :) )

ShellyGarion avatar Mar 13 '24 15:03 ShellyGarion

Could you please merge your branch with the main branch, fix the conflicts and the lint and docs errors?

  • We have been able to fix the errors and replace the U1/2 operators by T and H operators directly.
  • In our implementation we use circuit.append(operator_class, [qubit_indices], []) because we are following the same coding stile present in the file qiskit/circuit/library/standard_gates/x.py , where instead of using circuit.operation(qubit_index), the lines present the append function with lists of operator classes and qubit indices, that is why we decided to use a similar approach when implementing the modifications.

IsmaelCesar avatar Mar 13 '24 16:03 IsmaelCesar

Could you please rebase your code on the current main branch of Qiskit and remove all redundant PRs? It's impossible to review the code this way (there are over 200 files :) )

I apologize for the confusion. I had a small problem while rebasing the code. Fortunately I was able to undo the problem and reapply the changes.

IsmaelCesar avatar Mar 13 '24 16:03 IsmaelCesar

This PR is almost ready to go. It would be nice to finalize it (as well as #8710) for the Qiskit 1.1 release

ShellyGarion avatar Mar 31 '24 07:03 ShellyGarion

close #9740

ShellyGarion avatar Jul 07 '24 06:07 ShellyGarion