Skip to content

crz gate is incorrectly converted to RZZ #12

@clebrin

Description

@clebrin

Description

The crz gate is currently parsed and converted to an RZZ gate, which does not produce the same behaviour.

Proposed Fix

I can write a proper PR for that.

Remove crz from the supported gates entirely.

This requires three changes:

README.md, line 52 — Remove the crz row from the supported gates table:

| OpenQASM gate                                                    | Graphix instruction |
|------------------------------------------------------------------|---------------------|
| [ccx](https://openqasm.com/language/standard_library.html#ccx)   | CCX                 |
| [cx](https://openqasm.com/language/standard_library.html#cx)     | CNOT                |

parser.py, line 323 — Remove the crz branch from the gate parsing logic:

        instruction: Instruction
        if gate == "ccx":
            # https://openqasm.com/language/standard_library.html#ccx
            instruction = CCX(target=operands[2], controls=(operands[0], operands[1]))
        elif gate == "cx":
            # https://openqasm.com/language/standard_library.html#cx
            instruction = CNOT(target=operands[1], control=operands[0])

tests/test_parser.py, line 88 and 106 — Remove the crz instruction:

ccx q[0], q[1], q[2];
cx q[0], q[1];
    assert isinstance(instruction, CCX)
    assert instruction.target == 2
    assert instruction.controls == (0, 1)
    instruction = next(iterator)
    assert isinstance(instruction, CNOT)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions