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
1 vote
1 answer
32 views

Getting High cost function in code implementation of VQLS pennylane tutorial

I am currently trying to implement the tutorial in pennylane https://pennylane.ai/qml/demos/tutorial_vqls.html for very complex example in 3 Qubit and cost function is very high in spite of adding ...
Nithin Reddy Govindugari's user avatar
1 vote
1 answer
97 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
40 views

How to visualize the resulting state vector using CVNeuralNetLayers and Lightning qubit device

I'm trying to learn how to use PennyLane's CVNeuralNetLayers. I wrote this code below but I am not able to use the resulting state of the circuit generated by this layer. I looked for examples in the ...
Luccas Marim's user avatar
0 votes
0 answers
24 views

PennyLane: How to shift operations in pennylane like in cirq

Cirq allows us to not shift operations all the way to the left by writing the following programs ...
Pratyush's user avatar
1 vote
1 answer
105 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
2 votes
2 answers
111 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
  • 1,732
0 votes
2 answers
150 views

How to transform an Hamiltonian operator to a controlled gate (Hadamard test) in Pennylane?

I would like to perform an Hadamard test on a given Hamiltonian operator $\hat{H}$ acting on a 2-qubits system. For instance, suppose $\hat{H}$ can be decomposed into a ...
Constantin Economides's user avatar
1 vote
1 answer
26 views

How can one append a pre-defined quantum function (circuit) to another quantum function in Pennylane?

I want to use a pennylane quantum function that i created earlier somewhere else, again in a new function but have it applied to certain wires. The reason for this is, that I have a quantum circuit of ...
Constantin Economides's user avatar
1 vote
0 answers
32 views

Convert an integer to its basis state in Cirq

I am trying to implement Quantum Adder using QFT in Cirq. I previously did the same problem using Pennylane, in which I converted an integer into its Basis state using the BasisStatePreparation method ...
Jessica John Britto's user avatar
0 votes
0 answers
40 views

The loss function decreases, but the test accuracy is always 0.5

...
R-X Zhao's user avatar
  • 390
0 votes
0 answers
16 views

How do we know what angle formula X1 is encoded into qml.MottonenStatePreparation?

Known that X1 is a quantum state, it is prepared by qml.MottonenStatePreparation. How do we know what angle formula X1 is encoded into qml.MottonenStatePreparation? can be interpreted in python code. ...
R-X Zhao's user avatar
  • 390
1 vote
0 answers
42 views

Universality : Working with one qubit

I am working on the Pennylane's code camp problems and I'm stuck with the challenge 4. I am utterly clueless about this question, as in what is it asking from me, they provide us with a $2\times 2$ ...
Marco Puerto's user avatar
2 votes
1 answer
229 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
100 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,268
0 votes
0 answers
73 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 ...
R-X Zhao's user avatar
  • 390
0 votes
1 answer
239 views

Difference between qiskit SPSA optimize and minimize in runtime program

I use this tutorial with pennylane-qiskit.vqe_runtime_runner to familiarize myself with qiskit runtime using pennylane. Thereby, I wonder: What is the difference between qiskit.algorithms.optimizers....
qcabepsilon's user avatar
0 votes
0 answers
11 views

What is SqueezingEmbedding in Pennylane?

enter link description here This question comes mainly from the above link. Firstly, I don't know the reference for this coding method. Second, assuming there are N features, how many qubits are ...
R-X Zhao's user avatar
  • 390
2 votes
1 answer
250 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
0 votes
2 answers
261 views

Can I create a quantum circuit from a list of operations in pennylane?

Say, I have a list of operations which are pennylane gates, can I create a circuit from it? I tried: ...
qcabepsilon's user avatar
1 vote
1 answer
507 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
2 votes
0 answers
77 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 \...
Ananth_Rao's user avatar
1 vote
1 answer
170 views

qml.probs with another computational basis state

I am working with pennyLane library in Python and I have a circuit that involves several operations to 10 qubits. I want to measure the occupation probability of a target state. The function qml.probs(...
Borja Aizpurua's user avatar
0 votes
0 answers
70 views

How to understand Tensor observables and Combined measurements from the perspective of quantum mechanics?

This doubt comes from https://pennylane.readthedocs.io/en/stable/introduction/measurements.html pennylane mentioned two measurements, I can't tell the difference between the two. Such as $H=0.5Z+1Y$...
R-X Zhao's user avatar
  • 390
1 vote
1 answer
96 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
0 votes
0 answers
51 views

Performing QN-SPSA on hybrid quantum-classical neural networks

I had a question on the TorchConnector module in qiksit_machine_learning (based on this tutorial). If I'm not wrong, is ...
Ananth_Rao's user avatar
1 vote
2 answers
246 views

Gradient descent for a quantum-classical hybrid neural network

I am working on implementing a quantum-classical hybrid neural network in qiskit where input data is encoded on a quantum circuit (with say 3 qubits) using a ...
Ananth_Rao's user avatar
2 votes
2 answers
65 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
3 votes
1 answer
52 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
2 votes
1 answer
84 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? ...
Sarika Singh's user avatar
6 votes
1 answer
298 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
1 vote
1 answer
179 views

Implementing Noise in Pennylane (using qiskit.aer)

I want to implement noise in Pennylane using qiskit as a plug-in. I found this tutorial from Pennylane. But, when testing it the bit-flip error seems to have no effect at all. Here, I made some slight ...
qcabepsilon's user avatar
3 votes
1 answer
202 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
0 votes
1 answer
107 views

Using qml.AmplitudeEmbedding two times in a circuit raises an error

I'm trying to use qml.AmplitudeEmbedding() two times in a circuit but it raises an error saying that the device used does not support this feature.
Iheb CHAABANE's user avatar
3 votes
0 answers
86 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
2 votes
2 answers
113 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
4 votes
1 answer
327 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
3 votes
1 answer
168 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
2 votes
1 answer
62 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
  • 345
3 votes
1 answer
156 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
1 vote
1 answer
324 views

Binary classification using a very simple Neural Net with Qiskit and Pennylane

I implemented a simple Neural Net with Pennylane and Qiskit for classifying two half moons: notebook for two half moons (GitHub). It works somehow (not overwhelmingly by any means): I tried running ...
Eldar Sultanow's user avatar
1 vote
1 answer
310 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
3 votes
1 answer
96 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
  • 345
4 votes
1 answer
88 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
408 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
2 answers
536 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
5 votes
1 answer
346 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,268
4 votes
2 answers
756 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,268
10 votes
2 answers
423 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
170 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
3 votes
1 answer
222 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
  • 439