Skip to content

Preserve joint probabilities during recursive sampling - #106

Merged
GiggleLiu merged 1 commit into
mainfrom
automanage/propagate-sampling-cache
Sep 8, 2026
Merged

GiggleLiu merged 1 commit into
mainfrom
automanage/propagate-sampling-cache

Conversation

@GiggleLiu

Copy link
Copy Markdown
Member

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.

@GiggleLiu
GiggleLiu merged commit 708c835 into main Sep 8, 2026
2 checks passed
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