Feed forward Configurators
Configurators are the way to perform a feed-forward computation.
As they are non-unitary components, they can only be added to Processor
instances.
Their purpose is to link measurements on given modes to circuits to configure.
They are based on the following common features:
A default circuit is mandatory for when the measurement does not fall into one of the configured cases. This circuit determines the size of the configured circuit.
All referenced circuits have the same size.
The measured modes must be classical (placed after a detector).
The circuit position is determined by an offset between the configurator and the configured circuit.
This offset represents the number of modes between the measured modes and the circuit. For positive offsets, the circuit is placed below, the offset being the number of empty modes between the configurator and the circuit (0 means the circuit is right below the configurator). For negative values, the circuit is placed above the measured modes (-1 means that the circuit is right above the configurator).
Two configurators exist.
FFCircuitProvider class reference
This class directly links measurements to circuits or processors. Any circuit or processor matching the default circuit size can be used given all parameters have numerical values.
>>> import perceval as pcvl
>>> p = pcvl.Processor("SLOS", 4)
>>> c = pcvl.FFCircuitProvider(1, offset=1, default_circuit=pcvl.Circuit(2), name="FFCircuitProvider Example")
>>> c.add_configuration([1], pcvl.BS())
>>> p.add(0, c)
- class perceval.components.feed_forward_configurator.FFCircuitProvider(m, offset, default_circuit, name=None)
For any measurement, FFCircuitProvider will return a circuit or a processor, picked from known mapping of configurations. Each configuration links a measurement to a circuit or processor. If a measurement is received and was not set in the mapping, a mandatory default circuit or processor is returned.
- DEFAULT_NAME = 'FFC'
Abstract feed-forward configurator.
- Parameters:
m – The number of classical modes that are detected (after a detector)
offset – The distance between the configurator and the first mode of the implemented circuits. For positive values, it is the number of empty modes between the configurator and the configured circuit below. For negative values, it is the same but the circuit is located above the configurator (the number of empty modes is abs(offset) - 1, so an offset of -1 means that there is no empty modes between the configurator and the circuit). All circuits are considered to have the size of the biggest possible circuit in this configurator.
default_circuit – The circuit to be used if the measured state does not befall into one of the declared cases
- block_circuit_size()
Call this to prevent adding circuits bigger than the current maximum size
- circuit_template()
Return a fitting representation of the controlled circuit or processor.
- Return type:
ACircuit
- config_modes(self_modes)
Gives the list of modes on which to place the circuit
- Parameters:
self_modes (
tuple
[int
,...
]) – The tuple containing the modes on which the configurator is located, in crescent order- Return type:
tuple
[int
,...
]
- configure(measured_state)
Gives the circuit or processor that must be configured given the measured state
- Parameters:
measured_state (
FockState
) – The state of size self.m that corresponds to the measurements of the modes on which the configurator is located.- Return type:
ACircuit
- Returns:
The processor or circuit that must be set
- is_composite()
Returns True if the component is itself composed of subcomponents
- Return type:
bool
- property name: str
Returns component name
FFConfigurator class reference
This class links measurements to a mapping of parameter values that can be set in the given circuit.
>>> import perceval as pcvl
>>> p = pcvl.Processor("SLOS", 4)
>>> phi = pcvl.P("phi")
>>> c = pcvl.FFConfigurator(2, offset=1, controlled_circuit=pcvl.PS(phi), default_config={"phi": 0}, name="FFConfigurator Example")
>>> c.add_configuration([1, 0], {"phi": 1.23})
>>> p.add(0, c)
- class perceval.components.feed_forward_configurator.FFConfigurator(m, offset, controlled_circuit, default_config, name=None)
This class relies on a mapping between detections and a mapping of variable names and numerical values, controlling a circuit template.
- DEFAULT_NAME = 'FFC'
Abstract feed-forward configurator.
- Parameters:
m – The number of classical modes that are detected (after a detector)
offset – The distance between the configurator and the first mode of the implemented circuits. For positive values, it is the number of empty modes between the configurator and the configured circuit below. For negative values, it is the same but the circuit is located above the configurator (the number of empty modes is abs(offset) - 1, so an offset of -1 means that there is no empty modes between the configurator and the circuit). All circuits are considered to have the size of the biggest possible circuit in this configurator.
default_circuit – The circuit to be used if the measured state does not befall into one of the declared cases
- block_circuit_size()
Call this to prevent adding circuits bigger than the current maximum size
- circuit_template()
Return a fitting representation of the controlled circuit or processor.
- Return type:
ACircuit
- config_modes(self_modes)
Gives the list of modes on which to place the circuit
- Parameters:
self_modes (
tuple
[int
,...
]) – The tuple containing the modes on which the configurator is located, in crescent order- Return type:
tuple
[int
,...
]
- configure(measured_state)
Gives the circuit or processor that must be configured given the measured state
- Parameters:
measured_state (
FockState
) – The state of size self.m that corresponds to the measurements of the modes on which the configurator is located.- Return type:
ACircuit
- Returns:
The processor or circuit that must be set
- is_composite()
Returns True if the component is itself composed of subcomponents
- Return type:
bool
- property name: str
Returns component name