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.
Developed while writing the paper: Quantum Physics-Informed Neural Networks for Maxwell’s Equations: Circuit Design, “Black Hole” Barren Plateaus Mitigation, and GPU Acceleration
by Ziv Chen, Gal G. Shaviner, Hemanth Chandravamsi, Shimon Pisnoy, Steven H. Frankel, Uzi Pereg
https://arxiv.org/abs/2506.23246
For the simpler version associated with the following paper, please use the simple_for_PINNACLE branch: PINNACLE: An Open-Source Computational Framework for Classical and Quantum PINNs
by Shimon Pisnoy, Hemanth Chandravamsi, Ziv Chen, Aaron Goldgewert, Gal Shaviner, Boris Shragner, Steven H. Frankel
https://arxiv.org/abs/2604.15645
It is compatible with TorQ simple_for_PINNACLE branch and PINNACLE repos. Also, the simple_for_PINNACLE branch is the same as torq-bench v0.1.2 on PyPI.
Install
From source (recommended while developing):
pip install -e .[pennylane]
Or from PyPI:
pip install torq-bench[pennylane]
TorQ-bench depends on torq-quantum>=0.1.3. 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:
PennyLaneQLayersupports TorQ ansatz names:basic_entangling,single_rot_basic_ent,strongly_entangling,cross_mesh,cross_mesh_2_rots,cross_mesh_cx_rot,tile, andno_entanglement_ansatz.data_reupload_everyis supported.- Config-driven ansatz options are forwarded to PennyLane:
single_rot_basic_entusessingle_rotation_gate, andtileusestile_rotation_params,single_rotation_gate,tile_sublayers, andtile_cyclic. Thetile_cyclicwrap-around CNOT is applied only whenn_qubits > 2and even, matching TorQ. - Output observables follow TorQ's current
config.observablesAPI:Nonefor per-qubitZ, Pauli strings like"X"or"XI_ZZ", or Hermitian matrices with shape[2,2],[n_qubits,2,2],[2**n,2**n], or[m,2**n,2**n].
Using PennyLaneComparison directly
import torch
from torq_bench import PennyLaneComparison
n_qubits = 4
n_layers = 2
weights = torch.rand(n_layers, 1, n_qubits, 3) # current TorQ no-data layout
x = torch.rand(n_qubits)
qc = PennyLaneComparison(n_qubits=n_qubits, n_layers=n_layers, weights=weights)
circuit = qc.circuit_strongly_entangling()
state = circuit(x)
PennyLaneComparison also accepts the older no-data shape [n_layers, *per_layer_shape]
for backward compatibility.
Run the built-in demo
The comparison module includes a demo that builds and draws the supported TorQ
ansatzes, including single_rot_basic_ent and tile variants. It uses
qml.draw_mpl, so you will need matplotlib installed.
python -m torq_bench.PennyLaneComparison
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torq_bench-0.1.3.tar.gz.
File metadata
- Download URL: torq_bench-0.1.3.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3688a2bf5d0d6b97e14ca0e01bd6e8a53808c71770b10cc6a080a9ae95e1df90
|
|
| MD5 |
dc98a34897b208dbfc081a3d0debac8f
|
|
| BLAKE2b-256 |
7a0c7b68ecedde8ff7feb37e86594346da2debe12e9cbc01c99862b4868d5e1f
|
File details
Details for the file torq_bench-0.1.3-py3-none-any.whl.
File metadata
- Download URL: torq_bench-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eda8f8c53ce6c3419dc8671d004fe90a4f18deee0de2bae79db9eaf2d89d69e
|
|
| MD5 |
6dedf9d45f1b5962cfd0e542fdde39ef
|
|
| BLAKE2b-256 |
fb7f768e9054e56314988d93682e1b68b7b24d25cc5188144108c897df526ac0
|