← Back to all projects

Accelerating ML Inference with SOFIE and alpaka

CERN GSoC 2025 C++ alpaka CHEP 2026
View the CHEP 2026 slides (PDF) → GSoC 2025 @ CERN-HSF
Presented at CHEP 2026. This work was given as an oral talk at the 28th International Conference on Computing in High Energy and Nuclear Physics, in Bangkok, on 28 May 2026. I contributed the heterogeneous (GPU) side of it through Google Summer of Code 2025 at CERN-HSF, and I am a listed co-author.

SOFIE (System for Optimized Fast Inference code Emit) is CERN's inference engine inside ROOT / TMVA. You hand it a trained ML model, and instead of shipping a heavy runtime, it emits the exact standalone C++ needed to run that specific model, depending only on BLAS for the matrix math. That makes it small and predictable enough to drop into the tight environments of LHC experiments, including the trigger systems that decide, in real time, which collisions are worth keeping.

Why code generation, and not just PyTorch

Inference in high-energy physics has an unusual constraint profile: high throughput, low latency, strict memory limits, and a hard requirement for long-term maintainability with as few dependencies as possible. General frameworks carry runtimes that are awkward to deploy and maintain in that setting. SOFIE's answer is to write the code rather than interpret a graph at runtime. On CPU, recent work pushes SOFIE past ONNX Runtime on several real LHC models, through optimized kernels for common ops, better memory reuse, and improved dynamic-tensor support, while staying extremely lightweight.

The heterogeneous part (my GSoC work)

The High-Luminosity LHC will lean much harder on co-processors for anything that parallelizes well, and ML inference is a prime candidate. But heterogeneous hardware brings its own pain: non-uniform memory formats, diverse inference configurations, and costly data movement between host and device. My contribution was making SOFIE's generated code run across these backends without rewrites. SOFIE can now generate C++ that manages its memory through alpaka data buffers, so the same generated model runs on multiple accelerator backends with minimal modification and stays architecture-agnostic. Because the emitted code no longer bakes in a device, it slots into existing HEP workflows far more easily.

That left one portability leak. SOFIE relies on BLAS for optimized matrix operations, but each vendor ships its own BLAS with limited portability, which quietly breaks the write-once-run-anywhere promise. So we added sofieBLAS, a thin abstraction layer that exposes a single unified BLAS interface and selects the right backend at runtime. You keep vendor-optimized performance without hard-coding the vendor into the generated code. Alongside this I wrote parallel GPU kernels for the common ML operations SOFIE needs.

How it performs

We benchmarked SOFIE's generated code on both CPU and GPU against PyTorch and ONNX Runtime, on models that HEP actually runs in production: ATLAS GN2 (jet-flavour tagging), CMS ParticleNet, and diffusion models for fast detector simulation. The full numbers, on both CPU and GPU, are in the slides.

The CHEP 2026 slides

All 25 slides, scroll straight through them here.

CHEP 2026 SOFIE slide 1 CHEP 2026 SOFIE slide 2 CHEP 2026 SOFIE slide 3 CHEP 2026 SOFIE slide 4 CHEP 2026 SOFIE slide 5 CHEP 2026 SOFIE slide 6 CHEP 2026 SOFIE slide 7 CHEP 2026 SOFIE slide 8 CHEP 2026 SOFIE slide 9 CHEP 2026 SOFIE slide 10 CHEP 2026 SOFIE slide 11 CHEP 2026 SOFIE slide 12 CHEP 2026 SOFIE slide 13 CHEP 2026 SOFIE slide 14 CHEP 2026 SOFIE slide 15 CHEP 2026 SOFIE slide 16 CHEP 2026 SOFIE slide 17 CHEP 2026 SOFIE slide 18 CHEP 2026 SOFIE slide 19 CHEP 2026 SOFIE slide 20 CHEP 2026 SOFIE slide 21 CHEP 2026 SOFIE slide 22 CHEP 2026 SOFIE slide 23 CHEP 2026 SOFIE slide 24 CHEP 2026 SOFIE slide 25

Open the deck as a PDF →

Accelerating ML Inference on heterogeneous architectures using SOFIE and alpaka
Sanjiban Sengupta (CERN, University of Manchester), Olha Sirikova, S Akash (IIT Patna), Lorenzo Moneta (CERN)
Oral, Track 3 (Offline data processing). 28th Conference on Computing in High Energy and Nuclear Physics (CHEP 2026), Chulalongkorn University, Bangkok, 28 May 2026. Talk given by Lorenzo Moneta.