TeD-Q is an open-source software framework for quantum machine learning, variational quantum algorithm and simulation of quantum computing.
- Tensor-network enhanced. With tensor contraction, simulation of quantum circuts with large number of qubits is possible.
- Hybrid. TeD-Q seamlessly integrates classical machine learning libraries with quantum simulators, giving users the ability to laverage the power of classical machine learning while train quantum machine learning models.
- Distributed. TeD-Q is empowered with the capability of training quantum machine learning models in a distributed manner.
- Easy-to-use. Quantum circuit is seen as a python function.
- Device independent. The circuits can be run on different backends include software simulators (JAX and PyTorch) and quantum hardwares.
- Automatic differentiation. Provides back propagation, parameters shift, finite difference methods to obtain gradient.
- Flexible interfacing. Bridging quantum circuit to powerful machine learning libraries (like PyTorch).
- Good compatibility. Backend's optimizer can be directly applied.
- User friendly visualization. Quantum circuit and training progress can be visualized in real time.
pip install numpy torch jax jaxlib matplotlib panel jupyterlab ipywidgets toolz ray
It is strongly recommended to install and use JDtensorPath for tensor network contraction mode.
pip install -e .
Run the Run_all_tests.ipynb file under test document
import tedq as qai
def circuitDef(params):
qai.RX(params[0], qubits=[0])
qai.RY(params[1], qubits=[0])
return qai.expval(qai.PauliZ(qubits=[0]))
number_of_qubits = 1
parameter_shapes = [(2,)]
my_circuit = qai.Circuit(circuitDef, number_of_qubits, parameter_shapes = parameter_shapes)
drawer = qai.matplotlib_drawer(my_circuit)
drawer.draw_circuit()
my_compilecircuit = my_circuit.compilecircuit(backend="pytorch")
import torch
a = torch.tensor([0.54], requires_grad= True)
b = torch.tensor([0.12], requires_grad= True)
my_params = (a, b)
c = my_compilecircuit(*my_params)
>>> c = tensor([0.8515], grad_fn=<TorchExecuteBackward>)
c.backward()
%matplotlib ipympl
import tedq as qai
composer = qai.circuit_composer(4, figsize=(10,4))
Drag the template quantum gate on the bar on the top.
Click the gate on the quantum wire and drag to the trash box.
The composer can be converted to circuit object and compiled for evaluating the circuit.
circuit = composer.toCircuit()
compiledcircuit = circuit.compilecircuit(backend="pytorch")
User can also show the circuit definition by printing the circuit object.
print(circuit)
Follow the tutorial and the examples below to learn more usage of the TeD-Q framework.
For more diverse examples of using TeD-Q to solve quantum machine learning problem and variational quantum algorithm, please refer to the following tutorials or our official documentation website.
TeD-Q is released by JD Explore Academy and currently maintained by Xingyao Wu. The project is not possible without the efforts made by our contributors.
TeD-Q is free and open source, released under the Apache License, Version 2.0.