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

PyZX Interop: Converting bloqs to pyzx circuits #1550

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

anurudhp
Copy link
Contributor

First step towards #1517

  • Implements bloq_to_pyzx_circuit to generate a pyzx Circuit, which can then be converted to a pyzx graph using .to_graph().
  • Add annotations for a few leaf bloqs (ZGate, XGate, _ZVector)
  • Verify conversion by checking the tensors.

@anurudhp
Copy link
Contributor Author

@tanujkhattar ptal

Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks reasonable -- some comments

@@ -551,3 +554,8 @@ def wire_symbol(

def __str__(self):
return self.__class__.__name__

def as_zx_gates(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this need a big docstring (as all top level bloq methods)

"""A mapping from register names to an NDArray of ZX qubits"""


@define
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be frozen? if yes: make it so; if no, use attrs.mutable and explain why in docstring

Comment on lines +107 to +108
except NotImplementedError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so we fall back to the decomposition-based approach? Maybe some line comments could help guide the reader to the order of strategies

except NotImplementedError:
pass

cbloq = bloq.decompose_bloq()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider supporting the case where bloq is a composite bloq

placeholder = Soquet(None, Register('simulation_placeholder', QBit())) # type: ignore
Connection(cxn.left, placeholder)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

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

Successfully merging this pull request may close these issues.

2 participants