gradcheck 0.1.0

Finite-difference gradient checking for Rust ML frameworks. Verifies an autodiff engine against an independent numerical oracle, with a negative control that must fail.
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -D warnings

jobs:
  check:
    name: fmt + clippy + test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@v2

      - name: cargo fmt
        run: cargo fmt --all --check

      # The core crate builds with no ML framework at all, which is what keeps the oracle
      # independent. Check that configuration on its own before any adapter is enabled.
      - name: cargo clippy (no framework)
        run: cargo clippy --all-targets -- -D warnings

      - name: cargo test (no framework)
        run: cargo test

      # The same suite against two burn backends. Running identical checks on more than one
      # backend is the point: a backend-specific gradient bug is invisible until you do.
      - name: cargo clippy (burn-ndarray)
        run: cargo clippy --all-targets --features burn-ndarray -- -D warnings

      - name: cargo test (burn-ndarray)
        run: cargo test --features burn-ndarray

      - name: cargo test (burn-flex)
        run: cargo test --features burn-flex

      - name: cargo doc
        run: cargo doc --no-deps --features burn-ndarray
        env:
          RUSTDOCFLAGS: -D warnings

# Deliberately not in CI: --features burn-cpu.
#
# That configuration FAILS, and it is supposed to — burn's cpu backend leaks a freed
# allocation into the avg_pool1d backward at even channel counts (tracel-ai/burn#5308), and
# gradcheck detects it. A green CI badge should mean "the tool works", not "the framework is
# perfect", so the backend with a known open defect is run by hand:
#
#   cargo test --features burn-cpu --test burn_adapter
#
# Move it into this workflow once the upstream defect is fixed.