74 points · by tosh · 6y ago · 110 comments
Python is used as the language to describe things, but nobody is executing Python on the GPU. Instead, things are transpiled into highly optimized byte code, C++ source, or chains of optimized GPU sharers. See TensorFlow XLA and AOT.
So when I set up a training pipeline with TensorFlow, then it'll barely run any python while training. Instead, the TF C++ core will execute a network of TF CUDA operators for me, all inside one python function call. That's why pythons global interpreter lock is pretty much a non-issue by now.
Since only 1% of my training time is even running inside python, I don't expect any performance benefits from replacing it. And if both are equally fast, I prefer the familiar option, meaning python.
The relevant part of the their discussion is this one:
> Like Python is not the future of machine learning. It can't be. You know, it's so nicely hackable, but it's so frustrating to work with a language where you can't do anything fast enough unless you call out to some external code or C code, and you can't run anything in parallel unless you put in a whole other process. Like I find working with Python, there's just so much overhead in my brain to try to get it to work fast enough. It's obviously fine for a lot of things, but not really in the deep learning world or not really in the machine learning world. So, like, I really hope that Julia is really successful because there's a language with a nicely designed type system and a nicely designed dispatch system and most importantly, it's Julia all the way down so you can get in and write your GPU colonel in Julia, or all the basic stuff is implemented in Júlia all the way down until you hit the LLVM.
Here the point is that when using other languages (such as Julia) you actually can use the same language for your GPU and for the glue that keep your scripts together.
I prefer Clojure for this. Even simpler than Python, fast, and enables me to match or even surpass the speed expected from mainstream tools.
See this for example: https://dragan.rocks/articles/20/Deep-Diamond-Deep-Learning-...
It will take a lot for another language eco system to catch-up to something as broad and deep as python but these issues combined with the horrible experience that is dependency management with pure python vs compiled etc as well as the need for real-time/close to real-time systems, it seems very plausible that something like Julia or other llvm language will become the default over python for _these specific_ use cases, not in general though. Tooling on top of Julia can likely be far better and more easily made than living in python which is another aspect.
I agree that users don’t care, I use Spark a lot and don’t care if I write scala, python or even c# now.
Have a listen: https://www.wandb.com/podcast/jeremy-howard
(I think I have paraphrased the podcast correctly :) )
So to the end user who doesn't want to write CUDA, I don't see why using a Julia package for gpu acceleration is any better than using PyTorch in Python.
The main questionable implicit assumption that is made is that Python can't "the future" (which is severely underspecified without a time horizon) because of what is bad about it today. It even is literally there "Python isn't the future... It can't be" <because something in Python is bad>.
That's highly questionable, because it leaves out - that people appear to have reasons to adopt Python, likely because of something that is good about it, (this complements the observation that not that many people might be impacted by the disadvantages). - that Python and the ML tools in Python might not be static and actually evolve in "the future".
It seems to me a curious lack of reflection substituted for by being particularly assertive about it.
To my mind Python not being the future is more likely to happen if Python becomes less likable or the attempts to improve the shortcomings (which are there, HPy as a medium-term way to get out of the "C extension vs. parallelism/speedup/GIL" corner, mypyc/numba/TorchScript/JAX pushing the "what can be efficiently expressed in Python" boundary) fail.
Julia, Swift, Dex-Lang, HaskTorch all get things right that Python doesn't. But do they get all the things right that Python does get right?
Disclaimer: I'm biased because I like Python and have some involvement in Python ML tools.
"Like Python is not the future of machine learning. It can't be. You know, it's so nicely hackable, but it's so frustrating to work with a language where you can't do anything fast enough unless you call out to some external code or C code, and you can't run anything in parallel unless you put in a whole other process."
So exactly the point made here.
I have always wondered why. I see so many projects that miss those. Projects from big companies and teams. Are they intentionally adding hurdles to using the code?
I also think that not enough people are aware of the performance limitations of NumPy code and how much more straightforward it can be to drop into a lower level language once you cross a certain optimization barrier. This is where Julia can increasingly serve an important role.
Poorly written code in any language will be slow, so don't start with that.
Python is better for library users in the sense that Python has more libraries, but I remember not many years ago when nobody was doing anything serious in Python for statistics because the libraries were so poor and so few compared to R.
Julia has some great libraries being built that leverage some of the properties of Julia that Python can’t easily match.
Will Julia “beat” Python? Maybe in the sense that Python has “beaten” R. Note that R continues to do just fine, thank you. So too will Python do fine. But you may be surprised to find some killer libraries or frameworks that are firmly in Julia’s domain in the future.
The financials are more secure than stated in the video. (I don't work there, but I'm a fan)
Julia brings great improvements in ability to write simple idiomatic serial code that runs at near C speeds on the CPU (whereas idiomatic Python code is at least 10x slower if you use an optimal compiler, and 1000x slower if you use the standard python interpreter). But for highly parallel code dependent on element-wise or broadcasting array operations, I just don't see the issue with Python.
As far as I know, that example code creates an ad-hoc kernel that performs the computation in a single pass.
I honestly don't know if that is possible in other frameworks.
For example, the simple array expression v+cw (where v,w are vectors and c is a scalar) can be calculated using fused multiply-add instructions. But this is not possible when called in an interpreter, which has to make separate calls for each array operation. For the same reason, this same calculation may saturate the memory bus. This is not an issue with Julia or other compiled languages. Not sure how Numba and/or PyPy optimizes it.
Wrong. Julia can call out to Cuda kernels, but it also does codegen for custom ops and types. Technically with enough engineering time, someone could rewrite all those C cuda kernels in julia, and julia would just generate low level machine GPU code on the fly.
Unfortunately, it lacks a big-name sponsor like Go or Rust.
Python versatility is miles ahead. You can build Web APIs, Web apps, automation scrips, data scrapping and so on.
Python is not the de facto language of ML nowadays because its performance. All the underlying performance sensitive code is written is C/C++/Fortran.
Also, cython, which has great integration with python, is growing a lot and has been used in some cool projects such as aiohttp, fastapi, and spacy. So one more alternative to write fast code without giving up on python entirely.
For instance, in python you happily add a string to the list [1,2,3], but not in Julia because the list has been created as a vector of integers. However, if you create the list as Any[1,2,3], then you can append a variable of any type.
What? And you somehow cannot do that in Julia?
> So one more alternative to write fast code without giving up on python entirely.
I don't have to give up on Python, I can just use all libraries from Julia with PyCall. I'm just glad I don't have to use Python the language anymore than absolutely necessary.
You definitely can. My point is that python libs are more mature and there are more options to choose from than Julia.
Python community better embrace JIT tooling, now that projects like TensorFlow and Torch are going polyglot.
If Python were a blocker for the adoption and development of ML, it wouldn't be the default language of the most popular ML libs.
The reason is, the high performant code is written in C++/C/Fortran. Python is just used to glue everything and provide a nice and rich interface. That's what really matters.
To me Julia is more to Fortran than Python. And it doesn't have many usages outside numeric programming.
Scapping the Web, building rest APIs, Performing Data Analysis, Automation scripts is much easier in Python than Julia or Swift.
Edit: typos
I am going to watch Julia adoption, and use it more, when and if it becomes more popular.
> To me Julia is more to Fortran than Python. And it doesn't have many usages outside numeric programming.
Again, you're making unsubstantiated claims.
> Python is just used to glue everything and provide a nice and rich interface. That's what really matters.
So, now I have to not only learn Python but also Fortran/C++/C because the underlying library that I might want to adapt is written in one of these languages. In Julia the DL library, for example, is written in Julia. What you are claiming is a pro is actually a con.
> Scapping the Web, building rest APIs, Performing Data Analysis, Automation scripts is much easier in Python than Julia or Swift.
That might be true for Swift, but certainly not for Julia.
Basically the only time you'll want to do this from Python is if there is specific Fortran or C++ library you want to use. You'd have to do the same in Swift or Julia in this case.
You don't need to learn C/C++ or fortran. I've been working with python and ML for about 4 years and haven't touched any C/C++ or fortran to get work done. I agree that it'd be better if we could do everything with just one language but the truth is that Julia is not that language. It's great for HPC but expressive enough for generic things like Web.
Julia might be a good thing to explore once you're up and running.
The most important for newcomers is to pick one language and stick with it long enough to know it well (I would advise for a general-purpose programming language such as python). It will take time before you bump into its limits, and when that happen you can start to look around how things are being done in other languages.
The latter two are tools to send ML models and training pipelines around, so kind of like Google Docs for AI. Colab is on the internet, Jupyter on your PC.
That way, you can easily exchange your experiments with others and/or asks for help online.
I also believe Python is not the future of ML but it's because the future is more about the space maturing and becoming commoditised and "boring" which probably means, being completely honest, things that people have no interest in happening like it migrating over to the JVM etc.
But who wants to talk about that?
It's a very fast compiled language and compile faster than most of its competitors.
I supports interactive programming with rdmd and can work as a kernel inside Jupyter notebook through Jupyter's wire protocol[1].
It has friendly python vibe to it due to default to GC based ecosystem (but you choose to let go the GC where appropriate).
With the introduction of DPP, its FFI capability to C/C++ is second to none if the needs arise to interface with the existing libraries in those languages and it can also easily interface seamlessly with python and R libraries! [2]
It also has a growing library for big data analysis [3] and one of the main users of D is WekaIO, one of the prominent big data companies with the claim of the world's fastest file system for data storage [4].
If you insist on multiple dispatch style like Julia, you can emulate it as well in D [5].
If you want to see the glimpse of what D can offer for data science domain please check this "D is for Data Science" article [6].
Finally if you want to see D in action against Julia and Chapel for kernel matrix calculations that's common in AI type of applications please check this post [7].
[1] https://github.com/symmetryinvestments/jupyter-wire
[2] https://dlang.org/blog/2020/01/27/d-for-data-science-calling...
[3] https://dlang.org/blog/2018/12/04/interview-liran-zvibel-of-...
[4] http://docs.algorithm.dlang.io/latest/mir_ndslice.html
[5] https://en.wikipedia.org/wiki/Multiple_dispatch#D
[6] https://tech.nextroll.com/blog/data/2014/11/17/d-is-for-data...
[7] https://dlang.org/blog/2020/06/03/a-look-at-chapel-d-and-jul...
For comparison, at the age of 20 years (around 2010) Python was still playing a second fiddle to Perl, and at the same time Ruby was fast becoming popular due to RoR.
The good news is that now D already passed the growing pain problem regarding the transition from D1 to D2 (e.g. Tango library issue), very similar to Python transition from 2 to 3 that happened fairly recently, or perhaps it's still happening now.
Jeremy Howard says python will always be calling out to something else that's faster and more parallel. Writing fast python has too much cognitive overhead. He hopes Julia catches on because it's Julia all the way down.
- implement your work intensive logic with the adapted tools
- glue everything together with Python
It's a pain in the ass, and there is no need to pretend that it's great just because Python sucks (performance wise).