tcoopman

tcoopman

Anyone who wants to speculate about this tweet from José

I just saw this tweet passing by but I have no idea what it’s hinting at, but it looks awesome :slight_smile:

https://twitter.com/josevalim/status/1331359533504073729?s=19

So does anyone have an idea? I know we should probably just wait for more information, but speculation can be fun.

My first thought was about the JIT compiler, but the speedup seems to big for that. Anyone with a better idea?

Most Liked

juhalehtonen

juhalehtonen

Wrote down some notes. Please correct if something is wrong or missing, took these right while listening :slight_smile:


Nx = Numerical Elixir
Everything is WIP, baby steps!

In a nutshell
Nx is a project that consists of a core library (Nx) and other pieces that depend on the core library. Together, they introduce things very much related to machine learning and associated fields. Nx introduces the ability to work with tensors, boosts Elixir’s ability and performance when working with numbers, and makes it possible to compile code for the GPU.

The work has been ongoing for 3 months. Everything is still in flux, but the following were mentioned.

There are 3 fronts where work is happening:

1) Nx library (core)

  • Library for multidimensional arrays that are often called tensors.
  • Tensors are typed, not in type-system way but unsigned integers or float32 or float64 etc.
  • Earlier José made PR to support float16 in Erlang.
  • If you come from Python, it can be thought of as kind of like Numpy. Long way to go but working on that.
  • Written in pure Elixir
  • Tensors represented as large binaries
  • The “slowness in Elixir” with numbers is generally due to immutability and copying etc. This is addressed through a module that is part of Nx called Numerical Definitions

2) Numerical Definitions

  • Module in Nx
  • Looks like Elixir code
  • Can define functions with defn. That’s a numerical definition
  • In the definition you write with a subset of Elixir. Elixir kernel is replaced with Numerical kernel.
  • In this, operators + and - can only work with numbers and tensors.
  • In numdefs, we are not executing them immediately. We are building a computation graph of all tensor operations we want to do.
  • Now when you want to calculate X, fuse all operations together to pass through the tensor only once, which reduces copying considerably
  • Kind of like Elixir Streams but happens on syntax level inside defn
  • Defn allows for “automatic differentiation”. The problem that this solves is essentially loss function minimization in things like when creating neural networks etc.

3) EXLA

  • Based on Google XLA (accelerated linear algebra)
  • Nx team wrote wrote Bindings to XLA, which is part of Tensorflow repo
  • You can give it a computation graph and exla compiles it to run efficiently on CPU or GPU
  • You can change the compiler. In other words, the compiler backend is pluggable, so other compilers aside from XLA can also be integrated with
  • XLA compiler compiles numerical definitions to run on the GPU.
  • What this means is subset of Elixir is running on the GPU
  • Small subset of Elixir: still contains things like pipe operators and conditionals, but f.ex. limited pattern matching (only tuples)

More information will be available on February 17 at the Lambda Days 2021 conference where José will be speaking.

slouchpie

slouchpie

“Hey, what did you do over Christmas?”

me: “I drank too much and tried to read a book”

Jose Valim: “I rewrote my language’s kernel to afford tensorflow-like operations for efficient ML operations”

:expressionless:

ericmj

ericmj

Elixir Core Team

One really great part of this is that very few changes to Elixir itself were required. Nx is built on top what is already there in Elixir. It’s really good of example of the language extensibility we can have with meta programming and that you don’t have to be an Elixir core contributor to build libraries like this.

Last Post!

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement