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

Users can't map wavefunc coeffs to the corresponding configuration #85

Closed
caleb-johnson opened this issue Oct 15, 2024 · 3 comments · Fixed by #91
Closed

Users can't map wavefunc coeffs to the corresponding configuration #85

caleb-johnson opened this issue Oct 15, 2024 · 3 comments · Fixed by #91
Labels
bug Something isn't working

Comments

@caleb-johnson
Copy link
Collaborator

caleb-johnson commented Oct 15, 2024

Environment

All environments

What is happening and why is it wrong?

The wavefunction coefficients returned from solve_fermion are stored in an MxN matrix, where M is the number of unique alpha determinants and N is the number of unique beta determinants. The rows and columns are associated with the sorted (ascending) determinants.

Since users pass in a bitstring matrix, they have no way of knowing to what configuration each amplitude is associated (Keep in mind the output configurations don't even have to be present in the set of input configurations.)

Any suggestions?

The user should be returned a mapping from configuration to amplitude. The most straightforward thing to do would be to return a dict[int, float] mapping the full spin configuration to the associated amplitude.

We could also return a tuple as shown here.

@caleb-johnson caleb-johnson added the bug Something isn't working label Oct 15, 2024
@caleb-johnson caleb-johnson reopened this Oct 17, 2024
@kevinsung
Copy link
Collaborator

Actually, the wavefunction coefficients are returned as a PySCF SCIvector object, which does have the configurations stored in the _strs attribute. However, this is an issue for qiskit-addon-dice-solver.

@caleb-johnson
Copy link
Collaborator Author

caleb-johnson commented Oct 25, 2024

Actually, the wavefunction coefficients are returned as a PySCF SCIvector object, which does have the configurations stored in the _strs attribute. However, this is an issue for qiskit-addon-dice-solver.

As discussed offline, I'd like users to be able to inspect the coefficients and CI strings without needing to access a private field. Our source will still need to access that field to unpack the strings, which isn't great. We can assert (or error out) that sci_vec._strs is populated and well-formed as it is returned from PySCF, since that is an undocumented assumption we are making about that field (I think it's a safe assumption).

I will definitely cast the SCIVector to a vanilla np.ndarray after unpacking the _strs field to avoid storing redundant CI string data. I am debating whether the sci coefficients output from solve_fermion should be a data class containing the coeffs and the strings or a tuple as suggested above. Maybe a named tuple?

@caleb-johnson
Copy link
Collaborator Author

I think I favor the name SCIState for this dataclass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants