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 API implementation #432

Closed thisac closed 4 years ago

thisac commented 4 years ago

Context: The device spec API need to be implemented so that it is used/called when creating/compiling a program.

Description of the Change: Three major changes have been made:

  1. CircuitSpecs have been renamed to Compiler.

  2. A new property eng.spec has been added to RemoteEngine that pings the device spec API and downloads the hardware device specifications and stores it in a DeviceSpec object.

  3. The Program.compile method has been updated to support DeviceSpec objects as inputs as well as an optional compiler argument.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

codecov[bot] commented 4 years ago

Codecov Report

Merging #432 into master will increase coverage by 0.11%. The diff coverage is 99.27%.

@@            Coverage Diff             @@
##           master     #432      +/-   ##
==========================================
+ Coverage   97.84%   97.96%   +0.11%     
==========================================
  Files          58       67       +9     
  Lines        6784     6932     +148     
==========================================
+ Hits         6638     6791     +153     
+ Misses        146      141       -5     
Impacted Files Coverage Δ
strawberryfields/apps/plot.py 100.00% <ø> (ø)
strawberryfields/apps/train/embed.py 100.00% <ø> (ø)
...awberryfields/backends/gaussianbackend/__init__.py 100.00% <ø> (ø)
strawberryfields/backends/gaussianbackend/ops.py 100.00% <ø> (+2.70%) :arrow_up:
strawberryfields/utils/post_processing.py 100.00% <ø> (ø)
strawberryfields/utils/program_functions.py 97.77% <ø> (ø)
strawberryfields/utils/random_numbers_matrices.py 100.00% <ø> (ø)
strawberryfields/utils/states.py 100.00% <ø> (ø)
strawberryfields/io.py 97.70% <80.00%> (-1.13%) :arrow_down:
strawberryfields/backends/fockbackend/ops.py 94.04% <94.11%> (+2.04%) :arrow_up:
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f77e879...20bf121. Read the comment docs.

josh146 commented 4 years ago

@thisac, I've worked a bit on this PR today, finishing the circuitspec to compiler refactor, and integrating in the device specs. In particular, I've made the following changes:

Still to do:

josh146 commented 4 years ago

@antalszava @thisac I think this is now ready for review! @nquesada, what should the default compiler be for the X chips? Xcov or Xunitary?

thisac commented 4 years ago

@josh146 @antalszava I've updated the signature of Program.compile to compile(self, *, device=None, compiler=None) along with all the places that it was called. I've also added this to the docstring + documentation.

The only thing I think is left now is fixing the pylint issues regarding the tf-backend not overriding inherited methods, but I'm not sure why this is happening now (nor what would be the best way to handle it; disabling the error, etc.)

josh146 commented 4 years ago

[ch263]