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

AttributeError: 'FermiHubbard' object has no attribute '_N' when using Linear T encoding #30

Open
tyleratrigetti opened this issue Dec 2, 2024 · 2 comments

Comments

@tyleratrigetti
Copy link

pyLIQTR version: v1.3.3
Cpu: Mac M1

I receive the following error when trying to create a fermi hubbard qsvt circuit with linear T encoding:

pyLIQTR/BlockEncodings/LinearT.py:25

init__(self, ProblemInstance, approx_error, energy_error, **kwargs)
     22 super().__init__(ProblemInstance,**kwargs)
     24 self._encoding_type = VALID_ENCODINGS.LinearT
---> 25 self._num_coeffs = 3*2*self.PI._N # factor of 3 for T,U,V. Factor of 2 for spin
     27 if energy_error is not None:
     28     self.approx_error = self.get_approx_error(energy_error)

AttributeError: 'FermiHubbard' object has no attribute '_N'

Example to reproduce:

    from pyLIQTR.ProblemInstances.getInstance import getInstance
    from pyLIQTR.clam.lattice_definitions import SquareLattice
    from pyLIQTR.BlockEncodings.getEncoding import getEncoding, VALID_ENCODINGS
    from pyLIQTR.qubitization.qsvt_dynamics import qsvt_dynamics, simulation_phases

    # Create Fermi-Hubbard Instance
    J = -1.0
    N = 2
    U = 8.0
    eps = 0.025
    model = getInstance("FermiHubbard", shape=(N, N), J=J, U=U, cell=SquareLattice)
    times = 1.0
    eps = eps
    phases = simulation_phases(times, eps=eps, precompute=False, phase_algorithm="optimization")
    gate_qsvt = qsvt_dynamics(encoding=getEncoding(VALID_ENCODINGS.LinearT), instance=model, phase_sets=phases)
@kjm538
Copy link
Collaborator

kjm538 commented Dec 2, 2024

The LinearT encoding is for the broader electronic structure problems, so it doesn't currently work with the FermiHubbard instance. To get the specialized Fermi Hubbard encoding (which is also from the linear T paper) you can use VALID_ENCODINGS.FermiHubbardSquare.

I realize this is not clear from the error you receive so we'll work on fixing that.

@tyleratrigetti
Copy link
Author

The LinearT encoding is for the broader electronic structure problems, so it doesn't currently work with the FermiHubbard instance. To get the specialized Fermi Hubbard encoding (which is also from the linear T paper) you can use VALID_ENCODINGS.FermiHubbardSquare.

I realize this is not clear from the error you receive so we'll work on fixing that.

Ok great! I suspected I was using it improperly. Thanks for the great work and quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants