Skip to content

v1.49.0 — Stage 2b-1: Default 5-op SSA AD, Law 2 Backward Monoid Fusion & CPU BLAS cce_bwd

Choose a tag to compare

@iskandr iskandr released this 05 Dec 02:01
· 2 commits to master since this release

Highlights — Stage 2b-1: Default 5-op SSA AD, Law 2 Backward Monoid Fusion & CPU BLAS cce_bwd (#301)

This release switches Parakeet's public autodiff APIs (grad, value_and_grad, vjp, jvp, hvp, jacfwd, jacrev, hessian) to the unified 5-op SSA AD engine by default (config.ad_engine = "ssa", with automatic fallback only for the remaining unlifted ops slated for v1.50.0), while delivering major speedups on real ML training loops and zero runtime or memory regressions.

What's New

  • Default 5-op SSA AD (parakeet/ssa/frontend_ad.py, parakeet/ssa/autodiff.py):
    • Routes grad, value_and_grad, vjp, jvp, hvp, jacfwd, jacrev, and hessian through the value-SSA core IR (Map, Reduce, Scan, Recur, Scatter) with per-target dead constant pruning, higher-order AD, stop_gradient, checkpoint, custom_vjp/custom_jvp, structured control flow (If, ForRange, While), and Carry reduction handling.
  • Post-AD Law 2 Backward Monoid Fusion (parakeet/transforms/monoid_bwd.py, parakeet/transforms/monoid_tile.py):
    • Fuses backward FlashAttention (flash_monoid_bwd), fused cross-entropy (cce_bwd), and ephemeral pairwise VJP reductions directly on bufferized SSA AD IR with zero O(T^2) residual allocations and zero atomic scatter write-backs (using injective mixed-radix IndexMap write-backs).
  • Bounded-Memory CPU BLAS cce_bwd (parakeet/transforms/lowering.py, parakeet/backends/runtime_c.py):
    • Lowers CPU cce_bwd into BM<=1024, BN<=2048 (<= 8 MiB) tiles using @gemm forward logits, SIMD softmax gradient + O(1) target update, and @gemm_acc for dH and dW.
  • Block Outlining & Scatter/Fusion Parity (parakeet/transforms/outline.py, parakeet/transforms/fusion.py, parakeet/ssa/bufferize.py):
    • Preserves multi-site per-layer and derived integer dim_facts across outlined transformer blocks, simplifies Euclidean scatter targets, and prevents contraction IndexMaps from fusing into IndexScatter (keeping all 37/37 BLAS GEMMs intact in nanoGPT).

Benchmarks (Matched CPU Release Suite)

Workload Previous (v1.48.0 / Legacy AD) v1.49.0 (SSA AD) Speedup
mlp_grad (bench_release.py) 2.85 ms 0.81 ms (min 0.60 ms) 3.5× faster
attn_grad (causal FlashAttention) min 2.420 ms min 2.429 ms Parity (+0.4%, 0 O(T^2) alloc, 0 scatters)
nanoGPT L=2 (step_batched_compiled) med 35.17 ms (cold 2736 ms) med 8.72 ms (cold 2307 ms) 4.0× faster (-429 ms cold compile)

Verification

  • 17/17 CI checks green across macOS, Linux, Windows (Python 3.11–3.14), pandas interop, atomistic, strict docs, and ruff lint (PR #309).
  • Full test suite: 1,927+ passed, 0 failed.