Repository navigation
Fix BatchIntegralFunction handling in VEGAS and HCubatureJL - #390
Merged
Merged
Conversation
VEGAS allocated its in-place batch buffer with max_batch, which defaults to typemax(Int) and crashed with an invalid-memory-size ArgumentError; a smaller max_batch also mismatched the requested batch length. Size the buffer by the actual requested batch length (ncalls points per call) and chunk evaluation at max_batch when it is smaller. HCubatureJL hit a bare '@Assert f isa IntegralFunction' for batched integrands. Throw a descriptive ArgumentError naming the batch-supporting algorithms instead. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Muse <noreply@meta.com> Agent-Harness: Muse CLI Code Agent-Model: muse-ember-1.0 Agent-Session: local job 377-muse (no session URL)
VEGAS with an in-place BatchIntegralFunction at default max_batch and with max_batch below ncalls (chunking), checked against the known integral 2/3 over the unit square; HCubatureJL raises ArgumentError with a descriptive message for out-of-place and in-place batches. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Muse <noreply@meta.com> Agent-Harness: Muse CLI Code Agent-Model: muse-ember-1.0 Agent-Session: local job 377-muse (no session URL)
The .jl files in this branch were formatted with the Julia Runic package, but the worker pre-push hook cannot detect this repo's Runic declaration (SciML reusable runic.yml workflow) or run the Julia formatter, so the check is excepted with that explanation. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Muse <noreply@meta.com> Agent-Harness: Muse CLI Code Agent-Model: muse-ember-1.0 Agent-Session: local job 377-muse (no session URL)
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.
Fixes both
BatchIntegralFunctionfailures from #377. In the VEGAS solve path, the in-place output buffer was allocated withprob.f.max_batch— which defaults totypemax(Int)— crashing with an invalid-memory-sizeArgumentError, and anymax_batchsmaller thanalg.ncallsproduced a dimension mismatch. The buffer is now sized by the batch length VEGAS actually requests (ncallspoints per call), and evaluation is chunked into at mostmax_batchpoints whenmax_batchis smaller, assembling chunk outputs into the full-length result. InHCubatureJL, the bare@assert f isa IntegralFunctionis replaced by a descriptiveArgumentErrorstating thatHCubatureJLdoes not supportBatchIntegralFunctionand naming the batch-supporting alternatives (QuadGKJL,VEGAS,CubatureJLh,CubatureJLp,CubaVegas,CubaSUAVE,CubaDivonne,CubaCuhre).Tests
Added a
"BatchIntegralFunction regressions"testset totest/interface_tests.jlcovering: VEGAS with an in-placeBatchIntegralFunctionat defaultmax_batch(∫∫(x²+y²) over the unit square ≈ 2/3, seeded), the same withmax_batch = 10 < ncalls(chunking, same seed, matches the unchunked result), andArgumentError(with the descriptive message) for both out-of-place and in-placeBatchIntegralFunctionunderHCubatureJL.Before (issue reproducer, unmodified code):
Note the third failure line:
max_batch < ncallscrashed too — same root cause (buffer sized bymax_batchinstead of the actual batch length), fixed by the same change.After:
Test suite:
GROUP=Core julia --project=. -e 'using Pkg; Pkg.test()'— all 1,914 tests passed (interface_tests.jl 889/889, including the 9 new regression assertions). The new regression testset alone was also run against the pre-fix source (viagit stash) and errors with the reportedArgumentError: invalid GenericMemory size, then passes after. Also checked with Runic (JuliaFormatter) andtypos: no findings on the changed files.Risk assessment
BatchIntegralFunctionpath and theHCubatureJLdispatch only; no public API changes. Behavior change beyond the fixes: the VEGAS in-place batch path now allocates the output buffer per iteration instead of reusing one buffer (one extrancalls-length allocation per iteration; negligible next to the Monte Carlo evaluation itself), and HCubature.jl users previously hitting the bare assert now get a descriptiveArgumentError.GROUP=Coresuite passes.Not verified / reviewer pushback
GROUP=QA) not run.max_batch < ncalls) copies chunk inputs throughpts[pax..., s:e]so user integrands always see 1-based contiguous chunk arrays; if reviewers prefer zero-copy views with offset axes, that would assume user integrands iterateaxes(pts)rather than1:size(pts, ndims(pts)).VEGASMC,HAdaptiveIntegrationJLandFastTanhSinhQuadratureJLhave similar bare-assert/errorbatch messages that were left untouched as out of scope for BatchIntegralFunction: VEGAS in-place crashes with default max_batch; HCubatureJL gives bare AssertionError #377; happy to extend if wanted..factory-pre-push.jsonis added so the worker pre-push hook allows the push:.jlfiles in this branch were formatted with the Julia Runic package, but the hook cannot run that check here (it detects Runic only via a fredrikekre action/pre-commit config; this repo uses the SciML reusablerunic.ymlworkflow, and no Julia-formatterrunicbinary exists on this machine). The exception reason in the file states this; the file can be dropped on review if maintainers prefer.Closes #377
🤖 Posted by an AI agent — harness: Muse CLI Code · model: muse-ember-1.0
Conversation: local job 377-muse (no session URL)