Skip to main content

Tensor Operations for Research in Quantum systems - Benchmarking.

Project description

TorQ-bench

Benchmarks and PennyLane comparisons for TorQ.

TorQ-bench is a small companion package that lets you run the same layer logic in TorQ and PennyLane to compare outputs and timing. It intentionally keeps PennyLane out of the core TorQ package.

Install

From source (recommended while developing):

pip install -e .[pennylane]

Or with PyPI:

pip install torq-bench[pennylane]

TorQ-bench depends on torq-quantum>=0.1.2. PennyLane is optional and only required for the comparison wrappers.

Note: the PyPI distribution is torq-quantum, while the Python import package remains torq.

Quickstart: compare TorQ vs PennyLane

import torch
from torq.QLayer import QLayer
from torq_bench import PennyLaneQLayer

n_qubits = 4
n_layers = 2
x = torch.rand(8, n_qubits)

torq_layer = QLayer(n_qubits=n_qubits, n_layers=n_layers)
pl_layer = PennyLaneQLayer(
    n_qubits=n_qubits,
    n_layers=n_layers,
    pennylane_dev_name="default.qubit",
)

y_torq = torq_layer(x)
y_pl = pl_layer(x)

Notes:

  • PennyLaneQLayer currently supports only ansatz_name="basic_entangling".
  • data_reupload_every is not supported in PennyLaneQLayer.

Using PennyLaneComparison directly

import torch
from torq_bench import PennyLaneComparison

n_qubits = 4
n_layers = 2
weights = torch.rand(n_layers, n_qubits, 3)
x = torch.rand(n_qubits)

qc = PennyLaneComparison(n_qubits=n_qubits, n_layers=n_layers, weights=weights)
circuit = qc.circuit_strongly_entangling()
y = circuit(x)

Run the built-in demo

The comparison module includes a demo that builds and draws several circuits. It uses qml.draw_mpl, so you will need matplotlib installed.

python -m torq_bench.PennyLaneComparison

License

MIT

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

torq_bench-0.1.2.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torq_bench-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file torq_bench-0.1.2.tar.gz.

File metadata

  • Download URL: torq_bench-0.1.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for torq_bench-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9f9193a2a89bf9ed3ffdefdba9bdd80be90c3e1cab73c0287fcb944e8777d3c7
MD5 aa8cdc6cd7b8e855b4b4a66256151319
BLAKE2b-256 f47951e5eecdef2bc632310d221a1b208dabc59dd7a0bc46fbc29e7b2d37160d

See more details on using hashes here.

File details

Details for the file torq_bench-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: torq_bench-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for torq_bench-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0716375d781cbcd1347e399efcc2357b425a26c0c256ff906747d618274d5b0f
MD5 d6217586b1a69403e4e70903dcd256b5
BLAKE2b-256 4ae5f8bc7b58f506c8a4ff6075973616f66531535b08889c9fc9d4ea7ee11cb1

See more details on using hashes here.

Supported by

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