Release 0.15.0
New features since last release
-
Adds the ability to train variational GBS circuits in the applications layer. (#387) (#388) (#391) (#393) (#414) (#415)
Trainable parameters can be embedded into a VGBS class:
from strawberryfields.apps import data, train d = data.Mutag0() embedding = train.Exp(d.modes) n_mean = 5 vgbs = train.VGBS(d.adj, 5, embedding, threshold=False, samples=np.array(d[:1000]))
Properties of the variational GBS distribution for different choices of trainable parameters can then be inspected:
>>> params = 0.1 * np.ones(d.modes) >>> vgbs.n_mean(params) 3.6776094165797364
A cost function can then be created and its value and gradient accessed:
>>> h = lambda x: np.sum(x) >>> cost = train.Stochastic(h, vgbs) >>> cost(params, n_samples=1000) 3.940396998165503 >>> cost.grad(params, n_samples=1000) array([-0.54988876, -0.49270263, -0.6628071 , -1.13057762, -1.13568456, -0.70180571, -0.6266806 , -0.68803539, -1.11032533, -1.12853718, -0.59172261, -0.47830748, -0.96901676, -0.66938217, -0.85162006, -0.27188134, -0.26955011])
For more details, see the VGBS training demo.
-
Feature vectors of graphs can now be calculated exactly in the
apps.similarity
module of the applications layer. Datasets of pre-calculated feature vectors are available inapps.data
. (#390) (#401)>>> from strawberryfields.apps import data >>> from strawberryfields.apps.similarity import feature_vector_sampling >>> samples = data.Mutag0() >>> feature_vector_sampling(samples, [2, 4, 6]) [0.19035, 0.2047, 0.1539]
For more details, see the graph similarity demo.
-
A new
strawberryfields.apps.qchem
module has been introduced, centralizing all quantum chemistry applications. This includes various new features and improvements:-
Adds the
apps.qchem.duschinsky()
function for generation of the Duschinsky rotation matrix and displacement vector which are needed to simulate a vibronic process with Strawberry Fields. (#434) -
Adds the
apps.qchem.dynamics
module for simulating vibrational quantum dynamics in molecules. (#402) (#411) (#419) (#421) (#423) (#430)This includes:
-
dynamics.evolution()
constructs a custom operation that encodes the input chemical information. This custom operation can then be used within a Strawberry FieldsProgram
. -
dynamics.sample_coherent()
,dynamics.sample_fock()
anddynamics.sample_tmsv()
functions allow for generation of samples from a variety of input states. -
The probability of an excited state can then be estimated with the
dynamics.prob()
function, which calculates the relative frequency of the excited state among the generated samples. -
Finally, the
dynamics.marginals()
function generates marginal distributions.
-
-
The
sf.apps.vibronic
module has been relocated to within theqchem
module. As a result, theapps.sample.vibronic()
function is now accessible underapps.qchem.vibronic.sample()
, providing a single location for quantum chemistry functionality. (#416)
For more details, please see the qchem documentation.
-
-
The
GaussianState
returned from simulations using the Gaussian backend now has feature parity with theFockState
object returned from the Fock backends. (#407)In particular, it now supports the following methods:
GaussianState.dm()
GaussianState.ket()
GaussianState.all_fock_probs()
In addition, the existing
GaussianState.reduced_dm()
method now supports multi-mode reduced density matrices. -
Adds the
sf.utils.samples_expectation
,sf.utils.samples_variance
andsf.utils.all_fock_probs_pnr
functions for obtaining counting statistics from samples. (#399) -
Compilation of Strawberry Fields programs has been overhauled.
-
Strawberry Fields can now access the Xanadu Cloud device specifications API. The
Connection
class has a new methodConnection.get_device
, which returns aDeviceSpec
class. (#429) (#432) -
New
Xstrict
,Xcov
, andXunitary
compilers for compiling programs into the X architecture have been added. (#358) (#438) -
Finally, the
strawberryfields.circuitspecs
module has been renamed tostrawberryfields.compilers
.
-
-
Adds
diagonal_expectation
method for theBaseFockState
class, which returns the expectation value of any operator that is diagonal in the number basis. (#389) -
Adds
parity_expectation
method as an instance ofdiagonal_expectation
for theBaseFockState
class, and its own function forBaseGaussianState
. This returns the expectation value of the parity operator, defined as (-1)^N. (#389)
Improvements
-
Modifies the rectangular interferometer decomposition to make it more efficient for hardware devices. Rather than decomposing the interferometer using Clements :math:
T
matrices, the decomposition now directly produces Mach-Zehnder interferometers corresponding to on-chip phases. (#363) -
Changes the
number_expectation
method for theBaseFockState
class to be an instance ofdiagonal_expectation
. (#389) -
Increases the speed at which the following gates are generated:
Dgate
,Sgate
,BSgate
andS2gate
by relying on a recursive implementation recently introduced inthewalrus
. This has substantial effects on the speed of theFockbackend
and theTFbackend
, especially for high cutoff values. (#378) (#381) -
All measurement samples can now be accessed via the
results.all_samples
attribute, which returns a dictionary mapping the mod index to a list of measurement values. This is useful for cases where a single mode may be measured multiple times. (#433)
Breaking Changes
-
Removes support for Python 3.5. (#385)
-
Complex parameters now are expected in polar form as two separate real parameters. (#378)
Contributors
This release contains contributions from (in alphabetical order):
Juan Miguel Arrazola, Tom Bromley, Jack Ceroni, Aroosa Ijaz, Theodor Isacsson, Josh Izaac, Nathan Killoran, Soran Jahangiri, Shreya P. Kumar, Filippo Miatto, Nicolás Quesada, Antal Száva