M2 icon indicating copy to clipboard operation
M2 copied to clipboard

check_11 "SumsOfSquares" fails on i386

Open d-torrance opened this issue 5 years ago • 6 comments

On a build of the master branch on a Debian unstable i386 chroot:

i2 : check_11 "SumsOfSquares"
-* running test 11 of package SumsOfSquares in file:
   ../../Macaulay2/packages/SumsOfSquares.m2:1376:1:
   rerun with: check_11 "SumsOfSquares" *-
 -- making test results
 ulimit -c unlimited; ulimit -t 700; ulimit -m 850000; ulimit -s 8192; ulimit -n 512;  cd /tmp/M2-2519019-0/31-rundir/; GC_MAXIMUM_HEAP_SIZE=400M "/root/M2/M2/BUILD/doug/usr-dist/i686-Linux-Debian-unknown/bin/M2-binary" --int --no-randomize --no-readline --silent --stop --print-width 77 -e 'needsPackage("SumsOfSquares", Reload => true, FileName => "/root/M2/M2/Macaulay2/packages/SumsOfSquares.m2")' <"/tmp/M2-2519019-0/30.m2" >>"/tmp/M2-2519019-0/30.tmp" 2>&1
/tmp/M2-2519019-0/30.tmp:0:1: (output file) error: Macaulay2 exited with status code 1
/tmp/M2-2519019-0/30.m2:0:1: (input file)
M2: *** Error 1
stdio:2:6:(3): error: test #11 of package SumsOfSquares failed

i3 : get "/tmp/M2-2519019-0/30.tmp"

o3 = -- -*- M2-comint -*- hash: 245165013
     --warning: file doc.css not installed yet in package Style
     --warning: file katex not installed yet in package Style

     i1 : --/root/M2/M2/Macaulay2/packages/SumsOfSquares.m2:1376: location of test code
           --lowerBound
              debug needsPackage "SumsOfSquares"

     i2 :     results := checkLowerBound("CSDP")
     -- warning: experimental computation over inexact field begun
     --          results not reliable (one warning given per session)

     o2 = {true, false, true, true, true, true, true}

     o2 : List

     i3 :     assert all(results,t->t=!=false);
     stdio:5:5:(3): error: assertion failed

Note that we're using the Debian coinor-csdp package.

d-torrance avatar Nov 04 '20 22:11 d-torrance

The same test is failing on Fedora rawhide:

i1 : debug needsPackage "SumsOfSquares";
 -- warning: symbol "Verbosity" in Core.Dictionary is shadowed by a symbol in SemidefiniteProgramming.Dictionary
 --   use the synonym Core$Verbosity

i2 : checkLowerBound "CSDP"
-- warning: experimental computation over inexact field begun
--          results not reliable (one warning given per session)
stdio:2:1:(3): error: can't promote number to ring

From what I can gather, the error is happening here: https://github.com/Macaulay2/M2/blob/ec9e9ac60ed4a8e791448942202f077a88a87e15/M2/Macaulay2/packages/SumsOfSquares.m2#L1147

In this case, f is a polynomial over QQ and bound is an RR, and subtracting them raises the error.

d-torrance avatar Aug 11 '24 12:08 d-torrance

This csdp update?

mahrud avatar Aug 11 '24 14:08 mahrud

I think so -- Fedora switched to packaging a git snapshot a few months ago (https://src.fedoraproject.org/rpms/csdp/c/5e697065b0adcecc9963f57ea20315fd0538ed69?branch=rawhide). So maybe the csdp output has changed a bit?

d-torrance avatar Aug 11 '24 17:08 d-torrance

Fixed in #3444

d-torrance avatar Sep 13 '24 17:09 d-torrance

Re-opening -- the original issue (which was unrelated to the new csdp package on Fedora) just popped up again on a GitHub build:

-- -*- M2-comint -*- hash: 856345161

i1 :  --lowerBound
         debug needsPackage "SumsOfSquares"

i2 :     results := checkLowerBound("CSDP")
-- warning: experimental computation over inexact field begun
--          results not reliable (one warning given per session)

o2 = {true, false, true, true, true, true, true}

o2 : List

i3 :     assert all(results,t->t=!=false);
stdio:4:10:(3): error: assertion failed

d-torrance avatar Sep 14 '24 19:09 d-torrance

I think I found the underlying issue with this bug. The matrix that we construct and send to CSDP depends on the order of monomials in a list that is constructed using a set, so the order is based on the hash codes of these monomials at runtime and isn't deterministic.

In fact, if we randomly shuffle the list, then the check fails about one fifth of the time:

--- a/M2/Macaulay2/packages/SumsOfSquares.m2
+++ b/M2/Macaulay2/packages/SumsOfSquares.m2
@@ -475,7 +475,7 @@ createSOSModel(Matrix,Matrix) := o -> (F,v) -> (
     -- monomials in vvT
     vvT := entries(v* transpose v);
     mons := g -> set first entries monomials g;
-    K1 := toList \\ sum \\ mons \ flatten vvT;
+    K1 := random(toList \\ sum \\ mons \ flatten vvT);
 
     -- monomials in F and not in vvT
     lmf := sum \\ mons \ flatten entries F;
i1 : debug needsPackage "SumsOfSquares"

i2 : tally apply(100, i -> all checkLowerBound "CSDP")
-- warning: experimental computation over inexact field begun
--          results not reliable (one warning given per session)

o2 = Tally{false => 19}
           true => 81

o2 : Tally

d-torrance avatar Sep 25 '24 11:09 d-torrance

Fixed in #3519

d-torrance avatar Oct 31 '24 02:10 d-torrance

Re-opening again...

This test failed on the arm64 build of the Debian package:

SumsOfSquares.m2:1438:5-1442:3 error:
 -- i2 :     results := checkLowerBound("CSDP")
 -- -- warning: experimental computation over inexact field begun
 -- --          results not reliable (one warning given per session)
 -- 
 -- o2 = {true, false, true, true, true, true, true}
 -- 
 -- o2 : List
 -- 
 -- i3 :     assert all(results,t->t=!=false);
 -- stdio:4:10:(3): error: assertion failed
 -- 
../m2/debugging.m2:18:13:(1):[9]: error: test(s) #11 of package SumsOfSquares failed.

d-torrance avatar Nov 01 '24 17:11 d-torrance

LOL

mahrud avatar Nov 01 '24 18:11 mahrud