Skip to content

Conversation

@RidwanAdebosin
Copy link
Contributor

@RidwanAdebosin RidwanAdebosin commented Oct 15, 2025

Why it matters

Performance of Rune’s backward pass is currently blocking some users. This PR adds systematic benchmarks to provide numbers for both forward and backward passes, enabling investigation and future optimization.

What’s in this PR

  • Adds a benchmark suite in rune/bench/ for:
    • Forward and backward (grad) passes on key ops
    • JIT compilation benchmarks
    • PyTorch and JAX comparison scripts

How to run

dune exec rune/bench/bench_rune.exe
uv run rune/bench/bench_pytorch.py
uv run rune/bench/bench_jax.py

This PR implements the full benchmark suite as described in the task, covering all required operations, backward/JIT passes, and comparative scripts for PyTorch and JAX.
For more details, see the benchmark suite README.

Implements 162 benchmarks for forward/backward/JIT modes across 21
operations (elementwise, reductions, linalg, shape ops, neural ops).

Following nx/bench pattern with ubench library:
- Forward pass: direct operation execution
- Backward pass: automatic differentiation via Rune.grad
- JIT compilation: compiled execution via Rune.jit

Includes PyTorch (torch.autograd) and JAX (jax.grad) comparison
scripts for competitive analysis.

Test configuration:
- Sizes: [50, 100, 200] for systematic scaling
- Dtype: Float32
- Measurements: 10 per benchmark with 3 warmup iterations

System specs documented in README. JIT falls back to eager mode on
Linux (Metal backend requires macOS).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this file is not really related to neither this PR nor Raven

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the link. You can check now.

@tmattio
Copy link
Contributor

tmattio commented Oct 22, 2025

@RidwanAdebosin I've merge the rune benchmarks in 94cfac0, putting you as a co-author as it builds on your work in this PR.

I've decided to only include gradient benchmarks for now, since JIT is not ready yet, and the forward-pass benchmarks are already handled by Nx. I'm also only including comparative benchmarks against PyTorch, there's no good reason to track performance against Jax for now, we can do this when we measure JIT performance when it lands.

Thank you for your work on this!

@tmattio tmattio closed this Oct 22, 2025
@RidwanAdebosin
Copy link
Contributor Author

RidwanAdebosin commented Oct 22, 2025

@tmattio Thanks a lot! I’m glad to see the benchmarks merged and appreciate being added as a co-author. Makes perfect sense to focus on gradients for now. I’ll be happy to help once the JIT and JAX benchmarking work begins.

@tmattio tmattio linked an issue Oct 23, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create benchmark suite for Rune autodiff and JIT

3 participants