Skip to main content
The 2024 Developer Survey results are live! See the results
8 votes
Accepted

Computing expectation value of product of observables in PennyLane

PennyLane supports measurements of tensor products of observable via the @ operator, like so: ...
Josh Izaac's user avatar
7 votes

Pennylane and Qiskit for quantum machine learning

Have a look at these for quantum machine learning: Supervised learning with quantum computers by Schuld and Petruccione (2018) An introduction to quantum machine learning by the same authors of the ...
develarist's user avatar
6 votes

What are the differences between the IBM machines?

Besides number of qubits, the devices can have other differences as well. The architecture of the device can be different, meaning that each device could have different connectivity maps. This would ...
Matthew Stypulkoski's user avatar
5 votes
Accepted

PennyLane operations - Kerr, Displacement and Squeeze

Short, sort-of right answer: you can't This is in essence due to the superconducting qubits that e.g. IBM use being, well, qubits, while continuous variable (CV) operations don't act on qubits. Well, ...
Mithrandir24601's user avatar
  • 3,716
5 votes

What are the differences between the IBM machines?

First of all, the name of backends (devices) have nothing to do with their location! They are all located in US. Back to your question, as others already mentioned the difference is in the ...
26118in's user avatar
  • 508
5 votes

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

You are asking numpy to initialize an array with dimension greater than $2^{896} \approx 5 \times 10^{269}$. For reference, it is thought that there are maybe $10^{82}$ or so atoms in the observable ...
forky40's user avatar
  • 7,213
4 votes
Accepted

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

Here's a simple example if you're looking for a quick hack: ...
ryanhill1's user avatar
  • 2,513
4 votes
Accepted

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$?

Maybe it is best to just work out the calculation step-by-step. First, let $U = R_y(\phi_2) R_x(\phi_1) $, and $|\psi \rangle = U|0\rangle$. The goal is to calculate $ \langle \psi| \sigma_z |\psi \...
KAJ226's user avatar
  • 13.9k
4 votes

Computing expectation value of product of observables in PennyLane

I think the following should work: ...
KAJ226's user avatar
  • 13.9k
3 votes
Accepted

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

I received a great answer to my question here, through the Xanadu Discussion Forum: I’d say that your approach of having a quantum function that depends on the number of wires, creating separate ...
ryanhill1's user avatar
  • 2,513
3 votes

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

Note that we are not interested in differentiating the gate $U(\theta)$, but some expectation-value-based function $E(\theta)$, which "contains the gate twice", if you will: $$E(\theta)=\...
David Wierichs's user avatar
3 votes
Accepted

Is pennylane free?

Yes, Pennylane is "free". It is open-source software developed under the Apache 2.0 License. Creating circuits and running local simulations in Pennylane does not require an account. However,...
ryanhill1's user avatar
  • 2,513
3 votes
Accepted

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

It is the latter. One usually doesn't spell it out, but it should be understood that $Z$ acting on a single qubit means that it has to be padded by identities acting on the other qubits. Often one ...
Johannes Jakob Meyer's user avatar
3 votes

Pennylane and Qiskit for quantum machine learning

Since quantum machine learning with NISQ hardware is such a relatively new field, it is still very highly research driven, and a lot of the potential is still being determined. To make these new ...
Josh Izaac's user avatar
3 votes
Accepted

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

Your expressions for $\langle X_0X_1 \rangle$ and $\langle Y_0Y_1 \rangle$ are correct under the assumption that the two qubits are independently random. In the case that they are correlated, these ...
James Wootton's user avatar
3 votes

What are the differences between the IBM machines?

The inherent uncertainty of QM is managed by making sure you're taking enough shots relative to the error bounds and probability of success for a given algorithm. If you don't have exact equations, ...
Jonathan Trousdale's user avatar
3 votes
Accepted

How can I write unit tests for a pennylane circuit?

Simulator devices, like 'lightning.qubit' or 'default.qubit', can usually be run analytically. This is the default for most ...
albiero's user avatar
  • 46
3 votes
Accepted

Differentiable Programming of Quantum Computers

Yes, it is possible to do this with Qiskit and Cirq. For Qiskit, you can read up this tutorial page here. There was an answer by Josh Izaac from Pennylane here awhile back about parameter shift rule ...
KAJ226's user avatar
  • 13.9k
3 votes

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

Since the operations were already instantiated in list outside of the circuit context, you will have to use qml.apply(operations[0]) and ...
co9olguy's user avatar
  • 201
3 votes

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

What an interesting observation 😄 I work on the PennyLane team so hopefully I can help you. While indeed, the demo does use RZ in the MBQC part, it is not a gate that mandatorily needs to be added in ...
Guillermo Alonso's user avatar
3 votes

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

Good question - let me give it a shot. First of all, note that the application of a single-qubit gate before a measurement in the computational basis is mathematically the same as doing a projective ...
Buskruid's user avatar
3 votes

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

As the error suggests, you cannot use QubitStateVector twice in the same QNode. Take, for instance, this simpler example that reproduces your error. Here, I want to ...
isaac's user avatar
  • 171
3 votes
Accepted

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

Because single qubit observables on different wires commute, this is possible to compute in a single hardware execution. Internally, PennyLane uses the current approach to compute expectations on ...
Josh Izaac's user avatar
3 votes
Accepted

Problems trying to plot the classical Fisher information with Pennylane

There seems to be a bug in classical_fisher in combination with np.linalg.norm. I opened an issue here, should be resolved soon (...
Korbinian's user avatar
  • 145
3 votes

What is the meaning of @ and & in PennyLane?

The @ operator is syntactic sugar for the __matmul__ function in python. In the context you’re referring to, this operator has ...
diemilio's user avatar
  • 867
2 votes

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

In this tutorial in PennyLane, they guide you to create a custom gate (Rxx gate) https://pennylane.ai/blog/2021/05/how-to-add-custom-gates-and-templates-to-pennylane/ After creating it you can simply ...
BẢO BẠCH GIA's user avatar
2 votes
Accepted

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

This is a current restriction with PennyLane, in that only a single, initial state preparation routine can be used. However, you can use the ...
Josh Izaac's user avatar
2 votes

VQE from scratch, what have I got wrong?

Having tested your code locally, I actually don't believe there are any errors. But, there are a few reasons that you are not getting the exact expectation value. The first is just that the device is ...
glassnotes's user avatar
2 votes

Is this Quantum Neural Network overfitting?

First, it is useful to realize that your question is about statistical learning and not quantum computing. Your question better fits the Cross Validated stack. But since your code contains a tiny bit ...
MonteNero's user avatar
  • 2,908
2 votes
Accepted

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

PennyLane uses queuing under the hood so the issue in your code is that the operations have been instantiated outside of the circuit but haven't been applied to the circuit. You can fix this by simply ...
Catalina's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible