Caching behaviour on imported archives

Hi everyone

I have an external .aiida archive containing a bunch of calculations done - by other people - with a workchain I wrote, which I then found to have a bug. Since such bug manifested itself only seldomly in the practice, a large part of these calculations gave valid results and only a small fraction must be repeated. My idea was then to import the archive and relaunch everything with the debugged workchain; having enabled caching on my profile, I was expecting that
i) once imported into my database, previously external nodes are treated as if I myself produced them
ii) all calculations not affected by the bug, being provided the same input, are thus fetched from the cache instead of being actually run

To test this behaviour, I created on purpose an .aiida archive with only one call of the workchain (the last I had submitted myself), removing the corresponding node from the process list, and imported it back (node 47304 below). Since I hadnā€™t changed the workchain in the meantime, I then tried to resubmit it (47370) expecting the caching mechanism to take care of it. Yet, the calculation called by the workchain was run from scratch. At this point, I tried to run it once again (47393) and this time the calculation was correctly picked up from the cache.

47304 2D ago AmarantaWorkChain :stop_button: Finished [11]
47309 2D ago run_ase_calculation :stop_button: Finished [0]
47370 33m ago AmarantaWorkChain :stop_button: Finished [11]
47372 33m ago run_ase_calculation :stop_button: Finished [0]
47393 4s ago AmarantaWorkChain :stop_button: Finished [11]
47395 3s ago run_ase_calculation :heavy_check_mark: :stop_button: Finished [0]

I then checked the hash and is_valid_cache attributes for the three calculation nodes:

In [1]: m,n,o = load_node(47309), load_node(47372), load_node(47395)
In [2]: m.base.caching.get_hash()
Out[2]: ā€˜18ee3e98b06fa157428b9595ce8ab53ac5f03b2f6cfa4f1bbfee1c77c7b0c693ā€™
In [3]: n.base.caching.get_hash()
Out[3]: ā€˜18ee3e98b06fa157428b9595ce8ab53ac5f03b2f6cfa4f1bbfee1c77c7b0c693ā€™
In [4]: o.base.caching.get_hash()
Out[4]: ā€˜18ee3e98b06fa157428b9595ce8ab53ac5f03b2f6cfa4f1bbfee1c77c7b0c693ā€™
In [5]: m.base.caching.is_valid_cache
Out[5]: True
In [6]: n.base.caching.is_valid_cache
Out[6]: True
In [7]: o.base.caching.is_valid_cache
Out[7]: True

To my surprise, each of them ā€“ and the imported one 47309, specifically ā€“ is valid cache indeed and the hashes are the same, yet the imported nodes are not correctly picked up. Do you have any idea of why?

(In passing: the workchain - still bugged - is running in ā€œsafe modeā€, just executing the first calculation, and this is why its status is Finished [11] (most required output is not produced). Still, the caching mechanism holds for calculations only and here the calculations finished correctly [0] so Iā€™m assuming this is not an issue)

Thanks a lot for your help
Best regards
Federico Orlando

P.S. at present, the workchain (still bugged) is running in ā€œsafe modeā€, just executing the first calculation, and that is why the status is Finished [11] (most required output is not produced). Stil, the caching mechanism holds for calculations only and here the calculation finished correctly [0]

Hi Federico,

just a quick question, which aiida-core version are you using? If youā€™re not using the latest 2.6.x version, please try to upgrade since there have been quite a few changes and improvements to the caching mechanism.
Also note that when upgrading from earlier aiida versions, you will have to recalculate the hashes. The same probably applies if youā€™ll import an archive where some results were calculated with older aiida version

verdi node rehash

See changelog for more details:

I havenā€™t looked at the details of your report yet, itā€™s possible there is still a bug that is somehow specific to imported archives.

itā€™s possible there is still a bug that is somehow specific to imported archives.

While looking at a piece of code related to caching, I found this comment

# computer names are changed by aiida-core if imported 
# and do not have same uuid.

Itā€™s possible that this is (one of) reasons why caching would not work as expected for imported archives. Itā€™s possible that this comment is outdated as it was definitely written before v2.6. Iā€™ll dig more into this.

The problem is most likely indeed that the computer for the new calculation does not match that of the original calculation from the archive. And since the Computerā€™s UUID is part of the cache:

The computed hash will be different. We decided to include the computerā€™s UUID in the hash, because in principle changing a computer can change the results of a calculation for a whole host of reasons. Different environments, different libraries etc.

Unfortunately, there is currently no way to temporarily disable this. Implementing this wouldnā€™t be trivial, because it wouldnā€™t be as simple as simply temporarily removing the computer UUID from the objects that are used in computing the hash, as that will only affect the hash of any new calculations, but the old calculations will still have the hash that was computed with the computerā€™s UUID. So after disabling it, you would first have to recompute the hash of all (or some target subset) of calculations. Which is not really practical. So I am not sure what pragmatic solution we could provide here, to be honest.

1 Like