question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameters in MultiControlledX

See original GitHub issue

As I was inspecting the MultiControlledX gate, I noticed how it printed out:

MultiControlledX(array([[0, 1],
       [1, 0]]), wires=[0, 1, 2, 3])

And was quite confused as to where the array came from. It turns out MultiControlledX inherits from ControlledQubitUnitary with the Unitary matrix as an X gate. This makes MultiControlledX a parametrized gate.

Worse yet, that gate is trainable:

>>> with qml.tape.JacobianTape() as tape:
...    qml.MultiControlledX(control_wires=(0,1,2), wires=(3))
>>> tape.trainable_params
{0}

This further indicates to me that how we treat never trainable parameters needs fixing in the long run.

In the short term, we should just remove the inheritance on ControlledQubitUnitary.

This would involve duplicating only relevant code in ControlledQubitUnitary and changing the inheritance to Operation.


List of tasks for completion:

  1. Change the MultiControlledX operation such that it doesn’t inherit from ControlledQubitUnitary anymore;
  2. Include logic in MultiControlledX that is required for its full functionality;
  3. Adjust any tests as required.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
tgag17commented, Aug 18, 2021

Thank you @antalszava! I will try to tackle the issue and get back if I face any issue.

1reaction
albi3rocommented, Jul 12, 2021

Thanks @tgag17 ! 👍

I assigned you the issue. Feel free to ask any additional questions here or when you open a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

qml.MultiControlledX — PennyLane 0.27.0 documentation
Parameters. control_wires (Union[Wires, Sequence[int], or int]) – Deprecated way to indicate the control wires. Now users should use “wires” to indicate ...
Read more >
Use a single wires keyword in MultiControlledX #1679 - GitHub
Currently, the operation MultiControlledX accepts an arbitrary length of wires for control_wires keyword and a single wire for the wires ...
Read more >
qiskit.circuit.library.MCXRecursive
Using a single ancilla qubit, the multi-controlled X gate is recursively ... Gate parameters should be int, float, or ParameterExpression ...
Read more >
Toffoli simulator - Azure Quantum | Microsoft Learn
... CNOT , and multi-controlled X quantum operations. ... (or -s shortcut) parameter to specify the Toffoli simulator target machine.
Read more >
The Uniform Rotation — Data Cybernetics qiskit-algorithms 0.0.13 ...
Apply the dagger (inverse) a multi-controlled X gate depending on conditional binary representation. Parameters. self ( QuantumCircuit ) – either a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found