title: Sage: same code, (vastly) different results locally and at aleph.sagemath.org
body: <p>I have SageMath 9.4 for Ubuntu 20.04 downloaded from <a href="http://www-ftp.lip6.fr/pub/math/sagemath/linux/64bit/sage-9.4-Ubuntu_20.04-x86_64.tar.bz2" rel="nofollow noreferrer">a french mirror</a> and I am trying to run an <a href="https://bitbucket.org/malb/lwe-estimator" rel="nofollow noreferrer">LWE estimator</a> by <a href="https://www.degruyter.com/document/doi/10.1515/jmc-2015-0016/html" rel="nofollow noreferrer">Albrecht et al</a>.</p>
  <h3>Running on Aleph</h3>
  <p>Without any problem, I can paste <a href="https://bitbucket.org/malb/lwe-estimator/src/master/estimator.py" rel="nofollow noreferrer">the estimator.py code</a> into <a href="http://aleph.sagemath.org/" rel="nofollow noreferrer">Aleph</a>, followed by my parameters, e.g.:</p>
  <pre><code>n, stdv = 1024, 2^-30.0
  set_verbose(1)
  _ = estimate_lwe(n, sqrt(2*pi)*stdv, 2^32,  reduction_cost_model=BKZ.sieve, secret_distribution=(0,1))
  </code></pre>
  <p>from which I obtain</p>
  <pre><code>Warning: the LWE secret is assumed to have Hamming weight 512.
  usvp: rop: â‰ˆ2^108.0,  red: â‰ˆ2^108.0,  Î´_0: 1.005242,  Î²:  266,  d: 1889,  m:      864,  repeat:        1,  k:        0,  postprocess:        0
   dec: rop: â‰ˆ2^131.5,  m:     1198,  red: â‰ˆ2^131.5,  Î´_0: 1.004529,  Î²:  332,  d: 2222,  babai: â‰ˆ2^117.5,  babai_op: â‰ˆ2^132.6,  repeat:       17,  Îµ: 0.250000
  dual: rop: â‰ˆ2^112.1,  m:      994,  red: â‰ˆ2^112.1,  Î´_0: 1.005070,  Î²:  280,  repeat: â‰ˆ2^60.8,  d: 1986,  c:        8,  k:       32,  postprocess:        1
  </code></pre>
  <p>which tells me that I have 108.0 bits of security (2nd line: <code>usvp: rop: â‰ˆ2^108.0</code>). Until here -- fine.</p>
  <h3>Running locally</h3>
  <p>Now I need to process a heap of parameters automatically, which I am trying to run locally (using the aforementioned version of SageMath). Problems arise (with 1-3 possibly irrelevant, 4 indeed relevant):</p>
  <ol>
  <li>With the very same code I get: <code>ImportError: cannot import name complex_mpfr</code>, which seems to be resolved by adding <code>import sage.all</code> in the very beginning.</li>
  <li>Then I get: <code>n, stdv = 1024, 2^-30.0 .. TypeError: unsupported operand type(s) for ^: 'int' and 'float'</code> which I fix by replacing <code>2^-30.0</code> with <code>9.3132257e-10</code>.</li>
  <li>Next run: <code>NameError: name 'set_verbose' is not defined</code> which I solved by importing <code>from sage.misc.verbose import verbose, set_verbose, get_verbose</code> (still some warnings -- deprecated stuff and syntax -- which I ignore)</li>
  <li>Final run: I get the results,</li>
  </ol>
  <p>but with completely different numbers:</p>
  <pre><code>Warning: the LWE secret is assumed to have Hamming weight 512.
  usvp: rop: â‰ˆ2^44.9,  red: â‰ˆ2^44.9,  Î´_0: 1.013310,  Î²:   40,  d: 1024,  m:       -1,  repeat:        1,  k:        0,  postprocess:        0
   dec: rop: â‰ˆ2^43.6,  m:     -614,  red: â‰ˆ2^43.6,  Î´_0: 1.021759,  Î²:   40,  d:  410,  babai:        1,  babai_op: â‰ˆ2^15.1,  repeat:        1,  Îµ:        1
  </code></pre>
  <p>(and then <code>TypeError: unable to convert '2.5275472536193645856387667200778292581e-30+2.6845375638424411831060264943943048062e9*I' to a real number</code> which I ignore)</p>
  <p>Compared to 108.0 from Aleph, my local result 44.9 is completely false, though running the same code. I also pasted the modified code into Aleph and it still gives 108.0.</p>
  <p>Find <a href="https://pastebin.pl/view/ce3f0579" rel="nofollow noreferrer">my final code at Pastebin</a> (gives results both on Aleph and locally).</p>