Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processor run_state is not reproducible due to accumulation of noise channel #230

Closed
andgoldschmidt opened this issue Feb 21, 2024 · 1 comment

Comments

@andgoldschmidt
Copy link

There is an after effect to running a simulation. I would expect processors to be reusable and simulations to be repeatable.

Set up a processor for aT1 simulation.

processor = Processor(1, t1=t1, t2=None)
processor.add_pulse(Pulse(None, None, tlist=t_eval, coeff=False))
print(processor.noise)
[]

Run the processor.

a = qt.destroy(2)
psi0 = qt.basis(2,1)
result = processor.run_state(init_state=psi0, e_ops=[a.dag()*a])
print(processor.noise)
<qutip.qip.noise.RelaxationNoise object...>

Now, the next simulation has double the decoherence processes.

The after effect is noted in the docstring of processor.py

    def get_noisy_pulses(self, device_noise=False, drift=False):
        """
        It takes the pulses defined in the `Processor` and
        adds noise according to `Processor.noise`. It does not modify the
        pulses saved in `Processor.pulses` but returns a new list.
        The length of the new list of noisy pulses might be longer
        because of drift Hamiltonian and device noise. They will be
        added to the end of the pulses list.
...

due to calling

    noisy_pulses = process_noise(
        pulses, self.noise, self.dims, t1=self.t1, t2=self.t2,
        device_noise=device_noise)

instead of

    noisy_pulses = process_noise(
        pulses, deepcopy(self.noise), self.dims, t1=self.t1, t2=self.t2,
        device_noise=device_noise)

or modifying the process_noise not to add noise channels to the processor. Is there a reason why there is an append to self.noise inside process_noise?

@BoxiLi
Copy link
Member

BoxiLi commented Feb 22, 2024

Thanks for the issue.

Yes, this was a bug. process_noise should not change the list of noise channels in the processor. This should be fixed in #89 already, seeing the change in https://github.com/qutip/qutip-qip/pull/89/files. It is similar to what you did. It should be included in qutip-qip>=0.1.2

@BoxiLi BoxiLi closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants