You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-6Lines changed: 22 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,21 +25,23 @@
25
25
26
26
<palign="center"> English | <ahref="README_cn.md"> 简体中文 </a></p>
27
27
28
-
TensorCircuit-NG is a high performance quantum software framework, supporting for automatic differentiation, just-in-time compiling, hardware acceleration, and vectorized parallelism, providing unified infrastructures and interfaces for quantum programming.
28
+
TensorCircuit-NG is an open-source high-performance quantum software framework, supporting for automatic differentiation, just-in-time compiling, hardware acceleration, and vectorized parallelism, providing unified infrastructures and interfaces for quantum programming. It can compose quantum circuits, neural networks and tensor networks seamlessly with high simulation efficiency and flexibility.
29
29
30
-
TensorCircuit-NG is built on top of modern machine learning frameworks: Jax, TensorFlow, and PyTorch. It is specifically suitable for highly efficient simulations of quantum-classical hybrid paradigm and variational quantum algorithms in ideal, noisyand approximate cases. It also supports quantum hardware access and provides CPU/GPU/QPU hybrid deployment solutions.
30
+
TensorCircuit-NG is built on top of modern machine learning frameworks: Jax, TensorFlow, and PyTorch. It is specifically suitable for large-scale simulations of quantum-classical hybrid paradigm and variational quantum algorithms in ideal, noisy, approximate and analog cases. It also supports quantum hardware access and provides CPU/GPU/QPU hybrid deployment solutions.
31
31
32
-
TensorCircuit-NG is [fully compatible](https://tensorcircuit-ng.readthedocs.io/en/latest/faq.html#what-is-the-relation-between-tensorcircuit-and-tensorcircuit-ng) with TensorCircuit with more new features and bug fixes (support numpy>2 and qiskit>1).
32
+
TensorCircuit-NG is [fully compatible](https://tensorcircuit-ng.readthedocs.io/en/latest/faq.html#what-is-the-relation-between-tensorcircuit-and-tensorcircuit-ng) with TensorCircuit with more new features and bug fixes (support latest `numpy>2` and `qiskit>1`).
33
33
34
34
## Getting Started
35
35
36
36
Please begin with [Quick Start](/docs/source/quickstart.rst) in the [full documentation](https://tensorcircuit-ng.readthedocs.io/).
37
37
38
38
For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 70+ [example scripts](/examples) and 30+ [tutorial notebooks](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials). API docstrings and test cases in [tests](/tests) are also informative.
39
39
40
+
For beginners, please refer to [quantum computing lectures with TC-NG](https://github.com/sxzgroup/qc_lecture) to learn both quantum computing basis and representative usage of TensorCircuit-NG.
41
+
40
42
The following are some minimal demos.
41
43
42
-
- Circuit manipulation:
44
+
- Circuit construction:
43
45
44
46
```python
45
47
import tensorcircuit as tc
@@ -60,7 +62,7 @@ tc.set_dtype("complex128")
60
62
tc.set_contractor("greedy")
61
63
```
62
64
63
-
- Automatic differentiations with jit:
65
+
- Automatic differentiation with jit:
64
66
65
67
```python
66
68
defforward(theta):
@@ -348,7 +350,7 @@ Reference paper: https://arxiv.org/abs/2303.08154 (published in PRR as a Letter)
348
350
349
351
### TenCirChem
350
352
351
-
[TenCirChem](https://github.com/tencent-quantum-lab/TenCirChem) is an efficient and versatile quantum computation package for molecular properties. TenCirChem is based on TensorCircuit and is optimized for chemistry applications.
353
+
[TenCirChem](https://github.com/tencent-quantum-lab/TenCirChem) is an efficient and versatile quantum computation package for molecular properties. TenCirChem is based on TensorCircuit and is optimized for chemistry applications. The latest version TenCirChem-NG is open source and available at [TenCirChem-NG](https://github.com/tensorcircuit/TenCirChem-NG).
352
354
353
355
Reference paper: https://arxiv.org/abs/2303.10825 (published in JCTC).
354
356
@@ -364,6 +366,12 @@ For the setup and simulation code of neural network encoded variational quantum
364
366
365
367
Reference paper: https://arxiv.org/abs/2308.01068 (published in PRApplied).
366
368
369
+
### Effective temperature in approximate ansatzes
370
+
371
+
For the simulation implementation of quantum states based on neural networks, tensor networs and quantum circuits using TensorCircuit-NG, see the [project repo](https://github.com/sxzgroup/et).
Copy file name to clipboardExpand all lines: docs/source/advance.rst
+130-5Lines changed: 130 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,17 +5,65 @@ Advanced Usage
5
5
MPS Simulator
6
6
----------------
7
7
8
-
(Still experimental support)
9
-
10
-
Very simple, we provide the same set of API for ``MPSCircuit`` as ``Circuit``,
8
+
Very straightforward to use, we provide the same set of API for ``MPSCircuit`` as ``Circuit``,
11
9
the only new line is to set the bond dimension for the new simulator.
12
10
13
11
.. code-block:: python
14
12
15
13
c = tc.MPSCircuit(n)
16
14
c.set_split_rules({"max_singular_values": 50})
17
15
18
-
The larger bond dimension we set, the better approximation ratio (of course the more computational cost we pay)
16
+
The larger bond dimension we set, the better approximation ratio (of course the more computational cost we pay).
17
+
18
+
19
+
Stacked gates
20
+
----------------
21
+
22
+
Stacked gates is a simple grammar sugar to make constructing the circuit easily when multiple gate of the same type are applied on the different qubits, namely, the index for gate function can accept list of ints instead of one integer.
@@ -45,15 +93,92 @@ The two-qubit gates applied on the circuit can be decomposed via SVD, which may
45
93
46
94
Note ``max_singular_values`` must be specified to make the whole procedure static and thus jittable.
47
95
96
+
Analog circuit simulation
97
+
-----------------------------
98
+
99
+
TensorCircuit-NG support digital-analog hybrid simulation (say cases in Rydberg atom arrays), where the analog part is simulated by the neural differential equation solver given the API to specify a time dependent Hamiltonian.
100
+
The simulation is still differentiable and jittable. Only jax backend is supported for analog simulation as the neural ode engine is built on top of jax.
101
+
This utility is super helpful for optimizing quantum control or investigating digital-analog hybrid variational quantum schemes.
102
+
We support two modes of analog simulation, where :py:meth:`tensorcircuit.experimentaql.evol_global` evolve the state via a Hamiltonian define on the whole system, and :py:meth:`tensorcircuit.experimentaql.evol_local` evolve the state via a Hamiltonian define on a local subsystem.
103
+
104
+
.. Note::
105
+
106
+
``evol_global`` use sparse Hamiltonian while ``evol_local`` use dense Hamiltonian.
107
+
108
+
109
+
.. code-block:: python
110
+
111
+
# in this demo, we build a jittable and differentiable simulation function `hybrid_evol`
112
+
# with both digital gates and local/global analog Hamiltonian evolutions
113
+
114
+
import optax
115
+
import tensorcircuit as tc
116
+
from tensorcircuit.experimental import evol_global, evol_local
117
+
118
+
K = tc.set_backend("jax")
119
+
120
+
121
+
defh_fun(t, b):
122
+
return b * tc.gates.x().tensor
123
+
124
+
125
+
hy = tc.quantum.PauliStringSum2COO([[2, 0]])
126
+
127
+
128
+
defh_fun2(t, b):
129
+
return b[2] * K.cos(b[0] * t + b[1]) * hy
130
+
131
+
132
+
@K.jit
133
+
@K.value_and_grad
134
+
defhybrid_evol(params):
135
+
c = tc.Circuit(2)
136
+
c.x([0, 1])
137
+
c = evol_local(c, [1], h_fun, 1.0, params[0])
138
+
c.cx(1, 0)
139
+
c.h(0)
140
+
c = evol_global(c, h_fun2, 1.0, params[1:])
141
+
return K.real(c.expectation_ps(z=[0, 1]))
142
+
143
+
144
+
b = K.implicit_randn([4])
145
+
v, gs = hybrid_evol(b)
146
+
147
+
48
148
49
149
Jitted Function Save/Load
50
150
-----------------------------
51
151
52
152
To reuse the jitted function, we can save it on the disk via support from the TensorFlow `SavedModel <https://www.tensorflow.org/guide/saved_model>`_. That is to say, only jitted quantum function on the TensorFlow backend can be saved on the disk.
53
153
154
+
We wrap the tf-backend `SavedModel` as very easy-to-use function :py:meth:`tensorcircuit.keras.save_func` and :py:meth:`tensorcircuit.keras.load_func`.
155
+
54
156
For the JAX-backend quantum function, one can first transform them into the tf-backend function via JAX experimental support: `jax2tf <https://github.com/google/jax/tree/main/jax/experimental/jax2tf>`_.
55
157
56
-
We wrap the tf-backend `SavedModel` as very easy-to-use function :py:meth:`tensorcircuit.keras.save_func` and :py:meth:`tensorcircuit.keras.load_func`.
158
+
**Updates**: jax now also support jitted function save/load via ``export`` module, see `jax documentation <https://jax.readthedocs.io/en/latest/export/export.html>_`.
159
+
160
+
We wrape the jax function export capability in ``experimental`` module and can be used as follows
Copy file name to clipboardExpand all lines: docs/source/quickstart.rst
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,10 +29,8 @@ For more details on docker setup, please refer to `docker readme <https://github
29
29
30
30
- For Windows, due to the lack of support for Jax, we recommend to use docker or WSL, please refer to `TC via windows docker <contribs/development_windows.html>`_ or `TC via WSL <contribs/development_wsl2.html>`_.
31
31
32
-
- For MacOS, please refer to `TC on Mac <contribs/development_Mac.html>`_.
33
-
34
-
Overall, the installation of TensorCircuit is simple, since it is purely in Python and hence very portable.
35
-
As long as the users can take care of the installation of ML frameworks on the corresponding system, TensorCircuit will work as expected.
32
+
Overall, the installation of TensorCircuit-NG is simple, since it is purely in Python and hence very portable.
33
+
As long as the users can take care of the installation of ML frameworks on the corresponding system, TensorCircuit-NG will work as expected.
36
34
37
35
To debug the installation issue or report bugs, please check the environment information by ``tc.about()``.
0 commit comments