Questions tagged [pennylane]

PennyLane is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.

Filter by
Sorted by
Tagged with
10 votes
2 answers
493 views

What are the benefits of using quantum machine learning?

I have been investigating uses for quantum machine learning, and have made a few working examples (variations of variational quantum classifiers using PennyLane). However, my issue now is its ...
Andrew's user avatar
  • 323
8 votes
3 answers
192 views

What are the differences between the IBM machines?

I'm quite new to this field, and have started sending jobs to IBM's quantum computers. I have access to around 11 locations. I can see that these have different numbers of qubits within them, and then ...
Andrew's user avatar
  • 323
7 votes
3 answers
3k views

Pennylane and Qiskit for quantum machine learning

I'm interested in quantum computing, specifically in “quantum machine learning” (QML). I'm going to start my masters program in computer science and have previous experience in classical machine ...
Carlos Alfredo Vergara Rojas's user avatar
6 votes
1 answer
487 views

How linear combination of unitaries gradient work (Qiskit, PennyLane)?

I'm trying to implement linear combination of unitaries(LCU) gradient from Qiskit Gradient Framework but on PennyLane. First, i looked through the source code in Qiskit. In Qiskit LCU gradient if we ...
Natchapol Patamawisut's user avatar
5 votes
1 answer
641 views

Pennylane: creating QNodes for large numbers of circuits that only differ by number of wires

Take the following simple quantum function: ...
ryanhill1's user avatar
  • 2,503
4 votes
2 answers
1k views

Computing expectation value of product of observables in PennyLane

In PennyLane, the following circuit returns the expectation value of the PauliZ observable on qubit (wire) 1: ...
ryanhill1's user avatar
  • 2,503
4 votes
2 answers
787 views

How to create the equivalent of the Qiskit rxx gate in Pennylane?

How can I create the Pennylane equivalent of: from qiskit import QuantumCircuit circ = QuantumCircuit(2, 2) circ.rxx(theta=0.3, qubit1=0, qubit2=1)
Faiyaz Hasan's user avatar
4 votes
1 answer
113 views

How can I write unit tests for a pennylane circuit?

I have several mixing unitary circuits written using Pennylane to be used in the QAOA algorithm. Furthermore, I'd like to write unit tests for these mixing circuits to ensure that the code is doing ...
Faiyaz Hasan's user avatar
4 votes
1 answer
460 views

Differentiable Programming of Quantum Computers

Recently, I have tried PennyLane and TensorFlow Quantum. These platforms are said to provide differentiable programming of quantum computers but I can't understand it clearly though. I have searched ...
BẢO BẠCH GIA's user avatar
4 votes
1 answer
532 views

Implementation of Unitary in Shor's Algorithm in PennyLane

I've been working on implementing Shor's Algorithm in PennyLane, but am struggling to understand how the circuit for 'U' has been constructed according to Qiskit. In the Qiskit textbook, they seek to ...
Ella Ceroni's user avatar
4 votes
0 answers
97 views

What is the most efficient method to update the binary encoded values inside a quantum state?

We're implementing a QML algorithm in which we have to update the value stored inside a quantum state which is strictly unknown to us, by multiplying it with a real number classically stored with us. ...
Rohan Bhatia's user avatar
3 votes
1 answer
284 views

PennyLane operations - Kerr, Displacement and Squeeze

I am familiar with the quantum gates of Qiskit, but I become very confused when looking at the continuous variable (CV) operations in the PennyLane documentation. I am especially interested in the ...
QCQCQC's user avatar
  • 449
3 votes
1 answer
110 views

Why is $\langle \psi| \sigma_z |\psi \rangle=\cos(\phi_1)\cos(\phi_2)$ for $|\psi\rangle=R_y(\phi_2)R_x(\phi_1)|0\rangle$?

I'm trying some example with the rotation gates and stuck here: $$\langle \psi| \sigma_z |\psi \rangle = \langle 0 | R_x(\phi_1)^\dagger R_y(\phi_2)^\dagger \sigma_z R_y(\phi_2) R_x(\phi_1) | 0 \...
Monad's user avatar
  • 375
3 votes
1 answer
72 views

Why does the parameter circuit include both the positive and negative shift terms?

In the derivation of the parameter shift rules in the original paper, the Hermitian generator $G$ of any unitary $U(\theta)=\exp[-i\theta G]$ satisfies $$ U(\pm\frac{\pi}{4r})=\frac{1}{\sqrt{2}}(I\mp\...
blackfyre's user avatar
3 votes
1 answer
939 views

Expected value of a product of the Pauli matrices in different bases

I'm trying to reproduce the results of this article https://arxiv.org/abs/1801.03897, using Qiskit and Xanadu PennyLane. Particularly, this part with expected values of the Pauli operators: For ...
C-Roux's user avatar
  • 888
3 votes
1 answer
238 views

VQE from scratch, what have I got wrong?

I've been working on a code to run VQE with a grouped measurement. For some reason, my expectation values are slightly off from those computed by pennylane, the software I decided to use for this ...
Cuhrazatee's user avatar
3 votes
1 answer
320 views

How to convert Pennylane decompose_hamiltonian to Cirq PauliString?

I have a matrix that I would like to decompose into a Pauli String. Pennylane's qml.utils.decompose_hamiltonian does this and returns a list of coefficients and a list of operations representing the ...
Ruby's user avatar
  • 31
3 votes
1 answer
247 views

Quantum Phase Estimation - Should be getting exact answer

Having read the Qiskit demonstration in the Qiskit textbook on how to implement Quantum Phase Estimation, I tried to do so on PennyLane's framework. My code pretty well follows what was done in Qiskit,...
Ella Ceroni's user avatar
3 votes
1 answer
441 views

QUBO defined in Qiskit/DOcplex: how to solve it using Pennylane?

I have a complex Integer Linear Programming model defined in DOcplex/Qiskit representing a combinatorial optimization problem. Using the Qiskit utils, it is possible to covert it to either an Ising ...
Nepomuk Hirsch's user avatar
2 votes
2 answers
142 views

pennylane: How to carry out MB rotation without CB rotation?

I'm looking at this MBQC tutorial where there's an example that shows that a MB and CB single qubit rotations give the same result. CB version : ...
unknown's user avatar
  • 2,148
2 votes
1 answer
127 views

Problems trying to plot the classical Fisher information with Pennylane

I'm working with pennylane. My goal is to plot CFI(Classical Fisher Information)with following quantum state. With the above equation I set gamma as 0. Then It becomes: If gamma is not equal to zero,...
Donguk kim's user avatar
2 votes
1 answer
119 views

Is pennylane free?

I was going through the basics of pennylane. I am able to understand that it is used for quantum neural networks. I am not sure whether it is using paid cloud computer or simulator of xandu or ibmq? ...
Manu's user avatar
  • 483
2 votes
1 answer
76 views

What is the $K_i$ in Fubini-Study tensor?

Following this paper and tutorial from Pennylane, I'm trying to re-calculate the Fubini-Study tensor: $$ g_{i j}^{(\ell)}=\left\langle\psi_{\ell-1}\left|K_{i} K_{j}\right| \psi_{\ell-1}\right\rangle-\...
Monad's user avatar
  • 375
2 votes
1 answer
71 views

Optimizing a parametrized Quantum Circuit in batches does not decrease the cost function while unbatched optimization does

I want to optimize a variational quantum circuit to maximize the Hilbert-Schmidt Distance between the different classes of the UCI breast cancer data set. When I choose to use batched optimization, ...
jo87casi's user avatar
  • 141
2 votes
1 answer
730 views

Pennylane: take qml.state of one function and use it as the initialization for another

In Pennylane, I created a function to set the initial parameters of my qubit, and then called qml.state() to return the output. I now want to feed this initialization into another circuit, but I'm not ...
TuktukTaxi's user avatar
2 votes
1 answer
516 views

How can I see the circuit that was actually executed on the device in pennylane?

I do a VQE using the pennylane UCCSD ansatz for execution on the 'default.qubit' device and am interested in the actual circuit that is executed on the device (ideally without making changes in any ...
qcabepsilon's user avatar
2 votes
2 answers
109 views

Why does VQE with pennylane and scikit-optimize gp_minimize give 'func must be scalar' error?

I am trying to replace the SPSA optimizer in the VQE tutorial of pennylane by the bayesian optimizer of scikit-opimize. When running the code below I get the error "func should return a scalar&...
qcabepsilon's user avatar
2 votes
1 answer
410 views

How can Mid-Circuit Measurements be performed in pennylane

I am trying to understand how to do mid circuit measurements in pennylane. As an example here is a simple preperation of a bell state: ...
Constantin Economides's user avatar
2 votes
1 answer
167 views

Comparative analysis of TensorFlow-Quantum, Pennylane, and Qiskit, to implement quantum CNNs

I am currently working on a project wherein I have to implement a Quantum Convolutional Neural Network. The best options for NISQ devices are hybrid algorithms, so I will try integrating quantum ...
Chan's user avatar
  • 131
2 votes
2 answers
172 views

Platform for mixed-state quantum machine learning?

I have been using PennyLane to run numerical QML simulations but it now seems to only support backprop on pure state simulations. Does anyone familiar with other packages know if there exists one that ...
quantumrock's user avatar
2 votes
0 answers
32 views

IBMBackendValueError: number of circuits exceeds the maximum for this backend, 300

I am trying to run the QAOA on the IBMQ device. The QAOA circuit consists of 6 qubits, two layers. The number of total trainable parameters for the QAOA circuit is 14. The toy code is as follows: <...
Yang Qian's user avatar
2 votes
0 answers
31 views

Value error in variational quantum circuits

I am working on a project to find a unitary gate that arrives at a specific density matrix at the end. The circuit construct is shown below: ...
JiQing's user avatar
  • 35
2 votes
0 answers
25 views

Quantum Convolutional Neural Network not producing gradients

I am trying to bulid a quantum convolutional neural network for image classification with Pennylane and Keras but the model isn't training and I keep getting the warning: WARNING:tensorflow:Gradients ...
Umm's user avatar
  • 21
2 votes
0 answers
97 views

Plotting Fisher Information using PennyLane

I made 2-qubit based circuit with post-selection method. Post-selection method is, Let $$ K = \begin{bmatrix} \sqrt{1-\gamma} & 0 \\ 0 & 1 \end{bmatrix}\,. $$ Then, $$ \rho_{\text{post-...
Donguk kim's user avatar
2 votes
0 answers
206 views

SLSQP optimizer(scipy.minimize) doesn't update parameters

I'm trying to find optimal parameters that minimize the cost functions. In cost function, it calculates the classical-fisher-information at a certain point(phi[0] = np.pi). Cost-function takes 3-...
Donguk kim's user avatar
2 votes
0 answers
90 views

Post-selection on pennylane

I want to do something like this: For a single-qubit Apply Hadamard -> Time_evolution -> Phase_damping -> Hadamard -> Post-selection -> Get CFI(classical fisher info) Density matrix ...
Donguk kim's user avatar
2 votes
1 answer
161 views

Computing gradients in parallel with cost from probs (Pennylane-Braket)

Do circuits that measure probabilities instead of expectation values benefit from parallel execution? The Computing gradients in parallel with Amazon Braket tutorial shows how the multiple device ...
ryanhill1's user avatar
  • 2,503
2 votes
0 answers
133 views

Simulating density matrices in quantum simulators

I would like to load random quantum states sampled from a given density matrix based on its classical probabilities ie based on the definition of the given density matrix: $\rho = \sum_i p_i |\psi _i \...
quics-ilver's user avatar
1 vote
1 answer
744 views

How to create a quantum circuit with 800+ features using PennyLane

I am new to Quantum ML, and I am currently using PennyLane to do the QML activity. As per this article, total number of features is equal to the total number of qubits. (In the example, they have ...
Shikhar's user avatar
  • 11
1 vote
1 answer
275 views

How does Pennylane compute expected values of single-qubit operators over real hardware?

Imagine I have a quantum circuit of n qubits and I want to measure the expected value of a single-qubit operator (let's say PauliZ) for each qubit. This is easily done in Pennylane with the following ...
Paul's user avatar
  • 70
1 vote
1 answer
303 views

pennylane:fidelity calculation after swap test between entagled states. Swap test issue

What I am trying to do is first take an image and encode it into quantum states, for this I have taken an image from the MNIST dataset and then reshaped it to (4,4) and now I wrote the following ...
Pratyush's user avatar
1 vote
1 answer
49 views

Pennylane and Qutrit quantum circuit matrix representation bug

I want to find the operator that describes this qutrit quantum circuit. Where a TSub, some TRZ rotations and a TAdd are applied to 2 quitrits. I am using Pennylane 0.34.0. This is the code: ...
Daniele Trisciani's user avatar
1 vote
1 answer
68 views

Pennylane variational classifier demo - need for padding

In the variational classifier demo from Pennylane, the data loading is performed with ...
Sarvapriya Tripathi's user avatar
1 vote
1 answer
83 views

Implementing swap test on quantum register

I'm interested in implementing a controlled-swap operation on quantum registers. However, it appears that Qiskit's documentation primarily focuses on single qubits rather than registers. Could you ...
Yuval Idan's user avatar
1 vote
1 answer
214 views

Pennylane: Pennylane can not train the parameters of the problem

I asked this question in the Pennylane forum, but there was no reply for a long time, the link is: https://discuss.pennylane.ai/t/why-does-the-embedding-metric-learning-case-not-work/2211?u=rx1 The ...
Ren-Xin Zhao's user avatar
1 vote
1 answer
140 views

Is this Quantum Neural Network overfitting?

In the accuracy graphs (attached the graph images below) shown in this code (Binary Classification for Fraud Detection): validation loss is greater than training loss training accuracy is greater ...
kanha's user avatar
  • 11
1 vote
1 answer
116 views

Is there any library to create a uniformly random unitary matrix?

Is there any library to create a random special unitary $SU(N)$ that generates from Haar distribution? I understand in PennyLane there is qml.SpecialUnitary ...
Sudhir Kumar's user avatar
1 vote
1 answer
106 views

How to save a hybrid Tensorflow and Pennylane model?

I implemented a hybrid model with Keras and Pennylane that looks like this: The quantum layer is basically a quantum circuit converted to a keras layer with the ...
Ryan Wang's user avatar
  • 247
1 vote
1 answer
196 views

Create qnode with density matrix on pennylane

I'm using pennylane. What I want to do is Create a qnode with the 2*2 density matrix of a single qubit one. It has the parameter as phi Given density matrix: $$\...
Donguk kim's user avatar
1 vote
1 answer
65 views

Qubits are drawn multiple times in circuit using pennylane

When I draw my circuits some qubits are drawn multiple times (see 'circuit 1'). Does this mean that 1) the circuit itself is the same as 'circuit 2' below or 2) do I have some bug in my code that ...
qcabepsilon's user avatar