256 points · by agnosticmantis · 4y ago · 95 comments
Personally, I think you do need to pay some living stipend to translators and core authors, within the context of their physical lives. The "libre" movement is real, and has to mature too.
I agree. Institutions like MIT have the monetary resources to support things like this, but they just don't want to. Universities have still not figured out a great model to hire people from industry to help them with their problems. Some places, like the Broad Institute have.
You can see it in pt 2: "where is the Julia ML ecosystem currently inferior?". They identify some gap with using cuda optimized kernels, where Julia doesn't make use of built in cuda magic; a solution is proposed where users might manually override compiler behavior (if I understand correctly).
However, no mention at all about the gap in dev experience. Some examples:
- TERRIFIC efforts of various groups in porting ml models from research to easy-to-use torch code
- the super ergonomic data wrangling tools in torch. Practically speaking, ml ecosystems need quality interop: do i get my data in and out of the ml framework in a sensible way
- the ease of getting started building your first toy ML model in torch because the docs and the API are so great
Getting the ball rolling, adoption-wise, means overcoming the cost of switching to something new. And I don't see that happening soon because python+torch is just so comfy.
Now, one area where this dull problem work isn't as noticeable is on the "core" deep learning libraries (Flux and Zygote). AFAICT those two haven't received any significant funding for a couple of years, and there is at most 1 full time, active contributor for both of them. Compare with JAX or even higher-level wrapper libraries like Flax, Haiku or PyTorch Lightning, which have 5-10+ full time core devs. Given this, is it surprising that progress on anything (including docs + interface design) is slow?
Julia actually does quite ok on that front. Here's the 1400 page Julia manual
https://raw.githubusercontent.com/JuliaLang/docs.julialang.o...
What other language do you have in mind that has better documentation?
I'm inclined to agree with you here. To my mind, this means that there's ample scope for developers from many backgrounds to make positive contributions to the Julia ecosystem.
The Julia community feels a lot like the Scala community to me. Lots of proving why the theories are right, but in production it’s a mess
The main benefit I can think of is that Julia could theoretically do whole-program optimization, but it doesn't and it doesn't model side effects so even if it wanted to it would be quite limited.
Also writing packages in C++ creates a fair amount of friction. Combining packages becomes easier. The ML world in Julia allows a lot more code sharing while in Python PyTorch and TensorFlow are large monoliths. E.g. different ML packages in Julia can use the same library of activation functions. Each ML library is not a completely different island of functionality.
As a result, despite Julia being very FFI-friendly, the Julia community is trying to move towards a "pure Julia" ecosystem. Sometimes this attitude makes sense (Julia-native BLAS), other times not (Julia has no HTTP/2 packages).
There is not problem if a) someone has written that code in the other language already and b) it works correctly.
But it's harder to build, modify and debug these things, generally. Glue code is useful, but it definitely has a cost.
I was also seduced by the concept of "octave, but with fast loops". This is really all that was needed. But I'm a bit disenchanted by the "advanced" additional features of Julia that add (unnecessary, in my view) complexity to the language. All that multiple-dispatch stuff, all those arbitrary types. I would love a compilation option that forced everything to be of the same type (a multi-dimensional array of numbers), and then it could really run like C, including compilation time.
Single dispatch is an arbitrary restriction which should not exist. It only exists in most languages as a performance optimization because until Julia came along nobody could do multiple dispatch fast.
Is that correct/can you give a reference? Reading https://en.wikipedia.org/wiki/Multiple_dispatch#Use_in_pract..., julia uses it more in its standard library, but I don’t find indication that Julia is doing multiple dispatch better than, say, CLOS (https://en.wikipedia.org/wiki/Common_Lisp_Object_System) or Cecil (https://en.wikipedia.org/wiki/Cecil_(programming_language)).
It depends on the usage that you make of the language. I don't use Julia as a general-purpose programming language, but only for doing numeric computations. For that usage, the multiple dispatch feature is not necessary (all my variables are matrices of the same numeric type), and indeed it has downsides. For example, the infamous "time to first plot" is so large in Julia precisely due to the need to support multiple dispatch. If this benchmark is becoming faster is only due to a huge and complex effort in optimization. I would prefer if this effort could be spent in improving support for sparse matrices, for example.
I acknowledge that "time to first plot" may be a useless benchmark for many, even for most, people. But you can also acknowledge that multiple dispatch is a useless feature for a few graybeards like me, for whom multiple dispatch is the main reason why Julia feels slow. Indeed, when you use Julia as an interpreted language (e.g., write a Julia script), execution is very slow due to the complexities introduced by multiple dispatch, that force essentially to recompile all libraries upon each execution of my tiny script.
However, while they speak of ML they refer only to deep learning, and I was wondering where Julia stands in terms of scikit-learn equivalents and if they ever took off.
1-Plotting takes too long. Forget fast iterations. You'll be left waiting for non trivial amounts of time to your first plot. The latency between tests is simply not good enough.
2-Libraries are just not mature. Plotting anything not too standard yields broken graphs and you have to look for a billion of backends to find one that does not break (hello twinx). Matplotlib is slow for some graphs but more often than not you get the right visualization (except for that suptitle being cut out of the graph bug that will never be fixed).
The requests library is not robust enough. This one is quite possibility my fault. I have received "bad headers" errors for some websites, but doing the exact same "get"with python works just fine.
The impression that Libraries die all the time. Could be just an impression, but it is quite common to find top stackoverflow answers that point you to dead libraries (with the common "use this other library instead" hint)
I like Julia speed and well done memory management (especially from what I saw from Dataframe.jl high memory benchmarks). But right now I'd not use it in a critical environment. (And I also suck at reading and understanding the error messages thus far, but it's likely a lack of experience from my side)
* `add Plots` on a new temp environment takes about four and a half minutes, most of which is precompilation.
* `using Plots` took 16 seconds, and
* a `plot` call after that is 7 seconds.
For comparison, on 1.6, the times are seven and a half minutes for precompilation, 17 seconds for `using` and 10 seconds for the first `plot`. I'm not patient/masochistic enough to try the same on 1.5 too, but the trend is definitely one of continuous improvement.
This is certainly not the sort of machine any production Julia code will be run in, but it is in the category of machines that a lot of students and many others trying out the language will have access to, so it gives an idea of their experience.
The times on 1.6 and 1.7 have been a qualitative change for me. plot being sub-10 seconds means that instead of it being "run it, switch to something else while I wait (potentially losing my mental context), come back and hope it's done", it's now "run it, stare at my dog for a few seconds, the plot is ready".
I don't think time to first plot is that bad anymore.
Time to first gradient can be bad in Zygote/Flux.
However, if you are developing compute-intensive scientific software, I would recommend switching to Julia as soon as possible. IMHO, Julia is superior to the likes of Python, Fortran, C++, and C for those use cases.
--
PS. By the way, you can fix matplotlib's suptitle issue by calling this Figure method after the fact:
fig.tight_layout(rect=(0, 0, 1, 0.95)) # leaves 5% of top space for suptitleBut many of the "main" ml packages are written in actual fast languages and are well optimized so python's inefficiencies can be mostly ignored (pytorch/tensorflow/catboost are really fast. Sklearn is decent and statsmodels is dead slow)
But again if need some specific image processing algorithm you either have to hope for it to be implemented in c++ with python bindings (like opencv) or you are in for a world of pain.
With Julia you can just count on it to be fast and implement it yourself natively
Yes, I agree -- Julia is superior for scientific research -- including developing or working with new, cutting-edge algorithms that are not yet implemented in any third-party library.
That said, if one is willing to do a bit of upfront work, in many and perhaps a majority of cases, it's possible to implement new algorithms/ideas in terms of tensor/matrix/vector operations, i.e., using fast library primitives instead of resorting to slow Python loops.
using PyCall
plt = pyimport("matplotlib.pyplot")
and just using it as in Python does work very seamless as an alternative.Then, some bugs are not actually bugs. For example, the gradient of some function wrt to elements of a symmetric matrix is and should be different depending on whether the matrix is structurally symmetric or not. Or, when a function is not differentiable in the calculus sense, different ADs often have different conventions for what they will return. These cases come up all the time.
Ugh. Yes and no, but mostly no.
A gradient is a collection of partial derivatives. The normal meaning of partial derivative with respect to symmetric matrix elements does not actually exist, because you can't vary them independently. This is actually a generic problem for any overparameterized constrained system. People still want to be able to use the standard tools of calculus though. You can reasonably do things like use Lagrange multipliers to do constrained optimizations. Or you can express a symmetric matrix in terms of only the n(n+1)/2 variables, treat them as a vector and get the gradient over that. (This is often what is done without actually describing the underlying method. This is the so-called "symmetric gradient"). But it's generally not what you actually want, even though it can lead to the same stationary points.
The best you can do is the unconstrained gradient restricted to the manifold of symmetric matrices (or whatever constrained object you are interested in). But even this is a (subtly) different thing than the gradient in the ambient space, even though it works in as large a set of cases as possible. Happily for symmetric differentials applied to symmetric matrices, the naive formulas of symmetrizing the gradient just work.
See, e.g. https://arxiv.org/abs/1911.06491 for some tracking down of the history and cogent analysis of what went wrong and https://saturdaygenfo.github.io/posts/symmetric-gradients/ for why it matters in practice (e.g. wrong and changing direction of descent for gradient descent, though still "downwards").
I pass this as input to some function that uses more than just the diagonal and compute the gradient (here a matrix). In general, for the dense matrix, the resulting gradient will not be diagonal. Why should it be? If your function doesn't care if the matrix is diagonal, neither does the AD.
But what about for `Diagonal`? Well, the AD could handle this different ways. First, it could interpret all matrices as embedded in the dense, unconstrained matrices, in which case it would return a dense non-diagonal matrix. Or it could ignore that `Diagonal` represents a matrix entirely and instead return some nested structure that contains gradients of its stored fields, here the gradient of a stored diagonal vector. Similarly, it could represent this nested structure as just another `Diagonal`.
There are various reasons why an AD might do any one of these; neither is right or wrong. But note that the only case that gives you the same answer as the dense one is the one that promotes to a dense input, which is basically discarding all structure to begin with.
Most ADs don't ever have to work with matrix polymorphism, so their user bases don't need to think about this, but Julia has _many_ polymorphic matrix types, so Julia ADs have to take this seriously, and if new users naively pass a polymorphic matrix type as input to some `gradient` function, they might be perplexed at what they get back and think the AD engine has a bug. See the ChainRules talk at EuroAD 2021 for more details: https://youtu.be/B3bC49OmTdk?t=761
What reverse mode AD talks informally about as "gradients" are cotangents, and if you are constrained to a submanifold of another manifold (such as the space of all symmetric matrices, embedded in the space of all NxN matrices) then your cotangent is a projection of that in the larger space. This reduces to the obvious thing for symmetric matrices, as you say, but there are less obvious AD-relevant cases (like the space of orthogonal matrices, or the space of "ranges", vectors with uniformly spaced elements) where getting it right with your bare hands is tricky.
I don't see any of the relevant terminology in these links, but they do seem to be thinking about related problems. Perhaps they have re-invented the wheel? Amused to read that standard cookbooks seem to have faithfully reproduced the recipe for a square wheel, for decades.
Flux has historically been more of a research project then a production library. That's ok, it holds a lot of promise. But, time to first gradient can be excessive. Minutes to discover a small bug excessive. Last I checked all of the adjacent libraries around it were broken due to incredibly frequent changes to the API.
Mlj doesn't impress me. There was a serious opportunity to change the way people do routine modelling using the strengths of julia. They basically made a half baked sklearn instead. Missed opportunity in my mind.
In general the components for statistical libraries are exceptional. However the ecosystem falls short to do things with them in a stable way.
The best libraries imo for data science work stem from the excellent db adapters, optimization library's, data frames jl, Turing jl, etc. Anything beyond that and it's usually better off just rolling your own or using another language all together... Current state of production, ie not code running a notebook is also ok at best...
This was how PyTorch started out as well.
What it's missing is ... impactful improvements on the failures of libraries like this. Docs need more examples and less pointers to packages that wrap other packages(albeit they are written well). Despite being a multi-year long effort by very big names it still feels incomplete, and if someone wasn't sold on Julia there is technically no reason not to use R or Python or Matlab. Missed opportunity is all
https://alan-turing-institute.github.io/MLJ.jl/dev/about_mlj...
The ecosystem in Julia is quite strong for MCMC libs because people do not have to lower something to C++ to develop such a library: https://discourse.julialang.org/t/mcmc-landscape/25654/
Of course, for users, they might prefer something like Turing, but I think the Julia tends to blur the differences between user and developer more so than in most other languages (for good or worse) since everything is in one language.
There's always RCall for R inside of Julia, the best of both worlds.
Only because doing "AI" gets you bigger grants.
Machine learning Statistics
network, graphs model
weights parameters
learning fitting
generalization test set performance
supervised learning regression/classification
unsupervised learning density estimation, clustering
large grant = $1,000,000 large grant = $50,000
nice place to have a meeting: nice place to have a meeting:
Snowbird, Utah, French Alps Las Vegas in AugustWhile R definitely leads the pack on variety of useful stats packages, there are excellent tools for certain tasks in other languages. I do a lot of probabilistic programming, and PyMC in Python and Turing in Julia are excellent packages. And both languages have official Stan interfaces. Not knowing R has not been a problem for me.
https://www.google.com/search?q=%22statistics+is+a+subset+of...
1 result
https://www.google.com/search?q=%22machine+learning+is+a+sub...
2 results
Machine learning is a subset of statistics.