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

Fix compilation for Julia builds without GPL libraries #2

Closed
wants to merge 1 commit into from
Closed

Fix compilation for Julia builds without GPL libraries #2

wants to merge 1 commit into from

Conversation

jonathan-conder-sm
Copy link

I'm trying to use Flux.jl, which works fine without SuiteSparse provided you don't use any sparse matrices. However it depends on this package, which fails to compile if Base.USE_GPL_LIBS == false.

@ElOceanografo
Copy link
Owner

Can you confirm what the dependency chain is from Flux to here? I assume it's Zygote > ChainRules > SparseInverseSubset. (This package is required to calculate the rrule for the logdet of a sparse matrix, see JuliaDiff/ChainRules.jl#730.)

If that's the case, I think it might make more sense to put these conditionals in ChainRules? That package is still importing SuiteSparse and relying on its types, so I suspect you'd still get these compilation errors (though I haven't checked).

@jonathan-conder-sm
Copy link
Author

jonathan-conder-sm commented Oct 25, 2023

Can you confirm what the dependency chain is from Flux to here? I assume it's Zygote > ChainRules > SparseInverseSubset.

Yeah that's right

If that's the case, I think it might make more sense to put these conditionals in ChainRules? That package is still importing SuiteSparse and relying on its types, so I suspect you'd still get these compilation errors (though I haven't checked).

It works fine after this patch. It's only CHOLMOD, SPQR and UMFPACK that are missing from SuiteSparse.

@ElOceanografo
Copy link
Owner

After some more consideration, I think this logic really does belong in ChainRules rather than here. sparseinv(A::SparseMatrixCSC) just takes the Cholesky decomposition and then passes that factorization to sparseinv(F::SuiteSparse.CHOLMOD.Factor), which calls get_ldup, so the whole package will end up broken on non-GPL builds of Julia.

I think a better approach would be not defining the rrules for (log)determinants of sparse matrices in ChainRules if USE_GPL_LIBS == false, or perhaps implement an alternative version of them that raises an informative error saying that they depend on GPL libraries and data structures and so aren't available on GPL-free builds.

@jonathan-conder-sm
Copy link
Author

Makes sense to me.

I'm not going to do any more work on this though: after I made this PR I realised I can set USE_GPL_LIBS = true and just not distribute the GPL binaries. There's still an error message at compile time, from SparseArrays.__init__, but it doesn't prevent compilation and is easy to patch out.

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

Successfully merging this pull request may close these issues.

2 participants