feat(mps): add successive randomized compression (SRC) apply method - #471
Merged
Conversation
Add ApplyMethod::SuccessiveRandomized, a fifth MPO-MPS apply method computing the compressed product in a single right-to-left randomized-QB sweep without materializing the full product MPS (arXiv:2504.06475). - SuccessiveRandomizedParams: fixed-rank or adaptive stopping (leave-one-out error estimate against a relative cutoff), per-site rank caps, seeded Gaussian sketching; final rounding rides the shared TruncateParams argument like StreamingNaive - Dense-only: the block-sparse dispatch arm panics (a Gaussian sketch mixes symmetry sectors) - Hoist the shared canonicalize+truncate finishing pass out of apply_streaming_naive_dense for reuse - Consolidate dense test helpers (make_3site_test_mps/mpo, assert_dense_close, generic densify) into tests/mps/helpers.rs - Add rand/rand_distr as runtime deps of ariadnetor-mps Closes #470
There was a problem hiding this comment.
Pull request overview
Adds a new MPO→MPS apply algorithm, Successive Randomized Compression (SRC), as ApplyMethod::SuccessiveRandomized, including parameterization, dense dispatch wiring, kernel implementation, and a dedicated test suite.
Changes:
- Introduces
SuccessiveRandomizedParamsandApplyMethod::SuccessiveRandomized(re-exported fromariadnetor-mps), plus dispatch plumbing inMpsOps. - Implements the dense SRC kernel (
apply_successive_randomized_dense) and factors out a shared dense finishing pass (finish_dense) used by multiple apply methods. - Adds SRC-focused tests and consolidates shared dense test helpers; adds
rand_distrand promotesrand/rand_distrto runtime deps ofariadnetor-mps.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/ariadnetor-mps/tests/mps/helpers.rs | Adds shared 3-site fixtures, densify, and assert_dense_close used across apply tests. |
| crates/ariadnetor-mps/tests/mps/apply.rs | Switches to the consolidated helpers (removes local copies). |
| crates/ariadnetor-mps/tests/mps/apply_successive_randomized.rs | New SRC test suite covering exactness, adaptivity, reproducibility, and validation panics. |
| crates/ariadnetor-mps/tests/mps.rs | Registers the new SRC test module. |
| crates/ariadnetor-mps/tests/authority.rs | Adds dispatch “authority” coverage for SRC routing through the call-site backend. |
| crates/ariadnetor-mps/src/types.rs | Defines SuccessiveRandomizedParams and adds ApplyMethod::SuccessiveRandomized with docs/panic contract. |
| crates/ariadnetor-mps/src/lib.rs | Re-exports SuccessiveRandomizedParams. |
| crates/ariadnetor-mps/src/dispatch.rs | Adds sealed apply_successive_randomized_k to MpsOps, dense impl, and block-sparse panic arm; wires method into apply_with_method. |
| crates/ariadnetor-mps/src/apply/successive_randomized.rs | Implements the dense SRC kernel (sketch env recursion, QR-based QB step, adaptive stopping). |
| crates/ariadnetor-mps/src/apply/mod.rs | Adds SRC module and factors out finish_dense for shared finishing behavior. |
| crates/ariadnetor-mps/Cargo.toml | Adds rand/rand_distr as runtime dependencies. |
| Cargo.toml | Adds workspace rand_distr = "0.6". |
| Cargo.lock | Locks rand_distr 0.6.0 (and updates dependency graph accordingly). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Zipping raw data_slice buffers is element-correct only when both tensors share one memory order; assert it so a mismatch fails loudly instead of comparing wrong element pairs.
This was referenced Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
ApplyMethod::SuccessiveRandomized, a fifth MPO-MPS apply method implementing successive randomized compression (SRC, arXiv:2504.06475): a single right-to-left randomized-QB sweep that computes the compressed product directly, without materializing the full product MPS, with the output bond chosen adaptively per site from a leave-one-out error estimate (or fixed by the caller). Closes #470.Changes
crates/ariadnetor-mps/src/types.rs:SuccessiveRandomizedParams(fixed-rank / adaptive stopping, per-site clamping, seed) and theApplyMethod::SuccessiveRandomizedvariant, re-exported fromlib.rscrates/ariadnetor-mps/src/dispatch.rs: sealedMpsOps::apply_successive_randomized_k; the block-sparse impl panics (a Gaussian sketch mixes symmetry sectors), documented under# Panicscrates/ariadnetor-mps/src/apply/successive_randomized.rs(new): the kernel — per-column Gaussian environment recursion with prefix caching, per-site thin-QR QB step, adaptive growth with a rank-deficiency guard (singular R means the exact rank is covered) and saturating incrementscrates/ariadnetor-mps/src/apply/mod.rs: the canonicalize + truncate finishing pass is hoisted into a sharedfinish_dense, reused by streaming-naive and SRCCargo.toml/crates/ariadnetor-mps/Cargo.toml:rand_distr = "0.6"added to the workspace;rand/rand_distrbecome runtime deps ofariadnetor-mpstests/mps/apply_successive_randomized.rssuite, an SRC case intests/authority.rs, and consolidation of shared dense helpers (make_3site_test_mps/make_3site_test_mpo/assert_dense_close/ genericdensify) intotests/mps/helpers.rsImpact
Purely additive: no existing behavior changes, and the sole
matchonApplyMethodlives indispatch.rs. The sealedMpsOpstrait compile-enforces both storage impls; the Dense/BlockSparse asymmetry is deliberate and documented.ariadnetor-mpsgainsrand/rand_distras unconditional runtime dependencies.Test plan
1e-10; an interior fixed rank lands exactly on every bond100 * cutoffrelative error (the acceptance factor RandomMPOMPS's owncheck_randomized_applyverification uses) with all bonds within per-site capsMixed { center: 0 }with right-isometric sites; equal seeds give bit-identical outputmin_dimfloor,max_dimcap, and theTruncateParamsfinishing pass are each pinned; single-site chains return the exact productf32rejects a finite f64 cutoff that overflows after casting;should_paniccovers block-sparse input, a missing stopping rule, and fixed-mode validation of ignored fieldscargo make gate(fmt-check + clippy-D warnings+ workspace tests + doctests) passes; the committed tree also builds and passes in a freshgit worktreeNotes
cutoffis the per-site randomized QB stopping criterion, not a certified bound on the global relative error (documented on the variant)rand/rand_distrare unconditional dependencies; feature-gating the randomized method can be revisited before v0.1@coderabbitai ignore
Plan-vs-actual delta
Compared against #470's Scope / Out of scope / Acceptance and the implementation-plan comment there:
apply_with_methodreturnsMps(noResult) and panicking on caller contract violations is the apply surface's existing idiom. Recorded in the plan comment before implementation.params: Option<&TruncateParams>argument ofapply_with_method(theStreamingNaiveconvention) instead of thefinal_roundparams field named in the issue scope. Also recorded in the plan comment.finish_densehoisted out of the streaming-naive path (both apply paths would otherwise duplicate the finalization); dense test helpers consolidated intotests/mps/helpers.rswithmps_to_densereimplemented on a genericdensify; Y assembly through the existingDenseTensorData::stackprimitive instead of element-wise loops; saturating sketch growth. From PR review: a memory-order guard inassert_dense_close(Copilot finding, feat(mps): add successive randomized compression (SRC) apply method #471 (comment), fixed in a4e6608).f64tolerance without a post-cast finiteness check (the same overflow-to-infinity class this PR guards against in SRC) — filed as Guard f64-to-real tolerance casts against overflow to infinity #472; the newrand/rand_distrdependencies are not feature-gated in this PR (see Notes); revisit at v0.1 packaging.