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

import_open_qasm import S gate error #332

Closed
andrew-koren opened this issue Mar 12, 2024 · 2 comments
Closed

import_open_qasm import S gate error #332

andrew-koren opened this issue Mar 12, 2024 · 2 comments

Comments

@andrew-koren
Copy link

Describe the bug
Attempted to import multiple circuits from qasm, all circuits containing s gate failed to import.

TypeError: Phase() got multiple values for argument 'target'

The error message showed that this is due to part of parse_command() in qasm.py

if name in ("s", "t", "sdg", "tdg"):
        g = gates.Phase(pi / (2 if name.startswith("s") else 4),
                     control=None,
                     target=get_qregister(args[0], qregisters))
        if name.find("dg") != -1:
            g = g.dagger()
        return g

Changing this to

if name in ("s", "t", "sdg", "tdg"):
        g = gates.Phase(angle = pi / (2 if name.startswith("s") else 4),
                     control=None,
                     target=get_qregister(args[0], qregisters))
        if name.find("dg") != -1:
            g = g.dagger()
        return g

fixes the issue

To Reproduce
Steps to reproduce the behavior: Ideally an executable code snipped like

import tequila as tq

tq.import_open_qasm(
    '// Generated from Cirq v1.3.0\n\nOPENQASM 2.0;\ninclude "qelib1.inc";\n\n\n// Qubits: [q(0), q(1), q(2), q(3)]\nqreg q[4];\n\n\nu3(pi*1.5,pi*2.0,0) q[0];\n\n// Gate: CZ**-1.0\nu3(pi*0.5,0,pi*1.25) q[0];\nu3(pi*0.5,pi*1.0,pi*1.75) q[1];\nsx q[0];\ncx q[0],q[1];\nrx(0) q[0];\nry(pi*0.5) q[1];\ncx q[1],q[0];\nsxdg q[1];\ns q[1];\ncx q[0],q[1];\nu3(pi*0.5,pi*1.25,pi*1.0) q[0];\nu3(pi*0.5,pi*0.75,0) q[1];\n\nu3(pi*0.5,pi*1.0,pi*0.5) q[0];\nu3(pi*1.7198391408,pi*1.5,pi*0.5) q[2];\nu3(pi*1.5,pi*1.1295046702,pi*0.8704953298) q[3];\ncz q[2],q[3];\nu3(pi*1.5,0,0) q[2];\nu3(pi*1.5,pi*1.1295046702,pi*0.8704953298) q[3];\ncz q[2],q[3];\nu3(pi*0.6295046702,0,pi*0.5) q[2];\nu3(pi*0.7198391408,pi*0.5,pi*1.3704953298) q[3];\n'
)

Expected behavior
Should import s gate without error

Computer (please complete the following information):
tequila version: 1.9.4
python version: 3.10.13 (main, Feb 6 2024, 19:53:26) [GCC 9.4.0]
platform: #19~22.04.1-Ubuntu SMP Wed Jan 10 22:57:03 UTC 2024

@kottmanj
Copy link
Collaborator

Hi,

Thanks for the feedback. Since it appears that you have solved the issue already yourself, would you be interested in making a pull request to fix the issue? I usually prefer this, because the git log then credits you for solving.

kottmanj added a commit that referenced this issue Mar 18, 2024
Fixes issue #332
kottmanj added a commit that referenced this issue Mar 18, 2024
@kottmanj
Copy link
Collaborator

Should work now. Please let me know if not. Tanks for reporting!

kottmanj added a commit that referenced this issue Apr 5, 2024
* fixing syntax issue in post_init of dataclass (#327)
* phoenics support dropped
* more convenient randomization initialization for OO, avoiding numpy warnings
* Update qasm.py (#334)
Fixes issue #332
* added methods to create annihilation, creation, sz, sp, sm and s2 operators in qubit representation (#336)
* Update qasm.py (#335)
* Update ci_chemistry_psi4.yml (psi4 --> conda-forge channel)
* orbital names are better tracked through transformations (#338)
* keep basis info when re-initializing with mol.from_tequila
* orbital-optimization gives back molecule in the original basis
* more basis info (#339)
---------

Co-authored-by: davibinco <[email protected]>
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

No branches or pull requests

2 participants