qir-alliance / qcor

C++ compiler for heterogeneous quantum-classical computing built on Clang and XACC
http://docs.aide-qc.org
MIT License
97 stars 39 forks source link

[qcor-py] Raw fermion operators sneak in to the qreg::weighted_sum #242

Open 1tnguyen opened 3 years ago

1tnguyen commented 3 years ago

Repro test case:

geom = '''
Na  0.0   0.0      0.0
H   0.0   0.0  1.914388
'''
fo = [0, 1, 2, 3, 4, 10, 11, 12, 13, 14]
ao = [5, 9, 15, 19]

H = createOperator('pyscf', {'basis': 'sto-3g', 'geometry': geom,
                                       'frozen-spin-orbitals': fo, 'active-spin-orbitals': ao})

energy = ansatz.observe(H, qalloc(4), 1.234)

This will eventually invoke qreg::weighted_sum, which assumes the observable is of Pauli-type.

Note: the workaround is to explicitly apply operatorTransform("jw", H)