qiboteam / rtqem

Impact of error mitigation using a quantum device as a regressor.
3 stars 0 forks source link

Mitigated prediction #10

Closed BrunoLiegiBastonLiegi closed 1 year ago

BrunoLiegiBastonLiegi commented 1 year ago

Implementation of the prediction method mitigated with the CDR method. I added to the vqregressor initialization the backend and noise_model parameters that are needed for the CDR to run under simulated noise, but they can be useful in general to run the fit under simulated noise. Therefore, it might be worth analogously changing the one_prediction method to:

  def one_prediction(self, x):
    """This function calculates one prediction with fixed x."""
    self.inject_data(x)
    return self.circuit(nshots=1000).expectation_from_samples(
        np.prod([ Z(i) for i in range(self.nqubits) ])
    )
AlejandroSopena commented 1 year ago

Thanks. Yes, this is exactly what I suggested.

AlejandroSopena commented 1 year ago

I changed one_prediction to use frequencies $f$ instead of probabilities $p$. This way, the number of shots is taken into account and it is easier to compare with real data because $f$ = $p$ only when $\text{nshots} \rightarrow \infty$. I added a depolarizing channel with $\lambda=0.25$ so that we can get results for all possibilities before running on hardware. I have used a training set with 10 circuits for CDR and it seems to work. In the following results, $\text{nshots}=1000$

We have to play with the other mitigation methods and of course run it in hardware but it seems that using real-time error mitigation improves the results!

scarrazza commented 1 year ago

Excellent, good work @AlejandroSopena @MatteoRobbiati @BrunoLiegiBastonLiegi!

BrunoLiegiBastonLiegi commented 1 year ago

Awesome, thanks @AlejandroSopena !