Preserve joint probabilities during recursive sampling - #106
Merged
Merged
Conversation
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.
Sampling could reproduce individual-variable marginals while drawing the wrong joint distribution. Conditioning an internal variable did not consistently propagate its updated cache to parent contractions, and recomputation could sum over the new batch index. Refresh parent caches after recursive sampling and retain the batch index on conditioned outputs.
The existing four-site complex MPS test (seed 140) reproduces the defect on current main: sampled negative log-likelihood is 2.2700 against entropy 2.0025. The fix yields 2.0051. Existing sampling, evidence, and rescaled-array tests pass. New real/complex MPS tests compare both single and batched samples with an independent probability oracle built from ordinary ket-matrix products; all four joint-distribution cases fail on the unmodified base and pass with this fix, without changing the existing tolerance.
Local validation uses Julia 1.12.4 with the dependency environment already validated for the MMAP maintenance work: OMEinsum 0.9.4, OMEinsumContractionOrders 1.3.0, StatsBase 0.34.13, ProblemReductions 0.3.5, and TropicalNumbers 0.6.4. Source changes are limited to sampling-cache propagation; no probability model, sampling API or MMAP reference-data changes are included.