Repository navigation
fix: 馃悰 preserve input precision in apply and compress - #36
Merged
Panadestein merged 9 commits intoOct 6, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
馃煛 Changes recommended
Two test decorators require Ruff formatting to pass lint CI.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Preserves input precision by deriving random-sketch dtypes from tensor inputs.
Changes:
- Adds
sketch_dtypeinference. - Updates
applyandcompressdefaults and documentation. - Tests all four operations across real and complex precisions.
| File | Description |
|---|---|
src/鈥媠rc_method/鈥媢tils/鈥媉backend.py |
Adds sketch dtype resolution. |
src/鈥媠rc_method/鈥媋pply.py |
Infers sketch precision for applications. |
src/鈥媠rc_method/鈥媍ompress.py |
Infers sketch precision for compression. |
tests/鈥媡est_package.py |
Adds precision-preservation tests. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Simone Gasperini <simone.gasperini4@unibo.it>
Port the sketch dtype resolution onto the stack kernel and draw complex sketches from the complex Ginibre ensemble. Assisted-by: pi:claude-sonnet-5.5
Panadestein
approved these changes
Oct 6, 2026
Panadestein
left a comment
Member
There was a problem hiding this comment.
Thanks @SimoneGasperini !
Panadestein
added a commit
that referenced
this pull request
Oct 7, 2026
Resolve the conflicts with stdlib logging (#52), input-precision sketches (#36), validation (#38), ty enforcement (#37, #55) and the Fumadocs site (#56): - the sweep draws its sketches with gaussian_sketch and logs its plan, pass times and stalls at DEBUG with %-style arguments; - the working dtype is promoted over every site, not just the first; - docs/large-problems.md moves to features/large-problems.mdx and the out-of-core testing notes to contributing/testing.mdx; - bench_large.py logs through the stdlib and gains --debug. Type lazily read sites: the entry points accept any array-like with shape, dtype, ndim and np.asarray support but were typed Sequence[NDArray]. Add the SiteLike protocol and the Site alias, use them from src/apply/compress down to the site source, and export SiteLike. Also fix the other ty findings: the Tier list in the planner, known_kind() for validated trains, padded_shape without a type: ignore, cupyx as an allowed unresolved import, and typed fakes in the tests. Assisted-by: pi:claude-opus-5.5
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.

Fix #13.
Description
applyandcompresspreviously had default tofloat64Gaussian random sketch, silently promotingfloat32andcomplex64inputs to double precision.I implemented a simple utility function
sketch_dtypeto infer the default sketch dtype from the input arrays, preserving single precision where appropriate. Explicitdtypeoverrides remain supported.I also added tests to cover all four primitives: MPS compression, MPO compression, MPO-MPS application, and MPO-MPO application. Each runs with
float32,float64,complex64, andcomplex128inputs, checking that the output retains the input dtype and reproduces the original tensor within the appropriate tolerance.