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

Bug: IterationEnvironment #82

Open
renezander90 opened this issue Sep 24, 2024 · 1 comment
Open

Bug: IterationEnvironment #82

renezander90 opened this issue Sep 24, 2024 · 1 comment
Assignees

Comments

@renezander90
Copy link
Contributor

The following code yields:

Exception: Tried to invoke IterationEnvironment with code creating/deleting QuantumVariables

from qrisp import *

def test(qarg, t, steps):
    rx(np.pi*t/steps,qarg)


def U(qarg, t=1, steps=1, iter=1):
   print(qarg.qs.qv_list)
   with IterationEnvironment(qarg.qs, iteration_amount=iter*steps):
        test(qarg, t, steps)

qv = QuantumVariable(3)
res = QPE(qv,U,precision=3,kwargs={"t":3,"steps":2},iter_spec=True)

It does work for "steps":1. But why does it work in that case anyway?
In the first QPE step, qv.qs does not contain the qpe_res in any case.

@positr0nium
Copy link
Contributor

This IterationEnvironment behavior is still super clunky. I'll look into it how it can be handled better.

As a hotfix you can call merge([qarg]) as the first command of U. This will merge the qarg qs into the environment qs.

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