Skip to content

fix: 馃悰 preserve input precision in apply and compress - #36

Open
SimoneGasperini wants to merge 4 commits into
Algorithmiq:mainfrom
SimoneGasperini:fix-dtype-silent-promotion
Open

SimoneGasperini wants to merge 4 commits into
Algorithmiq:mainfrom
SimoneGasperini:fix-dtype-silent-promotion

Conversation

@SimoneGasperini

Copy link
Copy Markdown

Fix #13.

Description

apply and compress previously had default to float64 Gaussian random sketch, silently promoting float32 and complex64 inputs to double precision.

I implemented a simple utility function sketch_dtype to infer the default sketch dtype from the input arrays, preserving single precision where appropriate. Explicit dtype overrides 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, and complex128 inputs, checking that the output retains the input dtype and reproduces the original tensor within the appropriate tolerance.

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.

Single-precision inputs are silently promoted to double precision

1 participant