Repository navigation
Keep mcmc()'s one_by_one advice when a numerical error comes before the first draw (#577) - #863
Merged
Merged
Conversation
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.
Closes #577.
test_inference.R:351): numerical issues are handled in mcmc #577's test was commented out because its Cholesky model stopped raising a numerical error under TensorFlow 2, somcmc()had nothing to report. That model still samples without raising one.solve()of a matrix that is singular wheneverround(r)is 1 or -1, found a bug on main: when a numerical error stops sampling beforemcmc()keeps its first draw, the clean-up on exit traces an empty trace, and its "subscript out of bounds" replaces greta's error suggestingone_by_one = TRUE. Since Do more inside of TF and TFP + fix thinning issues #855, sampling withverbose = FALSEis one call to TensorFlow, so any numerical error during sampling comes before the first draw.What changes
trace_values()returns early when the trace has no draws, so the error that stopped sampling is the one users see.self$abort_numerical_error().stashed_samples(), which the docs point to after an aborted run, returns no draws when several chains stopped before their first, rather than erroring with "length of 'dimnames' [2] not equal to array extent". The sampler sized its empty trace withlength()of one traced row per chain, which made it the number of chains times too wide for its names; it now usesncol().What users see now, from the new snapshot:
Tests
tests/testthat/test_inference.R: the singularsolve()model stopsmcmc()with the advice (snapshot); with two chains it gives the advice andstashed_samples()then has no draws; the one_by_one test also checks it keeps all 40 draws. Against main's code, both new tests fail with "subscript out of bounds".tests/testthat/helpers.R:singular_at_one_model(), shared by the three numerical-error tests.tests/testthat/test_inference_numerical_issues.R, all commented out, is removed.NOT_CRAN=trueand the branch installed.🤖 Generated with Claude Code