Skip to content

Commit e0bcb52

Browse files
Merge pull request #362 from MMesch/numba-llvmlite-wasm
Add sponsor project: Numba and llvmlite in the browser
2 parents ccf4f3c + 0f2c853 commit e0bcb52

4 files changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
2+
import GetAQuotePage from '@site/src/components/fundable/GetAQuotePage';
3+
4+
export default function FundablePage() {
5+
const { siteConfig } = useDocusaurusContext();
6+
return (
7+
<GetAQuotePage/>
8+
);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
2+
import LargeProjectCardPage from '@site/src/components/fundable/LargeProjectCardPage';
3+
4+
export default function FundablePage() {
5+
const { siteConfig } = useDocusaurusContext();
6+
return (
7+
<LargeProjectCardPage/>
8+
);
9+
}

‎src/pages/sponsor/_projectsDetails.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Decimal32InArrowCppMD from "@site/src/pages/sponsor/descriptions/Decimal3
1010
import Float16InArrowCppMD from "@site/src/pages/sponsor/descriptions/Float16InArrowCpp.md"
1111
import RunEndEncodedInArrowCppMD from "@site/src/pages/sponsor/descriptions/RunEndEncodedInArrowCpp.md"
1212
import ParquetNullOptimizationsMD from "@site/src/pages/sponsor/descriptions/ParquetNullOptimizations.md"
13+
import NumbaInWasmMD from "@site/src/pages/sponsor/descriptions/NumbaInWasm.md"
1314

1415
export const fundableProjectsDetails = {
1516
jupyterEcosystem: [
@@ -50,6 +51,18 @@ export const fundableProjectsDetails = {
5051
currentFundingPercentage: 0,
5152
repoLink: "https://github.com/geojupyter/jupytergis"
5253
},
54+
{
55+
category: "Jupyter Ecosystem",
56+
title: "Numba and llvmlite in the browser",
57+
pageName: "NumbaInWasm",
58+
shortDescription: "Numba, the standard JIT compiler for numerical Python, now runs in the browser: we have it compiling and executing code inside JupyterLite, along with packages that depend on it such as PyTensor and PyMC. Help us upstream the llvmlite and Numba changes, expand test coverage, add persistent caching, and bring the wider Numba ecosystem to emscripten-forge.",
59+
description: NumbaInWasmMD,
60+
price: "TBD",
61+
maxNbOfFunders: 1,
62+
currentNbOfFunders: 0,
63+
currentFundingPercentage: 0,
64+
repoLink: "https://github.com/numba/llvmlite"
65+
},
5366
],
5467
packageManagement: [
5568
{
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#### Overview
2+
3+
[Numba](https://numba.pydata.org/) is the standard
4+
just-in-time (JIT) compiler for numerical Python, widely used
5+
across the scientific stack to accelerate compute-heavy code.
6+
Until recently it could not run in the browser: its JIT
7+
backend, [llvmlite](https://github.com/numba/llvmlite), relies
8+
on execution engines that WebAssembly does not provide.
9+
10+
We have made Numba work in the browser. Numba and llvmlite now
11+
run inside [JupyterLite](https://jupyterlite.readthedocs.io/),
12+
compiling Python functions to WebAssembly and executing them in
13+
the same page, with no server involved. We are looking for
14+
funding to turn this prototype into a capability the ecosystem
15+
can rely on, maintained upstream in Numba and llvmlite.
16+
17+
See our announcement,
18+
[Numba in the Browser](https://notebook.link/blog/numba-in-the-browser/),
19+
for the full story.
20+
21+
#### What Works Today
22+
23+
- llvmlite runs in the browser, through a WebAssembly execution
24+
engine that emits WebAssembly objects from LLVM IR, links them
25+
in-process with LLVM's linker LLD, and loads each result as an
26+
Emscripten side module.
27+
- Numba's `@jit` and `@njit` compile and execute inside a
28+
JupyterLite kernel, on arrays as well as scalars.
29+
- Packages that depend on Numba run in the browser, including
30+
[PyTensor](https://github.com/pymc-devs/pytensor),
31+
[PyMC](https://github.com/pymc-devs/pymc),
32+
[Dolo.py](https://github.com/EconForge/dolo.py) and
33+
[interpolation.py](https://github.com/EconForge/interpolation.py).
34+
- On the example in our announcement, Numba gives a roughly
35+
250x speedup in WebAssembly, against about 90x for the same
36+
code natively.
37+
38+
#### Why Numba in the Browser Matters
39+
40+
A substantial part of the scientific Python stack depends on
41+
Numba, frequently as a hard requirement rather than an optional
42+
accelerator. PyTensor, PyMC, QuantEcon, stumpy and others are in
43+
this category. Until now none of them could be installed in
44+
Pyodide or emscripten-forge at all: not a matter of running
45+
slower in the browser, but of not running.
46+
47+
Numba also covers a case that pre-compiled extensions
48+
structurally cannot. Code written interactively in a notebook
49+
does not exist until the user types it, so it cannot be shipped
50+
ahead of time in a wheel or a conda package. A JIT compiler is
51+
the only way to make that code fast, and notebooks are precisely
52+
where browser-based Python is used.
53+
54+
#### Why QuantStack
55+
56+
QuantStack has in-house Numba expertise, which is rare, combined
57+
with long experience of LLVM in WebAssembly. We develop
58+
[xeus-cpp](https://github.com/jupyter-xeus/xeus-cpp), a C++
59+
interpreter running in the browser via Clang and LLVM compiled
60+
to WebAssembly, and the execution engine behind Numba in the
61+
browser grew directly out of that work. We also maintain
62+
[emscripten-forge](https://github.com/emscripten-forge) and are
63+
core contributors to Jupyter and JupyterLite, where this work is
64+
deployed.
65+
66+
#### Proposed Work
67+
68+
The prototype establishes the end-to-end architecture. Making it
69+
dependable means:
70+
71+
- upstreaming the llvmlite and Numba changes as focused,
72+
reviewable contributions;
73+
- expanding test coverage, running the llvmlite and Numba test
74+
suites in the browser;
75+
- improving compilation performance and adding persistent
76+
caching, so that compiled functions survive a page reload;
77+
- validating and packaging more of the Numba ecosystem for
78+
emscripten-forge.
79+
80+
These are separable pieces of work: we advance incrementally and
81+
deliver sub-parts, so the project can be funded in full or in
82+
part.
83+
84+
##### Are you interested in this project? Either entirely or partially, contact us for more information on how to help us fund it.

0 commit comments

Comments
 (0)