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

Latte binary count called latte-count on archlinux #38651

Open
2 tasks done
videlec opened this issue Sep 12, 2024 · 10 comments
Open
2 tasks done

Latte binary count called latte-count on archlinux #38651

videlec opened this issue Sep 12, 2024 · 10 comments
Labels

Comments

@videlec
Copy link
Contributor

videlec commented Sep 12, 2024

In my setup (see below for details), the program count that sage expects to be from LattE (integral points count in polytope) is actually a binary from llvm.

Steps To Reproduce

With latte installed in SageMath 10.2 in a conda environment, the following computation fails

sage: V = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
....:      [0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
....:      [0, 0, 0, 1, 0, 0, 0, 0, 1, 0],
....:      [0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
....:      [0, 0, 0, 1, 0, 0, 1, 0, 0, 0],
....:      [0, 0, 0, 1, 0, 1, 0, 0, 0, 0],
....:      [0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
....:      [0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
....:      [0, 1, 0, 0, 0, 1, 0, 0, 0, 0],
....:      [1, 0, 0, 0, 1, 0, 0, 0, 0, 0]]
sage: P = Polyhedron(V)
sage: P.integral_points_count()

Expected Behavior

Same as

sage: len(P.integral_points())
10

Actual Behavior

File ~/sage/geometry/polyhedron/base_QQ.py:214, in Polyhedron_QQ.integral_points_count(self, verbose, use_Hrepresentation, explicit_enumeration_threshold, preprocess, **kwds)
    211     use_Hrepresentation = True
    213 from sage.interfaces.latte import count
--> 214 return count(
    215         p.cdd_Hrepresentation() if use_Hrepresentation else p.cdd_Vrepresentation(),
    216         cdd=True,
    217         verbose=verbose,
    218         **kwds)

File ~/sage/interfaces/latte.py:175, in count(arg, ehrhart_polynomial, multivariate_generating_function, raw_output, verbose, **kwds)
    173     else:
    174         err = ":\n" + err
--> 175     raise RuntimeError("LattE integrale program failed (exit code {})".format(ret_code) + err.strip())
    177 ans = bytes_to_str(ans)
    179 # There's an error handler below that uses the numOfLatticePoints
    180 # file created by latte, so we can't cleanup() the temporary
    181 # directory here. Instead we have to clean it up before the
    182 # (several) return statements.

RuntimeError: LattE integrale program failed (exit code 2):
usage: /usr/bin/count <expected line count>

Additional Information

No response

Environment

- **OS**: archlinux with sage in a conda environment, LattE not installed in conda and llvm installed on the system
- **Sage Version**: 10.2

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@videlec videlec added the t: bug label Sep 12, 2024
@maxale
Copy link
Contributor

maxale commented Sep 12, 2024

It works fine in https://sagecell.sagemath.org also running SageMath version 10.2

@videlec
Copy link
Contributor Author

videlec commented Sep 14, 2024

It works fine in https://sagecell.sagemath.org also running SageMath version 10.2

Thanks for trying this out! Do you know which version of LattE runs on sagecell?

@videlec
Copy link
Contributor Author

videlec commented Sep 14, 2024

The problem comes from the fact that my /usr/bin/count is not from the LattE suite but llvm. The LattE binaries are called: latte-count, latte-maximize, latte-minimize (see details on the package page). Not sure to know what solution should be adapted in sage...

@maxale
Copy link
Contributor

maxale commented Sep 15, 2024

@videlec: Nice find! It's worth it to update the title of this issue accordingly.

@videlec videlec changed the title Latte integral point count sometimes fail Latte binary count called latte-count on archlinux Sep 15, 2024
@videlec
Copy link
Contributor Author

videlec commented Sep 17, 2024

@antonio-rojas @mkoeppe any idea how to solve this consistently?

@antonio-rojas
Copy link
Contributor

@antonio-rojas @mkoeppe any idea how to solve this consistently?

There are two issues here: first one is Sage accepting any executable named count. This could be easily solved by adding an is_functional method to the Latte_count class in src/sage/features/latte.py that checks whether it actually comes from latte (by testing eg. that the output of the count command contains the "LattE" string).

The second issue is the conda-installed Sage choosing the system count executable over the conda one. I know nothing about conda, but I would expect stuff in conda to be run with a PATH that prioritizes conda's own bin paths over the system ones. Is that not the case?

@videlec
Copy link
Contributor Author

videlec commented Sep 17, 2024

@antonio-rojas @mkoeppe any idea how to solve this consistently?

There are two issues here: first one is Sage accepting any executable named count. This could be easily solved by adding an is_functional method to the Latte_count class in src/sage/features/latte.py that checks whether it actually comes from latte (by testing eg. that the output of the count command contains the "LattE" string).

This I can easily do. Thanks for the suggestion.

The second issue is the conda-installed Sage choosing the system count executable over the conda one. I know nothing about conda, but I would expect stuff in conda to be run with a PATH that prioritizes conda's own bin paths over the system ones. Is that not the case?

There is a priority of conda path over system paths. However, in my setup, LattE is not installed in conda.

@antonio-rojas
Copy link
Contributor

The second issue is the conda-installed Sage choosing the system count executable over the conda one. I know nothing about conda, but I would expect stuff in conda to be run with a PATH that prioritizes conda's own bin paths over the system ones. Is that not the case?

There is a priority of conda path over system paths. However, in my setup, LattE is not installed in conda.

OK, that makes sense then. I had interpreted "With latte installed in SageMath 10.2 in a conda environment" as you had installed latte from within sage.

@videlec
Copy link
Contributor Author

videlec commented Sep 19, 2024

#38678 does implement is_functional.

However, it could have worked in the initial setup (sage from conda, LattE from the system) if there was a way for sage to "discover automagically" count versus latte-count.

@antonio-rojas
Copy link
Contributor

However, it could have worked in the initial setup (sage from conda, LattE from the system) if there was a way for sage to "discover automagically" count versus latte-count.

As much as I would personally benefit from it (as it would allow me to get rid of the only remaining permanent downstream patch), I really don't think it is sage's job to cater to all possible downstream variations in the naming of executables. That could easily become a mess if each distro does its own thing.

The reasonable solution would be to convince upstream to rename its executables to something less generic.

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

No branches or pull requests

3 participants