blueqat/blueqatSDK
Quantum Computer Library for Everyone
✨ New cuQuantum Backend both on cuStateVec and cuTensorNet
- limited gate support with cusv and cutn backend.
✨ New default backend based on Tensor Network
- The back end has been changed to the tensor network. The previous backend environment can still be used with .run(backend="numpy").
✨ New QAOA function
- QAOA function is changed to the tensornetwork based.
bug fixed on qaoa
# QAOA with Tensornetwork ``` from blueqat.utils import qaoa from blueqat import Circuit from blueqat.pauli import qubo_bit as q from blueqat.pauli import X,Y,Z,I hamiltonian = (15-(1+2*q(0)+4*q(1))*(1+2*q(2)))**2 step = 1 init = Circuit().h[0].cx[0,1].x[0] mixer = (X[0]*X[1]+Y[0]*Y[1])*0.5 result = qaoa(hamiltonian, step, init, mixer) result.circuit.run(backend="quimb", shots=1000) ```
Bug fixed
📦 Get the single amplitude
- ```python
- Circuit(4).h[:].run(backend="quimb", amplitude="0101")
- ```
📦 Get the sample
- ```python
- Circuit(4).h[:].run(backend="quimb", shots=100)
- ```
📦 Get the expectation value of hamiltonian
- ```python
- from blueqat.pauli import Z
- hamiltonian = 1*Z[0]+1*Z[1]
- Circuit(4).x[:].run(backend="quimb", hamiltonian=hamiltonian)
- ```
# Photonics Continuous Variable Programming Integrated ```python from blueqat import photonqat as pq import numpy as np import matplotlib.pyplot as plt # mode number = 2, cutoff dimension = 15 F = pq.Fock(2, cutoff = 15) alpha = (1 + 1j) r = -0.5 F.D(0, alpha) # Displacement to mode 0 F.S(1, r) # Squeezeng to mode 1 F.run() # Plot Wigner fucntion for mode 0 using matplotlib (x, p, W) = F.Wigner(0, plot = 'y', xrange = 5.0, prange = 5.0) ```
📋 Changes
- Circuit drawing function with networkx
📋 Changes
- Correct `TGate.matrix()`, `TDagGate.matrix()`, `IGate.matrix()`
- New sampling feature is available in the numpy backend. This feature may effective for mid-circuit measurement.
- Circuit JSON scheme is updated due to experimental features.
📋 Changes
- Builtin-macros
- `mcx_with_ancilla(ctrl: list[int], target: int, ancilla: int) -> Circuit`
- `mcz_with_ancilla(ctrl: list[int], target: int, ancilla: int) -> Circuit`
- Remove wq module
- We recommend using dwave-ocean-sdk library for annealing task.
- `wq.pauli` function (It translates QUBO to pauli matrix for QAOA) is moved to `pauli.to_qubo` function.
- Internal implementation of Circuit
- It cheats type-checker likes pyright for suppressing errors.
📋 Changes
- Built-in macros.
- To activate, run `import blueqat.macros`.
- `draw`, `margolus`, `c3z`, `c4z`, `c3x`, `c4x`, `mcx_gray`, `mcz_gray`, `mcrx_gray`, `mcry_gray`, `mcrz_gray`, `mcr_gray`, `mcu_gray` are available.
- `blueqat.utils.circuit_to_unitary` is moved to `blueqat.circuit_utils.circuit_to_unitary`.
📋 Changes
- Add JSON serializer/deserializer. Refer [here](https://blueqat.readthedocs.io/en/latest/json.html).
- `Operation.create` method is added. All subclasses of `Operation` class must implement it.
- Remove circuit-local default backend, move `blueqat.circuit.GATE_SET` to `blueqat.gateset.GATE_SET`.
- Use `GATE_SET` directly is not recommended. Please use `blueqat.gateset.create` or `blueqat.gateset.get_op_type`.
- u1/u2/u3, cu1/cu2/cu3 gates are completely deleted.
📋 Changes
- Add the following methods. These methods are equivalent with `Circuit.run()` with `returns="..."` arguments, but these are typed.
- `Circuit.statevector() -> np.ndarray`
- `Circuit.shots(n: int) -> Counter`
- `Circuit.oneshot() -> Tuple[np.ndarray, str]`
📋 Changes
- Repair 1 qubit gate decomposition function
- Correct gamma factor of `U.matrix()`
📋 Changes
- Add `ryrz_decomposer`
- Debug wq (Ising model) module
- Debug phase/cphase gate matrix
📋 Changes
- U1(θ) → RZ(θ)
- U2(φ, λ) → U(π/2, φ, λ, -0.5 * (φ+λ))
- U3(θ, φ, λ) → U(θ, φ, λ, -0.5 * (φ+λ))
- CU1(θ) → CR(θ)
- CU2(φ, λ) → CU(π/2, φ, λ, -0.5 * (φ+λ))
- CU3(θ, φ, λ) → CU(θ, φ, λ, -0.5 * (φ+λ))
📋 Changes
- Input initial statevector for numpy and numba backend. #101
- Cache is not stored after running. If caching is required, use `circuit.run(save_cache=True)`.
- Correct qgate backend, SWAP gate error.
📋 Changes
- Make mat1 gate and basic transpiler. It will facilitate circuit optimizations and execution on the real quantum machine
- Add ZZ gate, this is for trapped-ion based machine's basis gate
- Update for next version of qgate (thank you, Morino san!)
- CCZ gate was not available. Now, it is available.
📋 Changes
- Add `reset` operation. This is equivalent with measurement without recording measured result and apply X gate when 1 is measured.
- Correct numba's global phase error.
- `opt` module is renamed to `wq`.
📋 Changes
- Improve speed for Pauli operator's `to_matrix()` method
- Add `n_qubits` property for Pauli operator term and expr.
- Correct pauli.Term.simplify method
- Solve the problem that constant value of `max_n` raises exception
📦 Random generated Hamiltonian
- Making CSC (sparse) matrix from random generated Hamiltonian.
- row: The number of qubits
- column: The number of terms
- cell: Time (sec.)
📦 Blueqat 0.3.16 (Previous release)
- 
📦 Blueqat 0.3.17 (This release)
- 
📦 Compare
- Time in v0.3.16 / Time in v0.3.17
- Greater than 1: v0.3.17 is faster than v0.3.16
- Less than 1: v 0.3.17 is slower than v0.3.16
- 
- For large Hamiltonian, this release is 100 times faster than previous release
📦 LiH Hamiltonian
- Compared with OpenFermion's `qubit_operator_sparse`.
- Normally, the number of qubits is 12, but can be add redundant qubit via n_qubits parameter.
- Measure 12 qubits to 19 qubits.
- 
- (*1): Due to lack of memory, so many swap out occurred. Blueqat implementation is less memory consumption than OpenFermion.
- New install
- `pip install blueqat`
- Update
- + 1 more
📦 `Vqe()` class
- When sampler is default, make sparse matrix and calculate expectation directly.
- This is for performance improvement.
- (If you're using default sampler, your VQE code is speed-up without any changes.)
- VQE is still under refactoring process and this API may be changed in future release, however, because this feature is very important, I want to merge this feature in the master.
- Many cases of VQEs, this change makes fantastic speed-ups.
- However, some cases, this change makes slow down.
- To make previous default behaviour, specify sampler as previous default sampler.
- ```py
- + 4 more
📦 `pauli.to_matrix()` qubit order is reordered.
- Previous: X[0] * Y[1] is X ⊗ Y
- New: X[0] * Y[1] is Y ⊗ X
- New behavior is equivalent with Blueqat circuit's statevector order.
📦 `Vqe()` class
- When sampler is default, make sparse matrix and calculate expectation directly.
- This is for performance improvement.
- (If you're using default sampler, your VQE code is speed-up without any changes.)
- VQE is still under refactoring process and this API may be changed in future release, however, because this feature is very important, I want to merge this feature in the master.
- Many cases of VQEs, this change makes fantastic speed-ups.
- However, some cases, this change makes slow down.
- To make previous default behaviour, specify sampler as previous default sampler.
- ```py
- + 4 more
✨ Features
- Add new gates, rxx, ryy, rzz, cswap.
- Add `Circuit.dagger`. `Circuit().rx(0.1)[0].cx[0, 1].t[0].dagger()` is `Circuit().tdg[0].cx[0, 1].rx(-0.1)[0]`.
- Add `mixer` argument for QaoaAnsatz. (This feature may be changed in the future.) This is for Quantum Alternative Operator Ansatz.
- Add `sparse` option for `pauli.Expr.to_unitary`. It returns scipy's sparse matrix. `(X[0] + Y[3]).to_matrix(sparse='csc') # csc matrix` The performance for larger qubits expr is better than (default's) dense matrix, but still not fast.
📦 Experimental
- Add `blueqat.experimental.utils.circuit_to_unitary`. It returns unitary matrix instead of statevector.
- Blueqat already has to_unitary method for sympy's unitary gate.
- However, this function runs the circuit with a backend which returns statevector.
- This feature is useful for debugging the circuit, and it's too heavy for larger circuit.
📦 Install
- New install
- `pip install blueqat`
- Update
- `pip install -U blueqat`
🐛 Bug Fix
- To avoiding qgate 0.2.1 bug, Blueqat had implementation of workaround.
- However, Blueqat workaround has bug.
- Now, bug fixed version qgate 0.2.2 was released.
- So, workaround was removed. It works well!
📦 Experimental
- Experimental feature is available in "blueqat.experimental" module.
- This is unstable features. It may modified or deleted.
📦 Install
- New install
- `pip install blueqat`
- Update
- `pip install -U blueqat`
📦 Circuit repr
- `Circuit.__repr__` method is implemented.
- Now, `Circuit` is printable.
- ```py
- c = Circuit().x[0].rz(1.2)[1]
- c.cx[0, 1]
- print(c)
- ```
📦 Adjust global phase
- These are Blueqat standard implementation of global phase.
- RZ and U1 gate:
- ```
- [e^-iθ/2, 0],
- [0, e^iθ/2]
- ```
- Phase gate (, S gate [θ=π/2], S† gate [θ=-π/2], T gate [θ=π/4], T† gate [θ=-π/4]):
- ```
- + 32 more
📦 numba backend
- Correct bugs in controlled gate of numba backend
📦 Install
- New install
- `pip install blueqat`
- Update
- `pip install -U blueqat`
📦 Enhance IBM Q backend "returns" option
- Add some `Circuit().run_with_ibmq(returns=...)` options:
- `shots`: (default) Returns measurement result
- `_exception`: If error occurs during importing qiskit, returns exception. otherwise, returns `None`.
- `draw`: (NEW): Draw the circuit via Qiskit QuantumCircuit.draw
- `qiskit_circuit`: (NEW): Returns Qiskit QuantumCircuit object
- `qiskit_job`: (NEW): Returns Qiskit Job object
- `qiskit_result`: (NEW) Returns Qiskit Result object
- Usage of draw option
- + 5 more
📦 Adjust global phase
- Adjust global phase for some gates.
✨ Add gates
- Add cy (controlled-y), ch (controlled-h), phase, cphase gates.
- phase gate is as same as rz gate except global phase.
- rz:
- [ e^-iθ/2, 0]
- [0, e^iθ/2]
- phase:
- [1, 0]
- [0, e^iθ]
- + 12 more
📦 numba backend
- Correct bugs in cnot gate and cz gate of numba backend
📦 Install
- New install
- `pip install blueqat`
- Update
- `pip install -U blueqat`
📦 `ignore_global` option for numpy and numba backend.
- Blueqat ignores global phase of statevectors.
- But it makes debugging difficult.
- We added `ignore_global` option to disable ignoring global phase.
- `Circuit().x[0].phase(0.123)[0].run()`
- => `array([0.+0.j, 1.+0.j])` Global phase is ignored.
- `Circuit().x[0].phase(0.123)[0].run(ignore_global=False)`
- => `array([0. +0.j , 0.99244503+0.12269009j])` Global phase is not ignored.
- Related to this change, we will modify global phases for some gates in future release.
✨ Modify IBMQ backend for new qiskit
- Modify for `qiskit~=0.11.1`
📦 Modify scipy requirements version
- Now, required scipy version is `scipy>1.1.0`
📦 Install
- New install
- `pip install blueqat`
- Update
- `pip install -U blueqat`
✨ New features
- Implemented Controlled-RX, RY, RZ.
📦 Install
- New install
- `pip install blueqat`
- Update
- `pip install -U blueqat`
✨ qgate backend (Thanks to Morino san): New backend for [qgate](https://github.com/shinmorino/qgate).
- qgate is required for this backend.
- Usage: `Circuit().h[:10].run(backend='qgate', shots=1000)` or `Circuit().h[:10].run(backend='qgate', runtime='cuda', shots=1000)`
✨ numba backend: New backend using numba.
- Usage: `Circuit().h[:10].run(backend='numba')`
✨ Add test for other backends
- To add backend, run `python -m pytest ./test --add-backend numba --add-backend qgate`.
🐛 Small modifications and debugging
- `pip install blueqat`
