Skip to content

cppjit series and a JupyterLite site: the C++ and cppjit notebooks in the browser, no install - #11

Merged
vgvassilev merged 1 commit into
masterfrom
sc-cppjit-series
Nov 5, 2026
Merged

vgvassilev merged 1 commit into
masterfrom
sc-cppjit-series

Conversation

@vgvassilev

Copy link
Copy Markdown
Contributor

New series cppjit/: five notebooks from the SC26 tutorial where a Python kernel compiles C++ through cppjit (call a header, use Clad's derivative of it, fit a C++ simulator with SciPy on that gradient, the Higgs on CMS open data without ROOT, a sixty-line tumour twin). CI runs them with the Python kernel (sanitised comparison: timings and fitted digits differ by machine); environment.yml gains numpy, scipy, matplotlib-base and cppjit.

lite/ + tools/: a JupyterLite site built from the xeus-cpp + cppjit kernel compiled to WebAssembly. The start-up set is python + numpy (5.9 MB); SciPy and matplotlib download in the background and unpack on first import; the CppInterOp module is relinked to export only what is used. 45 MB on the wire for the first notebook, 64 MB with SciPy and matplotlib. The C++ series runs in the same site (cpp/, notebook 10 excluded: its log lambda collides with std::log in the browser kernel's scope). .github/workflows/deploy-pages.yml rebuilds and publishes the site on GitHub Pages; the kernel binaries come from a release of this repository (lite/kernel/README.md), everything else from pinned locks (lite/env). Design, measurements and the rebuild recipe: lite/README-build.md.

@vgvassilev
vgvassilev force-pushed the sc-cppjit-series branch 4 times, most recently from f84560e to a46402b Compare November 5, 2026 10:01
The tutorials run only on a machine with a C++ toolchain and a kernel
installed, and the C++-from-Python direction (a Python kernel with a C++
compiler inside it) has no series at all. Derivatives of the C++ in such
notebooks have to be pre-generated, because no cppjit build carries Clad.

Add a cppjit series of five notebooks (call a header from Python, use the
derivative Clad writes for it, fit a C++ simulator on that exact gradient,
fit the Higgs mass on CMS open data without ROOT, calibrate a tumour twin)
and a JupyterLite site on which the C++ series and the cppjit series run
with nothing installed: xeus-cpp + cppjit compiled to WebAssembly on the
LLVM 23 line, with Clad built into CppInterOp, so clad::gradient works in a
C++ cell and through cppjit. The native side runs on a cppjit wheel built
with the same Clad plugin, and the notebooks generate their derivatives in
the session on both. SciPy and matplotlib load on first import; the wire
cost is 49.8 MB for the first notebook and 69.8 MB with SciPy loaded.

The kernel and the wheel are release assets verified against digests
committed in lite/kernel/SHA256SUMS; build-kernel.yml rebuilds both on a
runner and proposes new digests as a pull request. The release kernel is
linked against an LLVM 23 built with the ci-workflows llvm-wasm recipe
(WebAssembly target only, -Oz, LTO: 23.7 MB on the wire instead of 32.5,
cell times unchanged within noise); tools/build-wasm-kernel.sh takes such
an install through LLVM_WASM_DIR, and the workflow builds against the
conda package until that install is published as a cell. The kernel is built
from CppInterOp, cppjit and xeus-cpp main with compiler-research/CppInterOp
#1167 and Clad at 90a623d6 (vgvassilev/clad#2453: a failed input's
declarations are no longer replayed into CodeGen on clang >= 22, which hung
the kernel after any parse error), with the patches in lite/kernel/:
#1167's clad cross-build flags and static link interface under emsdk
4.0.9, cppjit as a wasm side module and with Clad on request. These are
candidates for upstream. Verified under nektos/act: the cppjit
job, the Pages build with the real assets and the kernel-and-wheel build.

Two cells of 07_stl_modern_cpp.ipynb ran lambdas that write to std::cout
inside top-level statements; clang-repl 21 (the xeus-cpp kernel) crashes
in the Itanium mangler on that pattern (compiler-research/xeus-cpp#476)
depending on heap layout, which is why the C++ job was green on master
in June and dead on every runner since. Both cells now define a named
function and call it, with the same outputs.
@vgvassilev
vgvassilev merged commit 3e333f1 into master Nov 5, 2026
10 checks passed
@vgvassilev
vgvassilev deleted the sc-cppjit-series branch November 5, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant