Live data from Hacker News

From Python to Elixir Machine Learning

thestackcanary.com

11–20 of 89 posts

Re: From Python to Elixir Machine Learning

#11
post #9

Earlier quoted context omitted.

Those are real issues though.

Is concurrency useful for ML?

No, parallelism is useful, concurrency without parallelism is not useful.

Go and elixir provide some parallelism but the primary focus for both languages is concurrency.

Re: From Python to Elixir Machine Learning

#12

Instead of moving to Elixir I believe it makes more sense to wait/move to Mojo when it's ready: https://www.modular.com/mojo

Elixir (NX) is ready now, Mojo might be, at some time in the future.... also Mojo won't have the BEAM or ergonomics around Functional Programming.

Python syntax has really good ergonomics around functional programming. I hardly write loops when I use the language now.

Re: From Python to Elixir Machine Learning

#13

Instead of moving to Elixir I believe it makes more sense to wait/move to Mojo when it's ready: https://www.modular.com/mojo

Given how Swift for Tensorflow went, how openai was equally pushing for it, I would rather take a "wait and see" approach to Mojo.

Re: From Python to Elixir Machine Learning

#14
post #9

Earlier quoted context omitted.

Those are real issues though.

Is concurrency useful for ML?

If your data loading pipeline grows even slightly complex, then yes, you absolutely need concurrency in order to deliver your samples to the GPU fast enough.

The current workarounds to make this happen in python are quite ugly imho, e.g. Pytorch spawns multiple python processes and then pushes data between the processes through shared memory, which incurs quite some overhead. Tensorflow on the other hand requires you to stick to their Tensor-dsl so that it can run within their graph engine. If native concurrency were a thing, data loading would be much more straightforward to implement without such hacks.

Re: From Python to Elixir Machine Learning

#15
post #9

Earlier quoted context omitted.

Is concurrency useful for ML?

You end up having to do a lot of things in a ML training run, some of which you can do in parallel because it’s not important now (eg saving metadata) or because you’d otherwise be resource limited (eg loading data and formatting batches for training)

And for this you cannot use Python's multiprocessing because ... ? Sure, moving data between processes is slow because of pickling [0]. However, I'm using parallel processing for the things you suggested, and for these it works great.

If I really had the use case and needed threads, I'd much rather use C++ bindings in a Python package than rebuilding the whole thing. Guess it depends on the scale we are talking about.

[0] https://pythonspeed.com/articles/faster-multiprocessing-pick...

Re: From Python to Elixir Machine Learning

#16

Earlier quoted context omitted.

Elixir (NX) is ready now, Mojo might be, at some time in the future.... also Mojo won't have the BEAM or ergonomics around Functional Programming.

ML is not an island, it is part of a much broader "data science" universe that is currently served fairly well (still imperfectly) by the Python/C++ stack and is not easy to replicate. Throwing BEAM or FP acronyms around won't really strike a chord with people working with data and models. Mojo will (as per promise) tap into the wider ecosystem. Other platforms are more than welcome to try but this ultimately require…

There are very real limitations to the tooling approach summarized as "slightly more ergonomic APIs to underlying C/C++ code" that is currently dominant in Python qua ML. One of the biggest is of course extensibility, which, if difficult enough (as is the case in most Python ML tools unless you're extending only at the relatively slow Python layer) drastically hinders progress in making tooling better while keeping performance good.

Other languages have certain features that make extension and integration feel like first-class concerns which lowers the barrier to contributions from a wider range of people and also helps keep e.g. dependencies and build processes relatively simple.

Re: From Python to Elixir Machine Learning

#18
I use Elixir for a long time and wouldn't recommend it for ML over Python. Yes, maybe Elixir has some advantages and solutions for pain points because of VM architecture and other subjective reasons but doesn't come close to what Python offers in terms of tooling, support, community. Also, if you juggle more complex data in Elixir, it's something that you need to get used to coming from Python, it will be much much different and therefore harder to grok for someone not used to the style.

You can always make Elixir app talk to Python ML backend and get the best of both worlds if you desire.

Re: From Python to Elixir Machine Learning

#19

I wish there wouldn’t be such a song and dance about “moving away from Python”. There’s nothing wrong with creating ML tools in Elixir, but it’s always Python is slow, Python has no concurrency support, blah blah

I come from Ruby but the reactions can be similar, happy to give my data point.

The thing is Elixir is really good at an increasing number of things.

If you need to write a HTTP proxy in the middle of your application, since Elixir processes & incoming HTTP workers are cheap, you do not need to go evented: it just works.

If you need to have reactive web apps with automated changes pushed to the client, it's the same: there is no need to external tools (e.g. any cable) at certain scale.

If you need to do some scripting, there is `Mix.install/2` for single-file dependencies description & use.

If you start crawling too much web pages or process to many APIs, the concurrency support kicks in and there is less need to scale (or later), turning into fewer machines, fewer ops problems (or delayed) etc.

And now you start being able to use MachineLearning, deploy the same type of code on GPU, embed Machine Learning models right in the middle of your web app without much work, etc, which in turns makes it a nice platform for apps / SaaS.

Elixir really is becoming a Swiss-army knife which scales easily :-)

Re: From Python to Elixir Machine Learning

#20
post #9

Earlier quoted context omitted.

Those are real issues though.

Is concurrency useful for ML?

Yes, it can be.

1. Loading data

2. Running algorithms that benefit from shared memory

3. Serving the model (if it's not being output to some portable format)

There are also general benefits of using one language across a project. Because Python is weak on these things, we end up using multiple languages.

Post reply on HN