Menu

Small reproducibility bug inheireted from Vina

2020-10-27
2020-10-27
  • Maria Kadukova

    Maria Kadukova - 2020-10-27

    I have recently noticed a minor bug in AutoDock Vina that also reproduces in smina under specific conditions.
    Dependent on the compiler, with which an executable was built, the output generated with the same seed may be different.
    The problem is in the
    qt random_orientation(rng& generator)
    function from the quaternion code https://sourceforge.net/p/smina/code/ci/master/tree/src/lib/quaternion.cpp .
    This function is used to generate random rotations. However, since the order of function arguments evaluation is undefined (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-order), the random generation of quaternion components that are passed to the quaternion's constructor

        qt q(random_normal(0, 1, generator), 
             random_normal(0, 1, generator), 
             random_normal(0, 1, generator), 
             random_normal(0, 1, generator));
    

    can be evaluated in different order. This does not make any sense if the conformation is randomly generated, but with a fixed seed the evaluation order becomes quite important, as we need to obtain the same sequence of random numbers. In my system (Ubuntu 18), arguments are evaluated from left to right if built with clang, and right to left if built with g++, resulting in the same four numbers arranged 'back and forth', and thus in different conformations.
    I think it could be nice to fix it with something like

        fl a0 = random_normal(0, 1, generator);
        fl a1 = random_normal(0, 1, generator);
        fl a2 = random_normal(0, 1, generator);
        fl a3 = random_normal(0, 1, generator);
        qt q(a0, a1, a2, a3);
    

    to be sure that the results generated with the same seed will be reproducible for any compiler.

     

    Last edit: Maria Kadukova 2020-10-27
  • David Koes

    David Koes - 2020-10-27

    I can't say that standardizing random number generation across different compilers makes my top 1000 list of desired code improvements, but it is a simple and safe change.
    https://sourceforge.net/p/smina/code/ci/7bd30e0a654cdee1d4935fea4ad1eec8038e63d2/

     
  • Maria Kadukova

    Maria Kadukova - 2020-10-27

    Thank you!

    I can't say that standardizing random number generation across different compilers makes my top 1000 list of desired code improvements

    :) I personally never use seeds for docking and discovered this issue when preparing a small educational example that was supposed to be fully reproducable. Before building everything on Mac, I did it on my Linux system with clang, and suddenly discovered that the output poses and energies are different.

     

    Last edit: Maria Kadukova 2020-10-27

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.