Skip to content

Examples

Every example below is a complete, runnable Rust program in examples/.

cargo run --release --example mlp
cargo run --release --example cnn
cargo run --release --example vit
cargo run --release --example gpt
cargo run --release --example qwen
cargo run --release --example diffusion
cargo run --release --example speech_to_speech
cargo run --release --example grpo
cargo run --release --example ppo
cargo run --release --example gemma4_e4b -- --small
cargo run --release --example inkling_mini_2_26b -- --small
cargo run --release --example deepseek_v4_flash -- --small
cargo run --release --example efficient_grad
cargo run --release --example benchmark

Put JACOBI_BACKEND=cpu in front of any command to force CPU execution. Interactive versions are also available in notebooks/.

Model Walkthroughs

  • MLP and Fused EpochsFits sin(x) with a compiled full-epoch loop, implicit randperm shuffling, and .safetensors checkpoint export.
  • CNN Image ClassifierClassifies synthetic bar images with Conv2d, global average pooling, nn::cross_entropy, AdamW, and .safetensors saving.
  • Vision TransformerBuilds a patch-based ViT with learnable cls_token and pos_emb tensors and multi-head attention.
  • Mini GPTTrains a causal Transformer in fused 20-step chunks, saves .safetensors, and runs compiled 64-token generation.
  • Pretrained Qwen2.5 (HF)Downloads real Qwen/Qwen2.5-0.5B weights from Hugging Face and runs compiled fixed-shape KvCache generation with RoPE and 7x GQA.

RL, Diffusion, and Speech

  • Diffusion Transformer (Flow Matching)Trains a 2D-RoPE AdaLN-Zero DiT with rectified flow matching (nn::diffusion) and runs compiled Euler ODE sampling.
  • Streaming Speech-to-SpeechCombines on-device log_mel_spectrogram, spec_augment, CausalConv1d, ConformerConvModule, and differentiable ctc_loss.
  • Batched Rollout and GRPOGenerates grouped trajectories with static-shape RolloutKvCache + batched_rollout_loop and updates policies via grpo_advantages and grpo_loss.
  • Actor-Critic PPO with GAEComputes reverse-scan Generalized Advantage Estimation (gae_advantages) and runs multi-epoch clipped surrogate updates (ppo_clipped_loss).

Distributed and Frontier Scale

  • Gemma-4-E4B (7.4B FP8)Trains the 42-layer 262k-vocab Gemma-4-E4B architecture in FP8 on 1x B200 with Per-Layer Embeddings, nn::flash_attention, nn::fused_geglu_linear, nn::chunked_cross_entropy_tn, and PleIAs/SYNTH streaming.
  • Distributed Inkling-2-Mini (26B MoE)Trains the 25.85B looped-core MoE architecture (48 logical visits, 128 experts, top-8, GQA, causal short conv) on 8x H200 with token-sharded FP8 all_to_all_axis Expert Parallelism and PleIAs/SYNTH streaming.
  • Multi-Node DeepSeek-V4-Flash (283B MoE)Trains the 283B mHC + low-rank MQA + 256-expert FP8 MoE architecture across 2 nodes (16x H200) with Mesh::hybrid_dp_ep, nn::moe_swiglu_dispatch_all_to_all_fused_tn, and EfficientAdamW::value_and_grad_hybrid.

Performance and Memory Efficiency

  • Low-Rank Training (efficient_grad)Trains a 4-layer MLP and a 4-layer Transformer LM with low-rank gradients and factorized AdamW moments, saving 86% to 98%+ of non-weight RAM.
  • Hardware BenchmarkCompares compile time, steady-state execution time, MFU, and 1T-token cost across CPU, B200, B300, 8x H200, and 16x H200 clusters.