Skip to main content

Quantum circuits on top of tensor network

Project description

TENSORCIRCUIT

This project is partially inspired by mpsim which builds the quantum circuit model on top of tensornetwork setups instead of directly matrix manipulations.

With TensorNetwork project announced by Google, such setup may gain benefits from swift implementation to auto differentiation abilities.

This is only a toy project at very early stage and it may always be at this stage. There might be not only sharp edges but also essential bugs in the project. Try it on your own risk.

Baisc Usage

import tensorcircuit as tc
c = tc.Circuit(2)
c.H(0)
c.CNOT(0,1)
print(c.perfect_sampling())
print(c.wavefunction())
print(c.measure(1))
print(c.expectation(tc.gates.z(), 1))

Runtime behavior changing:

tc.set_backend("tensorflow")
tc.set_dtype("complex128")
tc.set_contractor("greedy")

Auto differentiations with jit (tf and jax supported):

@tc.backend.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.gates.num_to_tensor(1.0)
print(g(theta))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorcircuit-0.0.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

tensorcircuit-0.0.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file tensorcircuit-0.0.1.tar.gz.

File metadata

  • Download URL: tensorcircuit-0.0.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for tensorcircuit-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1e1e2168feb090280948416606006befa1c81b77972e662486ea9a876463b036
MD5 caac5ab155794ee4048040a846f4b3fd
BLAKE2b-256 601f041c3c6e1afdd654542fad8697fbddd3921b36e7f4513bcb12f0be51df26

See more details on using hashes here.

File details

Details for the file tensorcircuit-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tensorcircuit-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for tensorcircuit-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bdc91ece34cc96bfd8e67b0c50b75e308b154b0b8d6c94783682bc295b216d89
MD5 b3c49b63fd79c509841b56c47d3152ef
BLAKE2b-256 ffe6f5acc9c43764baa5a44cb784589698263f992672f497f1462942895f5335

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page