Thank you for your interest in contributing to QMC.jl. This guide walks through the full developer setup, project conventions, and how to add new components.
Please submit pull requests to the develop branch and issues using a template from .github/ISSUE_TEMPLATE/.
Join team communications at qmc-software@googlegroups.com. If you develop a new component, consider writing a blog for qmcpy.org.
| Tool | Version | Notes |
|---|---|---|
| Julia | ≥ 1.10 | brew install julia on macOS, or download from julialang.org |
| Python | any recent | currently required for the QMCToolsCL-backed generators Lattice, DigitalNetB2, and Halton |
| Git | any recent | to clone the repo |
Python is currently a runtime dependency for the main low-discrepancy QMC generators
Lattice, DigitalNetB2, and Halton, because they rely on the QMCToolsCL shared library.
Conda is optional; it is only one way to provide that Python environment and can also host
an optional Jupyter frontend.
git clone https://github.com/QMCSoftware/QMC.jl.gitjulia --project=. -e 'using Pkg; Pkg.instantiate()'The main low-discrepancy generators are backed by QMCToolsCL. Install it into a Python visible to Julia:
python3 -m pip install qmctoolsclIf Julia should use a specific Python interpreter, set this before first use of those generators:
ENV["QMC_PYTHON"] = "/path/to/python"julia -e 'using Pkg; Pkg.add("IJulia")'
julia -e 'using IJulia; IJulia.installkernel("QMC", "--project=$(pwd())")'Run those commands from the repository root. This installs IJulia and creates a QMC kernel pinned to this repository's Julia environment, so demo notebooks use the same Julia environment as local development and CI. This step is only needed if you plan to run notebooks.
Full test suite:
julia --project=. -e 'using Pkg; Pkg.test()'All tests should pass with zero failures.
Interactive testing (useful during development):
using Pkg
Pkg.activate(".")
include("test/runtests.jl")Individual test groups:
using QMC, Test, Statistics, LinearAlgebra, Distributions
import QMC: Uniform, Kumaraswamy # resolve name conflicts with Distributions
include("test/test_discrete_distributions.jl")
include("test/test_true_measures.jl")
include("test/test_integrands.jl")
include("test/test_kernels.jl")
include("test/test_stopping_criteria.jl")
include("test/test_integration.jl")Note: Uniform and Kumaraswamy are exported by both QMC and Distributions.jl. When using both packages, resolve the ambiguity with import QMC: Uniform, Kumaraswamy.
QMC.jl/
├── Project.toml # Julia package metadata and dependencies
├── src/
│ ├── QMC.jl # Main module: includes, exports
│ ├── abstract_types.jl # Type hierarchy
│ ├── data/ # Embedded generating vectors and direction numbers
│ │ ├── kuo_lattice_gen_vector.jl # 9125 Kuo lattice generating vectors
│ │ └── joe_kuo_direction_numbers.jl # 1024×32 Joe-Kuo direction number matrix
│ ├── discrete_distribution/ # IIDStdUniform, Lattice, DigitalNetB2, Halton
│ ├── true_measure/ # Uniform, Gaussian, BrownianMotion, GBM, ...
│ ├── integrand/ # Keister, Genz, FinancialOption, ...
│ ├── kernel/ # KernelShiftInvar, KernelMatern*, ...
│ ├── stopping_criterion/ # CubMCCLT, CubQMCLatticeG, Bayesian, ...
│ └── util/ # Bernoulli polynomials, periodization, WHT, ...
├── test/
│ ├── runtests.jl # Test entry point
│ └── test_*.jl # Per-module test files
└── demos/
└── *.ipynb # Jupyter notebook versions
If you want the simplest path and do not need a separate Python environment, launch the notebook server from Julia:
julia -e 'using IJulia; notebook(dir="demos")'If you have not created the project-bound kernel yet, run this once from the repository root:
julia -e 'using IJulia; IJulia.installkernel("QMC", "--project=$(pwd())")'Then select the QMC kernel in Jupyter or VS Code once.
If you prefer to launch Jupyter from Python or Conda, that is also fine, but Python is only the notebook frontend in that setup. The notebook must still execute on the QMC Julia kernel.
Most demos use Lattice or DigitalNetB2, so they also require qmctoolscl
to be installed in a Python visible to Julia.
To run a notebook in VS Code:
- Install the
JuliaandJupyterextensions. - Open this repository folder in VS Code.
- Open a notebook from
demos/. - Click the notebook kernel picker and select
QMC. - Restart the notebook kernel if it was previously attached to another interpreter.
Do not use the Python qmcpy, or generic Python 3.12.x kernel for these notebooks, or Julia code such as using QMC will fail with a Python SyntaxError. A generic Julia kernel may also miss repository-specific dependencies like Plots.
We use JuliaFormatter.jl with the SciML style for consistent formatting. The style is configured in .JuliaFormatter.toml at the project root and is picked up automatically:
using JuliaFormatter
format("src/")
format("test/")Or via make:
make formatPlease format your code before submitting a pull request.
QMC.jl uses Julia's abstract type hierarchy with multiple dispatch. To add a new component:
- Create
src/discrete_distribution/my_dist.jl - Define a struct that subtypes
AbstractDiscreteDistribution - Implement
gen_samples(dd::MyDist, n::Int)→Matrix{Float64}(n × d) - Add
includeandexportinsrc/QMC.jl - Add tests in
test/test_discrete_distributions.jl
- Create
src/true_measure/my_measure.jl - Subtype
AbstractTrueMeasure - Implement
transform(tm::MyMeasure, x::Matrix{Float64})→Matrix{Float64} - Update module file and tests
- Create
src/integrand/my_integrand.jl - Subtype
AbstractIntegrand - Implement
evaluate(f::MyIntegrand, x::Matrix{Float64})→Vector{Float64} - Update module file and tests
- Create
src/stopping_criterion/my_criterion.jl - Subtype
AbstractStoppingCriterion - Implement
integrate(sc::MyCriterion)→QMCResult - Update module file and tests
- Create
src/kernel/my_kernel.jl - Subtype
AbstractKernel(orAbstractStationaryKernelfor distance-based kernels) - Implement
compute_kernel_eigenvalues(k::MyKernel, x)and/orkernel_eval(k, r) - Update module file and tests
- Julia docstrings (triple-quoted
"""...""", with arguments and examples) - A
Base.showmethod for REPL display - Unit tests covering construction, basic operation, and edge cases
- A demo notebook if the component is user-facing
includeandexportentries insrc/QMC.jl
VS Code with the Julia extension is the recommended editor.
- Open
QMC.jl/as your workspace - Activate the project:
Ctrl/Cmd+Shift+P→ Julia: Activate This Environment - Use the integrated terminal for test runs
- The Julia extension provides inline evaluation, debugging, and profiling
Helpful extensions: Julia, Jupyter, Git Graph, Code Spell Checker.