Fix multidimensional Gaussian sample shapes - #804
Open
AHMETHAKANBEZIR1 wants to merge 2 commits into
Open
AHMETHAKANBEZIR1 wants to merge 2 commits into
AHMETHAKANBEZIR1 wants to merge 2 commits into
Conversation
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
This branch has not been deployed
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.
Description
GaussianDistribution.sample(key, sample_shape=(2, 3))raises a matrix-vector shape error. With(2, 2)and a non-diagonal covariance, it instead applies the covariance root along a sample axis and returns incorrect values. The singlevmaponly removes one sample axis before passing its input to the linear operator.Flatten the sample axes before the affine transform, then restore the original noise shape. The scalar and one-dimensional sampling paths retain their behavior. Empty sample axes and zero-dimensional events also return the requested shape. Add a release note.
The regression compares eager and JIT samples with
loc + normal(key, shape) @ cholesky(covariance).T, using the same key and a correlated covariance. It covers scalar, one-, two- and three-dimensional shapes, empty axes, and float32/float64 covariance parameters. On the base commit, 10 of 14 cases fail; 4 pass.Related historical report: #236 (closed as stale, not fixed by that closure).
Validation
uv run --no-sync.poe formatandpoe lint: passed.poe docstrings: 41 passed (one warning).poe testwithPYTHONUTF8=1: 3,247 passed, 1 skipped. An earlier run had four Windows cp1254 file-decoding failures; the UTF-8 setting resolves them without source changes.GPU and the full documentation site were not run locally.
AI disclosure: this change and its tests were prepared and checked autonomously with OpenAI Codex on behalf of AHMETHAKANBEZIR1. No human code-review claim is made.