node-red-quantum / node-red-contrib-quantum

Quantum computing functionality for Node-RED
https://node-red-quantum.github.io/
Apache License 2.0
16 stars 2 forks source link

Multi-controlled U gate is throwing error #118

Closed ttoktassynov closed 3 years ago

ttoktassynov commented 3 years ago

Bug Description

I couldn't test this node, since it throws an error.

Steps to Reproduce Bug

Build following flow and run the circuit: Screen Shot 2021-09-01 at 22 32 06

Expected Behaviour & Actual Behaviour

Expected behavior is that debug node will output the script representation of the circuit. But instead following error occurs:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ttoktassynov/projects/nodejs_projects/node-red-contrib-quantum/venv/lib/python3.9/site-packages/qiskit/circuit/quantumcircuit.py", line 1012, in append
    for (qarg, carg) in instruction.broadcast_arguments(expanded_qargs, expanded_cargs):
  File "/Users/ttoktassynov/projects/nodejs_projects/node-red-contrib-quantum/venv/lib/python3.9/site-packages/qiskit/circuit/gate.py", line 222, in broadcast_arguments
    raise CircuitError(
qiskit.circuit.exceptions.CircuitError: 'The amount of qubit(1)/clbit(0) arguments does not match the gate expectation (2).'

The JSON file for this flow is here:

[
    {
        "id": "cbfe3f06.4aa17",
        "type": "tab",
        "label": "circuit diagram",
        "disabled": false,
        "info": ""
    },
    {
        "id": "f6572ad9.28d438",
        "type": "quantum-circuit",
        "z": "cbfe3f06.4aa17",
        "name": "qc",
        "structure": "qubits",
        "qbitsreg": 2,
        "cbitsreg": 1,
        "outputs": 2,
        "x": 130,
        "y": 200,
        "wires": [
            [
                "f1bfa70.6057858"
            ],
            [
                "f1bfa70.6057858"
            ]
        ]
    },
    {
        "id": "8a5c83a2.f5afe",
        "type": "inject",
        "z": "cbfe3f06.4aa17",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 360,
        "wires": [
            [
                "f6572ad9.28d438"
            ]
        ]
    },
    {
        "id": "65ce88ba.f72b88",
        "type": "debug",
        "z": "cbfe3f06.4aa17",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 360,
        "wires": []
    },
    {
        "id": "f1bfa70.6057858",
        "type": "multi-controlled-u-gate",
        "z": "cbfe3f06.4aa17",
        "name": "",
        "outputs": 2,
        "nbControls": "1",
        "targetPosition": "0",
        "theta": 0,
        "phi": 0,
        "lambda": 0,
        "x": 390,
        "y": 120,
        "wires": [
            [
                "5e28a95a.483368"
            ],
            [
                "5e28a95a.483368"
            ]
        ]
    },
    {
        "id": "68bcee5f.d6c4a",
        "type": "script",
        "z": "cbfe3f06.4aa17",
        "name": "",
        "x": 610,
        "y": 240,
        "wires": [
            [
                "65ce88ba.f72b88"
            ]
        ]
    },
    {
        "id": "5e28a95a.483368",
        "type": "qubit",
        "z": "cbfe3f06.4aa17",
        "name": "",
        "x": 440,
        "y": 320,
        "wires": [
            [
                "68bcee5f.d6c4a"
            ]
        ]
    }
]

Additional Information

System Information

Theo-Reignier commented 3 years ago

I think this is due to an old bug where we were allowing the user to have 0 classical bits even though Qiskit raises an error when we do so.

Personally, the Multi control qubit gate works just fine with me.
Can you test it again on the latest version please?

ttoktassynov commented 3 years ago

Test it out. Works fine. Closing the issue.