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

Reduce dependence on GateWithRegisters #960

Open
mpharrigan opened this issue May 16, 2024 · 2 comments
Open

Reduce dependence on GateWithRegisters #960

mpharrigan opened this issue May 16, 2024 · 2 comments
Milestone

Comments

@mpharrigan
Copy link
Collaborator

This class implements both the Bloq interface as well as the cirq.Gate interface (simultaneously). The factored way of doing this is to implement the Bloq interface and use the to-cirq functionality (including Bloq.on()) to explicitly access the cirq.Gate interface.

In theory, most places where algorithms descend from GateWithRegisters, it can be migrated to just Bloq as the superclass with minimal changes. These changes include:

  • if the gate overrides decompose_from_registers (i.e. cirq-style decomposition), you must add an explicit override
    def decompose_bloq(self) -> 'CompositeBloq':
        return decompose_from_cirq_style_method(self)
  • If the gate overrides circuit_diagram_info, you can use qualtran.cirq_interop._cirq_to_bloq._wire_symbol_from_gate or just implement the wire_symbol method (preferred)
@mpharrigan
Copy link
Collaborator Author

The name GateWithRegisters is somewhat unhelpful. History: I picked this name when it was literally just a cirq gate with names for the registers :) . A better name would indicate its true role as a cirq.gate/qualtran.bloq hybrid. But separating these concerns is the better medium+ term solution.

@mpharrigan
Copy link
Collaborator Author

This issue can be used to track places where porting GateWithRegisters to Bloq is non-trivial.

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

1 participant