Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to build hmatrix-tests-0.4.1.0 with GHC 7.10.2 and stack #144

Closed
samvher opened this issue Aug 28, 2015 · 7 comments
Closed

Failure to build hmatrix-tests-0.4.1.0 with GHC 7.10.2 and stack #144

samvher opened this issue Aug 28, 2015 · 7 comments

Comments

@samvher
Copy link

samvher commented Aug 28, 2015

I updated my haskell-platform to try to build your current master (my base version was insufficient earlier), I have not yet managed to build the version in this repository but I now also get an error if I stack install hmatrix-tests after successfully installing hmatrix and hmatrix-gsl:

Run from outside a project, using implicit global config
Using resolver: lts-3.2 from global config file: /Users/sam/.stack/global/stack.yaml
NOTE: the install command is functionally equivalent to 'build --copy-bins'
Populated index cache.    
hmatrix-tests-0.4.1.0: configure
hmatrix-tests-0.4.1.0: build

--  While building package hmatrix-tests-0.4.1.0 using:
      /Users/sam/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/sam/.stack/snapshots/x86_64-osx/lts-3.2/7.10.2/pkgdb/ /var/folders/19/5wrdz7h93tq2qx27bvhbkt9r0000gn/T/stack5697/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ build --ghc-options -hpcdir .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/hpc/.hpc/ -ddump-hi -ddump-to-file
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/sam/.stack/global/.stack-work/logs/hmatrix-tests-0.4.1.0.log

    Configuring hmatrix-tests-0.4.1.0...
    Building hmatrix-tests-0.4.1.0...
    Preprocessing library hmatrix-tests-0.4.1.0...
    [1 of 4] Compiling Numeric.LinearAlgebra.Tests.Properties ( src/Numeric/LinearAlgebra/Tests/Properties.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Numeric/LinearAlgebra/Tests/Properties.o )

    src/Numeric/LinearAlgebra/Tests/Properties.hs:197:1:
        Illegal equational constraint ComplexOf t ~ Complex Double
        (Use GADTs or TypeFamilies to permit this)
        When checking that ‘eigProp’ has the inferred type
          eigProp :: forall t.
                     (Field t, ComplexOf t ~ Complex Double) =>
                     Matrix t -> Bool

The reason I haven't managed to install the master version yet is related to stack (I installed the hackage version first, then if I install the master version of hmatrix stack installs it locally in the project directory, which means I can't seem to make it available when I try to install gsl and tests, because the old version is still installed globally).

@samvher
Copy link
Author

samvher commented Aug 28, 2015

Ok! After some more fiddling and nosing around, I found that hmatrix-tests does in fact build (the master version) on the latest GHC so that problem seems to be solved. Also, the mult tests that failed for me before are now successful. I managed to install the master version using stack (I overlooked something in the FAQ allowing me to install multiple packages locally).

However! The tests still don't completely pass on my machine :( Here is the output:

------ index
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ mult Double
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ sub-trans
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ ctrans
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ lu
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ inv (linearSolve)
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ luSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ ldlSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ cholSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ luSolveLS
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests (5% trivial).
+++ OK, passed 100 tests (5% trivial).
------ pinv (linearSolveSVD)
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ det
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ svd
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ eig
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ nullSpace
+++ OK, passed 100 tests (51% trivial).
+++ OK, passed 100 tests (61% trivial).
------ qr
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ hess
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ schur
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ chol
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
*** Failed! Falsifiable (after 13 tests): 
PosDef (11><11)
 [  39.730968786211314,  0.1979928766936253,  12.465706523953791, -0.5112077392772991,  7.5960057283175235, -0.9670593597820314,  -5.935870547515698,   1.797363859395338, -1.0094703027385559,   5.577468310659227, -0.4972226349924339
 ,  0.1979928766936253,   75.14561462562708, -1.9974254725609648,  -1.770717997023017,  -3.503265657233948, 0.17261250443893594, -1.2879266102914397,   4.885056752728854,   6.156667250780151, -0.9378297974404508,   4.135399937757443
 ,  12.465706523953791, -1.9974254725609648,    55.4639573498602,  -4.012516656111143, -1.3331487266976585,  -3.722591446859042,   4.247657716781713, -2.0487171370893766,  -0.217294516677691,  1.6483887963949144,  0.2305992452092958
 , -0.5112077392772991,  -1.770717997023017,  -4.012516656111143,    57.5933371596545,   4.353451911593413, -2.4467335943194275, -3.2416994423985446,   5.227408327522042,  0.2937690710760158,   5.132618559884971, -2.6989748313524697
 ,  7.5960057283175235,  -3.503265657233948, -1.3331487266976585,   4.353451911593413,  48.142589092661886,  1.4195383322100628,   6.885535899430806,  1.1577267216715637,  10.790656256591262,  -6.367045247973574,   1.308532987164213
 , -0.9670593597820314, 0.17261250443893594,  -3.722591446859042, -2.4467335943194275,  1.4195383322100628,   77.33759994064724, -0.8067064745944341,  -3.306402338475162, -0.6385043765254745,  2.3508866716134627,  2.1978094219888655
 ,  -5.935870547515698, -1.2879266102914397,   4.247657716781713, -3.2416994423985446,   6.885535899430806, -0.8067064745944341,  42.692662060282096,  -4.873939713820163,   5.856905128308519,   -5.62027240991787,   5.284443287348966
 ,   1.797363859395338,   4.885056752728854, -2.0487171370893766,   5.227408327522042,  1.1577267216715637,  -3.306402338475162,  -4.873939713820163,   59.36434759773856,    5.10949999350114,  3.6303068127909004,  3.4362190675202573
 , -1.0094703027385559,   6.156667250780151,  -0.217294516677691,  0.2937690710760158,  10.790656256591262, -0.6385043765254745,   5.856905128308519,    5.10949999350114,  37.417326290979275,  1.4344468313481462,  -3.282705193366731
 ,   5.577468310659227, -0.9378297974404508,  1.6483887963949144,   5.132618559884971,  -6.367045247973574,  2.3508866716134627,   -5.62027240991787,  3.6303068127909004,  1.4344468313481462,  48.883781657971305,    1.27888571805805
 , -0.4972226349924339,   4.135399937757443,  0.2305992452092958, -2.6989748313524697,   1.308532987164213,  2.1978094219888655,   5.284443287348966,  3.4362190675202573,  -3.282705193366731,    1.27888571805805,    60.1246709433958 ]

@albertoruiz
Copy link
Collaborator

Interesting! Can you please run the following small program:


{-# LANGUAGE FlexibleContexts #-}

import Numeric.LinearAlgebra

a = (11><11)
[ 39.730968786211314, 0.1979928766936253, 12.465706523953791, -0.5112077392772991, 7.5960057283175235, -0.9670593597820314, -5.935870547515698, 1.797363859395338, -1.0094703027385559, 5.577468310659227, -0.4972226349924339
, 0.1979928766936253, 75.14561462562708, -1.9974254725609648, -1.770717997023017, -3.503265657233948, 0.17261250443893594, -1.2879266102914397, 4.885056752728854, 6.156667250780151, -0.9378297974404508, 4.135399937757443
, 12.465706523953791, -1.9974254725609648, 55.4639573498602, -4.012516656111143, -1.3331487266976585, -3.722591446859042, 4.247657716781713, -2.0487171370893766, -0.217294516677691, 1.6483887963949144, 0.2305992452092958
, -0.5112077392772991, -1.770717997023017, -4.012516656111143, 57.5933371596545, 4.353451911593413, -2.4467335943194275, -3.2416994423985446, 5.227408327522042, 0.2937690710760158, 5.132618559884971, -2.6989748313524697
, 7.5960057283175235, -3.503265657233948, -1.3331487266976585, 4.353451911593413, 48.142589092661886, 1.4195383322100628, 6.885535899430806, 1.1577267216715637, 10.790656256591262, -6.367045247973574, 1.308532987164213
, -0.9670593597820314, 0.17261250443893594, -3.722591446859042, -2.4467335943194275, 1.4195383322100628, 77.33759994064724, -0.8067064745944341, -3.306402338475162, -0.6385043765254745, 2.3508866716134627, 2.1978094219888655
, -5.935870547515698, -1.2879266102914397, 4.247657716781713, -3.2416994423985446, 6.885535899430806, -0.8067064745944341, 42.692662060282096, -4.873939713820163, 5.856905128308519, -5.62027240991787, 5.284443287348966
, 1.797363859395338, 4.885056752728854, -2.0487171370893766, 5.227408327522042, 1.1577267216715637, -3.306402338475162, -4.873939713820163, 59.36434759773856, 5.10949999350114, 3.6303068127909004, 3.4362190675202573
, -1.0094703027385559, 6.156667250780151, -0.217294516677691, 0.2937690710760158, 10.790656256591262, -0.6385043765254745, 5.856905128308519, 5.10949999350114, 37.417326290979275, 1.4344468313481462, -3.282705193366731
, 5.577468310659227, -0.9378297974404508, 1.6483887963949144, 5.132618559884971, -6.367045247973574, 2.3508866716134627, -5.62027240991787, 3.6303068127909004, 1.4344468313481462, 48.883781657971305, 1.27888571805805
, -0.4972226349924339, 4.135399937757443, 0.2305992452092958, -2.6989748313524697, 1.308532987164213, 2.1978094219888655, 5.284443287348966, 3.4362190675202573, -3.282705193366731, 1.27888571805805, 60.1246709433958 ] :: Matrix R

exactProp m = chol (trustSym m) == chol (trustSym (m+0))

main = do
print (exactProp a)
print $ chol (trustSym a) - chol (trustSym (a+0))


@albertoruiz
Copy link
Collaborator

Sorry for copying directly the code. The program is also here:

http://dis.um.es/profesores/alberto/material/hmatrix/bugchol.hs

@samvher
Copy link
Author

samvher commented Aug 28, 2015

This is the output:

True
(11><11)
 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -8.881784197001252e-16, 1.1102230246251565e-16, -1.1102230246251565e-16
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0
 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,                    0.0,                    0.0,                     0.0 ]

@samvher
Copy link
Author

samvher commented Aug 28, 2015

(As an aside, out of personal interest, have you ever considered to/do you think it would be very difficult to put a GPU accelerated back-end behind hmatrix? E.g. cuBLAS + MAGMA/CULAtools? I think something like that behind a pure interface could be really powerful, for example for building Theano-like tools.)

@albertoruiz
Copy link
Collaborator

Again this is a problem with the tolerance of the test, the computation is correct. But in this case it is interesting to see that in some machines a+0 may not be exactly equal to a. This test was introduced to catch some old problem, but now it must be fixed or removed. You can comment out lines 666 and 667 in packages/tests/src/Numeric/LinearAlgebra/Tests.hs and recompile and run the tests to see if there are any other failures.

Thanks for testing!

A GPU back-end would be very useful but I have not yet tried it (some time ago only float elements were supported, if I am not mistaken) but now things are different with the explosion of deep learning. It should be easy to link with a GPU based blas/lapack library if the API is the same (although I don't know if memory transfers could be an issue). I will look into this.

I have just seen that there are some linear algebra libraries using cublas and magma:

https://github.com/bmsherman/LinAlg

@samvher
Copy link
Author

samvher commented Aug 28, 2015

That package looks interesting, I hadn't seen it before.

I commented out the faulty tests and everything works now.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants