All Projects → corbett → Quantumcomputing

corbett / Quantumcomputing

Licence: gpl-3.0
This is an implementation of IBM's Quantum Experience in simulation; a 5-qubit quantum computer with a limited set of gates. Please cite me if you end up using this academically.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Quantumcomputing

Cirq
A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Stars: ✭ 3,115 (+483.33%)
Mutual labels:  quantum-computing
Quantum
Microsoft Quantum Development Kit Samples
Stars: ✭ 3,453 (+546.63%)
Mutual labels:  quantum-computing
Qiskit Textbook
A university quantum algorithms/computation course supplement based on Qiskit
Stars: ✭ 404 (-24.34%)
Mutual labels:  quantum-computing
Qiskit Terra
Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and algorithms.
Stars: ✭ 3,177 (+494.94%)
Mutual labels:  quantum-computing
Qmasm
Quantum macro assembler for D-Wave systems
Stars: ✭ 315 (-41.01%)
Mutual labels:  quantum-computing
Grove
Quantum algorithms built using pyQuil.
Stars: ✭ 332 (-37.83%)
Mutual labels:  quantum-computing
Dwave Ocean Sdk
Installer for D-Wave's Ocean tools
Stars: ✭ 258 (-51.69%)
Mutual labels:  quantum-computing
Qiskit Aqua
Quantum Algorithms & Applications in Python
Stars: ✭ 514 (-3.75%)
Mutual labels:  quantum-computing
Quantumlibraries
Q# libraries for the Quantum Development Kit
Stars: ✭ 316 (-40.82%)
Mutual labels:  quantum-computing
Quantumcomputingbook
Companion site for the textbook Quantum Computing: An Applied Approach
Stars: ✭ 386 (-27.72%)
Mutual labels:  quantum-computing
Grassmann.jl
⟨Leibniz-Grassmann-Clifford⟩ differential geometric algebra / multivector simplicial complex
Stars: ✭ 289 (-45.88%)
Mutual labels:  quantum-computing
Blueqat
Quantum Computer Library for Everyone
Stars: ✭ 298 (-44.19%)
Mutual labels:  quantum-computing
Quilc
The @rigetti optimizing Quil compiler.
Stars: ✭ 336 (-37.08%)
Mutual labels:  quantum-computing
Qpp
A modern C++11 quantum computing library
Stars: ✭ 277 (-48.13%)
Mutual labels:  quantum-computing
Qiskit Api Py
This repository and the qiskit-api-py package are deprecated, and no longer supported. A Python library for the Quantum Experience API
Stars: ✭ 458 (-14.23%)
Mutual labels:  quantum-computing
Openfermion Cirq
Quantum circuits for simulations of quantum chemistry and materials.
Stars: ✭ 258 (-51.69%)
Mutual labels:  quantum-computing
Quantumkatas
Tutorials and programming exercises for learning Q# and quantum computing
Stars: ✭ 3,713 (+595.32%)
Mutual labels:  quantum-computing
Yao.jl
Extensible, Efficient Quantum Algorithm Design for Humans.
Stars: ✭ 514 (-3.75%)
Mutual labels:  quantum-computing
Strawberryfields
Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
Stars: ✭ 505 (-5.43%)
Mutual labels:  quantum-computing
Qcgpu
High Performance Tools for Quantum Computing
Stars: ✭ 380 (-28.84%)
Mutual labels:  quantum-computing

Quintuple

This is an implementation of IBM's Quantum Experience in simulation; a 5-qubit quantum computer with a limited set of gates "the world’s first quantum computing platform delivered via the IBM Cloud". Their implementation is available at http://www.research.ibm.com/quantum/.

This code allows you to execute code printed from the Quantum Composer in the following syntax:

description usage
available qubit list q[0], q[1], q[2], q[3], q[4]
1-qubit gate list h,t,tdg,s,sdg,x,y,z,id
1-qubit gate action gate q[i];
2-qubit CNOT gate list cx
2-qubit CNOT gate action cx q[control], q[target];
measurement operation list measure, bloch
measurement operation action operation q[i];

It is much easier to dig into the internals of how the quantum computer computes by seeing and tracing the linear algebra representation of gates and states and their interactions as desired–for IBM's examples or for one's own code.

100% of the examples on the IBM tutorial are provided here, tested for and supported, and many addition tests and examples are provided. In fact, the implementation of the 5-qubit quantum computer simulator is only 675 lines, with approximately twice as many lines of test programs and examples provided.

Check out any of the test functions for example usage, and the Programs class contains many example programs in IBM's syntax all available in one place.

If you make use of this work, please cite my paper available on the physics arXiv as Quintuple: a Python 5-qubit quantum computer simulator to facilitate cloud quantum computing. For the making of story of this code, along with some pointers to resources on quantum computation, check out my blog post.

Example usage

from QuantumComputer import *
ghz_example_code="""h q[0];
		h q[1];
		x q[2];
		cx q[1], q[2];
		cx q[0], q[2];
		h q[0];
		h q[1];
		h q[2];"""
qc=QuantumComputer()
qc.execute(ghz_example_code)
Probability.pretty_print_probabilities(qc.qubits.get_quantum_register_containing("q0").get_state())

This will print

|psi>=0.70710678118654724|000>+-0.70710678118654724|111>
Pr(|000>)=0.500000; Pr(|111>)=0.500000; 

Or, using the swap Qubits example IBM tutorial Section IV, Page 2

swap_example_code="""x q[2];
		cx q[1], q[2];
		h q[1];
		h q[2];
		cx q[1], q[2];
		h q[1];
		h q[2];
		cx q[1], q[2];
		measure q[1];
		measure q[2];"""
qc.reset()
qc.execute(swap_example_code)
Probability.pretty_print_probabilities(qc.qubits.get_quantum_register_containing("q2").get_state())

will print

|psi>=|10>
Pr(|10>)=1.000000; 
<state>=-1.000000

We'll continue with this example in pure python below.

Note: using IBM's measurment code measure q[0]; will actually collapse the state, but for convenience the internal state before collapse is stored in qubit.get_noop(). Nature doesn't give this to us, but I can give it to you!

Pure python quantum computing machinery

Quantum computing operations can also be done in pure python, either with the QuantumComputer machinery or by directly manipulating gates.

QuantumComputer machinery

# Swap Qubits example IBM tutorial Section IV, Page 2
qc=QuantumComputer()
qc.apply_gate(Gate.X,"q2")
qc.apply_two_qubit_gate_CNOT("q1","q2")
qc.apply_gate(Gate.H,"q1")
qc.apply_gate(Gate.H,"q2")
qc.apply_two_qubit_gate_CNOT("q1","q2")
qc.apply_gate(Gate.H,"q1")
qc.apply_gate(Gate.H,"q2")
qc.apply_two_qubit_gate_CNOT("q1","q2")
qc.measure("q1")
qc.measure("q2")
Probability.pretty_print_probabilities(qc.qubits.get_quantum_register_containing("q1").get_state())

Will print

|psi>=|10>
Pr(|10>)=1.000000; 
<state>=-1.000000

Working with Individual States and gates

Note that states are combined by using the Kronecker product. Gates that operate on entangled states are composed from single qubit gates by the Kronecker product of the gate with the Identity. See the internals of qc.apply_gate or qc.apply_two_qubit_gate_CNOT for general examples, or feel free to use them instead.

# Swap Qubits example IBM tutorial Section IV, Page 2
q1=State.zero_state
q2=State.zero_state
q2=Gate.X*q2
new_state=Gate.CNOT2_01*np.kron(q1,q2)
H2_0=np.kron(Gate.H,Gate.eye)
H2_1=np.kron(Gate.eye,Gate.H)
new_state=H2_0*new_state
new_state=H2_1*new_state
new_state=Gate.CNOT2_01*new_state
new_state=H2_0*new_state
new_state=H2_1*new_state
new_state=Gate.CNOT2_01*new_state
Probability.pretty_print_probabilities(new_state)

Will print

|psi>=0.99999999999999967|10>
Pr(|10>)=1.000000;
<state>=-1.000000

This final manner of working with the library provides the most complete mathematical understanding of what's going on. Any individual state or gate can be printed, and it is clear how entanglement is represented as this is not done under the hood in this scenario.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].