Closed thisac closed 4 years ago
Merging #432 into master will increase coverage by
0.11%
. The diff coverage is99.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.
@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:
Factored out the parameter validation into a separate DeviceSpec.validate_parameters
method.
Added support for validating gate parameters against the device spec by calling DeviceSpec.validate_parameters
in Program.compile()
.
Renamed the BaseBackend.circuit_spec
property to BaseBackend.compiler
Deleted the TensorFlow circuit spec (since it is identical to the Fock circuit spec).
Deleted X8Spec
and X12Spec
.
Updated the compilation section in doc/introduction/circuits.rst
.
Removed modes
, remote
, parameter_ranges
, and local
from the Compiler
class, since they have never been used (and belong in the DeviceSpec
class instead).
Previously, sf.io.to_program
would attempt to both convert a blackbird program to a SF program, and compile it using the bb.target
attribute. This no longer makes sense, since device targets are no longer local, so implicit compilation has been removed. This probably should not have been occurring at all; a program loader should not implicitly be transforming the program.
Finally, the engine would previously skip compilation if prog.target == eng.target
. This also does not make sense; having the target
attribute of a program set does not guarantee that a program has been correctly compiled, and is easily spoofed. For now, every submitted program is recompiled, but we should determine a better approach of certifying a program as 'compiled'.
Still to do:
Add more tests to cover the new logic
Currently, the API isn't returning default compilers for X8 and X12. We need to work out what to do for the time being --- add this to the API, or have a short term hot-fix in SF, whereby we assume compiler = "Xcov"
if device_spec.default_compiler == []
.
@antalszava @thisac I think this is now ready for review! @nquesada, what should the default compiler be for the X chips? Xcov
or Xunitary
?
@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.)
[ch263]
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:
CircuitSpecs
have been renamed toCompiler
.A new property
eng.spec
has been added toRemoteEngine
that pings the device spec API and downloads the hardware device specifications and stores it in aDeviceSpec
object.The
Program.compile
method has been updated to supportDeviceSpec
objects as inputs as well as an optionalcompiler
argument.Benefits:
Possible Drawbacks:
Related GitHub Issues: