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

cirq-style t_complexity protocol doesn't work with latest version of cirq #665

Closed
mpharrigan opened this issue Feb 14, 2024 · 1 comment · Fixed by quantumlib/Cirq#6467
Closed
Assignees

Comments

@mpharrigan
Copy link
Collaborator

example traceback:

``` _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ qualtran/cirq_interop/t_complexity_protocol.py:182: in t_complexity ret = _t_complexity_for_gate_or_op(stc, fail_quietly) ../py310-cf/lib/python3.10/site-packages/cachetools/__init__.py:675: in wrapper v = func(*args, **kwargs) qualtran/cirq_interop/t_complexity_protocol.py:155: in _t_complexity_for_gate_or_op return _t_complexity_from_strategies(gate_or_op, fail_quietly, strategies) qualtran/cirq_interop/t_complexity_protocol.py:144: in _t_complexity_from_strategies ret = strategy(stc, fail_quietly) qualtran/cirq_interop/t_complexity_protocol.py:84: in _is_clifford_or_t if cirq.has_stabilizer_effect(stc): ../cirq/cirq-core/cirq/protocols/has_stabilizer_effect_protocol.py:45: in has_stabilizer_effect result = strat(val) ../cirq/cirq-core/cirq/protocols/has_stabilizer_effect_protocol.py:109: in _strat_has_stabilizer_effect_from_decompose decomposition = decompose_protocol.decompose_once(val, default=None) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

val = PrepareUniformSuperposition(n=6, cvs=(1,)), default = None, flatten = True
context = DecompositionContext(qubit_manager=<cirq.ops.qubit_manager.SimpleQubitManager object at 0x1723452a0>), args = (), kwargs = {}
method = <bound method GateWithRegisters.decompose_with_context of PrepareUniformSuperposition(n=6, cvs=(1,))>

def decompose_once(
    val: Any,
    default=RaiseTypeErrorIfNotProvided,
    *args,
    flatten: bool = True,
    context: Optional[DecompositionContext] = None,
    **kwargs,
):
    """Decomposes a value into operations, if possible.

    This method decomposes the value exactly once, instead of decomposing it
    and then continuing to decomposing the decomposed operations recursively
    until some criteria is met (which is what `cirq.decompose` does).

    Args:
        val: The value to call `_decompose_` on, if possible.
        default: A default result to use if the value doesn't have a
            `_decompose_` method or that method returns `NotImplemented` or
            `None`. If not specified, non-decomposable values cause a
            `TypeError`.
        *args: Positional arguments to forward into the `_decompose_` method of
            `val`.  For example, this is used to tell gates what qubits they are
            being applied to.
        flatten: If True, the returned OP-TREE will be flattened to a list of operations.
        context: Decomposition context specifying common configurable options for
            controlling the behavior of decompose.
        **kwargs: Keyword arguments to forward into the `_decompose_` method of
            `val`.

    Returns:
        The result of `val._decompose_(*args, **kwargs)`, if `val` has a
        `_decompose_` method and it didn't return `NotImplemented` or `None`.
        Otherwise `default` is returned, if it was specified. Otherwise an error
        is raised.

    Raises:
        TypeError: `val` didn't have a `_decompose_` method (or that method returned
            `NotImplemented` or `None`) and `default` wasn't set.
    """
    if context is None:
        context = DecompositionContext(
            ops.SimpleQubitManager(prefix=f'_decompose_protocol_{next(_CONTEXT_COUNTER)}')
        )

    method = getattr(val, '_decompose_with_context_', None)
  decomposed = NotImplemented if method is None else method(*args, **kwargs, context=context)

E TypeError: GateWithRegisters.decompose_with_context() missing 1 required positional argument: 'qubits'

</details>
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 a pull request may close this issue.

3 participants