Giter Club home page Giter Club logo

tensorcircuit's Introduction

English | 简体中文

TensorCircuit is the next generation of quantum software framework with support for automatic differentiation, just-in-time compiling, hardware acceleration, and vectorized parallelism.

TensorCircuit 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, noisy and approximate cases. It also supports real quantum hardware access and provides CPU/GPU/QPU hybrid deployment solutions since v0.9.

Getting Started

Please begin with Quick Start in the full documentation.

For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 70+ example scripts and 30+ tutorial notebooks. API docstrings and test cases in tests are also informative.

The following are some minimal demos.

  • Circuit manipulation:
import tensorcircuit as tc
c = tc.Circuit(2)
c.H(0)
c.CNOT(0,1)
c.rx(1, theta=0.2)
print(c.wavefunction())
print(c.expectation_ps(z=[0, 1]))
print(c.sample(allow_state=True, batch=1024, format="count_dict_bin"))
  • Runtime behavior customization:
tc.set_backend("tensorflow")
tc.set_dtype("complex128")
tc.set_contractor("greedy")
  • Automatic differentiations with jit:
def forward(theta):
    c = tc.Circuit(2)
    c.R(0, theta=theta, alpha=0.5, phi=0.8)
    return tc.backend.real(c.expectation((tc.gates.z(), [0])))

g = tc.backend.grad(forward)
g = tc.backend.jit(g)
theta = tc.array_to_tensor(1.0)
print(g(theta))
More highlight features for TensorCircuit (click for details)
  • Sparse Hamiltonian generation and expectation evaluation:
n = 6
pauli_structures = []
weights = []
for i in range(n):
    pauli_structures.append(tc.quantum.xyz2ps({"z": [i, (i + 1) % n]}, n=n))
    weights.append(1.0)
for i in range(n):
    pauli_structures.append(tc.quantum.xyz2ps({"x": [i]}, n=n))
    weights.append(-1.0)
h = tc.quantum.PauliStringSum2COO(pauli_structures, weights)
print(h)
# BCOO(complex64[64, 64], nse=448)
c = tc.Circuit(n)
c.h(range(n))
energy = tc.templates.measurements.operator_expectation(c, h)
# -6
  • Large-scale simulation with tensor network engine
# tc.set_contractor("cotengra-30-10")
n=500
c = tc.Circuit(n)
c.h(0)
c.cx(range(n-1), range(1, n))
c.expectation_ps(z=[0, n-1], reuse=False)
  • Density matrix simulator and quantum info quantities
c = tc.DMCircuit(2)
c.h(0)
c.cx(0, 1)
c.depolarizing(1, px=0.1, py=0.1, pz=0.1)
dm = c.state()
print(tc.quantum.entropy(dm))
print(tc.quantum.entanglement_entropy(dm, [0]))
print(tc.quantum.entanglement_negativity(dm, [0]))
print(tc.quantum.log_negativity(dm, [0]))

Install

The package is written in pure Python and can be obtained via pip as:

pip install tensorcircuit

We recommend you install this package with tensorflow also installed as:

pip install tensorcircuit[tensorflow]

Other optional dependencies include [torch], [jax], [qiskit] and [cloud].

For the nightly build of tensorcircuit with new features, try:

pip uninstall tensorcircuit
pip install tensorcircuit-nightly

We also have Docker support.

Advantages

  • Tensor network simulation engine based

  • JIT, AD, vectorized parallelism compatible

  • GPU support, quantum device access support, hybrid deployment support

  • Efficiency

    • Time: 10 to 10^6+ times acceleration compared to TensorFlow Quantum, Pennylane or Qiskit

    • Space: 600+ qubits 1D VQE workflow (converged energy inaccuracy: < 1%)

  • Elegance

    • Flexibility: customized contraction, multiple ML backend/interface choices, multiple dtype precisions, multiple QPU providers

    • API design: quantum for humans, less code, more power

  • Batteries included

    Tons of amazing features and built in tools for research (click for details)
    • Support super large circuit simulation using tensor network engine.

    • Support noisy simulation with both Monte Carlo and density matrix (tensor network powered) modes.

    • Support approximate simulation with MPS-TEBD modes.

    • Support analog/digital hybrid simulation (time dependent Hamiltonian evolution, pulse level simulation) with neural ode modes.

    • Support Fermion Gaussian state simulation with expectation, entanglement, measurement, ground state, real and imaginary time evolution.

    • Support qudits simulation.

    • Support parallel quantum circuit evaluation across multiple GPUs.

    • Highly customizable noise model with gate error and scalable readout error.

    • Support for non-unitary gate and post-selection simulation.

    • Support real quantum devices access from different providers.

    • Scalable readout error mitigation native to both bitstring and expectation level with automatic qubit mapping consideration.

    • Advanced quantum error mitigation methods and pipelines such as ZNE, DD, RC, etc.

    • Support MPS/MPO as representations for input states, quantum gates and observables to be measured.

    • Support vectorized parallelism on circuit inputs, circuit parameters, circuit structures, circuit measurements and these vectorization can be nested.

    • Gradients can be obtained with both automatic differenation and parameter shift (vmap accelerated) modes.

    • Machine learning interface/layer/model abstraction in both TensorFlow and PyTorch for both numerical simulation and real QPU experiments.

    • Circuit sampling supports both final state sampling and perfect sampling from tensor networks.

    • Light cone reduction support for local expectation calculation.

    • Highly customizable tensor network contraction path finder with opteinsum interface.

    • Observables are supported in measurement, sparse matrix, dense matrix and MPO format.

    • Super fast weighted sum Pauli string Hamiltonian matrix generation.

    • Reusable common circuit/measurement/problem templates and patterns.

    • Jittable classical shadow infrastructures.

    • SOTA quantum algorithm and model implementations.

    • Support hybrid workflows and pipelines with CPU/GPU/QPU hardware from local/cloud/hpc resources using tf/torch/jax/cupy/numpy frameworks all at the same time.

Contributing

Status

This project is created and maintained by Shi-Xin Zhang with current core authors Shi-Xin Zhang and Yu-Qin Chen. We also thank contributions from the open source community.

Citation

If this project helps in your research, please cite our software whitepaper to acknowledge the work put into the development of TensorCircuit.

TensorCircuit: a Quantum Software Framework for the NISQ Era (published in Quantum)

which is also a good introduction to the software.

Research works citing TensorCircuit can be highlighted in Research and Applications section.

Guidelines

For contribution guidelines and notes, see CONTRIBUTING.

We welcome issues, PRs, and discussions from everyone, and these are all hosted on GitHub.

License

TensorCircuit is open source, released under the Apache License, Version 2.0.

Contributors

Shixin Zhang
Shixin Zhang

💻 📖 💡 🤔 🚇 🚧 🔬 👀 🌍 ⚠️ 📢 💬
Yuqin Chen
Yuqin Chen

💻 📖 💡 🤔 🔬 ⚠️ 📢
Jiezhong Qiu
Jiezhong Qiu

💻 💡 🤔 🔬
Weitang Li
Weitang Li

💻 📖 🤔 🔬 ⚠️ 📢
Jiace Sun
Jiace Sun

💻 📖 💡 🤔 🔬 ⚠️
Zhouquan Wan
Zhouquan Wan

💻 📖 💡 🤔 🔬 ⚠️
Shuo Liu
Shuo Liu

💡 🔬
Hao Yu
Hao Yu

💻 📖 🚇 ⚠️
Xinghan Yang
Xinghan Yang

📖 🌍
JachyMeow
JachyMeow

🌍
Zhaofeng Ye
Zhaofeng Ye

🎨
erertertet
erertertet

💻 📖 ⚠️
Yicong Zheng
Yicong Zheng

Zixuan Song
Zixuan Song

📖 🌍 💻 ⚠️
Hao Xie
Hao Xie

📖
Pramit Singh
Pramit Singh

⚠️
Jonathan Allcock
Jonathan Allcock

📖 🤔 📢
nealchen2003
nealchen2003

📖
隐公观鱼
隐公观鱼

💻 ⚠️
WiuYuan
WiuYuan

💡
Felix Xu
Felix Xu

💻 ⚠️
Hong-Ye Hu
Hong-Ye Hu

📖
peilin
peilin

💻 ⚠️ 📖
Cristian Emiliano Godinez Ramirez
Cristian Emiliano Godinez Ramirez

💻 ⚠️
ztzhu
ztzhu

💻
Rabqubit
Rabqubit

💡
Kazuki Tsuoka
Kazuki Tsuoka

💻 ⚠️ 📖

Research and Applications

DQAS

For the application of Differentiable Quantum Architecture Search, see applications.

Reference paper: https://arxiv.org/abs/2010.08561 (published in QST).

VQNHE

For the application of Variational Quantum-Neural Hybrid Eigensolver, see applications.

Reference paper: https://arxiv.org/abs/2106.05105 (published in PRL) and https://arxiv.org/abs/2112.10380 (published in AQT).

VQEX-MBL

For the application of VQEX on MBL phase identification, see the tutorial.

Reference paper: https://arxiv.org/abs/2111.13719 (published in PRB).

Stark-DTC

For the numerical demosntration of discrete time crystal enabled by Stark many-body localization, see the Floquet simulation demo.

Reference paper: https://arxiv.org/abs/2208.02866 (published in PRL).

RA-Training

For the numerical simulation of variational quantum algorithm training using random gate activation strategy by us, see the project repo.

Reference paper: https://arxiv.org/abs/2303.08154 (published in PRR as a Letter).

TenCirChem

TenCirChem is an efficient and versatile quantum computation package for molecular properties. TenCirChem is based on TensorCircuit and is optimized for chemistry applications.

Reference paper: https://arxiv.org/abs/2303.10825 (published in JCTC).

EMQAOA-DARBO

For the numerical simulation and hardware experiments with error mitigation on QAOA, see the project repo.

Reference paper: https://arxiv.org/abs/2303.14877 (published in Communications Physics).

NN-VQA

For the setup and simulation code of neural network encoded variational quantum eigensolver, see the demo.

Reference paper: https://arxiv.org/abs/2308.01068 (published in PRApplied).

More works

More research works and code projects using TensorCircuit (click for details)

If you want to highlight your research work or projects here, feel free to add by opening PR.

tensorcircuit's People

Contributors

allcontributors[bot] avatar buwantaiji avatar emilianog-byte avatar eurethia avatar felixxu35 avatar hongyehu avatar jallcock avatar king-p3nguin avatar liwt31 avatar ls-iastu avatar marksong535 avatar miao-jq avatar peilinzheng avatar pramitsingh0 avatar refraction-ray avatar royess avatar sexycarrots avatar susyustc avatar wiuyuan avatar xptree avatar yhpeter avatar yutuer21 avatar zhouquan-wan avatar ztzhu1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorcircuit's Issues

increase the abundance of the QAOA tutorial

Task description

add more details in the tutorial

Implementation

  1. More details about the Max-Cut problem.
  2. Give some examples as figures.
  3. How to convert the Max-Cut to a ground-state-searching problem.
  4. Why we use QAOA (the complexity of Max-Cut).
  5. How to construct the PQC: mixer Hamiltonian, objective Hamiltonian, parameters.
  6. A visualization of PQC.
  7. A classical solver, to verify the result.
  8. Weighted Max-Cut.
  9. Result visualization: convert the parameters we find to a map.

Requirements

difficulty: 1/5

Unexpected warning when calculating expectation with readout error

Issue Description

Unexpected warning when calculating expectation with readout error.
The problem is at

num_quantum = c.gate_count(list(noise_conf.nc.keys()))

When counting gates, standardize_gate is called.

How to Reproduce

c = DMCircuit(2)

nc = NoiseConf()
re = 0.95
nc.add_noise("readout", [[re, re],[re, re]])
c.sample_expectation_ps([0], shots=1024, noise_conf=nc)

Error Output

WARNING:tensorcircuit.abstractcircuit:gate name not in the common gate set that tc supported

Environment Context

commit df66795

TEP Explained

TEP - TEP Explained

Author
@refraction-ray

Status
Accepted

Created
2022-06-30

Abstract

This TEP describes what TEP is and how TEP system works.

Motivation and Scope

TEP stands for TensorCircuit Enhancement Proposal. TEP is a design note for major features development in TensorCircuit. It is published as an issue and referred as the issue number, say this one is TEP #23. TEP provides information to the community (developers and users) and describes a new major feature proposal for TensorCircuit.

Each TEP must have an owner—someone who writes the TEP using the tep issue template.

For now the status of TEP is decided by @refraction-ray , we will have a committee in the future with a growing community.

Write the TEP as concise as possible, but make the proposed API and implementation design self-contained.

Usage and Impact

Mainly on developer side.

  1. A better history track for feature development
  2. A place to discuss whether the proposed API and implementation is ready for PR
  3. A better and specific integration with tensorcircuit roadmap

Backward compatibility

No backward compatibility issue.

Related Work

Inspired from PEP and NEP.

Implementation

Using GitHub Issue system and issue templates.

Support inversion of circuits

Support inversion of circuits

Author
<list of authors’ GitHub id>

Status
<Draft | Accepted | Deferred | Rejected | Superseded>

Created
2022-07-03

Abstract

Add a function to Circuit to support the inversion of a circuit.

Motivation and Scope

Inversion of circuits is a basic feature for constructing quantum circuits. And it is useful in tasks like random benchmarking,

And as far as I know, the feature is supported by qiskit.

Usage and Impact

For a Circuit object c, c.inverse() will return the inversion of it by inverting each of its gates and putting them in a reversed order.

If c contains parametric gates, we may offer a parameter for users to decide whether gate parameters are independent or shared.

Backward compatibility

Related Work

Qiskit:

Help on method inverse in module qiskit.circuit.quantumcircuit:

inverse() -> 'QuantumCircuit' method of qiskit.circuit.quantumcircuit.QuantumCircuit instance
    Invert (take adjoint of) this circuit.
    
    This is done by recursively inverting all gates.
    
    Returns:
        QuantumCircuit: the inverted circuit
    
    Raises:
        CircuitError: if the circuit cannot be inverted.
    
    Examples:
    
        input:
    
        .. parsed-literal::
    
                 ┌───┐
            q_0: ┤ H ├─────■──────
                 └───┘┌────┴─────┐
            q_1: ─────┤ RX(1.57) ├
                      └──────────┘
    
        output:
    
        .. parsed-literal::
    
                              ┌───┐
            q_0: ──────■──────┤ H ├
                 ┌─────┴─────┐└───┘
            q_1: ┤ RX(-1.57) ├─────
                 └───────────┘

Implementation

Alternatives

References

Increase test coverage in CI

Currently codecov report gives very low test coverage, which is too low to have a badge on README :)

Plans:

  1. Add more package on requirements-dev, so that more test can be run on GitHub action
  2. Add more tests targeting missing lines
  3. Omit some modules in the codebase

tensorflow backend with torch interface has bugs in tensorcircuit==0.2.1

import torch
import tensorcircuit as tc
tc.set_backend("tensorflow")
def f(params):
c = tc.Circuit(1)
c.rx(0, theta=params[0])
c.ry(0, theta=params[1])
return c.expectation([tc.gates.z(), [0]])
f_torch = tc.interfaces.torch_interface(f, jit=True)
a = torch.ones([2], requires_grad=True)
b = f_torch(a)
c = b ** 2
c.backward()
print(a.grad)

Erros

RuntimeError Traceback (most recent call last)
in
9 f_torch = tc.interfaces.torch_interface(f, jit=True)
10 a = torch.ones([2], requires_grad=True)
---> 11 b = f_torch(a)
12 c = b ** 2
13 c.backward()

~/.conda/envs/RLQM_torch/lib/python3.6/site-packages/tensorcircuit/interfaces.py in forward(ctx, *x)
126 def forward(ctx: Any, *x: Any) -> Any: # type: ignore
127 ctx.xdtype = [xi.dtype for xi in x]
--> 128 x = general_args_to_numpy(x)
129 x = numpy_args_to_backend(x)
130 y = fun(*x)

~/.conda/envs/RLQM_torch/lib/python3.6/site-packages/tensorcircuit/interfaces.py in general_args_to_numpy(args, same_pytree)
30 alone = True
31 for i in args:
---> 32 res.append(tensor_to_numpy(i))
33 if not same_pytree:
34 return res # all list

~/.conda/envs/RLQM_torch/lib/python3.6/site-packages/tensorcircuit/interfaces.py in tensor_to_numpy(t)
18 def tensor_to_numpy(t: Tensor) -> Array:
...
---> 20 return t.numpy()
21 except AttributeError:
22 return np.array(t)

RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.

Torch interface error. The forward function in torch model cannot work well in gradient tensor.

How to get accurate expectation value of a circuit with conditional gates

I found that conditional_gate now is designed to work in a probabilistic way. I think a batched evaluation can work. But I want to know if there is a way to get the accurate expectation value, which is averaged over conditional measurement outcomes.

An example:

c = tc.Circuit(nqubits)
c.h(0)
z = c.cond_measure(0)
c.conditional_gate(z, [tc.gates.i(), tc.gates.x()], 2)
print(c.expectation_ps(z=[2]))

Now it gives -1 and +1 each with a 0.5 possibilities. But I want to get 0 as an expectation instead. And I suppose in principle this is implementable in the tensor contraction manner.

And this is also related to #46 , where the expectation value of circuits with conditional gates is needed.

Draw circuits with midcircuit-measurement and conditional gates

Issue Description

Draw circuits with conditional gates. Currently, such attempt will raise a qiskit.extensions.exceptions.ExtensionError: 'Input matrix is not unitary.'

Proposed Solution

I am not very sure whether it is easy to implement by still using the drawing utilities of qiskit. So I do not have very good solution proposed.

Additional References

In qiskit, it is done by introducing classical registers, e.g. https://quantum-computing.ibm.com/lab/docs/iql/manage/systems/midcircuit-measurement/.

Can't import tensorcircuit in nightly build

Issue Description

Can't import tensorcircuit in nightly build.
The psutil dependency is introduced in readout_mitigation.py but it is not included in setup.py.
In CI installing qiskit also installs psutil so the error will not be raised.

How to Reproduce

conda create -n psu python=3.8
conda activate psu
pip install tensorcircuit-nightly
python -m tensorcircuit

Error Output

tensorflow is not installed, and sparse Hamiltonian generation utilities are disabled
Traceback (most recent call last):
  File "/data/home/weitangli/miniconda3/envs/psu/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/data/home/weitangli/miniconda3/envs/psu/lib/python3.8/runpy.py", line 144, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/data/home/weitangli/miniconda3/envs/psu/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/data/home/weitangli/miniconda3/envs/psu/lib/python3.8/site-packages/tensorcircuit/__init__.py", line 33, in <module>
    from . import results
  File "/data/home/weitangli/miniconda3/envs/psu/lib/python3.8/site-packages/tensorcircuit/results/__init__.py", line 2, in <module>
    from . import readout_mitigation
  File "/data/home/weitangli/miniconda3/envs/psu/lib/python3.8/site-packages/tensorcircuit/results/readout_mitigation.py", line 10, in <module>
    import psutil
ModuleNotFoundError: No module named 'psutil'

Add circuit block to generate quantum supremacy random circuit

Task description

Add tc.templates.blocks.random_circuit to generate random circuit for demonstrating quantum supremacy, the circuit structure can be found from Google's paper: https://www.nature.com/articles/s41586-019-1666-5

Implementation

Add a function random_circuit in /tensorcircuit/templates/blocks.py which generate the corresponding circuit with given spec (1D/2D, entangling gate type, depth, qubit number, etc.)

Requirements

Difficulty: ★★

Error on sigmoid and relu functions under pytorchbackend

Issue Description

The sigmoid and relu functions under pytorchbackend should use torch.sigmoid() and torch.relu() instead of torch.nn.Sigmoid() and torch.nn.Relu()

How to Reproduce

from tensorcircuit.backends.pytorch_backend import PyTorchBackend
a = torch.tensor(2)
model = PyTorchBackend()
out = model.sigmoid(a=a)

Error Output

TypeError                                 Traceback (most recent call last)
Cell In[2], line 4
      2 a = torch.tensor(2)
      3 model = PyTorchBackend()
----> 4 out = model.sigmoid(a=a)
      5 out

File /opt/conda/envs/work/lib/python3.10/site-packages/tensorcircuit/backends/pytorch_backend.py:354, in PyTorchBackend.sigmoid(self, a)
    353 def sigmoid(self, a: Tensor) -> Tensor:
--> 354     return torchlib.nn.Sigmoid(a)

TypeError: Module.__init__() takes 1 positional argument but 2 were given

Environment Context

python=3.10.8
tensorcircuit=0.6.0
torch=1.13.1_cuda11.6

Need import torch first to use it as backend

I found that I need to import torch first to use it as backend. Otherwise there will be an import error.

If I first import torch:

>>> import torch
>>> import tensorcircuit as tc
2022-06-12 18:14:35.855582: I tensorflow/core/util/util.cc:169] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
>>> tc.set_backend("pytorch")
pytorch_backend

Otherwise:

>>> import tensorcircuit as tc
2022-06-12 18:11:49.161582: I tensorflow/core/util/util.cc:169] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
>>> tc.set_backend("pytorch")
Traceback (most recent call last):
  File "/home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/tensornetwork/backends/pytorch/pytorch_backend.py", line 37, in __init__
    import torch
  File "/home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/torch/__init__.py", line 199, in <module>
    from torch._C import *  # noqa: F403
ImportError: /home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/torch/lib/libtorch_cuda_cpp.so: undefined symbol: cudaGraphRetainUserObject, version libcudart.so.11.0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/cons.py", line 103, in set_tensornetwork_backend
    backend_obj = get_backend(backend)
  File "/home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/backends/backend_factory.py", line 50, in get_backend
    _INSTANTIATED_BACKENDS[backend] = _BACKENDS[backend]()
  File "/home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/backends/pytorch_backend.py", line 171, in __init__
    super(PyTorchBackend, self).__init__()
  File "/home/yuxuan/.julia/conda/3/envs/tc39/lib/python3.9/site-packages/tensornetwork/backends/pytorch/pytorch_backend.py", line 39, in __init__
    raise ImportError("PyTorch not installed, please switch to a different "
ImportError: PyTorch not installed, please switch to a different backend or install PyTorch.

Add and complete the "depolarizing channel" part in tensorcircuit/channels.py

TEP - Title

Author
yuqinchen

Status
Draft

Created
2022-7-4

Abstract

Add and complete the "depolarizing channel" part in tensorcircuit/channels.py

Motivation and Scope

It is an important part of noisemodel to add to quantum circuit for noise simulation and error mitigation.
It is my startpoint to contribute to TensorCircuit.

Usage and Impact

It is an important part of noisemodel to add to quantum circuit for noise simulation and error mitigation.

Implementation

https://github.com/tencent-quantum-lab/tensorcircuit/blob/fc31d3b87278aff005b625d12a718c3bcb89fba4/tensorcircuit/channels.py

Add QCNN blocks

Issue Description

I think it will be great if we have blocks to easily construct QCNN, which is a special but important category of quantum neural networks requiring mid-circuit measurements.

Proposed Solution

The key component of QCNN is a "pooling" layer, which includes measurement and a conditional gate on the measurement outcome. And I suppose we can easily implement QCNN by using cond_measure and conditional_gate, described in the white paper tutorials.

Additional References

Applying gates with jnp index

Issue Description

Hi, I'm trying to apply a gate with the qubit index specified by an integer i from jax.numpy array. But I get ValueError: Illegal index specification. I think it's because isinstance(i, int) returns False.

I want to do this because I need to jit, and forcing type conversion using int(i) will make it unjittable.

How to Reproduce

import jax.numpy as jnp
import tensorcircuit as tc

c = tc.Circuit(1)
ind = jnp.array([0], dtype=int)
c.X(ind[0])

Error Output

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[139], line 3
      1 c = tc.Circuit(1)
      2 ind = jnp.array([0], dtype=int)
----> 3 c.X(ind[0])

File [~/miniconda3/lib/python3.10/site-packages/tensorcircuit/abstractcircuit.py:196](~/miniconda3/lib/python3.10/site-packages/tensorcircuit/abstractcircuit.py:196), in AbstractCircuit.apply_general_gate_delayed..apply_list(self, *index, **kws)
    194         apply(self, *ind, **kws)
    195 else:
--> 196     raise ValueError("Illegal index specification")

ValueError: Illegal index specification

Environment Context

OS info: macOS-10.16-x86_64-i386-64bit
Python version: 3.10.10
Numpy version: 1.24.4
Scipy version: 1.11.0
Pandas version: 2.0.3
TensorNetwork version: 0.4.6
Cotengra is not installed
TensorFlow is not installed
Jax version: 0.4.13
Jax installation doesn't support GPU
JaxLib version: 0.4.13
PyTorch is not installed
Cupy is not installed
Qiskit version: 0.25.0
Cirq version: 1.2.0
TensorCircuit version 0.10.0

PyTorch2.0's jit is still not good enough to support jit in tc

Issue Description

Simply replacing torch.jit.script or torch.jit.trace with backend.jit still fail for tc functions

Example scripts:

@torch.jit.script
def f(param):
    c = tc.Circuit(6)
    for i in range(5):
        for j in range(5):
            c.rzz(i, i+1, theta=param[i, j])
    return c.expectation_ps(z=[1])

f(torch.ones([5, 5]))

or

@partial(torch.jit.trace, example_inputs=torch.ones([5, 5]))
def f(param):
    c = tc.Circuit(6)
    for i in range(5):
        for j in range(5):
            c.rzz(i, i+1, theta=param[i, j])
    return c.expectation_ps(z=[1])

f(torch.ones([5, 5]))

actually the latter somehow works, but very fragile, for example, if the jit transformation is nested with grad or vmap operation, torch mostly fails

Proposed Solution

  1. Wait for further development of torch or 2. use tf/jax backend with torch interface instead or 3. actually maybe slightly fix in the exsisting tc codebase may work but currently have no time to try 4. or try torch.compile later.

Additional References

Enhance <QAOA portfolio tutorial>

Task description

Separate the current tutorial into two files.
Increase the accessibility to both beginners and experienced developers.

Implementation

  1. Solving QUBO problem using QAOA
    • Overview
    • QUBO problem: an introduction
    • An example: 2-qubit QUBO, previously on the tutorial
    • Code
      • General Definition
      • Function definition: directly define the general (nqubits>2) ones
        • Ansatz
        • Cost function
        • Solve
      • Results visualization: show all results in a list, sorted with probabilities
    • General case with code
  2. Portfolio optimization using QAOA
    • Overview
    • HM model: what is portfolio optimization, relation to QUBO
    • Artificial data: generated by qiskit_finance
      • different mixer
      • different cost function
      • classical solver
    • real data: benchmarking paper
      • compare the performance

Requirements

difficulty: not much

tensor network representation of a tensor circuit

I'm working with tensorcircuit to build my quantum circuit and I've notice than we can use projector from tensorcircuit.quantum and it will return a QuOperator object which represent an operator in tensor network form. However, I can't figure out how to apply this porjector to my circuit. I think perhaps I need to represent my circuit in tensor network form. But I can't find relevent functions.

Can anybody please tell me how I can represent my tc.Circuit class circuit to as a tensor network? Many thanks!

Refactor to build a common base for different Circuit like class

TEP - Refactor to build a common base for different Circuit like class

Author
refraction-ray

Status
Finished

Created
2022-07-13

Abstract

Refactor matters

Motivation and Scope

Dry the code, as there are many reusable and similar modules in Circuit, DMCircuit and MPSCircuit class.

Usage and Impact

After the refactoring, the functionality of DMCircuit will be as much as Circuit, with many features now lacking.

Backward compatibility

No issue on compatibility.

Related Work

Implementation

Currently, I decided to take a progressive approach. This TEP only achieves the follows:

Only consider the common base of Circuit and DMCircuit classes, leave MPSCircuit class alone for this stage.

Build reusable functions in basecircuit.py, and use BaseCircuit class as parent of Circuit as well as DMCircuit classes. This stage can persist smoothly for a while and users should not be affected.

After this refactoring, I will further consider whether compose all functions in commons.py as a BaseCircuit class.

Alternatives

References

Add backend agnostic device primitives

Primitives include K.device(a) to check the device for tensor a; K.device_move(a, dev) to move tensor to device dev and a unified backend agnostic device representation (str? or class?)

Usage: make sure the tensor transformation via numpy in interfaces can keep the device

Failed to transfer Tensor to Numpy when using jit

Issue Description

when I using jit as the decorator it failed to transfer Tensor to Numpy

How to Reproduce

import numpy as np
import tensorcircuit as tc

tc.set_backend("tensorflow")  
tc.set_dtype("complex64")

@tc.backend.jit
def test():
    c = tc.Circuit(2)
    c.h(0)
    psi = c.state()
    np_psi = psi.numpy()

    return np_psi

if __name__ == "__main__":
    print(test())

Error Output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[d:\work\tensorcircuit\test\QC_test_VQA_nonunitary](file:///D:/work/tensorcircuit/test/QC_test_VQA_nonunitary) evolution.ipynb 单元格 57 in ()
      [8](vscode-notebook-cell:/d%3A/work/tensorcircuit/test/QC_test_VQA_nonunitary%20evolution.ipynb#Y142sZmlsZQ%3D%3D?line=7)     return np_psi
     [10](vscode-notebook-cell:/d%3A/work/tensorcircuit/test/QC_test_VQA_nonunitary%20evolution.ipynb#Y142sZmlsZQ%3D%3D?line=9) if __name__ == "__main__":
---> [11](vscode-notebook-cell:/d%3A/work/tensorcircuit/test/QC_test_VQA_nonunitary%20evolution.ipynb#Y142sZmlsZQ%3D%3D?line=10)     print(test())

File [d:\anaconda3\envs\tensorcircuit\lib\site-packages\tensorflow\python\util\traceback_utils.py:153](file:///D:/anaconda3/envs/tensorcircuit/lib/site-packages/tensorflow/python/util/traceback_utils.py:153), in filter_traceback..error_handler(*args, **kwargs)
    151 except Exception as e:
    152   filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153   raise e.with_traceback(filtered_tb) from None
    154 finally:
    155   del filtered_tb

File [~\AppData\Local\Temp\__autograph_generated_filerr9xwyu_.py:13](https://file+.vscode-resource.vscode-cdn.net/d%3A/work/tensorcircuit/test/~/AppData/Local/Temp/__autograph_generated_filerr9xwyu_.py:13), in outer_factory..inner_factory..tf__test()
     11 ag__.converted_call(ag__.ld(c).h, (0,), None, fscope)
     12 psi = ag__.converted_call(ag__.ld(c).state, (), None, fscope)
---> 13 np_psi = ag__.converted_call(ag__.ld(psi).numpy, (), None, fscope)
     14 try:
     15     do_return = True

AttributeError: in user code:

    File "[C:\Users\70933\AppData\Local\Temp\ipykernel_8888\1987878621.py](file:///C:/Users/70933/AppData/Local/Temp/ipykernel_8888/1987878621.py)", line 6, in test  *
        np_psi = psi.numpy()

    AttributeError: 'Tensor' object has no attribute 'numpy'

Environment Context

'0.2.2'

Breaking change on optimizer in tf2.11

Issue Description

TF optimizer module has a breaking change and even the basic API is changed (opt.apply_gradients gone). irresponsible and chaotic, but it is typical tensorflow ~~

How to Reproduce

Possible bug for tc.backend.optimizer and negative effect on many example scripts and tutorials, to be validate when available, contribution welcome. The possible fix should be compatible with both older and newer version of tensorflow and contribution is welcome

Error Output

Environment Context

tf >= 2.11

Can't convert qiskit circuit with complex Instructions

Issue Description

If the qiskit circuit has complex Instruction, tensorcircuit can not convert the circuit into tc Circuit.

How to Reproduce

import numpy as np
from qiskit.circuit.library import EfficientSU2
from tensorcircuit import Circuit

ansatz = EfficientSU2(num_qubits=4, reps=1, entanglement="linear")
ansatz = ansatz.assign_parameters(np.zeros(ansatz.num_parameters_settable))
c = Circuit.from_qiskit(ansatz)

Error Output

---------------------------------------------------------------------------
CircuitError                              Traceback (most recent call last)
/tmp/ipykernel_1791043/4095531436.py in <module>
      5 ansatz = EfficientSU2(num_qubits=4, reps=1, entanglement="linear")
      6 ansatz = ansatz.assign_parameters(np.zeros(ansatz.num_parameters_settable))
----> 7 c = Circuit.from_qiskit(ansatz)

~/miniconda3/envs/cq/lib/python3.7/site-packages/tensorcircuit/abstractcircuit.py in from_qiskit(cls, qc, n, inputs, circuit_params)
    596             n = qc.num_qubits
    597 
--> 598         return qiskit2tc(qc.data, n, inputs, is_dm=cls.is_dm, circuit_params=circuit_params)  # type: ignore
    599 
    600     def vis_tex(self, **kws: Any) -> str:

~/miniconda3/envs/cq/lib/python3.7/site-packages/tensorcircuit/translation.py in qiskit2tc(qcdata, n, inputs, is_dm, circuit_params)
    308         else:  # unitary gate
    309             idx_inverse = (x for x in idx[::-1])
--> 310             tc_circuit.any(*idx_inverse, unitary=gate_info[0].to_matrix())
    311     return tc_circuit
    312 

~/miniconda3/envs/cq/lib/python3.7/site-packages/qiskit/circuit/gate.py in to_matrix(self)
     54             # pylint: disable=no-member
     55             return self.__array__(dtype=complex)
---> 56         raise CircuitError(f"to_matrix not defined for this {type(self)}")
     57 
     58     def power(self, exponent: float):

CircuitError: "to_matrix not defined for this <class 'qiskit.circuit.gate.Gate'>"

A quick fix to the above problem is to use the decompose function. The following code works

import numpy as np
from qiskit.circuit.library import EfficientSU2
from tensorcircuit import Circuit

ansatz = EfficientSU2(num_qubits=4, reps=1, entanglement="linear")
ansatz = ansatz.assign_parameters(np.zeros(ansatz.num_parameters_settable))
c = Circuit.from_qiskit(ansatz.decompose())

However, the decomposition is "shallow", and does not work for general cases.
The following code doesn't work

from qiskit_nature.second_q.circuit.library import UCCSD
from qiskit_nature.second_q.mappers import ParityMapper
from qiskit_nature.second_q.mappers import QubitConverter

mapper = ParityMapper()
converter = QubitConverter(mapper=mapper, two_qubit_reduction=True)

ansatz = UCCSD(2, [1, 1], converter)
ansatz = ansatz.assign_parameters(np.zeros(ansatz.num_parameters_settable))
c = Circuit.from_qiskit(ansatz.decompose())

Environment Context

qiskit-terra: 0.22.3
qiskit-nature: 0.4.4
tensorcircuit: 0.6.0

Wired input and output of function "c.amplitude"

Issue Description

For a quantum circuit with n qubits, function "c.amplitude" returns the amplitude of a given quantum state. It will work when an n-bit binary string is passed into. An error will raise if the length of the string is not n, except n+1. If an (n+1)-bit string is passed into, "c.amplitude" will return the amplitude of a state corresponding to the first n bits, while the last bit controls the "phase". For example, if a circuit has 3 qubits, and one amplitude is
"000" -> 0.5
then
"0000" -> 0.5
"0001" -> 0.5*j
and j is the imaginary unit

How to Reproduce

Screenshot 2023-05-12 at 23 14 19

Error Output

Screenshot 2023-05-12 at 23 14 39

Environment Context

macOS 13.3.1(a)
tensorcircuit 0.8.0
BTW, why tc.about() gives me "module 'tensorcircuit' has no attribute 'about'"?

MPS simulator roadmap

API design

number after indicates priority: 3 is high and 1 is low

  • __init__: allow quvector form mps input? (2)
  • __init__: allow array form input by make it a mps with bond dimension truncation? (2) (redesign the API of from_wavefunction into init)
  • vgates, sgates: update to the new gate list (3)
  • support qir? to_qir and from_qir (2)
  • update gate docstring in _meta_apply (2)
  • check and add alias for several methods to keep consitence with Circuit class (3)
  • add expectation API to automatically branch to the suitable expectation function (3)
  • add expectation_ps API as Circuit (3)
  • add prepend and append methods to compose MPSCircuit (1)
  • add jittable unitary kraus and general kraus methods (1 for now but ultimately also very important if possible)
  • matrix API to return circuit unitary (1)
  • sample method for sampling (2)
  • quvector and quoperator API for return (2)
  • MPO gate support and make it compatible with MPS simulator (2)

Ultimately, we have to reconsider the implementation infrastructure of MPSCircuit, since many code can be reused from Circuit class, how do we organize the relation between the two classes? Inheritance is not a good idea, while separate class design makes many code repetitions

Benchmark

The full performance with the assistance and compatibility of AD, JIT, VMAP and GPU

  • Implement QML benchmark in MPS to check its VMAP support and distant two-qubit gate application performace
  • Run the benchmark sets on different hardware at Tencent Cloud

Stabilizer simulator

TEP - Stabilizer simulator

Author
@refraction-ray

Status
Draft

Created
2023-07-07

Abstract

Motivation and Scope

Ultimately, it is good to have a clifford simulator in tc, but there are more to consider since the scope and nature of a stabilizer simulator are very different from a general simulator.

The features we require include (from high to low):

  1. We implicitly assume the features like gate application, extract the stabilizer state representation and sampling (but making a circuit with named gates and sample from it is far from enough (actually of very little use...))
  2. entanglement entropy calculation
  3. multiple-qubit random Clifford gate support
  4. direct manipulation on stabilizers, clifford maps, etc.
  5. trace to subsystem on a stabilizer state to get a sub stabilizer
  6. mix state stabilizer simulation
  7. entanglement negativity calculation
  8. canonical method for stabilizers
  9. necessary F2 linalg methods
  10. decompose gate based on clifford map
  11. enumerate random gate explicitly
  12. extended stabilizer simulator (few T) (very low priority feature though)

In the meanwhile, we hope the simulator is as fast as possible.

Usage and Impact

The use cases include: measurement induced phase transition and random circuit research (high priority), quantum error correction (low priority), hybrid ansatz with Clifford and general part (medium priority), simulator backend for CDR method (medium priority), large scale simulation and benchmark on quantum algorithms and mitigation schemes (medium priority).

The general interface is of course tc.StabilizerCircuit(n) with gates application (the subtle part is about random Clifford gate: how to represent and implement them).

Backward compatibility

Try inherit from AbstractCircuit, but even this approach has some challenges as in stabilizer case, many gates are easy to direct represented by the Clifford map instead of the specific gate decomposition as native gate set, which is conflict with the minimal IR we have now in AbstractCircuit

Related Work

QuantumClifford.jl is an ideal package with basically all features that we need, but it is written in Julia, leaving the integration with TC a pain.

In Python world, Stim is said to be fast but the doc are spare and the feature we required are basically all missing, the package is more suitable for qec and not random circuit investigation unless a lots of work to build relevant feature in tc. (Even EE on stabilizer state is a pain: https://quantumcomputing.stackexchange.com/questions/16718/measuring-entanglement-entropy-using-a-stabilizer-circuit-simulator)
PyClifford has some of the required features and can serve as one option for the integration, but the efficiency is not benchmarked.

Implementation

Ideally, we would like to incorporate another package for Clifford simulation as the backend instead of reinventing all wheels again. But as we mentioned before, there are many challenges to fuse the stabilizer backend into our general framework since quantum circuit is not as simple as only one measurement shots interface (this is barely what qiskit does) when it comes to the numerical investigation. The good news is that, due to the discrete nature of stabilizer circuit, we will lose AD/JIT/VMAP anyway, so we feel ok to directly reuse other package to simulate.

A quick fix on random gate issue could be a specific API on StabilizerCircuit class with no IR involved, i.e. c.random_gate(0, 1, 2), but _qir not record it. c.stabilizer_state() will get the stabilizer to manipulate in the original backend package. The measurement API require some thought, afterall, we now have measure, sample, post_select, cond_measure for a general circuit, how and which to migrate require some efforts

Alternatives

References

Hybird loss backward when sums up the classical and quantum loss in pytorch interface with tf backend.

Minimal code:

`import time
import numpy as np
import tensorflow as tf
import torch

import tensorcircuit as tc

K = tc.set_backend("tensorflow")

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
x_train = x_train[..., np.newaxis] / 255.0

def filter_pair(x, y, a, b):
keep = (y == a) | (y == b)
x, y = x[keep], y[keep]
y = y == a
return x, y

x_train, y_train = filter_pair(x_train, y_train, 1, 5)
x_train_small = tf.image.resize(x_train, (3, 3)).numpy()
x_train_bin = np.array(x_train_small > 0.5, dtype=np.float32)
x_train_bin = np.squeeze(x_train_bin).reshape([-1, 9])
y_train_torch = torch.tensor(y_train, dtype=torch.float32)
x_train_torch = torch.tensor(x_train_bin)
x_train_torch.shape, y_train_torch.shape

def qpreds(x, weights):
c = tc.Circuit(n)
for i in range(n):
c.rx(i, theta=x[i])
for j in range(nlayers):
for i in range(n - 1):
c.cnot(i, i + 1)
for i in range(n):
c.rx(i, theta=weights[2 * j, i])
c.ry(i, theta=weights[2 * j + 1, i])
return K.stack([K.real(c.expectation_ps(z=[i])) for i in range(n)])

qpreds_vmap = K.vmap(qpreds, vectorized_argnums=0)
qpreds_batch = tc.interfaces.torch_interface(qpreds_vmap, jit=True)

qpreds_batch(x_train_torch[:2], torch.ones([2 * nlayers, n]))

class QuantumNetV3(torch.nn.Module):
def init(self):
super().init()
self.q_weights = torch.nn.Parameter(torch.randn([2 * nlayers, n]))

def forward(self, inputs):
    ypred = qpreds_batch(inputs, self.q_weights)
    return ypred

net3 = QuantumNetV3()

Class linear_layer(torch.nn.Module):
def init(self):
super().init()
self.l1 = torch.nn.Linear(n, 20)
def forward(self, x):
out = self.l1(x)
return out
clayer = linear_layer()

predict_q = net3(inputs)
predict_c = clayer(inputs)

criterion = torch.nn.BCELoss()
opt = torch.optim.Adam(model.parameters(), lr=1e-2)
loss_q = criterion(predict_q, labels)
loss_c = criterion(predict_c, labels)

loss = loss_q + loss_c

loss.backward()`
The error message is below:
image

Unexpected warning using parameter shift gradient with NumPy backend

Issue Description

Unexpected warning using parameter shift gradient with NumPy backend.
The problem is at

onehot = backend.cast(onehot, args[i].dtype)

The problem is probably also present in parameter_shift_grad_v2.

How to Reproduce

import numpy as np

import tensorcircuit as tc
from tensorcircuit import experimental as E

K = tc.set_backend("numpy")


def f1(param):
    c = tc.Circuit(1)
    c.rz(0, theta=param[0])
    return K.real(c.expectation_ps(y=[0]))

E.parameter_shift_grad(f1)(np.array([1]))

This is more generally an inconsistency between backends. JAX and NumPy will issue a warning when casting from complex to float while tensorflow will not.

import tensorcircuit as tc

K = tc.set_backend("jax")
a = K.ones(1)
K.cast(a, float)

NumPy and JAX use astype for casting while tensorflow uses plain cast. Since the function name is cast, it makes more sense to adopt the tensorflow behavior and suppress the warning.

Error Output

ComplexWarning: Casting complex values to real discards the imaginary part

Environment Context

commit df66795

Add parameterized_local_measurements in templates/measurements

Task description

A similar API as tc.templates.parameterized_measurements, tc.templates.parameterized_measurements(c, structures=[0, 2, 1]) returns $\langle Y_1X_2 \rangle$, and the new API tc.templates.parameterized_local_measurements(c, structures=[0, 2, 1]) is expected to return a tensor as $Tensor([\langle I_0 \rangle, \langle Y_1 \rangle, \langle X_2 \rangle])$.

Implementation

Similar to parameterized_measurements, but do expectation on each obs instead of obs list, and remember to set reuse=True as default.

Requirements

★★

Fermion Gaussian State Simulator

TEP - Fermion Gaussian State Simulator

Author
@refraction-ray

Status
Draft

Created
2023-07-02

Abstract

Create a new class for free fermion simulation with AD/JIT/VMAP/GPU support and a Circuit-like interface

Motivation and Scope

Can deal with free fermion evolution/measurement/post selection/entanglement entropy etc. Support system size of order 1000 at least.

Usage and Impact

Maybe helpful in large scale demonstration such as MIPT studies.

Backward compatibility

Related Work

To my knowledge, no such package (free fermion evo + mea simulation with AD) on the market.

Implementation

An independent tc.FermionCircuit class, indepedent from AbstractCircuit and they are intrinsically different

Alternatives

References

https://scipost.org/SciPostPhysLectNotes.54/pdf

for occupation measurement (post-selection): see Appendix in https://arxiv.org/pdf/2306.16595.pdf

https://arxiv.org/pdf/quant-ph/0108010.pdf

Support trainable adptive circuit

Issue Description

It will be really healpful if tensorcircuit can support quantum circuits supporting measurement in the middle of a quantum simulation, which the type of following gates can depend on the classical results of these measurements. More ideally, intruducing gradient optimization method to this type of circuits can be really helpful.

Proposed Solution

Perhaps giving conditing to the circuit design (like 'if') will be a promising way to do this.

thanks!

Failed to reproduce 600-qubit VQE because of being out of memory

I tried to reproduce the 600-qubit VQE mentioned in the whitepaper by running a script slightly modified from examples/vqe_extra_mpo.py. Modifications are:

  1. Only do one forward evaluation;
  2. Use CPU instead of GPU.

I use a machine with 36 cores and 251GB memory run the script. The backend is set as tensorflow. But the job is killed because of being out of memory, while the whitepaper shows that a 40GB GPU is enough for a same job.

Version information.
# Name                    Version                   Build  Channel
absl-py                   1.2.0                     <pip>
aiosignal                 1.2.0                     <pip>
alembic                   1.8.1                     <pip>
anyio                     3.6.1                     <pip>
argon2-cffi               21.3.0                    <pip>
argon2-cffi-bindings      21.2.0                    <pip>
asttokens                 2.0.8                     <pip>
astunparse                1.6.3                     <pip>
attrs                     20.3.0                    <pip>
autopage                  0.5.1                     <pip>
autoray                   0.3.2                     <pip>
Babel                     2.10.3                    <pip>
backcall                  0.2.0                     <pip>
beautifulsoup4            4.11.1                    <pip>
bleach                    5.0.1                     <pip>
ca-certificates           2022.07.19           h06a4308_0
cachetools                5.2.0                     <pip>
certifi                   2022.6.15        py39h06a4308_0
cffi                      1.15.1                    <pip>
charset-normalizer        2.1.1                     <pip>
chex                      0.1.5                     <pip>
cirq                      1.0.0                     <pip>
cirq-aqt                  1.0.0                     <pip>
cirq-core                 1.0.0                     <pip>
cirq-google               1.0.0                     <pip>
cirq-ionq                 1.0.0                     <pip>
cirq-pasqal               1.0.0                     <pip>
cirq-rigetti              1.0.0                     <pip>
cirq-web                  1.0.0                     <pip>
click                     8.0.4                     <pip>
cliff                     4.0.0                     <pip>
cmaes                     0.8.2                     <pip>
cmd2                      2.4.2                     <pip>
colorlog                  6.7.0                     <pip>
contourpy                 1.0.5                     <pip>
cotengra                  0.1.0                     <pip>
cryptography              38.0.1                    <pip>
cycler                    0.11.0                    <pip>
cytoolz                   0.12.0                    <pip>
debugpy                   1.6.3                     <pip>
decorator                 5.1.1                     <pip>
defusedxml                0.7.1                     <pip>
dill                      0.3.5.1                   <pip>
distlib                   0.3.6                     <pip>
dm-tree                   0.1.7                     <pip>
duet                      0.2.7                     <pip>
entrypoints               0.4                       <pip>
etils                     0.8.0                     <pip>
executing                 1.0.0                     <pip>
fastjsonschema            2.16.1                    <pip>
filelock                  3.8.0                     <pip>
flatbuffers               2.0.7                     <pip>
fonttools                 4.37.2                    <pip>
frozenlist                1.3.1                     <pip>
gast                      0.4.0                     <pip>
google-api-core           1.33.1                    <pip>
google-auth               2.11.0                    <pip>
google-auth-oauthlib      0.4.6                     <pip>
google-pasta              0.2.0                     <pip>
googleapis-common-protos  1.56.4                    <pip>
graphviz                  0.20.1                    <pip>
greenlet                  1.1.3                     <pip>
grpcio                    1.43.0                    <pip>
grpcio-status             1.48.1                    <pip>
h11                       0.9.0                     <pip>
h5py                      3.7.0                     <pip>
httpcore                  0.11.1                    <pip>
httpx                     0.15.5                    <pip>
idna                      3.4                       <pip>
importlib-metadata        4.12.0                    <pip>
importlib-resources       5.9.0                     <pip>
ipykernel                 6.15.3                    <pip>
ipython                   8.5.0                     <pip>
ipython-genutils          0.2.0                     <pip>
iso8601                   1.0.2                     <pip>
jax                       0.3.17                    <pip>
jaxlib                    0.3.15+cuda11.cudnn82           <pip>
jedi                      0.18.1                    <pip>
Jinja2                    3.1.2                     <pip>
json5                     0.9.10                    <pip>
jsonschema                4.16.0                    <pip>
jupyter-core              4.11.1                    <pip>
jupyter-server            1.18.1                    <pip>
jupyter_client            7.3.5                     <pip>
jupyterlab                3.4.7                     <pip>
jupyterlab-pygments       0.2.2                     <pip>
jupyterlab_server         2.15.1                    <pip>
kahypar                   1.1.7                     <pip>
keras                     2.10.0                    <pip>
Keras-Preprocessing       1.1.2                     <pip>
kiwisolver                1.4.4                     <pip>
lark                      0.11.3                    <pip>
ld_impl_linux-64          2.38                 h1181459_1
libclang                  14.0.6                    <pip>
libffi                    3.3                  he6710b0_2
libgcc-ng                 11.2.0               h1234567_1
libstdcxx-ng              11.2.0               h1234567_1
lxml                      4.9.1                     <pip>
Mako                      1.2.2                     <pip>
Markdown                  3.4.1                     <pip>
MarkupSafe                2.1.1                     <pip>
matplotlib                3.6.0                     <pip>
matplotlib-inline         0.1.6                     <pip>
mistune                   2.0.4                     <pip>
mpmath                    1.2.1                     <pip>
msgpack                   1.0.4                     <pip>
nbclassic                 0.4.3                     <pip>
nbclient                  0.6.8                     <pip>
nbconvert                 7.0.0                     <pip>
nbformat                  5.5.0                     <pip>
ncurses                   6.3                  h5eee18b_3
nest-asyncio              1.5.5                     <pip>
networkx                  2.8.6                     <pip>
notebook                  6.4.12                    <pip>
notebook-shim             0.1.0                     <pip>
ntlm-auth                 1.5.0                     <pip>
numpy                     1.23.3                    <pip>
oauthlib                  3.2.1                     <pip>
openssl                   1.1.1q               h7f8727e_0
opt-einsum                3.3.0                     <pip>
optax                     0.1.3                     <pip>
optuna                    3.0.2                     <pip>
packaging                 21.3                      <pip>
pandas                    1.4.4                     <pip>
pandocfilters             1.5.0                     <pip>
parso                     0.8.3                     <pip>
pbr                       5.10.0                    <pip>
pexpect                   4.8.0                     <pip>
pickleshare               0.7.5                     <pip>
Pillow                    9.2.0                     <pip>
pip                       22.1.2           py39h06a4308_0
platformdirs              2.5.2                     <pip>
ply                       3.11                      <pip>
prettytable               3.4.1                     <pip>
prometheus-client         0.14.1                    <pip>
prompt-toolkit            3.0.31                    <pip>
proto-plus                1.22.1                    <pip>
protobuf                  3.20.2                    <pip>
psutil                    5.9.2                     <pip>
ptyprocess                0.7.0                     <pip>
pure-eval                 0.2.2                     <pip>
py                        1.11.0                    <pip>
pyasn1                    0.4.8                     <pip>
pyasn1-modules            0.2.8                     <pip>
pycparser                 2.21                      <pip>
pydantic                  1.10.2                    <pip>
Pygments                  2.13.0                    <pip>
PyJWT                     2.4.0                     <pip>
pyparsing                 3.0.9                     <pip>
pyperclip                 1.8.2                     <pip>
pyquil                    3.3.0                     <pip>
pyrsistent                0.18.1                    <pip>
python                    3.9.13               haa1d7c7_1
python-dateutil           2.8.2                     <pip>
python-rapidjson          1.8                       <pip>
pytz                      2022.2.1                  <pip>
PyYAML                    6.0                       <pip>
pyzmq                     24.0.0                    <pip>
qcs-api-client            0.21.1                    <pip>
qiskit                    0.38.0                    <pip>
qiskit-aer                0.11.0                    <pip>
qiskit-ibmq-provider      0.19.2                    <pip>
qiskit-terra              0.21.2                    <pip>
ray                       2.0.0                     <pip>
readline                  8.1.2                h7f8727e_1
requests                  2.28.1                    <pip>
requests-ntlm             1.1.0                     <pip>
requests-oauthlib         1.3.1                     <pip>
retry                     0.9.2                     <pip>
retrying                  1.3.3                     <pip>
retworkx                  0.11.0                    <pip>
rfc3339                   6.2                       <pip>
rfc3986                   1.5.0                     <pip>
rpcq                      3.10.0                    <pip>
rsa                       4.9                       <pip>
ruamel.yaml               0.17.21                   <pip>
ruamel.yaml.clib          0.2.6                     <pip>
scipy                     1.8.1                     <pip>
Send2Trash                1.8.0                     <pip>
setuptools                63.4.1           py39h06a4308_0
six                       1.16.0                    <pip>
sniffio                   1.3.0                     <pip>
sortedcontainers          2.4.0                     <pip>
soupsieve                 2.3.2.post1               <pip>
SQLAlchemy                1.4.41                    <pip>
sqlite                    3.39.2               h5082296_0
stack-data                0.5.0                     <pip>
stevedore                 4.0.0                     <pip>
symengine                 0.9.2                     <pip>
sympy                     1.11.1                    <pip>
tensorboard               2.10.0                    <pip>
tensorboard-data-server   0.6.1                     <pip>
tensorboard-plugin-wit    1.8.1                     <pip>
tensorcircuit-nightly     0.4.0.dev20220915           <pip>
tensorflow                2.10.0                    <pip>
tensorflow-estimator      2.10.0                    <pip>
tensorflow-io-gcs-filesystem 0.27.0                    <pip>
tensornetwork             0.4.6                     <pip>
termcolor                 2.0.1                     <pip>
terminado                 0.15.0                    <pip>
tinycss2                  1.1.1                     <pip>
tk                        8.6.12               h1ccaba5_0
toml                      0.10.2                    <pip>
tomli                     2.0.1                     <pip>
toolz                     0.12.0                    <pip>
tornado                   6.2                       <pip>
tqdm                      4.64.1                    <pip>
traitlets                 5.4.0                     <pip>
tweedledum                1.1.1                     <pip>
typing_extensions         4.3.0                     <pip>
tzdata                    2022c                h04d1e81_0
urllib3                   1.26.12                   <pip>
virtualenv                20.16.5                   <pip>
wcwidth                   0.2.5                     <pip>
webencodings              0.5.1                     <pip>
websocket-client          1.4.1                     <pip>
websockets                10.3                      <pip>
Werkzeug                  2.2.2                     <pip>
wheel                     0.37.1             pyhd3eb1b0_0
wrapt                     1.14.1                    <pip>
xz                        5.2.5                h7f8727e_1
zipp                      3.8.1                     <pip>
zlib                      1.2.12               h5eee18b_3
The script.
"""
Demonstration of TFIM VQE with extra size in MPO formulation
"""
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

import time
import logging
import sys
import numpy as np

logger = logging.getLogger("tensorcircuit")
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)

sys.setrecursionlimit(10000)

import tensorflow as tf
import tensornetwork as tn
import cotengra as ctg
import optax

import tensorcircuit as tc

opt = ctg.ReusableHyperOptimizer(
    methods=["greedy", "kahypar"],
    parallel="ray",
    minimize="combo",
    max_time=360,
    max_repeats=4096,
    progbar=True,
)


def opt_reconf(inputs, output, size, **kws):
    tree = opt.search(inputs, output, size)
    tree_r = tree.subtree_reconfigure_forest(
        parallel="ray",
        progbar=True,
        num_trees=20,
        num_restarts=20,
        subtree_weight_what=("size",),
    )
    return tree_r.path()


tc.set_contractor("custom", optimizer=opt_reconf, preprocessing=True)
tc.set_dtype("complex64")
tc.set_backend("tensorflow")
# jax backend is incompatible with keras.save

dtype = np.complex64

# nwires, nlayers = 150, 7  # 600, 7
nwires, nlayers = 600, 7

Jx = np.array([1.0 for _ in range(nwires - 1)])  # strength of xx interaction (OBC)
Bz = np.array([-1.0 for _ in range(nwires)])  # strength of transverse field
hamiltonian_mpo = tn.matrixproductstates.mpo.FiniteTFI(
    Jx, Bz, dtype=dtype
)  # matrix product operator
hamiltonian_mpo = tc.quantum.tn2qop(hamiltonian_mpo)


def vqe_forward(param):
    print("compiling")
    split_conf = {
        "max_singular_values": 2,
        "fixed_choice": 1,
    }
    c = tc.Circuit(nwires, split=split_conf)
    for i in range(nwires):
        c.H(i)
    for j in range(nlayers):
        for i in range(0, nwires - 1):
            c.exp1(
                i,
                (i + 1) % nwires,
                theta=param[4 * j, i],
                unitary=tc.gates._xx_matrix,
            )

        for i in range(nwires):
            c.rz(i, theta=param[4 * j + 1, i])
        for i in range(nwires):
            c.ry(i, theta=param[4 * j + 2, i])
        for i in range(nwires):
            c.rz(i, theta=param[4 * j + 3, i])
    return tc.templates.measurements.mpo_expectation(c, hamiltonian_mpo)


if __name__ == "__main__":
    # refresh = False

    # time0 = time.time()
    # if refresh:
    #     tc_vg = tf.function(
    #         tc.backend.value_and_grad(vqe_forward),
    #         input_signature=[tf.TensorSpec([4 * nlayers, nwires], tf.float32)],
    #     )
    #     tc.keras.save_func(tc_vg, "./funcs/%s_%s_tfim_mpo" % (nwires, nlayers))
    #     time1 = time.time()
    #     print("staging time: ", time1 - time0)

    # tc_vg_loaded = tc.keras.load_func("./funcs/%s_%s_tfim_mpo" % (nwires, nlayers))

    # lr1 = 0.008
    # lr2 = 0.06
    # steps = 2000
    # switch = 400
    # debug_steps = 20

    # if tc.backend.name == "jax":
    #     opt = tc.backend.optimizer(optax.adam(lr1))
    #     opt2 = tc.backend.optimizer(optax.sgd(lr2))
    # else:
    #     opt = tc.backend.optimizer(tf.keras.optimizers.Adam(lr1))
    #     opt2 = tc.backend.optimizer(tf.keras.optimizers.SGD(lr2))

    # times = []
    param = tc.backend.implicit_randn(stddev=0.1, shape=[4 * nlayers, nwires])
    print(vqe_forward(param))

    # for j in range(steps):
    #     loss, gr = tc_vg_loaded(param)
    #     if j < switch:
    #         param = opt.update(gr, param)
    #     else:
    #         if j == switch:
    #             print("switching the optimizer")
    #         param = opt2.update(gr, param)
    #     if j % debug_steps == 0 or j == steps - 1:
    #         times.append(time.time())
    #         print("loss", tc.backend.numpy(loss))
    #         if j > 0:
    #             print("running time:", (times[-1] - times[0]) / j)


"""
# Baseline code: obtained from DMRG using quimb
import quimb
h = quimb.tensor.tensor_gen.MPO_ham_ising(nwires, 4, 2, cyclic=False)
dmrg = quimb.tensor.tensor_dmrg.DMRG2(m, bond_dims=[10, 20, 100, 100, 200], cutoffs=1e-10)
dmrg.solve(tol=1e-9, verbosity=1) # may require repetition of this API
"""

Add circuit pruning method to delete nearly identity gates

Task description

Add a function on AbstractCircuit as c.prune(threshold) which can delete the gate nearly identity (up to threshold) and save quantum reousrces

Implementation

Go through the c._qir, and check whether each gate matrix is close to identity enough, if so, dont put the gate in the new qir for the new circuit.

Requirements

Difficulty: ★★

Be caution on possible corner case of MPS gate.

Implementation of SHVQE with QAS

Issue Description

Implement Schrodinger-Heisenberg quantum variational eigensolver (SHVQE) with quantum architecture search.

Proposed Solution

I have already implemented it as a script (using tensorcircuit) at https://github.com/royess/QC-Contest-underwater/blob/main/shvqe_clifford.py and want to see whether I can contribute it to the tensorcircuit package in some ways.

Additional References

The paper: https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.131.060406

Add QFT circuit block

Task description

Add Quantum Fourier Transformation circuit block as tc.templates.blocks.qft

Implementation

Implement the function in /tensorcircuit/templates/blocks.py, the function input signature is sth like below:

def qft(c, *index):

eg. qft(c, 2, 3, 4) add a QFT(3) circuit on 2, 3, 4 qubit lines of circuit c.

Requirements

Difficulty: ★★

Some issues when migrating vqe_h2o.ipynb to use CO2

I am trying to migrate vqe_h2o.ipynb to use CO2 carbon dioxide molecule.

  1. For print(fh.terms[((0, 1), (0, 0))]) which is the two-body coefficients, it gives -36.01932840424451. When I try to access the one-body coefficients using the following code snippet, nothing is printed out. Could you advise how to decide which orbitals to be removed for CO2 ? The video comes with a notebook code which no longer runs since it is using deprecated qiskit-chemistry package. Besides, when I checked https://qiskit.org/documentation/nature/tutorials/05_problem_transformers.html#The-ActiveSpaceTransformer , code box [11] still need to be manually hand-picking the active orbitals. Correct me if I miss anything though
one_body_terms = fh.terms
for term, coefficient in one_body_terms.items():
    if len(term) == 2:
        # Only consider terms with one creation and one annihilation operator
        i, j = term
        if i[0] == "c" and j[0] == "c":
            print("Term: c^\dagger_{} c_{} Coefficient: {}".format(i[1], j[1], coefficient))
  1. Besides, the kernel crashes when running ma = tc.quantum.PauliStringSum2COO_numpy(lsa, wa)

image

image

CUDA running error when using pytorch warpper in tensorcircuit

Traceback (most recent call last):
File "SBQRL/models/QNN.py", line 164, in forward
quantum_output = self.qpreds_batch(inputs, params) # only return single value
File "~/lib/python3.6/site-packages/tensorcircuit/interfaces.py", line 128, in forward
x = general_args_to_numpy(x)
File "conda/envs/my_torch/lib/python3.6/site-packages/tensorcircuit/interfaces.py", line 32, in general_args_to_numpy
res.append(tensor_to_numpy(i))
File "/envs/QM_torch/lib/python3.6/site-packages/tensorcircuit/interfaces.py", line 20, in tensor_to_numpy
return t.numpy()
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
srun: error: compute-0-2: task 0: Exited with exit code 1

It seems that the hybrid model cannot well be executed in CUDA device. In interface file, t.numpy() is not consistent with t.cpu().numpy().

=============
pytorch version: 1.10 and cuda 11.3

docker file need updating

Issue Description

tensorcircuit is not installed in the image, as well as other issues after pip install tensorcircuit

How to Reproduce

docker run -it --network host --gpus all tensorcircuit/tensorcircuit
root@user-HP-Z8-G4-Workstation:/app# python
Python 3.8.12 (default, Oct 12 2021, 13:49:34)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorcircuit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorcircuit'
>>>

Change the definition of p for generaldepolarizingchannel

Issue Description

If p is a list then the definition is fine. However, if p is a float, the channel is defined as

$$ \mathcal{E}(\rho) = (1 - 3p)\rho + p(X\rho X + Y\rho Y + Z\rho Z) $$

which is counter-intuitive and not compatible with (all?) existing packages and papers.

Proposed Solution

Change the definition to

$$ \mathcal{E}(\rho) = (1 - p)\rho + p/3(X\rho X + Y\rho Y + Z\rho Z) $$

This is going to be a backward-incompatible change that may silently change the semantics of existing code.

Additional References

Circ https://quantumai.google/reference/python/cirq/DepolarizingChannel
Qiskit https://qiskit.org/documentation/stubs/qiskit_aer.noise.depolarizing_error.html
Pennylane https://docs.pennylane.ai/en/stable/code/api/pennylane.DepolarizingChannel.html

For papers see 8.103 of Nielsen&Chuang, Eq. 24 of https://arxiv.org/pdf/2112.15540.pdf, Eq.2.6 of https://arxiv.org/pdf/2004.02388.pdf, Eq.3 of https://arxiv.org/pdf/2003.04941.pdf and many more

Add a new series of jupyter notebooks in docs

Probably https://github.com/tencent-quantum-lab/tensorcircuit/tree/master/docs/source/preparation, with materials on basic quantum mechanics and quantum computing. The short-term aim for this series of notebooks is as an introductory material for xinghuo project 2022.

Add circuit ``to_cirq`` and ``from_cirq`` functionality

Task description

Similar to AbstractCircuit.to_qiskit method, ultimately we would like to transform tensorcircuit Circuit with cirq Circuit as well.

Implementation

Add functions similar to qir2qiskit in https://github.com/tencent-quantum-lab/tensorcircuit/blob/master/tensorcircuit/translation.py. And then add a wrapper method in https://github.com/tencent-quantum-lab/tensorcircuit/blob/master/tensorcircuit/abstractcircuit.py as .to_cirq and .from_cirq.
Add test similar to https://github.com/tencent-quantum-lab/tensorcircuit/blob/master/tests/test_circuit.py#L845 accordingly.

Requirements

Difficulty: ★★★

Autograph error when appending circuirt block

Issue Description

When I try to append circuit block on tf backend and use torch interface, I met an autograph error somehow related to MPS simulator. (Althought I am not using it.)

How to Reproduce

import tensorcircuit as tc
import torch
import torch.nn as nn

tc.set_backend('tensorflow')

K = tc.backend
assert str(K)=='tensorflow_backend' # currently only support tensorflow_backend

jit = False

def single_qubit_unitary_block(nqubits, blockqubits, weights):
    """Create a single qubit unitary block as described in the Tucci paper.
    Reference codes: https://www.tensorflow.org/quantum/tutorials/qcnn#152_qcnn_layers

    Parameters
    ----------
    nqubits : int
        number of qubits.
    blockqubits : List[int]
        qubits in the block.
    weights : tensor, shape (3,)
        weights.

    Returns
    -------
    tc.circuit.Circuit
        Circuit.
    """
    nblockqubits = len(blockqubits)
    c = tc.Circuit(nqubits)
    iqubit = blockqubits[0]
    c.rx(iqubit, theta=weights[0])
    c.ry(iqubit, theta=weights[1])
    c.rz(iqubit, theta=weights[2])
    return c

def hardware_efficient_layer(nqubits, blockqubits, nlayers, weights):
    """Create a hardware efficient block (on a ring topol) to fully connected qubits in a block. Entanglers are CNOTs. Rotators are U(2).

    Parameters
    ----------
    nqubits : int
        number of qubits.
    blockqubits : List[int]
        qubits in the block.
    nlayers : int
        number of layers.
    weights : tensor, shape (nlayers+1, nqubits, 3)
        weights.

    Returns
    -------
    tc.circuit.Circuit
        Circuit.
    """
    c = tc.Circuit(nqubits)
    nblockqubits = len(blockqubits)
    for ilayer in range(0, nlayers+1):
        if ilayer!=0:
            for i in range(ilayer%2, nblockqubits, 2):
                # the entanglers are misaligned for odd and even layers\
                iqubit = blockqubits[i]
                c.cnot(iqubit, (iqubit+1)%nqubits)
        for i in range(nblockqubits):
            iqubit = blockqubits[i]
            c.append(single_qubit_unitary_block(nqubits, [iqubit], weights[ilayer, iqubit]))
    return c

class QNNClf(torch.nn.Module):
    def __init__(self, nqubits, nlayers, encoding_func, init_params=None):
        """QNN classifer whose structure is hardware efficient.
        Parameters
        ----------
        nqubits : int
            number of qubits
        nlayers : int
            number of layers (layers of entanglers)
        encoding_func : Callable[[int, tensor], tc.circuit.Circuit]
            function that return an encoding circuit for a given input
        init_params : torch.Tensor, optional
            initial parameters of shape (nlayers+1, nqubits, 3), by default None for random initialization
        """
        super().__init__()
        self.nqubits = nqubits
        self.nlayers = nlayers
        self.encoding_func = encoding_func

        if init_params is not None:
            self.weights = nn.Parameter(init_params)
        else:
            self.weights = nn.Parameter(0.1*2*torch.pi*torch.rand(nlayers+1, nqubits, 3))

        def pred_tf(inputs, weights):
            c = tc.Circuit(self.nqubits)
            c.append(self.encoding_func(self.nqubits, inputs))
            c.append(self.circuit(weights))
            e = K.real(c.expectation_ps(z=[0])) # measure the first qubit
            return K.sigmoid(e)

        self.pred_torch = tc.interfaces.torch_interface(
            K.vmap(pred_tf, vectorized_argnums=0), jit=jit) # batched version

    def circuit(self, weights):
        """trainable circuit"""
        return hardware_efficient_layer(self.nqubits, range(self.nqubits), self.nlayers, weights)

    def draw(self):
        return self.circuit(self.weights.detach().numpy()).draw(output='text')

    def forward(self, inputs):
        return self.pred_torch(inputs, self.weights)

def prepare_cluster_state(nqubits, inputs):
    """Prepare a cluster state with excitations according to inputs.
    Refer to: https://www.tensorflow.org/quantum/tutorials/qcnn#151_cluster_state
    And data: https://www.tensorflow.org/quantum/tutorials/qcnn#14_data

    Parameters
    ----------
    nqubits : int
    inputs : tensor, shape=(batch_size, nqubits)
        excitation on each qubit
    """
    c = tc.Circuit(nqubits)
    for iqubit in range(nqubits):
        c.h(iqubit)
    for iqubit in range(nqubits):
        c.cz(iqubit, (iqubit+1)%nqubits)
    # exitations
    for iqubit in range(nqubits):
        c.rx(iqubit, theta=inputs[iqubit])
    return c

import numpy as np

print('QNN test.')
nqubits = 8
nlayers = 2
nbatches = 3
qnn_model = QNNClf(nqubits, nlayers, prepare_cluster_state)
print(qnn_model(2*np.pi*torch.rand(nbatches, nqubits)))
print(qnn_model.draw())

Error Output

2022-07-19 10:32:30.597203: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2022-07-19 10:32:30.597262: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
QNN test.
2022-07-19 10:32:34.398716: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:961] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2022-07-19 10:32:34.401481: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusolver.so.11'; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory
2022-07-19 10:32:34.401677: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusparse.so.11'; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory
2022-07-19 10:32:34.401827: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2022-07-19 10:32:34.402322: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "<code path>/replacemps.py", line 142, in <module>
    print(qnn_model(2*np.pi*torch.rand(nbatches, nqubits)))
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "<code path>/replacemps.py", line 112, in forward
    return self.pred_torch(inputs, self.weights)
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/interfaces/torch.py", line 76, in forward
    y = fun(*x)
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/backends/tensorflow_backend.py", line 743, in wrapper
    return tf.vectorized_map(pf, args[0])
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py", line 549, in vectorized_map
    return pfor(loop_fn, batch_size,
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py", line 206, in pfor
    outputs = f()
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/tmp/__autograph_generated_filel6ny7jfr.py", line 16, in tf__f
    retval_ = ag__.converted_call(ag__.ld(_pfor_impl), (ag__.ld(loop_fn), ag__.ld(iters)), dict(fallback_to_while_loop=ag__.ld(fallback_to_while_loop), parallel_iterations=ag__.ld(parallel_iterations)), fscope)
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/backends/tensorflow_backend.py", line 741, in pf
    return f(x, *args[1:], **kws)
  File "<code path>/replacemps.py", line 98, in pred_tf
    e = K.real(c.expectation_ps(z=[0])) # measure the first qubit
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1785, in _expectation_ps
    return c.expectation(*obs, reuse=reuse, **kws)  # type: ignore
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1656, in expectation
    nodes1 = self.expectation_before(*ops, reuse=reuse)
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1588, in expectation_before
    nodes1, edge1 = self._copy_state_tensor(reuse=reuse)
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1285, in _copy_state_tensor
    nodes, d_edges = self._copy()
  File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1256, in _copy
    newfront.append(edict[e])
tensorflow.python.autograph.pyct.error_utils.MultilineMessageKeyError: in user code:

    File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/backends/tensorflow_backend.py", line 741, in pf
        return f(x, *args[1:], **kws)
    File "<code path>/replacemps.py", line 98, in pred_tf
        e = K.real(c.expectation_ps(z=[0])) # measure the first qubit
    File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1785, in _expectation_ps
        return c.expectation(*obs, reuse=reuse, **kws)  # type: ignore
    File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1656, in expectation
        nodes1 = self.expectation_before(*ops, reuse=reuse)
    File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1588, in expectation_before
        nodes1, edge1 = self._copy_state_tensor(reuse=reuse)
    File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1285, in _copy_state_tensor
        nodes, d_edges = self._copy()
    File "/home/xan/anaconda3/envs/tc39/lib/python3.9/site-packages/tensorcircuit/circuit.py", line 1256, in _copy
        newfront.append(edict[e])

    KeyError:
    Edge(Dangling Edge)[0]

And I try to comment c.replace_mps_inputs(self.quvector()) in line 857 of circuit.py because my codes do not need MPS simulator. Then everything works well.

Environment Context

name: tc39
channels:
  - nvidia
  - defaults
dependencies:
  - _ipyw_jlab_nb_ext_conf=0.1.0=py39h06a4308_1
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=4.5=1_gnu
  - aiohttp=3.8.1=py39h7f8727e_1
  - aiosignal=1.2.0=pyhd3eb1b0_0
  - alabaster=0.7.12=pyhd3eb1b0_0
  - anaconda-client=1.9.0=py39h06a4308_0
  - anaconda-project=0.10.2=pyhd3eb1b0_0
  - anyio=3.5.0=py39h06a4308_0
  - appdirs=1.4.4=pyhd3eb1b0_0
  - argon2-cffi=21.3.0=pyhd3eb1b0_0
  - argon2-cffi-bindings=21.2.0=py39h7f8727e_0
  - arrow=1.2.2=pyhd3eb1b0_0
  - astroid=2.6.6=py39h06a4308_0
  - astropy=5.0.4=py39hce1f21e_0
  - asttokens=2.0.5=pyhd3eb1b0_0
  - async-timeout=4.0.1=pyhd3eb1b0_0
  - atomicwrites=1.4.0=py_0
  - attrs=21.4.0=pyhd3eb1b0_0
  - automat=20.2.0=py_0
  - autopep8=1.6.0=pyhd3eb1b0_0
  - babel=2.9.1=pyhd3eb1b0_0
  - backcall=0.2.0=pyhd3eb1b0_0
  - backports=1.1=pyhd3eb1b0_0
  - backports.functools_lru_cache=1.6.4=pyhd3eb1b0_0
  - backports.tempfile=1.0=pyhd3eb1b0_1
  - backports.weakref=1.0.post1=py_1
  - bcrypt=3.2.0=py39he8ac12f_0
  - beautifulsoup4=4.11.1=py39h06a4308_0
  - binaryornot=0.4.4=pyhd3eb1b0_1
  - bitarray=2.4.1=py39h7f8727e_0
  - bkcharts=0.2=py39h06a4308_0
  - black=19.10b0=py_0
  - blas=1.0=mkl
  - bleach=4.1.0=pyhd3eb1b0_0
  - blosc=1.21.0=h8c45485_0
  - bokeh=2.4.2=py39h06a4308_0
  - boto3=1.21.32=pyhd3eb1b0_0
  - botocore=1.24.32=pyhd3eb1b0_0
  - bottleneck=1.3.4=py39hce1f21e_0
  - brotli=1.0.9=he6710b0_2
  - brotlipy=0.7.0=py39h27cfd23_1003
  - brunsli=0.1=h2531618_0
  - bzip2=1.0.8=h7b6447c_0
  - c-ares=1.18.1=h7f8727e_0
  - ca-certificates=2022.4.26=h06a4308_0
  - cachetools=4.2.2=pyhd3eb1b0_0
  - certifi=2022.6.15=py39h06a4308_0
  - cffi=1.15.0=py39hd667e15_1
  - cfitsio=3.470=hf0d0db6_6
  - chardet=4.0.0=py39h06a4308_1003
  - charls=2.2.0=h2531618_0
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - click=8.0.4=py39h06a4308_0
  - cloudpickle=2.0.0=pyhd3eb1b0_0
  - clyent=1.2.2=py39h06a4308_1
  - colorama=0.4.4=pyhd3eb1b0_0
  - colorcet=2.0.6=pyhd3eb1b0_0
  - conda-content-trust=0.1.1=pyhd3eb1b0_0
  - conda-pack=0.6.0=pyhd3eb1b0_0
  - conda-package-handling=1.8.1=py39h7f8727e_0
  - conda-repo-cli=1.0.4=pyhd3eb1b0_0
  - conda-verify=3.4.2=py_1
  - constantly=15.1.0=pyh2b92418_0
  - cookiecutter=1.7.3=pyhd3eb1b0_0
  - cryptography=3.4.8=py39hd23ed53_0
  - cssselect=1.1.0=pyhd3eb1b0_0
  - cuda-nvcc=11.7.64=0
  - cudatoolkit=11.3.1=h2bc3f7f_2
  - curl=7.82.0=h7f8727e_0
  - cycler=0.11.0=pyhd3eb1b0_0
  - cython=0.29.28=py39h295c915_0
  - cytoolz=0.11.0=py39h27cfd23_0
  - daal4py=2021.5.0=py39h78b71dc_0
  - dal=2021.5.1=h06a4308_803
  - dask=2022.2.1=pyhd3eb1b0_0
  - dask-core=2022.2.1=pyhd3eb1b0_0
  - dataclasses=0.8=pyh6d0b6a4_7
  - datashader=0.13.0=pyhd3eb1b0_1
  - datashape=0.5.4=py39h06a4308_1
  - dbus=1.13.18=hb2f20db_0
  - debugpy=1.5.1=py39h295c915_0
  - decorator=5.1.1=pyhd3eb1b0_0
  - defusedxml=0.7.1=pyhd3eb1b0_0
  - diff-match-patch=20200713=pyhd3eb1b0_0
  - distributed=2022.2.1=pyhd3eb1b0_0
  - docutils=0.17.1=py39h06a4308_1
  - entrypoints=0.4=py39h06a4308_0
  - et_xmlfile=1.1.0=py39h06a4308_0
  - executing=0.8.3=pyhd3eb1b0_0
  - expat=2.4.4=h295c915_0
  - filelock=3.6.0=pyhd3eb1b0_0
  - flake8=3.9.2=pyhd3eb1b0_0
  - flask=1.1.2=pyhd3eb1b0_0
  - fontconfig=2.13.1=h6c09931_0
  - fonttools=4.25.0=pyhd3eb1b0_0
  - freetype=2.11.0=h70c0345_0
  - frozenlist=1.2.0=py39h7f8727e_0
  - fsspec=2022.2.0=pyhd3eb1b0_0
  - future=0.18.2=py39h06a4308_1
  - gensim=4.1.2=py39h295c915_0
  - giflib=5.2.1=h7b6447c_0
  - glib=2.69.1=h4ff587b_1
  - glob2=0.7=pyhd3eb1b0_0
  - gmp=6.2.1=h2531618_2
  - gmpy2=2.1.2=py39heeb90bb_0
  - google-api-core=1.25.1=pyhd3eb1b0_0
  - google-auth=1.33.0=pyhd3eb1b0_0
  - google-cloud-core=1.7.1=pyhd3eb1b0_0
  - google-cloud-storage=1.31.0=py_0
  - google-crc32c=1.1.2=py39h27cfd23_0
  - google-resumable-media=1.3.1=pyhd3eb1b0_1
  - googleapis-common-protos=1.53.0=py39h06a4308_0
  - greenlet=1.1.1=py39h295c915_0
  - grpcio=1.42.0=py39hce63b2e_0
  - gst-plugins-base=1.14.0=h8213a91_2
  - gstreamer=1.14.0=h28cd5cc_2
  - h5py=3.6.0=py39ha0f2276_0
  - hdf5=1.10.6=hb1b8bf9_0
  - heapdict=1.0.1=pyhd3eb1b0_0
  - holoviews=1.14.8=pyhd3eb1b0_0
  - hvplot=0.7.3=pyhd3eb1b0_1
  - hyperlink=21.0.0=pyhd3eb1b0_0
  - icu=58.2=he6710b0_3
  - idna=3.3=pyhd3eb1b0_0
  - imagecodecs=2021.8.26=py39h4cda21f_0
  - imageio=2.9.0=pyhd3eb1b0_0
  - imagesize=1.3.0=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py39h06a4308_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - incremental=21.3.0=pyhd3eb1b0_0
  - inflection=0.5.1=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - intake=0.6.5=pyhd3eb1b0_0
  - intel-openmp=2021.4.0=h06a4308_3561
  - intervaltree=3.1.0=pyhd3eb1b0_0
  - ipykernel=6.9.1=py39h06a4308_0
  - ipython=8.2.0=py39h06a4308_0
  - ipython_genutils=0.2.0=pyhd3eb1b0_1
  - ipywidgets=7.6.5=pyhd3eb1b0_1
  - isort=5.9.3=pyhd3eb1b0_0
  - itemadapter=0.3.0=pyhd3eb1b0_0
  - itemloaders=1.0.4=pyhd3eb1b0_1
  - itsdangerous=2.0.1=pyhd3eb1b0_0
  - jdcal=1.4.1=pyhd3eb1b0_0
  - jedi=0.18.1=py39h06a4308_1
  - jeepney=0.7.1=pyhd3eb1b0_0
  - jinja2=2.11.3=pyhd3eb1b0_0
  - jinja2-time=0.2.0=pyhd3eb1b0_3
  - jmespath=0.10.0=pyhd3eb1b0_0
  - joblib=1.1.0=pyhd3eb1b0_0
  - jpeg=9e=h7f8727e_0
  - jq=1.6=h27cfd23_1000
  - json5=0.9.6=pyhd3eb1b0_0
  - jsonschema=4.4.0=py39h06a4308_0
  - jupyter=1.0.0=py39h06a4308_7
  - jupyter_client=6.1.12=pyhd3eb1b0_0
  - jupyter_console=6.4.0=pyhd3eb1b0_0
  - jupyter_core=4.9.2=py39h06a4308_0
  - jupyter_server=1.13.5=pyhd3eb1b0_0
  - jupyterlab=3.3.2=pyhd3eb1b0_0
  - jupyterlab_pygments=0.1.2=py_0
  - jupyterlab_server=2.10.3=pyhd3eb1b0_1
  - jupyterlab_widgets=1.0.0=pyhd3eb1b0_1
  - jxrlib=1.1=h7b6447c_2
  - keyring=23.4.0=py39h06a4308_0
  - kiwisolver=1.3.2=py39h295c915_0
  - krb5=1.19.2=hac12032_0
  - lazy-object-proxy=1.6.0=py39h27cfd23_0
  - lcms2=2.12=h3be6417_0
  - ld_impl_linux-64=2.35.1=h7274673_9
  - lerc=3.0=h295c915_0
  - libaec=1.0.4=he6710b0_1
  - libarchive=3.4.2=h62408e4_0
  - libcrc32c=1.1.1=he6710b0_2
  - libcurl=7.82.0=h0b77cf5_0
  - libdeflate=1.8=h7f8727e_5
  - libedit=3.1.20210910=h7f8727e_0
  - libev=4.33=h7f8727e_1
  - libffi=3.3=he6710b0_2
  - libgcc-ng=9.3.0=h5101ec6_17
  - libgfortran-ng=7.5.0=ha8ba4b0_17
  - libgfortran4=7.5.0=ha8ba4b0_17
  - libgomp=9.3.0=h5101ec6_17
  - libidn2=2.3.2=h7f8727e_0
  - liblief=0.11.5=h295c915_1
  - libllvm11=11.1.0=h3826bc1_1
  - libnghttp2=1.46.0=hce63b2e_0
  - libpng=1.6.37=hbc83047_0
  - libprotobuf=3.19.1=h4ff587b_0
  - libsodium=1.0.18=h7b6447c_0
  - libspatialindex=1.9.3=h2531618_0
  - libssh2=1.10.0=h8f2d780_0
  - libstdcxx-ng=9.3.0=hd4cf53a_17
  - libtiff=4.2.0=h85742a9_0
  - libunistring=0.9.10=h27cfd23_0
  - libuuid=1.0.3=h7f8727e_2
  - libwebp=1.2.2=h55f646e_0
  - libwebp-base=1.2.2=h7f8727e_0
  - libxcb=1.14=h7b6447c_0
  - libxml2=2.9.12=h03d6c58_0
  - libxslt=1.1.34=hc22bd24_0
  - libzopfli=1.0.3=he6710b0_0
  - llvmlite=0.38.0=py39h4ff587b_0
  - locket=0.2.1=py39h06a4308_2
  - lxml=4.8.0=py39h1f438cf_0
  - lz4-c=1.9.3=h295c915_1
  - lzo=2.10=h7b6447c_2
  - markdown=3.3.4=py39h06a4308_0
  - markupsafe=2.0.1=py39h27cfd23_0
  - matplotlib=3.5.1=py39h06a4308_1
  - matplotlib-base=3.5.1=py39ha18d171_1
  - matplotlib-inline=0.1.2=pyhd3eb1b0_2
  - mccabe=0.6.1=py39h06a4308_1
  - mistune=0.8.4=py39h27cfd23_1000
  - mkl=2021.4.0=h06a4308_640
  - mkl-service=2.4.0=py39h7f8727e_0
  - mkl_fft=1.3.1=py39hd3c417c_0
  - mkl_random=1.2.2=py39h51133e4_0
  - mock=4.0.3=pyhd3eb1b0_0
  - mpc=1.1.0=h10f8cd9_1
  - mpfr=4.0.2=hb69a4c5_1
  - mpi=1.0=mpich
  - mpich=3.3.2=hc856adb_0
  - mpmath=1.2.1=py39h06a4308_0
  - msgpack-python=1.0.2=py39hff7bd54_1
  - multidict=5.2.0=py39h7f8727e_2
  - multipledispatch=0.6.0=py39h06a4308_0
  - munkres=1.1.4=py_0
  - mypy_extensions=0.4.3=py39h06a4308_1
  - navigator-updater=0.2.1=py39_1
  - nbclassic=0.3.5=pyhd3eb1b0_0
  - nbclient=0.5.13=py39h06a4308_0
  - nbconvert=6.4.4=py39h06a4308_0
  - nbformat=5.3.0=py39h06a4308_0
  - ncurses=6.3=h7f8727e_2
  - nest-asyncio=1.5.5=py39h06a4308_0
  - networkx=2.7.1=pyhd3eb1b0_0
  - nltk=3.7=pyhd3eb1b0_0
  - nose=1.3.7=pyhd3eb1b0_1008
  - notebook=6.4.8=py39h06a4308_0
  - numba=0.55.1=py39h51133e4_0
  - numexpr=2.8.1=py39h6abb31d_0
  - numpy=1.21.5=py39he7a7128_1
  - numpy-base=1.21.5=py39hf524024_1
  - numpydoc=1.2=pyhd3eb1b0_0
  - olefile=0.46=pyhd3eb1b0_0
  - oniguruma=6.9.7.1=h27cfd23_0
  - openjpeg=2.4.0=h3ad879b_0
  - openpyxl=3.0.9=pyhd3eb1b0_0
  - openssl=1.1.1q=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pandas=1.4.2=py39h295c915_0
  - pandocfilters=1.5.0=pyhd3eb1b0_0
  - panel=0.13.0=py39h06a4308_0
  - param=1.12.0=pyhd3eb1b0_0
  - parsel=1.6.0=py39h06a4308_0
  - parso=0.8.3=pyhd3eb1b0_0
  - partd=1.2.0=pyhd3eb1b0_1
  - patchelf=0.13=h295c915_0
  - pathspec=0.7.0=py_0
  - patsy=0.5.2=py39h06a4308_1
  - pcre=8.45=h295c915_0
  - pep8=1.7.1=py39h06a4308_0
  - pexpect=4.8.0=pyhd3eb1b0_3
  - pickleshare=0.7.5=pyhd3eb1b0_1003
  - pillow=9.0.1=py39h22f2fdc_0
  - pip=21.2.4=py39h06a4308_0
  - pkginfo=1.8.2=pyhd3eb1b0_0
  - plotly=5.6.0=pyhd3eb1b0_0
  - pluggy=1.0.0=py39h06a4308_1
  - poyo=0.5.0=pyhd3eb1b0_0
  - prometheus_client=0.13.1=pyhd3eb1b0_0
  - prompt-toolkit=3.0.20=pyhd3eb1b0_0
  - prompt_toolkit=3.0.20=hd3eb1b0_0
  - protego=0.1.16=py_0
  - protobuf=3.19.1=py39h295c915_0
  - psutil=5.8.0=py39h27cfd23_1
  - ptyprocess=0.7.0=pyhd3eb1b0_2
  - pure_eval=0.2.2=pyhd3eb1b0_0
  - py=1.11.0=pyhd3eb1b0_0
  - py-lief=0.11.5=py39h295c915_1
  - pyasn1=0.4.8=pyhd3eb1b0_0
  - pyasn1-modules=0.2.8=py_0
  - pycodestyle=2.7.0=pyhd3eb1b0_0
  - pycosat=0.6.3=py39h27cfd23_0
  - pycparser=2.21=pyhd3eb1b0_0
  - pyct=0.4.6=py39h06a4308_0
  - pycurl=7.44.1=py39h8f2d780_1
  - pydispatcher=2.0.5=py39h06a4308_2
  - pydocstyle=6.1.1=pyhd3eb1b0_0
  - pyerfa=2.0.0=py39h27cfd23_0
  - pyflakes=2.3.1=pyhd3eb1b0_0
  - pygments=2.11.2=pyhd3eb1b0_0
  - pyhamcrest=2.0.2=pyhd3eb1b0_2
  - pyjwt=2.1.0=py39h06a4308_0
  - pylint=2.9.6=py39h06a4308_1
  - pyls-spyder=0.4.0=pyhd3eb1b0_0
  - pyodbc=4.0.32=py39h295c915_1
  - pyopenssl=21.0.0=pyhd3eb1b0_1
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pyqt=5.9.2=py39h2531618_6
  - pyrsistent=0.18.0=py39heee7806_0
  - pysocks=1.7.1=py39h06a4308_0
  - pytables=3.6.1=py39h77479fe_1
  - pytest=7.1.1=py39h06a4308_0
  - python=3.9.12=h12debd9_0
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - python-fastjsonschema=2.15.1=pyhd3eb1b0_0
  - python-libarchive-c=2.9=pyhd3eb1b0_1
  - python-lsp-black=1.0.0=pyhd3eb1b0_0
  - python-lsp-jsonrpc=1.0.0=pyhd3eb1b0_0
  - python-lsp-server=1.2.4=pyhd3eb1b0_0
  - python-slugify=5.0.2=pyhd3eb1b0_0
  - python-snappy=0.6.0=py39h2531618_3
  - pytz=2021.3=pyhd3eb1b0_0
  - pyviz_comms=2.0.2=pyhd3eb1b0_0
  - pywavelets=1.3.0=py39h7f8727e_0
  - pyxdg=0.27=pyhd3eb1b0_0
  - pyyaml=6.0=py39h7f8727e_1
  - pyzmq=22.3.0=py39h295c915_2
  - qdarkstyle=3.0.2=pyhd3eb1b0_0
  - qstylizer=0.1.10=pyhd3eb1b0_0
  - qt=5.9.7=h5867ecd_1
  - qtawesome=1.0.3=pyhd3eb1b0_0
  - qtconsole=5.3.0=pyhd3eb1b0_0
  - qtpy=2.0.1=pyhd3eb1b0_0
  - queuelib=1.5.0=py39h06a4308_0
  - readline=8.1.2=h7f8727e_1
  - regex=2022.3.15=py39h7f8727e_0
  - requests=2.27.1=pyhd3eb1b0_0
  - requests-file=1.5.1=pyhd3eb1b0_0
  - ripgrep=12.1.1=0
  - rope=0.22.0=pyhd3eb1b0_0
  - rsa=4.7.2=pyhd3eb1b0_1
  - rtree=0.9.7=py39h06a4308_1
  - ruamel_yaml=0.15.100=py39h27cfd23_0
  - s3transfer=0.5.0=pyhd3eb1b0_0
  - scikit-image=0.19.2=py39h51133e4_0
  - scikit-learn=1.0.2=py39h51133e4_1
  - scikit-learn-intelex=2021.5.0=py39h06a4308_0
  - scipy=1.7.3=py39hc147768_0
  - scrapy=2.6.1=py39h06a4308_0
  - seaborn=0.11.2=pyhd3eb1b0_0
  - secretstorage=3.3.1=py39h06a4308_0
  - send2trash=1.8.0=pyhd3eb1b0_1
  - service_identity=18.1.0=pyhd3eb1b0_1
  - setuptools=61.2.0=py39h06a4308_0
  - sip=4.19.13=py39h295c915_0
  - six=1.16.0=pyhd3eb1b0_1
  - smart_open=5.1.0=pyhd3eb1b0_0
  - snappy=1.1.9=h295c915_0
  - sniffio=1.2.0=py39h06a4308_1
  - snowballstemmer=2.2.0=pyhd3eb1b0_0
  - sortedcollections=2.1.0=pyhd3eb1b0_0
  - sortedcontainers=2.4.0=pyhd3eb1b0_0
  - soupsieve=2.3.1=pyhd3eb1b0_0
  - sphinx=4.4.0=pyhd3eb1b0_0
  - sphinxcontrib-applehelp=1.0.2=pyhd3eb1b0_0
  - sphinxcontrib-devhelp=1.0.2=pyhd3eb1b0_0
  - sphinxcontrib-htmlhelp=2.0.0=pyhd3eb1b0_0
  - sphinxcontrib-jsmath=1.0.1=pyhd3eb1b0_0
  - sphinxcontrib-qthelp=1.0.3=pyhd3eb1b0_0
  - sphinxcontrib-serializinghtml=1.1.5=pyhd3eb1b0_0
  - spyder=5.1.5=py39h06a4308_1
  - spyder-kernels=2.1.3=py39h06a4308_0
  - sqlalchemy=1.4.32=py39h7f8727e_0
  - sqlite=3.38.2=hc218d9a_0
  - stack_data=0.2.0=pyhd3eb1b0_0
  - statsmodels=0.13.2=py39h7f8727e_0
  - sympy=1.10.1=py39h06a4308_0
  - tabulate=0.8.9=py39h06a4308_0
  - tbb=2021.5.0=hd09550d_0
  - tbb4py=2021.5.0=py39hd09550d_0
  - tblib=1.7.0=pyhd3eb1b0_0
  - tenacity=8.0.1=py39h06a4308_0
  - terminado=0.13.1=py39h06a4308_0
  - testpath=0.5.0=pyhd3eb1b0_0
  - text-unidecode=1.3=pyhd3eb1b0_0
  - textdistance=4.2.1=pyhd3eb1b0_0
  - threadpoolctl=2.2.0=pyh0d69192_0
  - three-merge=0.1.1=pyhd3eb1b0_0
  - tifffile=2021.7.2=pyhd3eb1b0_2
  - tinycss=0.4=pyhd3eb1b0_1002
  - tk=8.6.11=h1ccaba5_0
  - tldextract=3.2.0=pyhd3eb1b0_0
  - toml=0.10.2=pyhd3eb1b0_0
  - tomli=1.2.2=pyhd3eb1b0_0
  - toolz=0.11.2=pyhd3eb1b0_0
  - tornado=6.1=py39h27cfd23_0
  - tqdm=4.64.0=py39h06a4308_0
  - traitlets=5.1.1=pyhd3eb1b0_0
  - twisted=22.2.0=py39h7f8727e_0
  - typed-ast=1.4.3=py39h7f8727e_1
  - typing-extensions=4.1.1=hd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - tzdata=2022a=hda174b7_0
  - ujson=5.1.0=py39h295c915_0
  - unidecode=1.2.0=pyhd3eb1b0_0
  - unixodbc=2.3.9=h7b6447c_0
  - urllib3=1.26.9=py39h06a4308_0
  - w3lib=1.21.0=pyhd3eb1b0_0
  - watchdog=2.1.6=py39h06a4308_0
  - wcwidth=0.2.5=pyhd3eb1b0_0
  - webencodings=0.5.1=py39h06a4308_1
  - werkzeug=2.0.3=pyhd3eb1b0_0
  - wget=1.21.3=h0b77cf5_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - widgetsnbextension=3.5.2=py39h06a4308_0
  - wrapt=1.12.1=py39he8ac12f_1
  - wurlitzer=3.0.2=py39h06a4308_0
  - xarray=0.20.1=pyhd3eb1b0_1
  - xlrd=2.0.1=pyhd3eb1b0_0
  - xlsxwriter=3.0.3=pyhd3eb1b0_0
  - xz=5.2.5=h7b6447c_0
  - yaml=0.2.5=h7b6447c_0
  - yapf=0.31.0=pyhd3eb1b0_0
  - yarl=1.6.3=py39h27cfd23_0
  - zeromq=4.3.4=h2531618_0
  - zfp=0.5.5=h295c915_6
  - zict=2.0.0=pyhd3eb1b0_0
  - zipp=3.7.0=pyhd3eb1b0_0
  - zlib=1.2.12=h7f8727e_2
  - zope=1.0=py39h06a4308_1
  - zope.interface=5.4.0=py39h7f8727e_0
  - zstd=1.4.9=haebb681_0
  - pip:
    - absl-py==1.1.0
    - astunparse==1.6.3
    - chex==0.1.3
    - commonmark==0.9.1
    - dill==0.3.5.1
    - dm-tree==0.1.7
    - etils==0.6.0
    - flatbuffers==1.12
    - flax==0.5.2
    - gast==0.4.0
    - google-auth-oauthlib==0.4.6
    - google-pasta==0.2.0
    - importlib-resources==5.8.0
    - jax==0.3.14
    - jaxlib==0.3.14+cuda11.cudnn82
    - keras==2.9.0
    - keras-preprocessing==1.1.2
    - libclang==14.0.1
    - ntlm-auth==1.5.0
    - oauthlib==3.2.0
    - opt-einsum==3.3.0
    - optax==0.1.3
    - pbr==5.9.0
    - ply==3.11
    - python-graphviz==0.20
    - qiskit==0.37.0
    - qiskit-aer==0.10.4
    - qiskit-ibmq-provider==0.19.2
    - qiskit-terra==0.21.0
    - requests-ntlm==1.1.0
    - requests-oauthlib==1.3.1
    - retworkx==0.11.0
    - rich==11.2.0
    - stevedore==4.0.0
    - symengine==0.9.2
    - tensorboard==2.9.1
    - tensorboard-data-server==0.6.1
    - tensorboard-plugin-wit==1.8.1
    - tensorcircuit==0.2.2
    - tensorflow==2.9.1
    - tensorflow-estimator==2.9.0
    - tensorflow-io-gcs-filesystem==0.26.0
    - tensornetwork==0.4.6
    - termcolor==1.1.0
    - torch==1.12.0+cu116
    - torchaudio==0.12.0+cu116
    - torchvision==0.13.0+cu116
    - tweedledum==1.1.1
    - websocket-client==1.3.3
    - websockets==10.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.