XanaduAI / strawberryfields

Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
https://strawberryfields.ai
Apache License 2.0
754 stars 191 forks source link

Device spec validation using complex mode structures #483

Closed antalszava closed 2 years ago

antalszava commented 3 years ago

Certain devices specify modes conditionally to characteristics of the circuit to be simulated. For example, simulating circuits that contain measurements using PNR detectors might require more computational power as simulating the same circuit, but with homodyne measurements.

Therefore, we would like to extend the check for modes in Program, so that a dictionary of options for modes can also be used.

thisac commented 3 years ago

Here's an example of a device-spec with modes as a dictionary (specifically containing a lower maximum value for the number of photon number measurements and a higher one for homodyne). Note that the TD2 modes in the device spec also is a dictionary, but has it's own mode validation. It doesn't compile using the Program.compile() method, and thus never calls the mode check mentioned above.

thisac commented 2 years ago

Has been fixed by the addition of this assert_modes function.