Skip to content

One array layout, batch scores through BLAS, and the guides under docs/ - #12

Open
mlapin wants to merge 1 commit into
masterfrom
docs/array-layout-and-guides
Open

mlapin wants to merge 1 commit into
masterfrom
docs/array-layout-and-guides

Conversation

@mlapin

@mlapin mlapin commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

Changes for the unreleased 0.4.0, on top of master.

One array layout

NumPy, Rust, C and C++ now describe the same memory the same way, and the native library reads and writes the caller's buffers in place, without copies.

Array Shape (row-major)
Features (n, d)
Weights, center (num_classes, d): one weight vector per class
Duals (n, num_classes)
  • NumPy: Model.weights and center were Fortran-ordered (d, num_classes); they are C-ordered (num_classes, d). SDCAClassifier.coef_ is unchanged.
  • Rust: the crate no longer copies weights into (d, num_classes); Start::center is passed as given.
  • C++: make_input_feature(n, d, X) and make_input_kernel(n, n_train, K) take the number of examples first (they took it second).
  • MATLAB keeps its column-major view of the same memory.

docs/API.md states the layout once.

Batch scores through BLAS

  • sdca_model_scores (C) and sdca::batch_scores (C++) compute the (n, num_classes) scores of a feature or kernel batch with one gemm.
  • Rust's Model::decision_function calls it instead of looping over examples and classes.
  • The built-in BLAS takes the A' B case through contiguous dot products.

Documentation

  • The Python, PyTorch, JAX and Rust guides move to docs/ (PYTHON.md, TORCH.md, JAX.md, RUST.md); the package and crate readmes point there.
  • Dense paragraphs are split into short paragraphs, bullets and tables across the README and the guides.
  • New reference for the projections and proximal operators of sdca/prox.h in docs/API.md and docs/CPP.md, and the matsdca_prox options in docs/MATLAB.md.
  • Links to the technical report carry no anchors or table numbers.
  • tools/check_docs.py checks local Markdown links, heading anchors and GitHub math, rejects report anchors, and runs in tools/quality.py.

Tests

  • C ABI: sdca_model_scores against plain loops, its argument validation, and the extent and BLAS-dimension overflow checks.
  • C++: batch_scores for features and kernels in both precisions, with the built-in and an external BLAS.
  • Python: a fit shares the caller's buffers without reordering; model scores and contracts in the new layout.
  • Rust: decision_function equals the product with the class rows; the consumer crate checks the scores against plain loops.

Validation

Linux x86_64 (AVX2)

Step Result
C++ tests, built-in BLAS and external BLAS 26/26 passed each
MATLAB gateway checks passed
Rust: fmt, clippy, tests, MSRV 1.74, consumer crate (built-in and reference BLAS) passed
Python, all groups 4,744 passed, 3,041 skipped, 173 expected failures
tools/quality.py (clang-format, ruff, basedpyright, complexity, docs check) passed

macOS arm64

Step Result
C++ tests, warnings as errors, Accelerate and the C ABI 26/26 passed
Python core group 1,027 passed, 597 skipped, 66 expected failures
Rust: fmt, clippy, tests, consumer crate passed

Not covered locally: the Rust consumer crate against OpenBLAS and BLIS (the Rust (BLAS) job covers it), and a scores call with more than 2^31 entries.

… under docs/

- Array layout: NumPy, Rust, C and C++ share row-major features (n, d),
  weights (num_classes, d) and duals (n, num_classes), read and written in
  place without copies. C++ make_input_feature(n, d, X) and
  make_input_kernel(n, n_train, K) take the number of examples first.
- Scores: sdca_model_scores (C), sdca::batch_scores (C++) and Rust's
  Model::decision_function compute a batch of scores with one BLAS gemm.
- Docs: the Python, PyTorch, JAX and Rust guides move to docs/; dense
  paragraphs become short paragraphs, bullets and tables; API.md and CPP.md
  document the projections and proximal operators; links to the technical
  report carry no anchors or table numbers.
- tools/check_docs.py checks local links, heading anchors and GitHub math,
  and runs in quality.py.

This branch has not been deployed

No deployments
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