Generating Approximate Ground States of Molecules Using Quantum Machine Learning

Hello all! I’m trying to replicate the results from this paper:, and its GitHub is linked here: GitHub - XanaduAI/generative_qml_qchem: Repository for the generative QML for quantum chemistry project.

I noticed the code came out a year or 2 ago, and since Pennylane is fast paced, would any Pennylane expert know if it is possible to get this code working? For example, I noticed that this code uses qml.qchem.sparse_hamiltonian in file, but I noticed Pennylane doesn’t have this anymore? Will the function be anywhere in Pennylane’s other libraries, and in general, how would I go about adapting this code to use with Pennylane’s current function?


Hey @ImranNasrullah!

qml.qchem.sparse_hamiltonian was deprecated in v0.29, and you should use a Hamiltonian’s sparse_matrix method: qml.Hamiltonian — PennyLane 0.35.1 documentation.

If you run into any other features that are deprecated in that code, check out our deprecation page: Deprecations — PennyLane 0.35.1 documentation

Hope this helps!

A quick question. Some of the code seems a bit incomplete (but I know it can’t be because they ran the code. For example in their file, they call an n_params attribute of “model.obj”, but in the ModelObject class, that isn’t even a defined class attribute.

Would you mind taking a look at the code for me to see what I’m talking about and if I’m missing something?

Hi @ImranNasrullah ,

I mentioned this to one of the authors to see if they can help you understand the code. We’ll be back with more info in the next couple of days.

Hi @ImranNasrullah,

Unfortunately the code is quite old and the authors are busy at the moment so there isn’t much help they can provide at the moment.

You may need to dig deep into the code and rewrite parts of it to make it work. I’m sorry there’s no easy solution here.