Skip to content

Comments

QC: PennyLane#2

Draft
garncarz wants to merge 8 commits intomasterfrom
pennylane
Draft

QC: PennyLane#2
garncarz wants to merge 8 commits intomasterfrom
pennylane

Conversation

@garncarz
Copy link
Owner

A new attempt to use QC. This time hopefully even on a real (IBM?) device.

@garncarz garncarz self-assigned this Jun 18, 2025
@garncarz
Copy link
Owner Author

🤔 So far it doesn't work (using a default.qubit device). For formula $\displaystyle \left(x \vee \neg y\right) \wedge \left(y \vee \neg z\right) \wedge \left(x \vee y \vee z\right)$, it samples {'x': False, 'y': False, 'z': True} which doesn't satisfy it.

Copilot helped a lot, but I'm not sure if it's recommending a suitable
QC approach.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new approach to quantum circuit creation using PennyLane, aiming to run experiments on a real quantum device. The key changes include:

  • Insertion of a new markdown cell that documents the transition to a PennyLane-based approach.
  • Addition of multiple code cells to build and execute a quantum circuit based on a Boolean formula, including clause conversion and QAOA circuit construction.
  • Integration of simulation devices for analytic and sampling evaluations of the cost Hamiltonian.
Comments suppressed due to low confidence (2)

quantum_computing.ipynb:905

  • Consider adding an inline comment to explain the expected structure of 'params', ensuring future readers understand that each layer in the QAOA circuit expects a pair of parameters (gamma and beta).
    "            gamma, beta = params[layer]\n",

quantum_computing.ipynb:906

  • It would be helpful to document why '1' is used as the number of time steps in ApproxTimeEvolution, clarifying its intended role in the QAOA circuit.
    "            qml.templates.ApproxTimeEvolution(cost_h, gamma, 1)\n",

" projector = (qml.Identity(idx) - sign * qml.PauliZ(idx)) / 2\n",
" projectors.append(projector)\n",
" if projectors:\n",
" term = reduce(lambda a, b: a @ b, projectors)\n",
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a brief comment to explain the use of the '@' operator for combining projectors may improve readability and aid maintainability.

Copilot uses AI. Check for mistakes.
@garncarz
Copy link
Owner Author

💡 Solution for statement = (x | y | z) & (x | ~y | ~z) can be found quite quickly, but it cannot solve statement = (x | y | z) & (y).

@garncarz garncarz marked this pull request as draft June 19, 2025 11:04
garncarz added 2 commits June 19, 2025 14:55
Unsuccessful, cannot create a Session having a free account.
@garncarz
Copy link
Owner Author

PennyLane-Qiskit plugin creates a session even for the most simple circuits, like this taken from docs:

dev_real_test = qml.device('qiskit.remote', wires=5, backend=backend, shots=10)

@qml.qnode(dev_real_test)
def circuit_real_test(x, y, z):
    qml.RZ(z, wires=[0])
    qml.RY(y, wires=[0])
    qml.RX(x, wires=[0])
    qml.CNOT(wires=[0, 1])
    return qml.expval(qml.PauliZ(wires=1))

circuit_real_test(0.2, 0.1, 0.3)

But IBM doesn't allow free accounts to use sessions. It seems it's been already fixed in PennyLaneAI/pennylane-qiskit#632, but it's still not released and the actual master branch produces (probably an unrelated) error ModuleNotFoundError: No module named 'pennylane.exceptions', so I guess I'll need to wait for a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant