PsiQ / bartiq

Bartiq
https://psiq.github.io/bartiq/
Apache License 2.0
30 stars 9 forks source link

Passthrough port sizes don't get compiled correctly #72

Closed mstechly closed 1 month ago

mstechly commented 4 months ago

After running the following piece of code:

import json
from bartiq import Routine, compile_routine, evaluate
from bartiq.integrations import qref_to_bartiq

with open("docs/data/alias_sampling_basic.json", "r") as f:
    routine_dict = json.load(f)

uncompiled_routine = qref_to_bartiq(routine_dict)
compiled_routine = compile_routine(uncompiled_routine)

And inspecting swap:

compiled_routine.children["swap"]

I get the following result:

Screenshot 2024-06-19 at 7 26 01 PM

These P_1 and P_2 are not defined anywhere, they are placeholder variables coming from the passthroughs. At this stage they should have been replaced by real values coming from ports they're connected to, but something went wrong.

This might get resolved while working on #18 , but if not, needs to be fixed after it's resolved.

I was using bartiq==0.2.0.

mstechly commented 3 months ago

A potentially related issue:

When running basic tutorial as part of https://github.com/PsiQ/bartiq/pull/76 with new verification, I got the following warning from verifying compiled routine:

/Users/mstechly/Documents/code/2024-06-04-18-validation/bartiq/src/bartiq/compilation/_compile.py:117: UserWarning: Found the following issues with the provided routine after the compilation has finished: ["Symbol n_b found in subroutine: my_algorithm.B, which is not among top level params: {'n', 'z'}."]

Here similarly, the n_b does not get compiled out – it might be the same or related bug.