pasqal-io/qadence-protocols

Implement model-free readout error mitigation

RolandMacDoland opened this issue · 8 comments

@gvelikova @rajaiitp Please add a description and link it to the current PR.

Moved comments:

@gvelikova gvelikova 5 days ago
Can these be taken out as yet another helper function that can take as arguments the specific _den or _num variables?

Collaborator
@gvelikova gvelikova 5 days ago
Lines 68-73 and 75-80.

Collaborator
@rajaiitp rajaiitp 5 days ago
Yup, was thinking of the same. But it just runs the circuit with a specific configuration and returns samples, so writing a function seems like an overkill. I can write a for loop, but not sure if its worth it with just 2 different configs and 5 lines of code. I will wait for @Roland-djee to decide which of the 2 would be better.

Collaborator
@rajaiitp rajaiitp 4 days ago
@Roland-djee i have not changed this. Let me know what you think.

The observables are not specified in the standard fashion. This needs to be changed, but idk how to manipulate them to retrieve index locations and coefficients of each pauli term when written in that fashion

The protocol runs only for diagonal observables as measurements make only sense in this basis. I have not put these checks in place. For other cases one needs to include basis rotations as a part of the circuit and evaluate those circuits independently. (true for any readout mitigation protocol)

Not sure what the arguments need to be, should it be at the level of circuit or model

Measurement of samples from observables has been written thru some homemade hacky code. Maybe have it on qadence at the level of circuit or model ?

Hey @rajaiitp, thank you for this. Before going further, I would suggest few main points:

Use the current infra in place in Qadence (essentially this file). Because it makes for a better interface and we might what to pass options to mitigation protocols.
Maybe we should think about what object needs to be passed to the mitigation function. I don't think that
expectation_mitigated = twirl_mitigation(n_qubits, circuit, backend, noise, n_shots, observable)
is very useful nor generic. What about passing model and noise objects ? WOuld that be enough ?

Passing model, noise and observable should be enough, thou i need to extract the circuit blocks back again and reconstruct the circuit with changes made to the end.
I am not passing observable the standard way, so that needs to fixed. It can be fixed only after qadence allows to compute expectation values from samples I think. So need that to be done first.
I will push my current changes and then work on the interfacing to look like qadence following that.
I presume the model structure is meant for training. Shouldnt we work at the circuit level for sampling and expectation values ?

@Roland-djee Roland-djee Pending
The tensor type in pytorch is Tensor.

@rajaiitp I would suggest you to develop along these lines:

model = QuantumModel(...) <-- to hold circuit, backend, noise etc
mitigate = Mitigations(Mitigations.TWIRL).mitigate() <-- returns a function
mitigated_vals = mitigate(model)

Also: please allow passing samples through options if you need to apply mitigations to ready made samples.

Closing this one as its completed and merged