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]

If published on 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.1.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.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torq_bench-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c860160891b617d20a7b69d8d6e0012a76794d280ac0ef062f96484adbd29b76
MD5 a0097e2265cbd7e4ec0333871ba6e06d
BLAKE2b-256 3a82d1b60e9d6f852f17d60d0319b1e216dbfe63efa255f7a1017f28c5bd6143

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torq_bench-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b59eff29234d115dcb9a6a6d9bed1a80c15490aae0c0c065dcd678d511903fb
MD5 a0aa5eea212fdc831bfa24e30a65b39a
BLAKE2b-256 8a987f2cb6513d9c98f8ee410bea55391efd861ebad575c5c5c46b86fceb7fc0

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