Manuscript Offprint

arXiv:2609.10632

Numbat: Building and Verifying a Self-Contained Machine-Learning Stack

Thang Tran, Lan Dang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Machine-learning systems are built almost exclusively on a few large Python-orchestrated frameworks, and they inherit those stacks' engineering costs: environments of hundreds of version-coupled packages, separate export toolchains for deployment, and the split between the language research is written in and the language products ship in. We report on the construction and verification of numbat, a machine-learning stack written in one general-purpose language (Zig) with no third-party runtime dependencies. The stack spans tensor computation, automatic differentiation, neural-network modules, mixed precision, multi-GPU training, data loading and monitoring; an SDK exposes it behind a stable, additively versioned C ABI of over 1,400 entry points, with bindings for six languages; and its clinical domain planes encode regulatory requirements as executable acceptance gates rather than documentation. Verifying such a stack is the harder half of building it: a defective training run rarely fails, it converges quietly to a slightly worse model. We treat a widely used reference implementation as an executable specification and verify against it at five levels, from operator gradient checks to an automated trajectory gate against a same-machine reference run — the arrangement our companion study formalizes as a trajectory-level differential oracle. The protocol surfaced ten silent recipe divergences, which we catalog with mechanisms and symptoms. As the acceptance test, we train a 25.9M-parameter detector of the YOLOv8m class from random initialization on COCO 2017 for the full 500-epoch schedule: the exported weights score 0.4956 mAP 50−95_{50-95} under the official protocol, scored by the reference stack's own validator (published endpoint 0.502), with single-GPU step time at parity on identical hardware. Weights, per-epoch metrics and the full run manifest are released.

1 Introduction

Contemporary deep-learning practice is concentrated on a small number of large Python-orchestrated frameworks [1, 5, 27]. These systems are mature and productive. They are also expensive in ways their own authors acknowledge [2, 27]. Per-operator dispatch through the interpreter adds host-side overhead, which PyTorch 2 mitigates with an additional bytecode-capture and graph-compilation layer [2] at the price of further system complexity. A GPU-enabled installation spans gigabytes across hundreds of packages, and the version coupling among framework, accelerator libraries, driver and Python dependencies makes environments costly to reproduce and audit. Deployment to edge, embedded, mobile or air-gapped targets goes through separate export toolchains rather than

*Corresponding author: thang.tran@cloudkites.com through the stack that trained the model, yielding the familiar two-language pattern — research in Python, production re-implemented in a systems language — which duplicates engineering and invites divergence. Organizations that must audit their supply chain, or bound memory behavior on constrained devices, inherit all of it. The demand for self-contained runtimes is directly evidenced by the adoption of inference engines such as llama.cpp [8] and ONNX Runtime [25]; such systems deliberately stop short of training. Independent training stacks outside the mainstream ecosystem exist [10, 14, 33], but public evidence that one can reproduce the training outcome of a mature, competitive recipe — rather than merely execute gradient descent — remains scarce.

numbat removes these costs at their root: one dependency-free stack in a single general-purpose language, covering training through deployment, with applications shipping as single static binaries. Building it, however, is only half the work, and the smaller half. A modern training recipe is specified de facto by its implementation rather than by any paper: initializer distributions, mixed-precision autocast placement, optimizer parameter grouping, exponential-moving-average (EMA) semantics, gradient-clipping policy, loss-scaler dynamics, augmentation details and random-number-generator (RNG) structure are behavioral properties of code, individually undocumented and individually capable of degrading the final metric without any overt failure. This is a recognized reproducibility problem even within one framework [4, 13, 28]; across independently implemented frameworks it is the central difficulty, and it is a software-engineering difficulty — a verification problem with no oracle — before it is a numerical one. In a companion study we formalized the two-stack arrangement as a trajectory-level differential oracle and applied it to language-model fine-tuning, where the comparison exposed seventeen faults that single-implementation development had missed [35]. This paper is about the stack itself: how it is put together, how its interfaces are kept stable, how domain requirements are made executable, and what it took to reproduce a competitive from-scratch training outcome end to end.

The paper makes five contributions.

  1. Design. We describe numbat, a self-contained ML framework written in Zig covering tensors, autograd, modules, mixed precision, distributed data-parallel training, data pipelines and monitoring, with CPU and CUDA backends in production use and vendor-neutral GPU paths including a single-source kernel plane compiled by the framework's own compiler ( §3§3). One design principle carries most of the weight: reference-default semantics — numbat adopts the dominant ecosystem's defaults (initializers, autocast policy, optimizer and loss-scaler defaults, RNG streams) as its own, so recipes transfer across stacks unchanged.

  2. Interface discipline. The numbat SDK packages the full training and inference capability behind one C ABI that is versioned and strictly additive, with thin bindings for six languages whose numerical agreement is enforced by shared tests and, at trajectory level, evidenced in the companion study ( §4§4).

  3. Requirements as executable gates. For the clinical domains the stack targets, design requirements are encoded as acceptance gates — executable checks with verdicts and exit codes — backed by typed diagnostic registries whose coverage is measured rather than asserted ( §5§5). We describe the method and what it caught.

  4. Reproduction protocol and divergence catalog. We define a five-level cross-framework training-reproduction protocol — operator, module, step, trajectory, outcome — with an automated trajectory gate against a same-machine reference trajectory ( §6§6), and we catalog the ten silent recipe divergences it surfaced, with mechanisms and symptoms ( §7§7). The catalog is of independent value to anyone porting a training recipe between frameworks.

  5. End-to-end evidence. We train YOLO-NB-M, a YOLOv8m-class detector, from scratch on COCO 2017 for 500 epochs on three power-capped consumer GPUs, tracking the reference trajectory throughout, and report accuracy under the official COCO protocol as scored by the reference stack's own validator on exported weights, plus same-machine throughput, memory and energy accounting, including negative results ( §8§8). Weights, metrics and the run manifest are released ( §9§9).

References (38)

  • A system for large-scale machine learning
  • YOLOv4: Optimal Speed and Accuracy of Object Detection
  • Unreproducible research is reproducible
  • JAX: Composable transformations of Python+NumPy programs, 2018
  • Sigmoid-weighted linear units for neural network function approximation in reinforcement learning
  • TOOD: Task-aligned one-stage object detection
  • llama.cpp: LLM inference in C/C++, 2023
  • Simple copy-paste is a strong data augmentation method for instance segmentation
  • MLX: Efficient and flexible machine learning on Apple silicon, 2023
  • Delving deep into rectifiers: Surpassing human-level performance on ImageNet classification
  • Rethinking ImageNet pre-training
  • Deep reinforcement learning that matters
  • tinygrad, 2023
  • Batch normalization: Accelerating deep network training by reducing internal covariate shift
  • Ultralytics YOLOv8, 2023
  • Fast algorithms for convolutional neural networks
  • Chuyi Li, Lulu Li, Hongliang Jiang, Kaiheng Weng, Yifei Geng, Liang Li, Zaidan Ke, Qingyuan Li, Meng Cheng, Weiqiang Nie, et al. YOLOv6: A single-stage object detection framework for industrial applications. arXiv preprint arXiv:2209.02976, 2022. (opens arXiv in a new tab)
  • PyTorch distributed: Experiences on accelerating data parallel training
  • Generalized focal loss: Learning qualified and distributed bounding boxes for dense object detection
  • Microsoft COCO: Common objects in context
  • Feature pyramid networks for object detection
  • Path aggregation network for instance segmentation
  • Mixed precision training
  • On the difficulty of training recurrent neural networks
  • PyTorch: An imperative style, high-performance deep learning library
  • Improving reproducibility in machine learning research (a report from the NeurIPS 2019 reproducibility program)
  • YOLOv3: An incremental improvement (opens arXiv in a new tab)
  • You only look once: Unified, real-time object detection
  • Parallel random numbers: As easy as 1, 2, 3
  • DSOD: Learning deeply supervised object detectors from scratch
  • Burn: A next-generation tensor library and deep learning framework, 2024
  • Triton: An intermediate language and compiler for tiled neural network computations
  • Cross-Stack Validation of Language-Model Training: A Clinical Fine-Tuning Case Study
  • CSPNet: A new backbone that can enhance learning capability of CNN. In IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, 2020
  • YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
  • mixup: Beyond empirical risk minimization
  • Distance-IoU loss: Faster and better learning for bounding box regression
  • Random erasing data augmentation