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
745 stars 187 forks source link

Add support for npz results #633

Closed lneuhaus closed 2 years ago

lneuhaus commented 2 years ago

Context: Some devices on the Xanadu Quantum Cloud need to return multiple arrays of data with different shapes or data types. Furthermore, sometimes the size of a job result is a limiting factor due to limited bandwidth. This PR adds support for compressed result data, and supports returning dictionaries of result arrays instead of a single array per job.

Description of the Change: With this change, job results can be serialized using numpy.savez or numpy.savez_copressed. In this format, a dictionary of numpy arrays can be transferred, with compression disabled or enabled.

Benefits: Cloud devices can now return dictionaries of numpy arrays, and comporession can be used to reduce the data payload.

Possible Drawbacks: For single result arrays, it is not clear whether the client supports compression or not.

~Related GitHub Issues:~

codecov[bot] commented 2 years ago

Codecov Report

Merging #633 (226a15c) into master (c0fd8cc) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #633   +/-   ##
=======================================
  Coverage   98.55%   98.55%           
=======================================
  Files          77       77           
  Lines        8989     8998    +9     
=======================================
+ Hits         8859     8868    +9     
  Misses        130      130           
Impacted Files Coverage Δ
strawberryfields/api/result.py 100.00% <ø> (ø)
strawberryfields/api/connection.py 100.00% <100.00%> (ø)

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 c0fd8cc...226a15c. Read the comment docs.

lneuhaus commented 2 years ago

Any action needed for fixing CodeFactor or Codecov failures?