ProjectQ-Framework / FermiLib

FermiLib: Open source software for analyzing fermionic quantum simulation algorithms
https://projectq.ch/
Apache License 2.0
87 stars 39 forks source link

Handled IOError in MolecularData.get_from_file() function #145

Closed hsim13372 closed 7 years ago

hsim13372 commented 7 years ago

I tried to set up an instance of MolecularData that was a "new" molecule (ie molecule that didn't exist in the default data directory in FermiLib) and ran into an IOError because the function get_from_file() in MolecularData didn't handle it/assumed this MolecularData instance has been saved into a HDF5 file.

idk3 commented 7 years ago

The test that failed isn't linked to Hannah's PR - is it possible there's some randomness in ProjectQ? Increasing the Trotter number for the failed test will likely fix it, but I'm not sure why it failed to begin with

babbush commented 7 years ago

This is new. @damiansteiger, @thomashaener any idea what's happening here?

damiansteiger commented 7 years ago

I don't know and currently I don't have FermiLib installed to debug.

Given that ProjectQ did not change in the last 22 days, my bet is an error in FermiLib as otherwise it would/could have appeared earlier. Might be because of randomness. If you like you can seed the random number generator of ProjectQ (see docs) but the test in FermiLib is clearly random:

for i in range(len(initial_state)):
            initial_state[i] = (random.random() *
                                numpy.exp(1j * 2 * numpy.pi * random.random()))

So maybe that is the problem...

idk3 commented 7 years ago

Good point, is the best option to set a numpy seed for those? Could alternatively raise the trotter number. (Don't want to have to set the full vector, but can see how it might look hacky otherwise)

On Thu, Aug 17, 2017, 00:15 Damian Steiger notifications@github.com wrote:

I don't know and currently I don't have FermiLib installed to debug.

Given that ProjectQ did not change in the last 22 days, my bet is an error in FermiLib as otherwise it would/could have appeared earlier. Might be because of randomness. If you like you can seed the random number generator of ProjectQ (see docs http://projectq.readthedocs.io/en/latest/projectq.backends.html?highlight=simulator#projectq.backends.Simulator) but the test in FermiLib is clearly random:

for i in range(len(initial_state)): initial_state[i] = (random.random() numpy.exp(1j 2 numpy.pi random.random()))

So maybe that is the problem...

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ProjectQ-Framework/FermiLib/pull/145#issuecomment-322988902, or mute the thread https://github.com/notifications/unsubscribe-auth/AKRqnbd2jeMoUiPxdU2atKNkninjNk3Oks5sY-icgaJpZM4O5bm9 .

babbush commented 7 years ago

You should absolutely hard seed any random tests!

On Aug 17, 2017 00:26, "idk3" notifications@github.com wrote:

Good point, is the best option to set a numpy seed for those? Could alternatively raise the trotter number. (Don't want to have to set the full vector, but can see how it might look hacky otherwise)

On Thu, Aug 17, 2017, 00:15 Damian Steiger notifications@github.com wrote:

I don't know and currently I don't have FermiLib installed to debug.

Given that ProjectQ did not change in the last 22 days, my bet is an error in FermiLib as otherwise it would/could have appeared earlier. Might be because of randomness. If you like you can seed the random number generator of ProjectQ (see docs http://projectq.readthedocs.io/en/latest/projectq. backends.html?highlight=simulator#projectq.backends.Simulator) but the test in FermiLib is clearly random:

for i in range(len(initial_state)): initial_state[i] = (random.random() numpy.exp(1j 2 numpy.pi random.random()))

So maybe that is the problem...

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ProjectQ-Framework/FermiLib/pull/145# issuecomment-322988902, or mute the thread https://github.com/notifications/unsubscribe-auth/ AKRqnbd2jeMoUiPxdU2atKNkninjNk3Oks5sY-icgaJpZM4O5bm9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ProjectQ-Framework/FermiLib/pull/145#issuecomment-322991133, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlTf3-m-3EzjUdt-Saitkr_vzOH5kl_ks5sY-s8gaJpZM4O5bm9 .

damiansteiger commented 7 years ago

For a start, I would seed the random.random(). No need to seed the ProjectQ simulator as you don't collapse the wavefunction or any other process which requires randomness...

But yes, if it keeps failing for many seeds, I would play with the number of Trotter steps...

babbush commented 7 years ago

@idk3 can you please fix this unseeded random test?

idk3 commented 7 years ago

Added https://github.com/ProjectQ-Framework/FermiLib/pull/147 which should address this!