Simulating quantum circuits parallel

Hello i want to simulate quantum circuit simultaneously.
I searched google and saw there are two kind of method, one is using qnode’s parameter broadcasting and one is use QNodeCollection.

When i tried to see QNodeCollection document, 404 error happens for website. How to use this? Is this discarded?

Also qnode does not seems to work. My test code was below

import pennylane as qml
import numpy as np

n_qubits=3
dev=qml.device("default.qubit",wires=n_qubits)
N_test=1000
def qc(theta0,theta1,theta2):
    qml.RX(theta0,wires=0)
    qml.RX(theta1,wires=1)
    qml.RX(theta2,wires=2)
    return qml.state()
qn=qml.QNode(qc,dev)
th=np.random.randn(3,N_test)
res=qn(th[0],th[1],th[2])

Then such error happens :

ValueError: all input arrays must have the same shape

Also when i printed device’s capabilities, there was no “supports_broadcasting”

print(dev.capabilities())
>>>{'model': 'qubit', 
'supports_finite_shots': True,
'supports_tensor_observables': True,
'returns_probs': True,
'supports_reversible_diff': True,
'supports_inverse_operations': True,
'supports_analytic_computation': True,
'returns_state': True, 
'passthru_devices': {'tf': 'default.qubit.tf', 'torch': 'default.qubit.torch', 'autograd': 'default.qubit.autograd', 'jax': 'default.qubit.jax'}}

Here’s my pennylane information

Name: PennyLane
Version: 0.23.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: c:\users\user\anaconda3\lib\site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-qiskit, PennyLane-SF

Platform info:           Windows-10-10.0.19041-SP0
Python version:          3.8.5
Numpy version:           1.20.2
Scipy version:           1.6.2
Installed devices:
- default.gaussian (PennyLane-0.23.1)
- default.mixed (PennyLane-0.23.1)
- default.qubit (PennyLane-0.23.1)
- default.qubit.autograd (PennyLane-0.23.1)
- default.qubit.jax (PennyLane-0.23.1)
- default.qubit.tf (PennyLane-0.23.1)
- default.qubit.torch (PennyLane-0.23.1)
- strawberryfields.fock (PennyLane-SF-0.20.1)
- strawberryfields.gaussian (PennyLane-SF-0.20.1)
- strawberryfields.gbs (PennyLane-SF-0.20.1)
- strawberryfields.remote (PennyLane-SF-0.20.1)
- strawberryfields.tf (PennyLane-SF-0.20.1)
- qiskit.aer (PennyLane-qiskit-0.24.0)
- qiskit.basicaer (PennyLane-qiskit-0.24.0)
- qiskit.ibmq (PennyLane-qiskit-0.24.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.24.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.24.0)
- lightning.qubit (PennyLane-Lightning-0.23.0)

Hi @maar_hybrid , thanks for checking in! :slight_smile:

You’re spot on, QNodeCollection was deprecated in PennyLane v0.31, just a month and a half ago. This might be a great time for you to upgrade to the latest version of PennyLane! :smiley:

In PennyLane v0.31 your device reports as 'supports_broadcasting' and parameter broadcasting should work as expected. :smiling_face:

Thank you! It works well after update pennylane

Awesome, really glad to hear that. Hope you enjoy playing with parameter broadcasting! :slight_smile: