Skip to content

Robust permutation into dressed basis #3

@kmsherbertvt

Description

@kmsherbertvt

Hi, Oinam; I'm a new postdoc at Virginia Tech, working on ctrlVQE. I've just discussed a couple of apparent bugs in the ctrlq code with other members of the group, and we wanted to share our thoughts with you.

When selecting the permutation of eigenvectors in the ham.dresser function, the following expression is used to select the ith vector:
max(evecs, key=lambda x: numpy.abs(numpy.dot(x,i)))
This can sometimes result in selecting the same vector multiple times, such as when multiple vectors have the same overlap with a particular set of basis states. The max function will always return the first vector reached, even if it was already added to the list of vectors.

The most obvious symptom this has occurred is when a transmon object's dsham matrix contains off-diagonal elements. At least, I'm pretty sure this issue is the cause of that symptom, which has definitely happened to me. Let me know if it would be valuable to draft a minimum working example where this error occurs.

The problem can be resolved by explicitly sorting the vectors according to the overlap with the ith basis element, then looping through the sorted list until you locate a vector that has not already been selected. In principle this should be doable with just a factor log N extra time to sort rather than simply find the max, and a subsequent extra O(N) search to find the first new vector in the sorted list (though linear rather than quadratic scaling here requires some clever data structures). All in all, the fact that this needs only happen once at the beginning of any calculations makes this fairly unimportant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions