qua-platform / quam

The Quantum Abstract Machine (QuAM) is a comprehensive framework designed to abstract and manage quantum programming environments, providing robust tools for configuring and running quantum operations effectively. It is built over the QUA programming language, offering an organized structure for handling complex quantum components and operations.
http://qua-platform.github.io/quam/
BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

Multiple QuAMs causing issues with references #58

Open JacobHast opened 2 months ago

JacobHast commented 2 months ago

When initializing multiple quam roots in a single script something appears to go wrong with referencing. I'm not sure when it makes sense to initialize multiple quams, but in my case this has caused some hard-to-find bugs when testing various things out. If initializing multiple roots is not allowed, maybe a suggestion would be to raise an error if it happens.

image

nulinspiratie commented 4 weeks ago

You're right, creating multiple QuamRoot objects causes issues because QuamBase._root is always set to the latest QuAM, which is needed for absolute referencing to work. However, I don't see a straightforward solution for this. There are several situations where one would create a new QuamRoot object. For instance, if one is running a live kernel and loads QuAM multiple times.

I will keep this open, but for now I don't see a solution that wouldn't introduce significant overhead. @JacobHast if you have suggestions please let me know

JacobHast commented 4 weeks ago

I see. Would it be possible to add a warning when creating a new root if a root already exists to facilitate debugging?

nulinspiratie commented 3 weeks ago

At least for now I wouldn't want it as a warning because that usually shows up by default. I could do logging.info, which will or will not show up depending on the log filtering. Does that work?