Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not hardcode symbol transformation #905

Open
jcjaskula-aws opened this issue Mar 6, 2024 · 0 comments
Open

Do not hardcode symbol transformation #905

jcjaskula-aws opened this issue Mar 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jcjaskula-aws
Copy link
Contributor

jcjaskula-aws commented Mar 6, 2024

Describe the bug
In the unicode diagram builder, control modifiers and swap gate symbols are transformed via a hardcoded piece of code like here. It would be better to avoid transforming symbols into other new symbols.

Random thoughts

  • (Neg)Control modifiers are implemented in two ways which does not help to design a solution without hardcoded the mapping. These two ways are:
    • multiple target qubits and including "C" in ascii_symbols
    • adding qubits in control
      For some gates (like CNot), the first qubit of the control register is transferred to the target register: CNot(target=0, control=1) -> CNot(target=[0,1]) as the CNot is a 2-qubit gate. For these gates, nothing indicates that they are essentially controlled gates, which means that one can only figure it out by searching the character "C" in ascii_symbols. This is currently done at the very end of the current implementation.
      On the other side, any gate can be controlled by the state of other qubits. These qubits are tracked in a control_qubits set, which is inspected earlier to define the scope of the gate (i.e [min(full_qubit_register):max(full_qubit_register)] to build the connection map.

Ideas for a solution

  • Long-term: redefine the gate interface such that for instance CNot is Ctrl @ X and consequently CNot.ascii_symbols = ["X"]. This would limit the way to define control qubits to a single possibility.
  • Shorter-term: Using a GateSymbol representation class with inheritance for the specific cases like NoGate (untouched qubits between min(full_qubit_register) and max(full_qubit_register)), Swap gate and control modifier. Here is an unfinished attempt. These classes can be specific to AsciiDiagramBuilder and UnicodeDiagramBuilder. This would be a way to associate (qubit, symbol, connections) for each moment but still requires to browse through the ascii_symbol table to search for control modifiers.
@jcjaskula-aws jcjaskula-aws added the bug Something isn't working label Mar 6, 2024
@jcjaskula-aws jcjaskula-aws self-assigned this Mar 6, 2024
@jcjaskula-aws jcjaskula-aws removed the bug Something isn't working label Mar 6, 2024
@jcjaskula-aws jcjaskula-aws removed their assignment Mar 28, 2024
@jacofeld jacofeld added the enhancement New feature or request label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants