pcvl.Processor.copy() thows error if input state is specified


I’ve been trying to obtain a deepcopy of a Perceval processor in my code and this action results in an error.

I narrowed down the copying problem to the following snippet

proc = pcvl.Processor(backend="SLOS", m_circuit= pcvl.Circuit(4))

Where this code does not throw any error if the with_input() line is commented.
The error thrown happens in the copy.deepcopy() method and concerns pickling a exqalibur.FockState:

TypeError: cannot pickle 'exqalibur.FockState' object

The class Processor explicitely implements the method copy() by first calling deepcopy() on itself so I would assume that an istance of this class is intended to be safe to copy at any moment.

Concerning why I need to resort to copying a Processor, I’d like to create multiple standalone async batch jobs with slight variations in the underlying circuit.
The Job object that gets created by the Sampler supposedly mantains some kind of reference to the Processor used to create it, so if the number of parameters in the Processor circuit changes after the creation of the async job, the batch job somehow executes on the new circuit and looks for some old nonexisting parameters.

I’d like to pass the Processor as an argument to a function that iterates over some circuits and at each step feeds the circuit to the existing processor and creates a async batch job on it.
My solution was then to ask at each step a copy of the processor that I can safely modify.
I would be interested in knowing If there’s an easier way to do that without explicitly constructing a Processor each time (which requires loads of parameters my methods should not be aware of).


Thanks for your message. This bug has already been taken care of in the upcoming 0.11.0 release (which is getting a bit long to be released :slight_smile: )
For now, as you saw, the work-around is to unset the input state before copying, if you need to.

Best wishes,

1 Like