Live data from Hacker News

Numba: A High Performance Python Compiler

numba.pydata.org

41–50 of 63 posts

Re: Numba: A High Performance Python Compiler

#41
Does anyone know how this approach of adding decorators to numerical functions compare to Elixir's Nx approach of compiling those functions through a specialized macro for numerical computations? Would Numba benefit if (PEP 638?) macros were added to python?

Re: Numba: A High Performance Python Compiler

#43
post #29

Earlier quoted context omitted.

For a compositor, I'd think of the set pixels being changed (an "invalidation") a good example: the constraint would be to update it on the screen. Unchanged? Don't bother, leave it as-is. I think that's how Intel power saving works. Now think about the MVC model: some changes in the data could result in a change in the view if the data currently shown on screen is what has changed - like triggers in SQL. I wonder if…

You're right, and thank you for bringing async up. And thankyou for bringing up constraint propagation. One of my ideas is the definition of formulas that act as materialized views over other materialised views. So we can layer materialized views over other materialized views and then work out a derived formula that is potentially nearer to what we want and potentially summarise the formula without needing to calcula…

> I think it's an application of algebra and JIT compilers could do it to expressions if we fed symbolic expressions of programming languages into sympy or machine algebra

Yes and the constraints could be the used to reduce the computational costs, giving higher performance and lower latency.

A while back, a good friend (we even shared HN accounts for a while lol) pointed me to pipelinedb: a PostgreSQL timeseries plugin for continuously updating """materialized views"""

I use a lot of quotes around, because it wasn't either like a regular view (computed when you query it, which introduces latency) or a materialized view (frozen, needs to be refreshed, same problem) but more like the NO_HZ tickless kernel: the update of the calculations was caused by the introduction of new data, not the passage of time (which would be wasteful)

The general approach makes a lot of sense to me, and I see how it could be used for more generic problems.

Re: Numba: A High Performance Python Compiler

#44

Quick overview of the design space: * PyPy JITs everything, so it can do _normal_ Python numerical code that is quite fast and regular Python code that is fast. However, its interactions with libraries like NumPy add overhead, and it seems like it can't JIT code that interacts with NumPy in a useful way (AFAIK, would be happy to be proven wrong). So not useful for optimizing numeric functions that interact with libra…

Good overview. "Vectorized" is an old term that's been around since the early days of supercomputers and maybe before, not sure where it came from. Numba does a bunch of different things for code written to the Numpy API including CUDA acceleration. Certain machine learning frameworks like PyTorch and JAX also roughly follow the Numpy API because it is widely familiar and easy enough to work with. The kind of code that benefits from this kind of acceleration is hard to write yourself. A lot of workloads lean on linear algebra operations that are conceptually simple but complicated to implement with good performance, thus why all of this tooling isn't just a couple thousand lines of C. Good overview of matmul on CPU:

https://gist.github.com/nadavrot/5b35d44e8ba3dd718e595e40184...

Re: Numba: A High Performance Python Compiler

#45

Are there a standard set of benchmarks these python JIT projects use? I’m very interested in adding something like this to some projects but it needs to be 10-100x faster to be worth the hassle. Otherwise, for our applications, it’s a better time investment to rewrite in Go and get the speed and pro tooling than to further optimize python.

I’m surprised you’d rewrite in Go rather than Julia. I’d expect Julia would be much easier to translate to from Python and have much better support for any mathematical operation.

Re: Numba: A High Performance Python Compiler

#46
Related:

Faster Python calculations with Numba - https://news.ycombinator.com/item?id=30392367 - Feb 2022 (66 comments)

Numba: a JIT compiler for Python that works best on code that uses NumPy - https://news.ycombinator.com/item?id=21614533 - Nov 2019 (9 comments)

How Numba and Cython speed up Python code - https://news.ycombinator.com/item?id=17678758 - Aug 2018 (45 comments)

Numba: High-Performance Python with CUDA Acceleration - https://news.ycombinator.com/item?id=15301766 - Sept 2017 (62 comments)

Numba - JIT specializing compiler for annotated Python and NumPy code to LLVM - https://news.ycombinator.com/item?id=5927787 - June 2013 (8 comments)

Accelerating Python Libraries with Numba (Part 2) - https://news.ycombinator.com/item?id=5757231 - May 2013 (23 comments)

Accelerating Python Libraries with Numba - https://news.ycombinator.com/item?id=5680722 - May 2013 (30 comments)

Numba: NumPy-aware optimizing compiler for Python - https://news.ycombinator.com/item?id=4430780 - Aug 2012 (23 comments)

NumPy aware dynamic Python compiler using LLVM - https://news.ycombinator.com/item?id=3864659 - April 2012 (9 comments)

Numba - A NumPy aware (LLVM-based) optimizing compiler for Python - https://news.ycombinator.com/item?id=3692055 - March 2012 (6 comments)

Re: Numba: A High Performance Python Compiler

#47
post #5

[flagged]

That's a bit too cynical, I think. People post follow-up/related stories because the brain likes to follow chains of associations.

You're right that these chains tend towards already-familiar associations, which lower their value as HN stories. The best HN stories are the ones that can't be predicted from any existing sequence: https://hn.algolia.com/?dateRange=all&page=0&prefix=true&sor...

Re: Numba: A High Performance Python Compiler

#48

I am really intrigued by the Codon project, which aims to be a JIT compiler for Python with Numba/JAX decorator syntax: https://github.com/exaloop/codon

It's not going to take off, since it doesn't have full (or even most) API compatibility with Python. Numba seems strictly better because it can interop with Python.

Re: Numba: A High Performance Python Compiler

#49
post #12

We were very heavy numba users at my former company. I would even go so far as to say numba was probably the biggest computational enabler for the product. I’ve also made a small contribution to the library. It’s a phenomenal library for developing novel computationally intensive algorithms on numpy arrays. It’s also more versatile than Jax. In presentations, I’ve heard Leland McInnes credits numba often when he spea…

> It’s also more versatile than Jax Does numba do automatic differentiation? I view JAX as primarily an automatic differentiation tool with the bonus that it makes great use of XLA and can easy make use of GPU/TPUs. I don’t usually see numba and JAX as solving the same problem, but would be excited to be wrong

I’ve been disappointed with Jax which I was trying to use for backward auto differentiation. The issue is that XLA JIT compilation is very slow and easily adds half a minute of overhead to the first call of the base function just by using jax.numpy instead of numpy, which made it a non starter for my use case. It’s definitely optimised for large flow computations where the JIT overhead is dwarfed by the rest. In the end I reverted to using autograd which did the job fine.

I had never heard of tai chi until now, I’m curious how it compares.

Re: Numba: A High Performance Python Compiler

#50
post #19

I will save you the pain: switch to Julia.

Indeed! Converting one's entire code base to a different language ecosystem, finding equivalents to each of your third-party dependencies, is less painful than employing a library to selectively compile a few performance bottlenecks in your code. (Modules like PyJulia facilitate a more incremental approach.)

That's why you should switch before creating the codebase in the first place.
Post reply on HN