-
Notifications
You must be signed in to change notification settings - Fork 21
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
use the juliacall package instead of julia #394
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #394 +/- ##
===========================================
- Coverage 87.43% 87.43% -0.01%
===========================================
Files 81 81
Lines 6137 6135 -2
===========================================
- Hits 5366 5364 -2
Misses 771 771
Continue to review full report in Codecov by Sentry.
|
# Conflicts: # mrmustard/utils/settings.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works! 💯
# Conflicts: # poetry.lock
I just added a hack to suppress the julia outputs that happen the first time you import it (in other words, the first time you increase the precision). If we don't mind the outputs happening in a fresh environment once, then I think we should revert that change. lmk what you think! |
confirmed offline, it's ok to have the output |
Context:
The
julia
python package is backed byPyCall
, andPyCall
kinda sucks.juliacall
/pythoncall
is a much easier package to work with, with very simple single-file configurationDescription of the Change:
Replace uses of the
julia
python package withjuliacall
and do a bit of re-naming/tidying.Benefits:
juliacall
requires much less configuration up-frontPkg.instantiate("julia_pkg")
thing we were doing before), it will do that automatically as well!Possible Drawbacks:
I do not know if performance is worse. It might even be better?If a reviewer could help me prove this, that would be fantastic. That said, the creator of PyCall himself seems to like PythonCall. @ziofil sent me a pretty simple notebook to use to confirm things, and the results suggest that the performance is basically the same, but we might save a smidge with some import overhead, idk.self.astensor
because for some reason, there is no auto-conversion happening from Julia to Python although it should theoretically happen withjuliacall
. See note on memory below.Notes on memory consumption
Julia arrays returned to Python are wrapped in a Python object called an
ArrayValue
. According to the FAQ, the object satisfies the Python array protocol, but is not actually a NumPy array. If needed (it sometimes is), the class has ato_numpy
function, and its default value forcopy
is True. If we don't intend on mutating array values, we can set this toFalse
and just read the values from Julia's allocated memory. The performance trade-offs would require extensive benchmarking to be sure which is better.