Skip to content

Add proptest coverage for autodiff primitive round-trips #5

@Apocky

Description

@Apocky

Summary

cssl-autodiff implements source-to-source automatic differentiation with 19 math primitives (FAdd, FSub, FMul, FDiv, FNeg, Sqrt, Sin, Cos, Exp, Log, and piecewise-linear min/max/abs).

The forward-mode (apply_fwd) and backward-mode (apply_bwd) passes are tested via unit tests, but property-based tests (using the proptest crate, already in workspace deps) could catch more edge cases — especially NaN/inf behaviour and the chain rule invariant.

What to do

In cssl-autodiff/src/ (or a tests/ subdirectory), add proptest cases for:

  1. Linearity of forward-mode: apply_fwd(a*f + b*g) == a*apply_fwd(f) + b*apply_fwd(g) (for affine-safe primitives)
  2. Chain rule sanity: apply_fwd(compose(f, g)) == apply_fwd(f) ∘ apply_fwd(g) for a simple two-primitive chain
  3. Primal preservation: applying DiffMode::Primal is identity on the MIR body

Proptest is already available via proptest.workspace = true in Cargo.toml.

Why this is a good first issue

  • Proptest is straightforward to use — see existing property tests in cssl-testing
  • Autodiff is one of Sigil's headline features; more coverage is always welcome
  • No unsafe, no GPU, no FFI involved
  • Tests live entirely within the cssl-autodiff crate

Files

  • compiler-rs/crates/cssl-autodiff/src/ (add tests here or in tests/proptest.rs)
  • compiler-rs/Cargo.toml (proptest.workspace = true already defined)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions