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

Deep-copy circuit with Program._linked_copy #691

Open
1 task done
thisac opened this issue Mar 11, 2022 · 0 comments
Open
1 task done

Deep-copy circuit with Program._linked_copy #691

thisac opened this issue Mar 11, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@thisac
Copy link
Contributor

thisac commented Mar 11, 2022

Before posting a bug report

  • I have searched exisisting GitHub issues to make sure the issue does not already exist.

Expected behavior

When creating a linked copy of a program (e.g., when calling the compiler), the register references are retained. Gate parameters may contains MeasuredParameter objects, which are used as placeholders for mid-circuit measurements. They contain register references to the registers that are measured, and thus have to be kept in the linked copy.

Currently, the circuits are referenced in the linked copy, rather than copied. Expected behaviour would be that only the register references are retained, while the rest of the circuit (parameters, etc.) should be copied.

>>> cprog = prog._linked_copy()
>>> cprog.circuit is prog.circuit
False

Above: the program circuit should be equal but not the same.

Actual behavior

>>> cprog = prog._linked_copy()
>>> cprog.circuit is prog.circuit
True

Reproduces how often

Every time a program is copied.

System information

Strawberry Fields: a Python library for continuous-variable quantum circuits.
Copyright 2018-2020 Xanadu Quantum Technologies Inc.

Python version:            3.9.6
Platform info:             macOS-12.2.1-arm64-arm-64bit
Installation path:         /Users/theodor/Repos/strawberryfields/strawberryfields
Strawberry Fields version: 0.22.0-dev
Numpy version:             1.21.3
Scipy version:             1.7.0
SymPy version:             1.8
NetworkX version:          2.6.1
The Walrus version:        0.19.0-dev
Blackbird version:         0.5.0-dev
XCC version:               0.2.0-dev
TensorFlow version:        2.4.1

Source code

No response

Tracebacks

No response

Additional information

No response

@thisac thisac added the bug Something isn't working label Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant