Skip to content

feat: add MaybeUninit-safe overwrite matmul - #270

Open
shinaoka wants to merge 1 commit into
sarah-quinones:mainfrom
shinaoka:feat/maybe-uninit-matmul
Open

shinaoka wants to merge 1 commit into
sarah-quinones:mainfrom
shinaoka:feat/maybe-uninit-matmul

Conversation

@shinaoka

Copy link
Copy Markdown

Summary

Add a typed write-only destination for overwrite-only matrix multiplication:

  • add public MatUninitMut over MaybeUninit<T> storage;
  • add matmul_with_conj_uninit with explicit Par;
  • use the existing native gemm path with read_dst = false;
  • use a raw-pointer scalar fallback without forming destination references before writes;
  • return an initialized MatMut only after every logical output element has been written;
  • cover column-major, row-major, strided/conjugated, empty-inner-dimension, Rayon, and non-native scalar paths.

The API preserves the existing initialized matmul entry points. A destination made with from_raw_parts_mut retains the existing raw-view safety preconditions, including exclusive borrowing, valid allocation, and non-overlapping logical elements.

Contract

The implementation does not read prior destination values in overwrite mode, does not use assume_init or zero-fill an output-sized temporary, and accepts explicit parallelism rather than ambient Rayon state. On panic, the caller retains MaybeUninit<T> storage and no initialized reference is exposed.

Downstream tracking: tensor4all/strided-rs#198
Upstream request: #269

Verification

  • cargo test --workspace --quiet (Faer 197 passed, 2 ignored; faer-ffi 37 passed)
  • cargo check --workspace --all-targets
  • cargo check -p faer --no-default-features --features linalg
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps
  • rustfmt check on all changed files
  • git diff --check

@shinaoka
shinaoka force-pushed the feat/maybe-uninit-matmul branch from 7ae4f48 to 276d196 Compare July 31, 2026 11:21
@shinaoka

Copy link
Copy Markdown
Author

Added a negative destination-stride regression test in commit 276d196; it passes together with the existing native, strided/conjugated, K=0, Rayon, and non-native scalar cases. Fresh local verification: workspace tests 198 passed, 2 ignored; workspace all-target check passed; rustfmt and diff checks passed.

@shinaoka

Copy link
Copy Markdown
Author

Canonical upstream correction

The Faer repository's Cargo metadata and current upstream activity identify https://codeberg.org/sarah-quinones/faer as the canonical repository. The GitHub repository is a mirror: its main commit matches the Codeberg release head, but GitHub issue/PR numbers are not synchronized. In particular, Codeberg #269/#270 are unrelated closed changes.

Therefore GitHub #269/#270 should be treated only as a public implementation prototype and review artifact, not as an upstream issue/PR. The current prototype head remains 276d1966b89d86bb99ca59f507ac5a0d3f8f0d7f; it has local workspace, all-target, rustdoc, focused test, and formatting evidence, but it has no canonical upstream review or release.

This workspace has no Codeberg API token or accepted Codeberg SSH key, so I cannot create the canonical issue/PR from here. No strided-rs adoption or dependency pin will be made against this unreleased prototype. The downstream prerequisite remains open until the canonical Codeberg API request is reviewed, released, and adopted with the tests and t1/t4 evidence required by this issue.

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