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

Instantiation with controlled VariableUnitaryGate #310

Open
martinanibbi opened this issue Feb 6, 2025 · 2 comments
Open

Instantiation with controlled VariableUnitaryGate #310

martinanibbi opened this issue Feb 6, 2025 · 2 comments

Comments

@martinanibbi
Copy link

I would like to use instatiation on a parametrized circuit which includes controlled operations:

circuit = Circuit(4)
V1 = VariableUnitaryGate(3)
# control on 0
circuit.append_gate(ControlledGate(V1, num_controls=1), [0,1,2,3])

circuit.instantiate(
            unitary,
            method='qfactor',
            diff_tol_a=1e-12,   # Stopping criteria for distance change
            diff_tol_r=1e-10,    # Relative criteria for distance change
            dist_tol=1e-12,     # Stopping criteria for distance
            max_iters=100000,   # Maximum number of iterations
            min_iters=1000,     # Minimum number of iterations
            slowdown_factor=0,   # Larger numbers slowdown optimization
            # to avoid local minima
        )

I currently get the following error:

Cannot instantiate circuit with qfactor because the following gates are not locally optimizable: Controlled(VariableUnitaryGate(3, (2, 2, 2))).

When using minimization the code produces a similar error.

From my understanding, the problem is that ControlledGate is not a LocallyOptimizableUnitary.
Is there a way to circumnavigate this issue, is it a missing feature or is it simply impossible to use controlled parametrized gates with the instantiation method?

@edyounis
Copy link
Member

It is hard to say if it is possible or impossible, but it is not currently implemented. If the instantiation is more important than using Qfactor, you can swap the VariableUnitaryGate for a PauliGate, which should work with minimization.

@edyounis
Copy link
Member

I think it should be possible to make a ControlledGate locally optimizable conditioned on the inner gate being locally optimizable.

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

2 participants