Live data from Hacker News

Jax vs. Julia (Vs PyTorch)

kidger.site

81–90 of 111 posts

Re: Jax vs. Julia (Vs PyTorch)

#81
post #35
post #23

Earlier quoted context omitted.

Exactly. I actually find Julia's ecosystem (not the language) way more approachable than Python's. In Python, most libraries are big monoliths. Whereas in Julia, libraries are small and composable. Furthermore, it's the same language all the way down. Python's libraries are superb, but the learning curve to develop (not to use them) is really steep.

I don't understand. What do you mean by "learning curve to develop" an existing Python library?

Python's story for package development is a mess compared to Julia. If you know what you're doing you can make a new Julia package in the general registry with unit tests, CI, and code coverage in about 30 minutes.

To contribute to an existing repository, you can ]dev the package to download the git repository, @edit a function to open the source in an editor, and push the changes to a PR in about 10 minutes. This makes it much easier for package users to turn into package developers.

I've contributed to a bunch of Julia libraries that if I still used python, I wouldn't have contributed to the equivalent python library because contributing to Julia packages is at least an order of magnitude easier.

Re: Jax vs. Julia (Vs PyTorch)

#82
post #59

Earlier quoted context omitted.

On HN I am often seeing libraries/blog authors react very quickly to references of their projects. I'm curious, how do you achieve this, is it a coincidence and where you reading HN comments, or do you have a crwaler/API than send you a notification when your project github link is found in a new HN comment ?

I was actually socializing with folks at the Cambridge Area Julia meetup where I gave a talk on Enzyme’s Julia bindings no less when someone shared this. So in this case pure coincidence.

Did you catch your plane?

Re: Jax vs. Julia (Vs PyTorch)

#83
The main idea (both pro and con) with Jax is its "automatic performance" model. Essentially, Jax uses a tracer down to XLA which then does some linear algebra optimizations to generate code. For the DSL case where Jax is generally used, this tends to be "good enough" for a good number of use cases. The issue is that when it's not "good enough", it doesn't give package developers much recourse to really dig into the details and optimize for the things which the compiler (and compilers in general) is unable to do.

For example, we released the library SimpleChains.jl that was optimized for a lot of cases for small neural networks (https://julialang.org/blog/2022/04/simple-chains/). There was discussion about Jax, and we saw that for any case where individuals had a modern multi-core CPU threaded machine setup, SimpleChains.jl had about a 10x performance improvement on CPU over the Jax equinox library. This shouldn't be surprising to anyone because the details of how that was achieved was quite clear (memory handling, manual SIMD bits, etc.), though those of course are not the kinds of things you get "automatically" with either language. The main difference of having a full programming language instead of a DSL is that such code can be written to manually optimize what the compilers are not doing.

And this is the pattern that tends to repeat. For small static-like differential equation solves, Jax is fine, but for example the PDE code optimizations done in this tutorial (https://diffeq.sciml.ai/dev/tutorials/faster_ode_example/#Ex...) are completely incompatible with the Jax programming model and accelerate the PDE solve by more than 10x. And if you look into detail at things showing Jax is fine for PDEs, they are using the slower code style and comparing to that slower Julia code, not the faster iteration form. Of course, these are optimizations most people don't know to do so they are the kind of extra order of magnitude you see in Julia packages over Jax, but not as much in user code.

Another repeat of this pattern is the sub-optimality of vmap. It doesn't run code completely independently so it's not optimal in CPU cases where you'd want to effectively use multithreading or MPI, but it's also not generating kernels so it's not optimal in the case of GPUs (for example, we have a new GPU-based ODE solver coming out soon that outperforms the older Julia form and the Jax form by like 100x. Again, no surprises here because special-built GPU kernels have already demonstrated this as possible from C++ directly in this context). So vmap will always get you parallelism, but when you build a library you have to leave it behind at some point if you really want to keep optimizing.

I think what it does is admirable. If you can get a code to compile with Jax (which is a big if, it does require pure functions and a lot of extra things Python code normally doesn't satisfy) then it does get you something relatively performant. But there's a reason why what's mentioned here is Flux and Zygote, not SimpleChains and Enzyme, the real tools the Julia community is pushing towards with the full mutation support and the full speed behind it. Jax can compare in the former case, but not the latter case.

Re: Jax vs. Julia (Vs PyTorch)

#84

Earlier quoted context omitted.

Unicode should not be in public APIs. This is a standard around Julia. Flux is breaking the standard. Yes, it's not a good thing.

Interesting! do you have any links talking about that standard? I'm super interested in Julia and this seems like a good opportunity to learn something I've been missing so far.

I'm not sure if/where it's formalized, but it's just generally something that's been enforced throughout Julia's Base, along with many of the package organizations (like SciML among others). It's something that would be mentioned at code review time by most contributors. It's why you don't see unicode keyword arguments. There's a lot of reasons. I think the best one is that you want the API to be compatible with old terminals you tend to get on HPCs which do not tend to support unicode. We should probably make it a part of the standard formatter rules or something at this point.

Re: Jax vs. Julia (Vs PyTorch)

#85

Earlier quoted context omitted.

And if you ever do want to edit the code, you have to know the name of every non-ASCII symbol the codebase uses if you want to type out those same symbols without copying and pasting them. If you're not familiar with the material, entering a character like ξ can be a real challenge, and is actually more keystrokes than just typing "xi".

For me it’s one keystroke, with the dead-Greek modifier key. I’ll do it right here, by typing : ξ

How do you go from reading ξ to saying "oh I need to press " ?

Re: Jax vs. Julia (Vs PyTorch)

#86
post #59

Earlier quoted context omitted.

I was actually socializing with folks at the Cambridge Area Julia meetup where I gave a talk on Enzyme’s Julia bindings no less when someone shared this. So in this case pure coincidence.

Did you catch your plane?

I did!

Re: Jax vs. Julia (Vs PyTorch)

#87

Earlier quoted context omitted.

Interesting! do you have any links talking about that standard? I'm super interested in Julia and this seems like a good opportunity to learn something I've been missing so far.

I'm not sure if/where it's formalized, but it's just generally something that's been enforced throughout Julia's Base, along with many of the package organizations (like SciML among others). It's something that would be mentioned at code review time by most contributors. It's why you don't see unicode keyword arguments. There's a lot of reasons. I think the best one is that you want the API to be compatible with old…

Word. Thank you for the response.

Re: Jax vs. Julia (Vs PyTorch)

#88
post #85

Earlier quoted context omitted.

For me it’s one keystroke, with the dead-Greek modifier key. I’ll do it right here, by typing : ξ

How do you go from reading ξ to saying "oh I need to press " ?

Because I recognized the Greek letter that we usually represent in English as “xi”. In fact I wasn’t sure, but I guessed x, and it turned out to be right. For each letter there’s usually one obvious latin-alphabet equivalent.

I bet you know right away how to type α and β.

Re: Jax vs. Julia (Vs PyTorch)

#89
post #42

Earlier quoted context omitted.

What? Did you not read the parent of this thread? > strongly agree with readability in my opinion its cause Academia people live in "bubbles" and they assume everyone knew what a domain specific terms and greek letters means In any case, I program HPC stuff myself with pytorch and no - I don't know the Greek alphabet and probably don't understand "non trivial math". The assumption that these people can't contribute i…

So you think there's a cabal of "gatekeeper" scientists who are trying to hold the hordes of capable (yet somehow unfamiliar with the corresponding mathematical literature) engineers from making useful contributions to their libraries, because they use the conventional notation from the scientific literature? They should instead tread carefully and dispose of all Greek letters in their code to ensure you are not put…

> So you think there's a cabal of "gatekeeper" scientists

No. I suggested I myself have seen gatekeeping and referenced your comment as example. Make of that what you will, but don't extrapolate it to a conspiracy theory I didn't suggest.

Re: Jax vs. Julia (Vs PyTorch)

#90

Another massive frustration for me is that Julia has no formal way to say "here are public functions and these are private" but does have a completely orthogonal way of saying "these are functions that will populate your global namespace if you use `using`", i.e. `export variable_name`, and people absolutely confuse the hell out of these. I don't think there's even agreement in the Julia community if you should use `…

I use export for my public functions. What is wrong with that? How exactly does Python signal what is public? Nothing but conventions like underscore, which btw Julia developers use as well. If I really really don't want somebody to use a function, I might underscore it but generally I don't see the point.

The underscore naming convention is far from ubiquitous in either the Python or Julia communities.

The more practical indicator of a function being "public" is whether or not it appears in the published API documentation. Unlike Julia, Python projects are more likely to have complete documentation (or even documentation at all). So there is a better understanding of what "public" means in Python. Without docs, it's a guessing game.

Post reply on HN