Hi,
I think there might be a bug regarding parameter assignment in processors. I am working off perceval version: 0.11.0.post2.
I’ll give an example:
import perceval as pcvl
import perceval.components.unitary_components as comp
from perceval import Processor, P
from perceval.algorithm import Sampler
processor = Processor("SLOS", 2)
processor.add(0, comp.PS(P("A")))
processor.add(0, comp.BS.H())
processor.set_parameters({"A": 0.5})
processor.with_input(pcvl.BasicState([1, 0]))
sampler = Sampler(processor)
results = sampler.sample_count(100)['results']
print(results)
And I receive the warning/error:
UserWarning: An exception was raised during job execution.
<class 'AssertionError'>: All parameters must be defined to compute numeric unitary matrix
warnings.warn(f"An exception was raised during job execution.\n{type(e)}: {e}")
This suggests that the parameter “A” was not assigned the value specified. I can verify this by doing:
In a Processor, there are two layers of parameters.
The processor-related parameters which are mainly used to pass specific configuration in case of remote processors (as all platforms on Quandela Cloud do not have exactly the same features)
The circuit-level parameters. A processor contains a linear-optics circuit that can contain variable floating point parameters.
Calling set_parameters sets a processor-level parameter.
Calling get_circuit_parameters retrieves all circuit-level parameters.
However, I understand the misunderstanding. We’ll need to document this better, or even change some namings.
What I suggest is you either keep an instance of P("A") so that you can set a value later on.