-
Notifications
You must be signed in to change notification settings - Fork 50
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
Move Cirq-FT infrastructure to Qualtran #393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you comment on lingering compatibility issues? It looks like Signature
is almost the same but not quite
qualtran/_infra/registers.py
Outdated
@@ -19,7 +19,7 @@ | |||
from typing import Dict, Iterable, Iterator, List, overload, Tuple, TYPE_CHECKING | |||
|
|||
import numpy as np | |||
from attr import frozen | |||
from attr import field, frozen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this has already snuck through, but try to change these to attrs
when you see one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
@@ -74,7 +74,7 @@ def test_swap_with_zero_gate(selection_bitsize, target_bitsize, n_target_registe | |||
def test_swap_with_zero_gate_diagram(): | |||
gate = SwapWithZeroGate(3, 2, 4) | |||
q = cirq.LineQubit.range(cirq.num_qubits(gate)) | |||
circuit = cirq.Circuit(gate.on_registers(**cirq_ft.infra.split_qubits(gate.signature, q))) | |||
circuit = cirq.Circuit(gate.on_registers(**split_qubits(gate.signature, q))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your intentions with this module (as well as swap_network.py
). These are sortof half-hearted attempts at providing a bloq user-api from cirq gates from some time ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these would be removed and replaced with swap_network.py
from Cirq-FT which already derives from GateWithRegisters
and thus would be a Bloq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you going to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
_FREDKIN_GATESET = cirq.Gateset(cirq.FREDKIN, unroll_circuit_op=False) | ||
|
||
|
||
def _fredkin(qubits: Sequence[cirq.Qid], context: cirq.DecompositionContext) -> cirq.OP_TREE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder that per our agreement if this code still exists like 1 month from now I will unceremoniously remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to keep this code either. The project that takes care of supporting different decompositions when counting resources should remove this code as a first proof of concept. Whoever removes this code should make sure the T-counts of higher level primitives remain the same, and then I'm happy.
Cirq-FT signature is lacking a few accessor methods (like |
@mpharrigan I've addressed all your comments. This is ready for another look. |
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweeeeeeeeet
This PR is the first big PR that moves code from Cirq-FT to Qualtran as part of Qualtran & Cirq-FT Integration
Some key features:
GateWithRegisters
now exists inQualtran
and is both acirq.Gate
and aBloq
.And
andMultiAnd
bloq's inQualtran
now derive from theGateWithRegisters
class. They pass all existing tests and are used in cirq-ft style tests as well.CirqGateAsBloq
andBloqAsCirqGate
don't depend uponcirq_ft
at the top-level anymore. There still exists some temporary glue code that needs to support bothcirq_ft.GateWithRegisters
andqualtran.GateWithRegisters
as part of the transition period, but that'll be gone once the migration is completed.TComplexity
,decompose_protocol
etc. also make their way into qualtran as part of thecirq_interop
repository. In follow-up PRs, we can rearrange this code (for example: move all or parts ofTComplexity
toresource_counting/
instead ofcirq_interop
).cc @fdmalone @mpharrigan