Skip to content

Add OpenBLAS dense backend to linalg - #111

Open
MesTTo wants to merge 1 commit into
trueagi-io:mainfrom
MesTTo:pr/linalg-blas-backend
Open

Add OpenBLAS dense backend to linalg#111
MesTTo wants to merge 1 commit into
trueagi-io:mainfrom
MesTTo:pr/linalg-blas-backend

Conversation

@MesTTo

@MesTTo MesTTo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Adds an optional OpenBLAS-backed dense f32 backend to the linalg crate, behind the existing blas feature.

blas_backend exposes row-major dense matmul and attention (scores + apply) kernels that delegate to OpenBLAS sgemm, for standard dense workloads where a vendor BLAS beats a hand-written kernel. The module is gated behind blas, which now also enables dense (the backend builds on Dense). No default build changes: blas stays opt-in.

The tests check the kernels against hand-computed results:

  • rectangular matmul matches the expected product
  • attention scores match manual dot products
  • attention apply matches a manual weighted sum

Validation (OpenBLAS installed):

  • CARGO_HOME=/home/user/Dev/.cargo-isolated RUSTFLAGS='-C target-cpu=native -Awarnings' cargo +nightly test -p linalg --features blas blas_backend
  • rustfmt +nightly --edition 2024 --check linalg/src/blas_backend.rs
  • git diff --check
  • jscpd --reporters ai --min-lines 5 --min-tokens 50 linalg/src/blas_backend.rs

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.

1 participant