Skip to content

Arithmetic circuit library: multipliers#6470

Merged
mergify[bot] merged 100 commits into
Qiskit:mainfrom
mantcep:multipliers
Jun 1, 2021
Merged

Arithmetic circuit library: multipliers#6470
mergify[bot] merged 100 commits into
Qiskit:mainfrom
mantcep:multipliers

Conversation

@mantcep
Copy link
Copy Markdown
Contributor

@mantcep mantcep commented May 27, 2021

Summary

Part of qiskit-community/qiskit-advocate-mentorship-program#12 with @Cryoris and @ManjulaGandhi.

Add a new circuit library submodule to perform classical multiplication of two equally-sized
qubit registers including:

Details and comments

Example:

from qiskit.circuit import QuantumCircuit
from qiskit.circuit.library import RGQFTMultiplier
from qiskit.quantum_info import Statevector

num_state_qubits = 2

# a encodes |11> = 3
a = QuantumCircuit(num_state_qubits)
a.x(range(num_state_qubits))

# b encodes |11> = 3
b = QuantumCircuit(num_state_qubits)
b.x(range(num_state_qubits))

# multiplier on 2-bit numbers
multiplier = RGQFTMultiplier(num_state_qubits)

# add the state preparations to the front of the circuit
multiplier.compose(a, [0, 1], inplace=True, front=True)
multiplier.compose(b, [2, 3], inplace=True, front=True)

# simulate and get the state of all qubits
sv = Statevector(multiplier)
counts = sv.probabilities_dict(decimals=10)
state = list(counts.keys())[0]  # we only have a single state

# skip both input registers
result = state[:-2*num_state_qubits]
print(result)  # '1001' = 9 = 3 * 3

mantcep and others added 30 commits March 8, 2021 09:49
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
* Implement initial draft of ripple-carry adder circuit

* Switch to ancilla register for ancilla qubits

* Remove padding for simpler implementation

* Add small fixes from review

* Add initial unit tests

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Switch carry out from ancilla to usual register

* Update __init__ docstring with raises

* Add suggestions from review; Clean-up

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add additional test for ripple-carry adder

* Implement initial QFT adder circuit

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Fix QFT adder carry out; Switch to non-modular as default

* Expand adder tests with QFT adder

* Rename test_adder.py -> test_adders.py

* Include additional QFT adder documentation

* Fix typos

* Fix documentation math

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Add non-modular test as default

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>

* Remove duplicate file after merge

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
* empty

* empty

* Implemented classical adder in QFT paper

* Implemented classical adder in QFT paper

* fix classicaladd imports

* fix missing imports

* Added the tests part for ClassicalAdd

* move cin to bottom

* Updated the documentation and test parts for ClassicalAdder

* Updated init files

* Deleted adder folder from the git repository

* Deleted test_classicaladd.py

* Deleted old classicaladder file

* Deleted __init__.py file from repository

* Updated classical_adder file

Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
mantcep and others added 13 commits May 29, 2021 15:02
…ultiplier.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>
…ultiplier.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>
…ultiplier.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…ultiplier.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Comment thread qiskit/circuit/library/arithmetic/multipliers/multiplier.py Outdated
Comment thread qiskit/circuit/library/arithmetic/multipliers/multiplier.py Outdated
Copy link
Copy Markdown
Collaborator

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

LGTM thanks for the contribution @mantcep!

@Cryoris Cryoris added automerge Changelog: Added Add an "Added" entry in the GitHub Release changelog. labels Jun 1, 2021
@mergify mergify Bot merged commit 57d6f9d into Qiskit:main Jun 1, 2021
@mantcep
Copy link
Copy Markdown
Contributor Author

mantcep commented Jun 1, 2021

Thanks @Cryoris, really appreciate your help on the PR 🙂

@mantcep mantcep deleted the multipliers branch June 1, 2021 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Added Add an "Added" entry in the GitHub Release changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants