Skip to content

Add caller-driven randomized lattice QMC integration - #8

Open
ValentinHirschi wants to merge 9 commits into
symbolica-dev:mainfrom
ValentinHirschi:codex/havana-qmc
Open

ValentinHirschi wants to merge 9 commits into
symbolica-dev:mainfrom
ValentinHirschi:codex/havana-qmc

Conversation

@ValentinHirschi

@ValentinHirschi ValentinHirschi commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Havana currently provides Monte Carlo grids and accumulation, but no separate randomized rank-one lattice lane. This adds numerical_integration::qmc so applications can generate lattice points on their workers, evaluate vector integrands, and merge complete randomized-shift observations while retaining control of scheduling and stopping.

The public API provides validated supplied or published rules, deterministic random shifts with dimension/count prefixes, index-only work packages, reusable-buffer point generation, symmetric Korobov-2 and Korobov-3 periodization, and covariance of vector estimates from complete independent shifts. Accumulation rejects overlapping, duplicate, incomplete, or mismatched returns. Fixed package boundaries and canonical reduction make results independent of worker arrival order. Optional serde preserves exact checkpoint float bits and validates restored state.

The implementation reuses Havana's RNG primitives and Numerica's integer GCD. It owns no threads, worker pool, integrand callback, stopping policy, or adaptive integration loop; examples/qmc.rs demonstrates serial and caller-owned threaded use. Existing Monte Carlo algorithms and random sequences are unchanged. Coordinates and numerical observations are binary64, with explicit range errors and coverage-only inspection when numerical reduction fails.

Published Kuo33002, Kuo38005, Kuo39101, and ten-dimensional HKKN alpha-three vectors are attributed numerical data, not copied integration code. Their construction limits are enforced without rounding, extrapolation, vector search, or fallback. The source revisions, original text where applicable, conversion details, payload hashes, and Apache-2.0 notices are included under src/numerical_integration/qmc/data/; Numerica's implementation remains MIT licensed. No new runtime dependency is introduced; serde_json is test-only.

Both periodizations share the checked product-Jacobian path: invalid coordinates are rejected before mutation, exact original endpoints receive zero weight, and lost normal range in interior attenuation is an explicit error. Korobov-2 evaluates the lower half of t^3 (10 - 15t + 6t^2) and reflects, with Jacobian 30 t^2 (1-t)^2. This is an additive caller choice; Korobov-3 arithmetic, Monte Carlo behavior, and checkpoint formats are unchanged.

Validation of the current change on Linux x86_64:

  • Exact Rust 1.89.0 / Cargo 1.89.0, cargo test --locked: 174 library, 47 integration, and 22 documentation tests passed (243 total).
  • Exact Rust 1.89.0, cargo test --locked --features serde: 174 library, 50 integration, and 22 documentation tests passed (246 total).
  • Exact Rust 1.89.0, cargo test --locked --no-default-features --features integer-malachite,float-astro,serde: 151 library, 50 integration, and 22 documentation tests passed (223 total).
  • Rust 1.98.1: all four focused QMC test targets passed, including six new Korobov-2 tests; public Rust callers for both transforms compile and run.
  • cargo fmt --all --check and git diff --check: passed.

There were no failed or ignored tests in these gates. The declared Rust 1.89 minimum remains unchanged. Korobov-2 controls cover exact native Rational references, reflection/derivative, normalization and transformed moments, multidimensional weight application, invalid coordinates, endpoint versus interior underflow, attenuation ordering, overflow, and caller-owned workers preserving the complete vector and covariance. Existing QMC and nine Monte Carlo tests remain in the full suites. Independent source/reuse review accepted the shared guard and additive API.

Scoped library/QMC-test/example Clippy exits zero with no changed-QMC diagnostics; it reports existing warnings in unrelated library code. The earlier advisory all-target serde Clippy attempt remains blocked by 29 existing approx_constant errors in unchanged test fixtures in src/domains/float/complex_tests.rs and src/domains/integer.rs. This PR does not fix unrelated upstream lint findings or claim a clean all-target lint gate.

At the preceding reviewed revision, cargo package --list verified the vector data and attribution/license files, and the serial/caller-threaded QMC example agreed bit for bit. Those files are unchanged by the Korobov-2 addition. The broader QMC tests cover modular arithmetic near binary64 limits, small periodic residues, full-vector covariance beside large offsets, correlated cancellation, independent-seed calibration, checkpoint validation, gap/overlap detection, and catalogue provenance. No physical performance or additional uncertainty-calibration claim is made for Korobov-2. macOS qualification remains unperformed.

Catalogue quality remains integrand-dependent. This API does not promise that any particular rule or periodization outperforms Monte Carlo, and does not implement CBC construction or pySecDec integration.

Tagging @benruijl for review of the QMC API and its integration with Havana.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@CLAassistant

CLAassistant commented Oct 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ codex
❌ ValentinHirschi
You have signed the CLA already but the status is still pending? Let us recheck it.

@ValentinHirschi

Copy link
Copy Markdown
Contributor Author

@benruijl, could you review the added f6ecdac fix alongside this QMC extension? DiscreteGrid::clone_without_samples computed the recursively cleared child but discarded it, so worker clones retained nested pending samples. Assigning that returned child fixes the issue. The regression covers nested discrete/continuous grids, unchanged proposals, and exactly-once sample merging; 249 native and 226 portable tests pass.

GitHub does not permit ValentinHirschi to issue a formal review request in this repository, so I am tagging you here.

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.

3 participants