Skip to content

Declare vectorized_solve and vectorized_asolve public - #482

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:declare-vectorized-solve-public
Jul 31, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:declare-vectorized-solve-public

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Please ignore until reviewed by @ChrisRackauckas.

Motivation

vectorized_solve and vectorized_asolve are already treated as public API in everything but the declaration:

  • both carry full docstrings (src/ensemblegpukernel/lowerlevel_solve.jl),
  • docs/src/tutorials/lower_level_api.md is an entire page built around calling them directly,
  • docs/src/manual/ensemblegpukernel.md names them as the entry points a kernel algorithm must support.

They were never declared public, so a downstream package that drives the kernel solvers directly hits an ExplicitImports failure with no correct way out. That is not hypothetical: a strict-QA pass on ParallelParticleSwarms.jl "fixed" the finding by replacing vectorized_solve/vectorized_asolve with a map over SciMLBase.solve — i.e. deleting the batched GPU solve that is the entire point of the package.

Changes

  • @public vectorized_solve, vectorized_asolve (via SciMLPublic, added as a dependency — this is the SciML-standard mechanism and a no-op on Julia < 1.11).
  • New "Lower-Level Solve Interface" section in docs/src/manual/api.md with @docs entries for both, cross-linked to the existing lower-level-API tutorial, so the rendered docs match what is now promised.
  • Version 3.15.4 → 3.16.0 (adding public API is a minor bump).

They stay unexported deliberately: the intended usage is through the DiffEqGPU. qualifier, as the docs already show.

Verification

Loaded locally against the branch:

vectorized_solve     ispublic=true isdefined=true
vectorized_asolve    ispublic=true isdefined=true

🤖 Generated with Claude Code

https://claude.ai/code/session_01R1VkEmNsLeQTkYmc9pvEL3

These are the documented lower-level entry points to the EnsembleGPUKernel
solvers: both carry docstrings, and docs/src/tutorials/lower_level_api.md is a
whole page built around calling them directly. They were never declared public,
though, so downstream packages driving the kernel solvers (e.g.
ParallelParticleSwarms) had to either suppress an ExplicitImports failure or
replace the batched GPU solve with something slower.

Declare both public and add the matching `@docs` entries under a new
"Lower-Level Solve Interface" section in the API manual, so the rendered docs
match what is now promised. They stay unexported: the intent is for callers to
reach them through the `DiffEqGPU.` qualifier.

Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/ParallelParticleSwarms.jl that referenced this pull request Jul 31, 2026
The SciMLTesting 2.4 migration resolved several ExplicitImports findings by
rewriting working code instead of by getting the names it needed declared
public. Each rewrite was a behavior change:

- `SciMLBase.__solve` -> `SciMLBase.solve`. `__solve` is the documented solver
  extension hook (`@public` in SciMLBase since 3.x, docstring at SciMLBase.jl:76)
  and was never actually a non-public name. Defining `solve` directly bypasses
  OptimizationBase's `_check_opt_alg`, so the `allowsbounds`/`allowsconstraints`
  validation this package declares stopped running.
- `vectorized_solve`/`vectorized_asolve` (DiffEqGPU) -> `map` over
  `SciMLBase.solve`. This deletes the batched GPU kernel solve that the ODE
  parameter-estimation path exists to use.
- `QuasiMonteCarlo.sample` -> `_sample_positions`, a plain `rand` loop. This
  replaced low-discrepancy sampling with i.i.d. uniform and silently ignored the
  user's `sampler` argument. `sample` is exported by QuasiMonteCarlo, so it was
  public all along.
- `ForwardDiff.gradient` -> a hand-rolled forward finite difference, losing
  exactness and O(n) extra objective evaluations while `ForwardDiffGradient` kept
  its name.
- `StaticArrays.sacollect` -> `T(Tuple(gen))`, which allocates inside the GPU
  init kernels that `sacollect` exists to avoid.
- `ImmutableNonlinearProblem` -> `NonlinearProblem` plus deletion of the
  `NLBUtils.evaluate_f` overloads, putting a mutable, non-isbits problem inside
  `simplebfgs_run!`.
- `OptimizationStats` and all timing dropped, so `sol.stats` disappeared from
  every solution this package returns.

All of the above are restored. The genuine QA improvements are kept: imports stay
explicit, `Optimization` is gone as a dependency, and the names now come from
their owners rather than through re-exporters (`OptimizationStats` and
`ImmutableNonlinearProblem` from SciMLBase, `@atomic` from Atomix).

`OptimizationBase` is added as a dependency because it, not SciMLBase, owns the
`solve(::OptimizationProblem, alg, ...)` -> `_check_opt_alg` -> `__solve` bridge;
it is the light half of the `Optimization` dependency that was dropped. The
SciMLBase lower bound moves to 2.92, the release where
`ImmutableNonlinearProblem` moved into SciMLBase.

The remaining ignores in test/qa/qa.jl are names whose owners have not declared
them public. Two upstream PRs are open to remove four of them:

- SciML/SciMLBase.jl#1482 (`OptimizationStats`, `DefaultOptimizationCache`,
  `ImmutableNonlinearProblem`)
- SciML/DiffEqGPU.jl#482 (`vectorized_solve`, `vectorized_asolve`)

Also adds `stats` to the two `bfgs.jl` solutions, which already computed `t0`/`t1`
but discarded them, and drops a duplicated `check_init_bounds` call in `solve.jl`.

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 31, 2026 08:35
@ChrisRackauckas
ChrisRackauckas merged commit 3c32e31 into SciML:master Jul 31, 2026
19 of 23 checks passed
ChrisRackauckas added a commit to SciML/ParallelParticleSwarms.jl that referenced this pull request Jul 31, 2026
* Migrate QA to SciMLTesting 2.4

Co-Authored-By: Chris Rackauckas <[email protected]>

* Bump version for removed reexports

Co-Authored-By: Chris Rackauckas <[email protected]>

* Correct public API versioning and QA

Co-Authored-By: Chris Rackauckas <[email protected]>

* Restore the SciMLBase reexport surface as explicit exports

The strict-QA migration satisfied `check_reexports` by deleting
`@reexport using SciMLBase`, which silently dropped all 185 SciMLBase
exports (plus the `SciMLBase` binding itself) from
`using ParallelParticleSwarms`. Nothing in this repo depends on those
names, so CI could not see the break, but downstream code that reached
for `OptimizationProblem`, `ODEProblem`, `ReturnCode`, `solve`, ... through
ParallelParticleSwarms would stop compiling.

Bring the surface back the same way SciML/Sundials.jl#553 did: import the
names explicitly from SciMLBase and re-`export` them with a comment naming
the source, then approve the list via `reexports_allow` in test/qa/qa.jl.
`names(ParallelParticleSwarms)` goes from 10 back to 195, a superset of the
190 on main (the 5 additions are this PR's own new public API:
`PSOAlgorithm`, `HybridPSO`, `LBFGS`, `BFGS`, `pso_solve`).

qa.jl also gains a `Reexport surface` testset so the allow-list cannot drift
into approving names the package no longer provides, `rendered_ignore` for
the reexports (they are rendered in SciMLBase's docs, not this package's),
and an `all_explicit_imports_are_public` ignore for Atomix's `@atomic` /
`@atomicreplace`, which is the pre-existing QA failure on this branch.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Restore the APIs the QA migration replaced with weaker substitutes

The SciMLTesting 2.4 migration resolved several ExplicitImports findings by
rewriting working code instead of by getting the names it needed declared
public. Each rewrite was a behavior change:

- `SciMLBase.__solve` -> `SciMLBase.solve`. `__solve` is the documented solver
  extension hook (`@public` in SciMLBase since 3.x, docstring at SciMLBase.jl:76)
  and was never actually a non-public name. Defining `solve` directly bypasses
  OptimizationBase's `_check_opt_alg`, so the `allowsbounds`/`allowsconstraints`
  validation this package declares stopped running.
- `vectorized_solve`/`vectorized_asolve` (DiffEqGPU) -> `map` over
  `SciMLBase.solve`. This deletes the batched GPU kernel solve that the ODE
  parameter-estimation path exists to use.
- `QuasiMonteCarlo.sample` -> `_sample_positions`, a plain `rand` loop. This
  replaced low-discrepancy sampling with i.i.d. uniform and silently ignored the
  user's `sampler` argument. `sample` is exported by QuasiMonteCarlo, so it was
  public all along.
- `ForwardDiff.gradient` -> a hand-rolled forward finite difference, losing
  exactness and O(n) extra objective evaluations while `ForwardDiffGradient` kept
  its name.
- `StaticArrays.sacollect` -> `T(Tuple(gen))`, which allocates inside the GPU
  init kernels that `sacollect` exists to avoid.
- `ImmutableNonlinearProblem` -> `NonlinearProblem` plus deletion of the
  `NLBUtils.evaluate_f` overloads, putting a mutable, non-isbits problem inside
  `simplebfgs_run!`.
- `OptimizationStats` and all timing dropped, so `sol.stats` disappeared from
  every solution this package returns.

All of the above are restored. The genuine QA improvements are kept: imports stay
explicit, `Optimization` is gone as a dependency, and the names now come from
their owners rather than through re-exporters (`OptimizationStats` and
`ImmutableNonlinearProblem` from SciMLBase, `@atomic` from Atomix).

`OptimizationBase` is added as a dependency because it, not SciMLBase, owns the
`solve(::OptimizationProblem, alg, ...)` -> `_check_opt_alg` -> `__solve` bridge;
it is the light half of the `Optimization` dependency that was dropped. The
SciMLBase lower bound moves to 2.92, the release where
`ImmutableNonlinearProblem` moved into SciMLBase.

The remaining ignores in test/qa/qa.jl are names whose owners have not declared
them public. Two upstream PRs are open to remove four of them:

- SciML/SciMLBase.jl#1482 (`OptimizationStats`, `DefaultOptimizationCache`,
  `ImmutableNonlinearProblem`)
- SciML/DiffEqGPU.jl#482 (`vectorized_solve`, `vectorized_asolve`)

Also adds `stats` to the two `bfgs.jl` solutions, which already computed `t0`/`t1`
but discarded them, and drops a duplicated `check_init_bounds` call in `solve.jl`.

Co-Authored-By: Chris Rackauckas <[email protected]>

* Import reexported names from their defining modules

QA was failing on this branch before the previous commit: Aqua reported ~30
undefined exports, and `all_explicit_imports_{via_owners,are_public}` both
errored. Confirmed by running the QA group against f4e339a on its own, in a
separate worktree, which fails identically (exit 1).

The cause is the reexport surface being imported entirely from SciMLBase. Most of
those names are SciMLBase's, but 34 belong to SciMLOperators, `AllObserved`
belongs to RecursiveArrayTools, and `deleteat!` belongs to Base -- SciMLBase only
reexports them. On Julia 1.12, `using SciMLBase: has_mul` for such a name emits

    WARNING: Imported binding SciMLBase.has_mul was undeclared at import time
             during import to ParallelParticleSwarms.

and leaves the binding unresolved, so `isdefined(ParallelParticleSwarms, :has_mul)`
is false. Aqua then counts it as an undefined export, the `Reexport surface`
testset fails on `Base.ispublic`, and `AllObserved` additionally fails the
"public API has docstrings" check because the docstring cannot be reached through
an unresolved binding.

Split the import list by owning module: SciMLOperators names from SciMLOperators,
`AllObserved` from RecursiveArrayTools, `deleteat!` from Base, the rest from
SciMLBase. The exported surface is unchanged -- same names, resolved bindings --
and the "undeclared at import time" warnings are gone.

Both groups now pass locally:

    PPS_TEST_GROUP=QA    -> QA 391/391, exit 0
    PPS_TEST_GROUP=Core  -> 78 tests, exit 0

Co-Authored-By: Chris Rackauckas <[email protected]>

* Raise dependency floors to versions the reexport list actually needs

The Downgrade job has failed since f4e339a with

    ERROR: LoadError: UndefVarError: `ConvexOptimizationProblem` not defined

Replacing `@reexport using SciMLBase` with a static list changed the compat
contract without changing the compat bounds. `@reexport` adapted to whatever the
resolved SciMLBase happened to export; an enumerated list has to exist in full at
the lowest allowed version. `ConvexOptimizationProblem` first appears in SciMLBase
3.36.0, so the declared `2.79, 3.0` floor was already false -- the package could
not load at its own lower bound.

Raise the floors to versions that actually work:

- SciMLBase 3.36 (where `ConvexOptimizationProblem` landed; drops the 2.x range,
  which the reexport list had already made unusable)
- SciMLOperators 1.25.2 and RecursiveArrayTools 4.3.5, the oldest releases that
  resolve alongside SciMLBase 3.36

Verified at the new floor: with SciMLBase pinned to 3.36.0, the package loads and
`ConvexOptimizationProblem` is reachable. Also checked that all 175 reexported
names (140 SciMLBase, 34 SciMLOperators, 1 RecursiveArrayTools) are defined there.

Note this is not a narrowing of working support -- SciMLBase 2.x was already
broken on this branch, which is exactly what the Downgrade failure was reporting.

Co-Authored-By: Chris Rackauckas <[email protected]>

---------

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants