HenryNdubuaku/jacobi
关于
ML framework for Rust with PyTorch ergonomics and Hugging Face integration, compiled via XLA/PJRT
人工智能与机器学习实测星标增长
- 24小时
- 0
- 7天
- -1
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
Jacobi
A machine learning framework for Rust compiled via XLA/PJRT to CPUs, GPUs (CUDA, ROCm), and TPUs, with native AMX/SME2 and Metal acceleration on Apple Silicon. Jacobi feels like PyTorch, compiles like JAX, and integrates with the ML ecosystem (Hugging Face, ONNX, Safetensors, NumPy, Candle).
This project started as Nanodl early 2023, a JAX framework for ML, but over time, I maintained a private fork for experiments and gradually replaced all Python interface with Rust directly on XLA, for performance. These were merged into NanoDL and renamed to Jacobi. Gradually testing all optimisation I stacked up over time and merging in, the git history is preserved for old users of NanoDL.
Benchmarks
1-1024-1024-1tanh network for 200 full-batch steps on 2,048 points ofsin(x)inf32.- Median of 5 runs after 1 warm-up with identical initial weights and matching convergence (
0.3586 -> 0.0133).
| Framework | Nvidia B300 | Nvidia B300 CPU | Nvidia B200 | Nvidia B200 CPU | Apple M5 Max GPU | Apple M5 Max CPU |
|---|---|---|---|---|---|---|
| Jacobi 0.1.0 (jit + for_loop) | 0.0139s | 2.98s | 0.0171s | 2.66s | 0.14s | 1.13s |
| JAX 0.12.1 (jax.jit + fori_loop) | 0.0147s | 3.31s | 0.0175s | 2.67s | - | 1.22s |
| PyTorch (eager) | 0.0856s | 24.29s | 0.1042s | 2.73s | 0.31s | 2.23s |
PyTorch (torch.compile) |
- | - | - | - | 0.31s | 2.30s |
| MLX 0.32.5 | - | - | - | - | 0.15s | 3.86s |
Production Training
See docs/examples/benchmark.md for the full benchmark setup, methodology, and reproducible commands.
| Model | Hardware | Parallelism | Mode | Precision | Batch | Peak RAM | Throughput | Cost / 1T |
|---|---|---|---|---|---|---|---|---|
| Gemma-4-E4B (7.4B) | 1x B200 180GB | Single GPU | Forward/Prefill (4k) | FP8 | 16 | 22 GB | 154,127 tok/s | $9k |
| Train (Fwd+Bwd+Update) | FP8 | 8 | 155 GB | 35,021 tok/s | $40k | |||
| Rollout/Decode (4k -> 1k) | FP8 | 512 | 20 GB | 30,999 tok/s | $45k | |||
| Inkling-2-Mini (26B) | 8x H200 141GB | Expert Parallel | Forward/Prefill (4k) | FP8 | 192 | 210 GB | 356,044 tok/s | $22k |
| Train (Fwd+Bwd+Update) | FP8 | 192 | 1,015 GB | 105,420 tok/s | $74k | |||
| Rollout/Decode (4k -> 1k) | FP8 | 2,048 | 150 GB | 63,084 tok/s | $123k | |||
| DeepSeek-V4-Flash (283B) | 16x H200 141GB | Data + Expert Parallel | Forward/Prefill (4k) | FP8 | 64 | 744 GB | 217,234 tok/s | $72k |
| Train (Rank-32 EfficientAdamW) | FP8 | 80 | 2,115 GB | 52,966 tok/s | $294k | |||
| Rollout/Decode (4k -> 1k) | FP8 | 2,048 | 797 GB | 42,924 tok/s | $362k |
EfficientAdamW vs Full AdamW
Jacobi ships (EfficientAdamW) for memory- and communication-bound training (such as 100B+ MoE models over multi-node RDMA), cuts optimizer state by ~99% and compresses DP AllReduce traffic.
It works well when HBM capacity or inter-node gradient sync is the bottleneck, but on smaller models or compute-bound dense runs where full AdamW already fits in memory,
projection overhead slows steps down and low-rank updates can lag full-rank AdamW over long horizons.
| Model & Hardware | Optimizer | State / GPU | Peak HBM / GPU | Throughput | 15-Step CE Loss (PleIAs/SYNTH) |
|---|---|---|---|---|---|
| DeepSeek-V4-Flash 16L (106B, 16x H200 DP=2 x EP=8, batch 64) | Full AdamW | 62.56 GB | 120.00 GB | 57,865 tok/s | 12.59 -> 8.15 |
| DeepSeek-V4-Flash 16L (106B, 16x H200 DP=2 x EP=8, batch 64) | Rank-32 EfficientAdamW (gap=50, scale=2.5) | 0.60 GB (99.0% saved) | 58.88 GB | 140,018 tok/s (2.42x) | 12.59 -> 7.76 |
| DeepSeek-V4-Flash 43L (283B, 16x H200) | Full AdamW (EP=16, batch 16 min) | >141 GB | OOM | OOM | - |
| DeepSeek-V4-Flash 43L (283B, 16x H200 DP=2 x EP=8, batch 80) | Rank-32 EfficientAdamW (gap=50, scale=2.5) | 1.59 GB (99.0% saved) | 132.19 GB | 52,966 tok/s | 12.57 -> 10.62 |
Quick Start
cargo add jacobi
use jacobi::prelude::*;
#[module]
struct Mlp {
l1: Linear,
l2: Linear,
}
impl Mlp {
fn forward(&self, x: &Tensor) -> Tensor {
self.l2.forward(&self.l1.forward(x).tanh())
}
}
let step = jit(move |(mut m, mut o): (Mlp, AdamW<Mlp>)| {
let (loss, grads) = value_and_grad(
|p| nn::mse_loss(&p.forward(&x), &y),
&m,
);
o.step(&mut m, &grads);
(m, o, loss)
});
Citation
If you use Jacobi in your research or production workloads, use freely, but please cite as follows and give proper credit.
@software{ndubuaku2026jacobi,
author = {Ndubuaku, Henry},
title = {Jacobi: A Machine Learning Framework for Rust Compiled via XLA and PJRT},
year = {2026},
url = {https://github.com/HenryNdubuaku/jacobi}
}
Read the documentation, browse the examples, or point AI assistants and coding agents at llms.txt and llms-full.txt.
探索相关项目
加载中…