How Mojo Hopes to Revamp Python for an AI World (acm.org) 28
Python "come with downsides," argues a new article in Communications of the ACM. "Its programs tend to run slowly, and because it is inefficient at running processes in parallel, it is not well suited to some of the latest AI programming."
"Hoping to overcome those difficulties, computer scientist Chris Lattner set out to create a new language, Mojo, which offers the ease of use of Python, but the performance of more complex languages such as C++ or Rust." Lattner tells the site "we don't want to break Python, we want to make Python better," while software architect Doug Meil says Mojo is essentially "Python for AI... and it's going to be way faster in scale across multiple hardware platforms." Lattner teamed up with Tim Davis, whom he had met when they both worked for Google, to form Modular in January 2022. The company, where Lattner is chief executive officer and Davis chief product officer, provides support for companies working on AI and is developing Mojo.
A modern AI programming stack generally has Python on top, Lattner says, but because that is an inefficient language, it has C++ underneath to handle the implementation. The C++ then must communicate with performance accelerators or GPUs, so developers add a platform such as Compute Unified Device Architecture (CUDA) to make efficient use of those GPUs. "Mojo came from the need to unify these three different parts of the stack so that we could build a unified solution that can scale up and down," Lattner says. The result is a language with the same syntax as Python, so people used to programming in Python can adopt it with little difficulty, but which, by some measures, can run up to 35,000 times faster. For AI, Mojo is especially fast at performing the matrix multiplications used in many neural networks because it compiles the multiplication code to run directly on the GPU, bypassing CUDA...
"Increasingly, code is not being written by computer programmers. It's being written by doctors and journalists and chemists and gamers," says Jeremy Howard, an honorary professor of computer science at the University of Queensland, Australia, and a co-founder of fast.ai, a. "All data scientists write code, but very few data scientists would consider themselves professional computer programmers." Mojo attempts to fill that need by being a superset of Python. A program written in Python can be copied into Mojo and will immediately run faster, the company says. The speedup comes from a variety of factors. For instance, Mojo, like other modern languages, enables threads, small tasks that can be run simultaneously, rather than in sequence. Instead of using an interpreter to execute code as Python does, Mojo uses a compiler to turn the code into assembly language.
Mojo also gives developers the option of using static typing, which defines data elements and reduces the number of errors... "Static behavior is good because it leads to performance," Lattner says. "Static behavior is also good because it leads to more correctness and safety guarantees."
Python creator Guido van Rossum "says he is interested to watch how Mojo develops and whether it can hit the lofty goals Lattner is setting for it..." according to the article, " but he emphasizes that the language is in its early stages and, as of July 2023, Mojo had not yet been made available for download."
In June, Lattner did an hour-long interview with the TWIML AI podcast. And in 2017 Chris Lattner answered questions from Slashdot's readers.
"Hoping to overcome those difficulties, computer scientist Chris Lattner set out to create a new language, Mojo, which offers the ease of use of Python, but the performance of more complex languages such as C++ or Rust." Lattner tells the site "we don't want to break Python, we want to make Python better," while software architect Doug Meil says Mojo is essentially "Python for AI... and it's going to be way faster in scale across multiple hardware platforms." Lattner teamed up with Tim Davis, whom he had met when they both worked for Google, to form Modular in January 2022. The company, where Lattner is chief executive officer and Davis chief product officer, provides support for companies working on AI and is developing Mojo.
A modern AI programming stack generally has Python on top, Lattner says, but because that is an inefficient language, it has C++ underneath to handle the implementation. The C++ then must communicate with performance accelerators or GPUs, so developers add a platform such as Compute Unified Device Architecture (CUDA) to make efficient use of those GPUs. "Mojo came from the need to unify these three different parts of the stack so that we could build a unified solution that can scale up and down," Lattner says. The result is a language with the same syntax as Python, so people used to programming in Python can adopt it with little difficulty, but which, by some measures, can run up to 35,000 times faster. For AI, Mojo is especially fast at performing the matrix multiplications used in many neural networks because it compiles the multiplication code to run directly on the GPU, bypassing CUDA...
"Increasingly, code is not being written by computer programmers. It's being written by doctors and journalists and chemists and gamers," says Jeremy Howard, an honorary professor of computer science at the University of Queensland, Australia, and a co-founder of fast.ai, a. "All data scientists write code, but very few data scientists would consider themselves professional computer programmers." Mojo attempts to fill that need by being a superset of Python. A program written in Python can be copied into Mojo and will immediately run faster, the company says. The speedup comes from a variety of factors. For instance, Mojo, like other modern languages, enables threads, small tasks that can be run simultaneously, rather than in sequence. Instead of using an interpreter to execute code as Python does, Mojo uses a compiler to turn the code into assembly language.
Mojo also gives developers the option of using static typing, which defines data elements and reduces the number of errors... "Static behavior is good because it leads to performance," Lattner says. "Static behavior is also good because it leads to more correctness and safety guarantees."
Python creator Guido van Rossum "says he is interested to watch how Mojo develops and whether it can hit the lofty goals Lattner is setting for it..." according to the article, " but he emphasizes that the language is in its early stages and, as of July 2023, Mojo had not yet been made available for download."
In June, Lattner did an hour-long interview with the TWIML AI podcast. And in 2017 Chris Lattner answered questions from Slashdot's readers.
Good luck, Mojo (Score:2)
Julia (Score:2)
Julia has all these desired features save one. It's radically different in syntax and thought than python.
Re: (Score:2)
Yeah, it's highly technical, but in the essence, it says "keep your fee-fee bull out of programming languages, we're trying to get shit done here".
What is this "AI World"? (Score:1)
Is it plastic? Is it fantastic? The same generative craptastic crap from semi-literate idiots every day...
Nothing new (Score:2)
Re: (Score:2)
Came here to say the same thing. Slashdot already discussed Mojo - its purpose, its implementation, its potential future use - back in May/June of this year [slashdot.org]. This latest article doesn't seem to add much.
Re: (Score:2)
Because fortran is good enough.
Re: (Score:2)
Will Mojo achieve the feat to beat Fortran in popularity? I seriously doubt.
Python is already plenty good for what it has to do WRT AI. It simply acts as a glue for lower level libraries written in C++, so unless you are implementing core loops in Python (which you shouldn't, though Cython already allows to do that w.out leaving Python code), Python is good for that, has zillions available libraries a
Re: (Score:3)
Hey! Fortran is 1.04% on TIOBE
What does that even mean?
I run PWRs on fortran, and no combination of C++, python and kotlin can get even close.
Re: Why not Julia? (Score:2)
Re: (Score:1)
Might as well talk about languages that are NEW, and not stuff as Julia which is OLD.
Because we are in a site that is called NEWS for NERDS, not OLD CRUMPY PEOPLE who do not want to know what is new.
Without knowing about Mojo: you would not know it does not fit your use case. So move on, scroll down, read next.
Oh: and I do not like Julia, I find Python more esthetic, so Mojo is interesting NEWS for me.
Oooh metal is too hard to use (Score:2)
This is like people talking about using wood to make massive sky scrapers because wah metal is too hard to use even though everyone knows it is the right choice and *real* engineers use it successfully every day.
Its like a sub qualified group who decided to just throw out the rigid engineering as too hard and chastise real engineers as elitist who profess to simply use the right damn tool for the job.
Re: (Score:1)
Re: (Score:2)
Yeah, I was thinking; just use a real programming language that supports threads etc. but nowadays kids think easier == more modern.
Re: (Score:2)
There are lots of ways to construct metal structures. For now, let's just consider fasteners (e.g., bolts) versus welding. In general, welding will yield stronger, cleaner results. But it takes real skill to achieve those ends. And there are lots of examples of really shitty welding jobs to - there's a big difference between some hack with a stick welder [google.com] and someone produce stack-of-dimes MIG welds [google.com].
On the other hand - most any idiot can turn a wrench and put pieces
Python's strenght is not speed but libraries (Score:3)
By Python has quite a few advantages over say C/C++ for ML work. Ease of C/C++ invocation is one and the very important one. Usually it takes me a day or so to figure out a calling procedure between the languages, for Python it took less than an hour. The number of libraries and ease of use for the libraries is another great advantage. Amount of documentation and examples is another one. The ecosystem of the language probably on par with much older languages like C/C++. It takes time and effort to build.
Most of the AI researchers suck at programming. Very few are capable of writing efficient compute kernel, in C/C++ or CUDA or anything else. That is why specialists exist. You just think of the operation you want to do, implement it accurately in non-efficient language, and then specialist will take it and implement it in CUDA or whatever fast language is needed.
So this new language has to overcome a lot of headwinds before even having a chance at adoption. Python supports multi-threading quite well and the CUDA or C/C++ libraries take care of the low level part. But good luck to them, even if luck is not on their side.
Re: (Score:2)
Re: (Score:3)
Even for the actual learning and inference, Python is used to define the model then execution is passed on to C/C++/assembly. There's no reason at all to have a single do-everything language that you can use to program GPU shaders and also let children wire together Keras objects.
Re: (Score:3)
Really? Because a lot of that is pretty annoying and awkward and doesn't necessarily fit into, say torch, primitives for which efficient GPU kernels exist. As soon as you need a for-loop per data element you're basically utterly fucked speed wise and now you're going to be waiting a long time just for the prepping and cleaning stage.
Long run (Score:2)
>> If speed mattered for AI work Python would be replaced long ago.
Nope.
Speed matters on the long run, when you try to scale up, i.e. when tech matures.
It's now avilable on some platforms (Score:4, Informative)
The article is a little outdated, you can download Mojo and experiment with it now. Looks interesting. I think the optional static typing is very useful, the faster execution speed is very welcome, and maybe they will be able to implement parallelism in a way that uses all the cores appropriately. I want to see how well it does with tensorflow.
https://developer.modular.com/... [modular.com]
What's wrong with Numba? (Score:2)
Proprietary language for now (Score:3)
https://github.com/modularml/m... [github.com] says "We plan to open-source Mojo progressively over time, but it's changing very quickly now."
As someone interested in faster Python (remember Parrot?), that's disappointing, but I guess modular.com wants to capitalize on any interest in the language by building up their customer base / contact list.
I'll invest time in evaluating Mojo when (and if) it is released as free software.
Bypassing CUDA would be great (Score:2)
Last time I checked, CUDA only worked with NVIDIA GPUs. So if a better GPU comes along from AMD, tough, you'll have to rewrite your ML code.
If Mojo will really let me write neural net code that runs on all GPUs, I'm interested.