Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Python AI

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.
This discussion has been archived. No new comments can be posted.

How Mojo Hopes to Revamp Python for an AI World

Comments Filter:
  • I say the more programming languages the better!
    • Julia has all these desired features save one. It's radically different in syntax and thought than python.

  • by Anonymous Coward

    Is it plastic? Is it fantastic? The same generative craptastic crap from semi-literate idiots every day...

  • Since the last article.
    • by necro81 ( 917438 )

      Since the last article.

      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.

  • 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.

    • What isn't being said here is the fact that Lattner's also trying to put the whole AI thing on solid grounds engineering-wise. The Python AI software landscape is just an unprofessionally lumped together hot mess right now and I welcome everyone trying to change things for the better.
    • by ls671 ( 1122017 )

      Yeah, I was thinking; just use a real programming language that supports threads etc. but nowadays kids think easier == more modern.

    • by necro81 ( 917438 )
      Extending the metal analogy...

      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
  • by xwin ( 848234 ) on Sunday November 19, 2023 @01:50PM (#64016555)
    If speed mattered for AI work Python would be replaced long ago. The syntax is somewhat weird with space a syntactic element, but only when indentation is concerned.
    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.
    • The largest chunk of work in building ML models is preparing, cleaning and labeling the data. This is where Python shines. I see what they are trying to do with Mojo but this does not warrant a new language.
      • by ceoyoyo ( 59147 )

        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.

      • 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.

    • >> 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.

  • by ZipNada ( 10152669 ) on Sunday November 19, 2023 @01:52PM (#64016561)

    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 Chis is trying to do sounds a lot like Numba [readthedocs.io]. It leverages LLVC and compiles fast machine code on the fly. It can parallelize code and even run some on suitable graphics cards by using CUDA.
  • by DenialS ( 21305 ) on Sunday November 19, 2023 @03:34PM (#64016735) Homepage Journal

    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.

  • 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.

You know, the difference between this company and the Titanic is that the Titanic had paying customers.

Working...