Incorrect Energy and Basis Set Behavior with LANL2DZ in qchem.molecular_hamiltonian (Sn compounds + H₂)

Hello PennyLane team,

I’ve encountered issues with inaccurate energy outputs and basis set mismatches when using qchem.molecular_hamiltonian for VQE calculations, especially on heavy atoms like Sn (in triorganotin compounds) using LANL2DZ basis. I suspect PennyLane may silently fall back to STO-3G, despite explicit LANL2DZ selection.

I tested this in both large and small systems. For instance:

Use Case: Fentin Chloride (Sn Compound)

  • Traditional DFT energy (LANL2DZ): ~ -713 Ha
  • PennyLane VQE energy: ~ -1311 Ha
  • Suggests fallback to minimal basis set?
hamiltonian, qubits = qchem.molecular_hamiltonian(
                    symbols, coordinates, charge=0, mult=1, basis=basis,
                    method=method, active_electrons=ae, active_orbitals=ao
                )
hf = qchem.hf_state(electrons=ae, orbitals=qubits)
num_wires = qubits
dev_sim = qml.device("lightning.gpu", wires=num_wires)

@qml.qnode(dev_sim)
def exp_energy_sim(state):
    qml.BasisState(np.array(state), wires=range(num_wires))
    return qml.expval(hamiltonian)

expectation_energy = float(exp_energy_sim(hf))
log_to_file(file_name_log, f"HF Expectation Energy: {expectation_energy:.8f} Ha")

single_excitations, double_excitations = qchem.excitations(ae, num_wires)
s_wires, d_wires = qml.qchem.excitations_to_wires(single_excitations, double_excitations)

def cost_function(params, wires, s_wires, d_wires, init_state):
    qml.UCCSD(params, wires=range(num_wires), s_wires=s_wires, d_wires=d_wires, init_state=init_state)
    return qml.expval(hamiltonian)

num_params = len(single_excitations) + len(double_excitations)
theta_sim = np.zeros(num_params, requires_grad=True)

opt = qml.GradientDescentOptimizer(stepsize=learning_rate)
print("Starting VQE optimization...")
for n in range(max_iteration):
    theta_sim, cost_sim = opt.step_and_cost(cost_function, theta_sim, wires=range(qubits), s_wires=s_wires, d_wires=d_wires, init_state=hf)
    if abs(prev_energy - cost_sim) < tolerance:
        log_to_file(file_name_log, f"Converged at iteration {n} with energy {cost_sim:.8f} Ha")
        break
    prev_energy = cost_sim
    

If you want help with diagnosing an error, please put the full error message below:

# Put full error message here

And, finally, make sure to include the versions of your packages. Specifically, show us the output of qml.about().

Hi @22iscute , welcome to the Forum and thank you for reporting this issue!

The preferred way to use qchem.molecular_hamiltonian is to use a qml.qchem.Molecule object instead of providing some of the arguments that you’re using at the moment.

The qml.qchem.Molecule object only supports basis sets STO-3G , 6-31G , 6-311G and CC-PVDZ . However other basis sets can be loaded from the basis-set-exchange library by setting load_data=True.

Regarding the specific energies you’re getting I really have no idea what the energy should be so I don’t know if this is an indication of a fallback to the minimal basis set. However if you still see the same result after changing to using the Molecule object and using load_data=True, please share the information below and I’ll check with our team.

  • PennyLane version you’re using
  • Any arguments required to run your code, e.g. symbols, coordinates, basis, method, ae, and ao.

I hope this helps!

basis = "lanl2dz"  # LANL2DZ for heavy elements
method = "pyscf"
ansatz = "uccsd"
learning_rate = 0.01
max_iteration = 5000
tolerance = 1e-8

hamiltonian, qubits = qchem.molecular_hamiltonian(
                    symbols, coordinates, charge=0, mult=1, basis=basis, load_data=True,
                    method=method, active_electrons=ae, active_orbitals=ao
                )

i did this, but still got around -1311.1910 for Fentin Chloride which i ssupposed to be -713.2151037 QAQ
by the way my H2 is -1.15142731 Ha
how is pennylane’s official anwser for H2 with basis lanl2dz? i want to check if i used it correct

Hi @22iscute and thanks for using PennyLane!

Could you please construct your Hamiltonian manually following the steps described in “Computing molecular integrals” section of this demo and let us know if the energies are still different than what you expect?

Please let us know if you have any questions on that.

Thanks.