QuantumApplicationLab / vqls-prototype

A Variational Quantum Linear Solver Prototype for Qiskit
Apache License 2.0
12 stars 4 forks source link

HTreeQST assumes positive samples #8

Closed bgard1 closed 9 months ago

bgard1 commented 10 months ago

Steps to reproduce the problem

If the method HTreeQST().get_statevector() is used with a Qiskit run that has SPAM mitigation (resilience_level=1) then negative values for samples may be returned (typically these are small values).

What is the current behavior?

def get_statevector(self, parameters): """summary

    Args:
        parameters (_type_): _description_
    """
    samples = self.get_samples(parameters)
    amplitudes = np.sqrt(samples[0])
    weights = self.get_weight(samples)
    signs = self.get_signs(weights)
    return amplitudes * signs

The amplitudes above assumes samples will be positive valued (which makes sense in most cases).

What is the expected behavior?

While the physical nature of negative samples is not meaningful, it can occur in some rare cases and therefore should ideally not break this tomography technique. While it may not be very rigorous, the obvious quick fix is to redefine amplitudes = np.sqrt(np.abs(samples[0])) .

NicoRenaud commented 9 months ago

Hey @bgard1 Thanks for opening an issue ! I'll look into it and it shouldn't be a big change

NicoRenaud commented 9 months ago

solved in #9