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

get_cost_value fails when applied to a CirqGateAsBloq with a known decomposition into gates that should be countable. #1426

Open
wjhuggins opened this issue Sep 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working resource_counting
Milestone

Comments

@wjhuggins
Copy link
Collaborator

When I execute the code:

import sympy
import cirq

from qualtran.cirq_interop import CirqGateAsBloq
from qualtran.resource_counting import QECGatesCost, get_cost_value

theta = sympy.Symbol("theta", real=True)
cirq_swappow = cirq.SwapPowGate(exponent=theta)

# Would be cool if it worked:
swappow_bloq = CirqGateAsBloq(cirq_swappow)

get_cost_value(swappow_bloq, QECGatesCost())

I would expect that get_cost_value would automatically use cirq.decompose to break the SwapPowGate into gates that can be ingested by Qualtran and costed out, but instead I get an error message:

ValueError: Cirq gate must be directly countable, not SWAP**theta.

When I run (with the appropriate imports of course)

g, sigma = swappow_bloq.call_graph()

show_call_graph(g)

show_counts_sigma(sigma)

I get the expected behaviour:
image

@mpharrigan mpharrigan self-assigned this Oct 7, 2024
@mpharrigan mpharrigan added bug Something isn't working resource_counting labels Oct 10, 2024
@mpharrigan mpharrigan added this to the v1.0 milestone Oct 10, 2024
@mpharrigan
Copy link
Collaborator

I was trying to limit the use of cirq functionality in the resource counting code but was overzealous here. I agree the call graph and resource counting code should be in agreement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resource_counting
Projects
None yet
Development

No branches or pull requests

2 participants