Validation and Benchmarks
On this page
caroli was written from the author's PhD thesis by Claude, Anthropic's AI model, under his supervision, and nothing in it is accepted on trust. Every method is checked four ways: against the thesis, by reproducing the outputs of its Fortran codes on 26 small cases to rounding error; against itself, by computing the same quantity with two independent algorithms; against physics, by exact results, conservation laws and symmetries; and against other codes, by solving the same Hamiltonians as Kwant, TBtrans and Quantica.jl, whose transmissions must agree before their times are compared. This page describes each kind of check, with the numbers the tests assert and those that were recorded, and the benchmarks that place caroli among the codes of the field. The checks of each method are also given on its own page.
Against the thesis: 26 golden cases
The baseline
The thesis codes (Fortran 90 with MPI, 2013 to 2015) are not part of the repository. The baseline tool of caroli-validation compiles them from a private copy with gfortran, a serial stand-in for MPI, LAPACK95 and FFTW, runs 26 small cases and compares their outputs with the recorded ones (reference/baseline/golden, about 650 KiB). Each case keeps the production parameters of a program and shrinks its sizes, so that it runs in under a second. The outputs are the files exactly as the programs wrote them, Fortran unformatted records of f64 or complex numbers (pairs of f64); a comparison is byte by byte first, then record by record within a tolerance.
As of 11 October 2026 all 26 cases pass, the results are the same from run to run, and the optimised build and a build with bounds checking (-O0 -fcheck=bounds) agree within the cases' tolerances (relative \(10^{-8}\)). Without the thesis sources, the tests of caroli-validation still compare caroli with the recorded outputs, so every CI run checks them.
The cases and how well caroli reproduces them
"Asserted" is what the test of caroli-validation requires; "recorded" is the agreement measured when the case was validated (ARCHITECTURE.md). Cases with disorder use the thesis's own impurity configurations and random vectors (next section).
| Golden case | What it computes | Asserted | Recorded |
|---|---|---|---|
ti-diag | The 144 eigenvalues of a clean \(6 \times 6\) BHZ flake | \(10^{-10}\) | \(10^{-10}\) |
ti-ribbon-bands | Bands \(E(k_y)\) of a 16-site BHZ ribbon with a uniform exchange | \(10^{-10}\) | \(10^{-10}\) |
ti-ribbon-bands-fourier-y | The same from the 2013 code, \(\lambda = -0.1\) | \(10^{-10}\) | \(2 \cdot 10^{-14}\) |
ti-dos-spin-lesser | The 2013 recursive "spin density of states", \(8 \times 8\) sample | relative \(10^{-9}\) | \(7 \cdot 10^{-11}\) |
ti-cond2t-clean | Conductance of a clean \(16 \times 10\) BHZ ribbon at 13 energies | caroli's \(T\) an integer to \(10^{-8}\), within 0.025 of the thesis | caroli exact integers; the thesis off by up to 1 % |
ti-cond2t-same-g, -isotropic, -opposite-g | The same ribbon with magnetic impurities (along \(z\) with same-g coupling, isotropic with same-g, along \(z\) with opposite-g), 3 couplings \(\times\) 5 energies | the thesis formula to \(10^{-9}\) | \(10^{-13}\); the exact transmission differs by up to \(0.22\, e^2/h\) |
ti-cond4t-anderson | \(T_{13}\) and \(T_{24}\) of an \(8 \times 8\) cross with four leads, Anderson disorder, spin-up block | \(10^{-4}\) | \(3 \cdot 10^{-5}\) |
ti-cond-ldos-current | The 2014 manuscript code: conductance, local density of states and bond currents of a disordered \(12 \times 8\) ribbon | relative \(10^{-10}\) | \(10^{-14}\) |
ti-lcur-same-g, -opposite-g, -anderson | Keldysh bond currents and occupied local densities of a \(20 \times 8\) ribbon under a bias, for the three disorders | identical impurity positions; currents and densities to \(10^{-9}\) | currents \(10^{-17}\), densities \(10^{-14}\) |
ti-scba-anderson | Self-consistent Born approximation, Anderson disorder | \(10^{-10}\) | \(10^{-15}\) |
ti-scba-matrix-same-g, -opposite-g | The \(4 \times 4\) Born approximation with magnetic impurities | \(10^{-10}\) | \(10^{-15}\) |
ti-scba-analytic-same-g, -opposite-g | The reduced Born approximation of the topological-insulator paper | \(10^{-10}\) | \(10^{-15}\) |
ti-dos-kpm-same-g, -opposite-g, graphene-dos-kpm | Densities of states by the kernel polynomial method, with magnetic impurities (spin-up block) | relative \(10^{-9}\) | \(10^{-15}\) |
graphene-current-clean, -af, -para | Current and electron–hole pair creation in graphene under an electric field: clean, with moments along \(+z\) on sublattice A and \(-z\) on B, with isotropic moments | \(10^{-10}\) | \(10^{-16}\) |
graphene-width | Width \(w(t)\) of a wave packet in disordered graphene | relative \(10^{-10}\) | \(10^{-16}\) |
graphene-density | Electron and hole densities on the two sublattices | \(10^{-12}\) | \(10^{-19}\) |
To reproduce a case exactly, caroli replays the thesis program's conventions where they differ from its own, in a replica beside its own methods: the broadening truncated to its real part and the lead self-energies at \(E + i\eta\) of the conductance codes (below), the element-wise products and storage slots of the local-current code, the iteration schedules of the Born codes, the slice on which the four-terminal code puts \(E + i\eta\), the bias of the 2014 code, whose leads sit at the opposite of the potential carried by its boundary slices. caroli_validation::thesis rebuilds each set-up, and the exact caroli result is computed beside the replica, so that the effect of each convention is measured too.
Beyond the 26 cases, caroli's disorder averages of the conductance maps of the topological-insulator paper (\(400 \times 64\) ribbons, 50 realisations) agree with the thesis data within the statistical error, and the two thesis studies are reproduced as examples of the caroli crate, with their figures: ti_magnetic (Raymond, Verga and Demion) and graphene_field (Demion and Verga, Phys. Rev. B 90, 085412 (2014)). For the clean sheet of the latter, at \(E = 0.02\) and \(t = 100\), caroli gives a current of 0.041 and 0.0274 pairs per cell, where the paper has 0.040 and 0.0275 (ARCHITECTURE.md).
Identical random streams
Disordered cases can be compared value by value only if caroli draws the same impurities and the same random vectors as the thesis. The thesis codes draw from gfortran's random_number after random_seed(put = [seed, seed, …]); gfortran 9 and later use xoshiro256**. caroli draws all its randomness from the same generator (Xoshiro256 in caroli-disorder):
Xoshiro256::gfortran(seed)puts the generator in the state gfortran reaches: the eight 32-bit seed words copied into the 256-bit state in gfortran's order, then combined by exclusive or with gfortran's four fixed keys;uniformtakes the top 53 bits of the next output, \(u = \lfloor x / 2^{11} \rfloor \cdot 2^{-53}\), exactly gfortran'srandom_numberforreal(8);integer(lo, hi)is \(lo + \lfloor (hi - lo + 1)\, u \rfloor\), the thesis'srandom_integer;- the disorder generators follow the draw order of the thesis programs.
A test compares the first numbers with values printed by gfortran 16: they are equal bit for bit. The local-current cases also read the impurity positions that the thesis program wrote to its output and check them against caroli's draws, impurity by impurity. Outside the replicas, Xoshiro256::seed_from_u64 seeds the same generator from 64 bits through splitmix64, so that a seed gives the same disorder on every platform and every version of caroli.
One case needed more than the random stream. In the graphene dynamics the initial band state's gauge is fixed by the phase of \(h(\mathbf k)\), and at a few \(\mathbf k\) points where \(h\) is real and negative its imaginary part is zero up to rounding: gfortran's \(-0\) and the sign of the rounding of sin and cos decide between \(+\pi\) and \(-\pi\). On the \(16 \times 16\) grid of the golden cases there are eight such points; at two of them glibc's sin and cos give an exact zero where macOS's, with which the goldens were recorded, give a positive residue. The replica takes the macOS sign there: of the 256 sign choices at the eight points, only that one reproduces the disordered goldens on Linux (to \(5 \cdot 10^{-16}\)).
Bugs of the thesis found this way
The broadening truncated to its real part. All the thesis conductance codes compute the broadening as real(IM*(Σ − Σ†)), element by element: they keep the real part of the Hermitian matrix \(\Gamma = i(\Sigma - \Sigma^{\dagger})\) and drop its imaginary part, which the complex hoppings of BHZ make nonzero. The Caroli formula with this matrix is no longer exact:
- a clean ribbon matched to its leads, which transmits every open channel exactly, gets a conductance between 1.988 and 2.012 instead of 2 in
ti-cond2t-clean, and about 1.99 in the thesis-era data; - with magnetic impurities in a ribbon 10 sites wide, the error reaches \(0.22\, e^2/h\);
- at the 64-site width of the thesis production runs it is below \(10^{-3}\) (
examples/gamma_impact.rs), negligible in the published maps.
When it uses the same truncated formula, the same impurity configurations and lead self-energies at \(E + i\eta\), caroli reproduces every ti-cond2t-* golden value to \(10^{-13}\): the whole chain (Hamiltonian, impurities, exchange, self-energies, recursion) is validated exactly, and the exact transmission differs only by the truncation.
The reduced Born approximation. The thesis's reduced (analytic) self-consistent Born approximation, reproduced exactly by ti-scba-analytic-*, differs from caroli's general one in two places: the sign of the mass self-energy, and the weight of the \(z\) component of the moments, \((1 - n_I^2)\, M_z^2 + (1 - M_z)^2/3\) where the second cumulant gives \((1 - n_I)\, M_z^2 + (1 - M_z)^2/3\). With both corrected, the reduced equations give the general matrix approximation to \(10^{-5}\) (test corrected_reduction_is_the_matrix_scba). Self-consistent Born approximation describes the general approximation and the corrected results.
Out-of-bounds accesses. The build with bounds checking found reads and writes outside arrays: a loop of the 2015 local-current code that read the Hamiltonian beyond its last column, giving values that changed from run to run; time tables of the graphene wave-packet codes that received one value more than their size, which corrupted the heap and caused random crashes; a mesh routine that looped over \(N + 1\) points into \(N \times N\) arrays, which may have altered \(w(t)\) in the thesis runs. The current–pair-creation code added the wall-clock time to its disorder seed. The baseline compiles a copy of the sources with minimal fixes for these (listed in reference/baseline/README.md): the values within bounds are unchanged, and the seed becomes fixed.
Smaller findings. The 2013 ribbon code's \(\Gamma_{14}\) is anti-Hermitian and LAPACK's heev reads only its upper triangle (its edge states move by up to \(1.5 \cdot 10^{-3}\)); the 2013 recursive "spin density of states" never forms \(G^{<}\), and its up and down sums are a split by position across the ribbon, not by spin.
Against itself
The same quantity computed by independent algorithms of caroli:
| Comparison | Systems | Asserted |
|---|---|---|
| Recursive Green's function against nested dissection | Square lattice clean and disordered, BHZ, graphene, a constriction, long strips and short devices, cubic samples, bond disorder | relative \(10^{-9}\) or better |
| Nested multi-terminal solver against the dense multi-terminal inversion | Crosses of square and BHZ lattices, graphene with a narrow lead | relative \(10^{-9}\) |
| Mode matching against decimation (\(\eta = 10^{-9}\) to \(10^{-10}\)), away from the eigenvalues of the lead cell | BHZ ribbons, clean and with impurities | \(10^{-6}\) |
| The Hermitian fast path of the lead modes against the general algorithm | Strips, subband edges, degenerate channels, random leads | self-energies \(10^{-10}\) |
| Scattering states of nested dissection against the recursive lesser Green's function | Square, BHZ, graphene, a magnetic field: occupations and bond currents | \(10^{-10}\) |
| The scattering matrix against the transmissions, and between the two solvers | Crosses of square and BHZ lattices, graphene, a field | unitarity \(10^{-9}\); \(\sum \lvert S_{pq} \rvert^2 = T_{pq}\) to \(10^{-9}\) |
| Split-operator on a torus against the fourth-order Magnus integrator on the same region | Disordered spinful graphene with magnetic impurities | densities and currents within \(2 \cdot 10^{-3}\) |
| The reduced Born approximation, corrected, against the general one | BHZ with magnetic impurities, same-g and opposite-g | \(10^{-5}\) |
| The structured quantum-walk step against the explicit sparse operator | Rings and a graph of degree 3, four kinds of coin | \(10^{-13}\) |
| Accelerate against faer; the GPU against the CPU; f32 against f64 | Dense linear algebra, Reduced precision and the GPU | \(10^{-11}\) between the libraries; the reduced precisions on their page |
Against physics
| Exact result | Asserted |
|---|---|
| A clean wire transmits one per open channel: the steps of a quantum wire, a Rashba wire in a Zeeman field, a BHZ ribbon | \(10^{-9}\) to \(10^{-8}\) |
| Quantum spin Hall plateau of a BHZ ribbon in the gap, \(T = 2\) | \(10^{-8}\) |
| Quantum Hall plateaus \(T = 1, 2, 3\) in disordered ribbons along \(x\) and \(y\); in a Hall cross, the chiral transmissions (\(\nu\) into the next lead, 0 elsewhere) | \(10^{-6}\) |
| Gauge invariance of the transmissions; symmetry of a clean Hall cross under a quarter turn, with leads in different gauges; Onsager reciprocity \(T_{pq}(b) = T_{qp}(-b)\) | \(10^{-10}\), \(10^{-9}\), \(10^{-9}\) |
| Current conservation: every cross-section carries \(T(E) [f_L - f_R]\); Kirchhoff's law at every inner site of a cross, with or without a field; the \(s_z\) current through every cut of a BHZ ribbon with a Zeeman term is \(T_{\uparrow} - T_{\downarrow}\) | \(10^{-9}\) |
| No spin flip in BHZ; the transmissions between sectors add up to \(T_{pq}\); a normal–superconducting junction reflects electrons as holes below the gap | \(10^{-10}\); Andreev reflection within 5 % of the channel count |
| Kernel polynomial method: the exact trace gives the Chebyshev moments of the eigenvalues; spin projections and local densities add up to the total; the density of states integrates to the number of states | \(10^{-10} N\); \(10^{-9}\); \(2 \cdot 10^{-3}\) |
| Kubo–Bastin conductivity of the Qi–Wu–Zhang Chern insulator: \(\lvert \sigma_{xy} \rvert = e^2/h\) in the gap, opposite for opposite masses, \(\sigma_{xx} = 0\) | 0.01; \(10^{-3}\); \(10^{-4}\) |
| Born approximation: \(\Sigma = (W^2/12)\, G_0\) for weak Anderson disorder; the sum rule of the averaged density of states | 2 %; 2 % |
| Stark breathing of a wave packet under a force \(F\) on a square lattice of hopping \(J\): \(\langle x^2 \rangle = (8 J^2/F^2) \sin^2(F t/2)\) along the force (Bloch oscillation), \(\langle y^2 \rangle = 2 J^2 t^2\) across (free spreading); the width \(\sqrt{\langle x^2 \rangle + \langle y^2 \rangle}\) is checked | relative \(10^{-6}\) |
| Graphene with magnetic impurities: \(\rho_{\uparrow}(i, \varepsilon) = \rho_{\downarrow}(i, -\varepsilon)\) on every site, and \(j_{\downarrow}(E) = -j_{\uparrow}(-E)\), from the symmetry of the sublattice sign times time reversal | \(10^{-12}\) |
| Quantum walk: unitarity of a step; the free walk at \(J = 0\) | \(10^{-13}\), \(10^{-12}\) |
The caroli command is tested the same way (crates/caroli-cli/tests/cli.rs): each kind of run against the library call or the physics, and every example input must build.
Kwant's tutorials
The classic transport tutorials of Kwant's documentation, written with caroli (crates/caroli/tests/tutorials.rs), with the physics each one shows checked:
| Tutorial | Checked |
|---|---|
| Quantum wire, 10 sites wide | \(T(E)\) counts the open subbands, \(E \gt 2 - 2\cos(q\pi/11)\), to \(10^{-9}\) |
| Rashba wire in a Zeeman field | One per channel of the leads, to \(10^{-8}\); recursive Green's function and nested dissection agree to \(10^{-9}\) |
| Aharonov–Bohm ring | \(T\) periodic in the flux with period \(2\pi\), to \(10^{-9}\), and changed by the flux |
| Zigzag graphene ribbon | The single edge channel near the Dirac point, \(T = 1\) to \(10^{-8}\) |
| Hall bar | Landauer–Büttiker resistances on the plateaus \(\nu = 1, 2\), in units of \(h/e^2\): Hall resistance \(1/\nu\), and a two-terminal resistance equal to it (no longitudinal resistance), to \(10^{-6}\) |
A k·p model discretised on a lattice, as Kwant's continuum.discretize | The BHZ Hamiltonian of an inverted HgTe well gives two helical edge channels, \(T = 2\) to \(10^{-6}\) |
Against other codes: the transport benchmarks
Rules
The benchmarks (benchmarks/, driven by caroli-bench) compare caroli with Kwant 1.5, TBtrans (SIESTA 5.4.2) and Quantica.jl 1.4 on the two-terminal and four-terminal transmission of samples between clean leads, most of them disordered:
- Same Hamiltonian.
caroli-bench preparewrites the model and the disorder of every width to files, from which every code builds its system. - Same results first. The report gives, for every run, the largest difference of its transmissions from caroli's. Times count only when the results agree.
- One process per run, under
/usr/bin/time -lfor the peak memory; on an idle machine (a run during which another job was active is flagged). - Threads. The other codes run on one thread (
OMP_NUM_THREADS,OPENBLAS_NUM_THREADS,MKL_NUM_THREADS,VECLIB_MAXIMUM_THREADSat 1; Kwant's MUMPS is sequential), and caroli on one thread for the latencies. For the throughput, \(N\) energies run on all the cores, builds included: caroli on its thread pool, Kwant on a pool of as many processes. - Each code at its best. Kwant uses MUMPS with Accelerate's BLAS, computes only the block of the scattering matrix it needs and skips the Hermiticity check. TBtrans takes its electrodes at \(\eta = 10^{-6}\) eV (agreement to about \(10^{-5}\) for 20 % more time than its default) and writes double precision. Quantica.jl solves a small instance first, so that compilation is not timed. caroli splits independent blocks, such as the spin blocks of BHZ, and uses nested dissection.
| Problem | Model | Widths \(W\) | Anderson disorder (width of the distribution) |
|---|---|---|---|
square-clean | Square lattice, one orbital, \(W \times W\) | 32–512 | none |
square-anderson | Square lattice, one orbital | 32–512 | 2 |
bhz-anderson | The thesis BHZ preset, four orbitals | 32–256 | 0.5 |
square-strip | Square lattice, length 2048 | 32–128 | 1 |
graphene-anderson | Honeycomb, \(t = 1\), zigzag axis | 32–256 | 1 |
square-cross | A \(W \times W\) square with four arms of \(W/4\) and four leads, every \(T_{pq}\) | 32–256 | 1 |
TBtrans needs a real Hamiltonian, so it skips BHZ; TBtrans and Quantica.jl run the two-terminal problems up to \(W = 256\).
Results
Second campaign, 12 October 2026, on an idle Mac mini M4 Pro (10 performance and 4 efficiency cores), caroli at commit 53d13c9 (benchmarks/results/report-2026-10-12-53d13c9.md). One thread, median time per energy at the largest widths:
| Problem | \(W\) | caroli | Kwant | TBtrans | Quantica.jl | caroli's speed-up | Peak memory, caroli / fastest other (MB) | Largest \(\lvert \Delta T \rvert\): Kwant, TBtrans, Quantica.jl |
|---|---|---|---|---|---|---|---|---|
square-clean | 512 | 0.41 s | 6.98 s | 17.1× | 537 / 2021 | \(10^{-10}\) | ||
square-anderson | 512 | 0.40 s | 6.81 s | 16.8× | 545 / 1982 | \(10^{-9}\) | ||
square-anderson | 256 | 0.071 s | 1.07 s | 6.88 s | 4.26 s | 15.1× | 152 / 655 | \(4 \cdot 10^{-11}\), \(2 \cdot 10^{-6}\), \(4 \cdot 10^{-4}\) |
square-strip | 128 | 0.187 s | 2.18 s | 6.60 s | 2.69 s | 11.7× | 292 / 1313 | \(7 \cdot 10^{-11}\), \(5 \cdot 10^{-7}\), \(3 \cdot 10^{-3}\) |
square-cross | 256 | 0.241 s | 4.69 s | 19.5× | 855 / 978 | \(6 \cdot 10^{-11}\) | ||
bhz-anderson | 256 | 3.21 s | 29.3 s | 207 s | 9.1× | 808 / 2942 | \(2 \cdot 10^{-7}\), —, \(3 \cdot 10^{-3}\) | |
graphene-anderson | 256 | 0.333 s | 2.43 s | 18.7 s | 3.84 s | 7.3× | 312 / 947 | \(7 \cdot 10^{-11}\), \(3 \cdot 10^{-4}\), \(10^{-3}\) |
The speed-up is over the fastest other code of each case, Kwant here. Over all the widths, on one thread, caroli is 11–17 times faster than the fastest other code on the square lattice, 14–20 times on the four-terminal cross, 6–12 times on the long strips, 4.7–9 times on BHZ and 4.6–7.3 times on graphene. At the largest sizes it needs 3 to 4.5 times less memory than Kwant (1.1 times on the cross).
- The fastest other code. Kwant is the fastest of the three from \(W = 64\) up, except on the long strips up to \(W = 64\), where Quantica.jl is ahead; at \(W = 32\), TBtrans (square lattice) and Quantica.jl (graphene) beat Kwant. TBtrans's block-tridiagonal solver costs \(O(L W^3)\) and falls behind on square samples; Quantica.jl's BHZ leads are slow.
- All the cores (56 energies, builds included): caroli on 14 threads against Kwant on 14 processes is 10 times faster on the largest square samples, the strips, the cross and BHZ, and 4.7 to 5.9 times on graphene. At small sizes the start-up of the Kwant processes dominates, hence speed-ups of up to 100 times there. Large samples scale 4 to 6 times on 14 threads over one: the dense kernels share the matrix units and the memory bandwidth of each cluster of cores.
- One energy on all the cores. caroli runs the independent branches of nested dissection in parallel: on 14 threads one energy takes half the time of one thread at \(W = 512\), and a fifth on the strips. Kwant's MUMPS is sequential.
- Agreement. Kwant to \(10^{-9}\) or better, except BHZ at \(W = 256\) (\(2 \cdot 10^{-7}\)); TBtrans to about \(10^{-5}\), from its electrode broadening \(\eta = 10^{-6}\) eV; Quantica.jl to \(10^{-4}\)–\(3 \cdot 10^{-3}\), from the broadening \(\sqrt\varepsilon\) it adds to real energies and from its lead solver.
Since the first campaign (report-2026-10-12-08246f7.md, against Kwant only), caroli's single-thread times went down 1.6–1.7 times on the square lattice, 1.8 times on the cross, 2 times on graphene, 1.15 times on the strips and 1.1 times on BHZ: products and lead spectra through Accelerate, assembly plans, small-front elimination, the real pencil for real leads (Dense linear algebra).
The quantum-walk benchmark
The walk of Sellapillay and Verga is compared with two Python versions written for the benchmark (the one-step operator as a SciPy sparse matrix, and the step in vectorised NumPy; the authors' code is not part of the comparison), after checking that every method gives caroli's position distribution. On a ring of 19 nodes (\(2 \cdot 10^7\) amplitudes, the paper's largest system), a step takes 51 ms with the SciPy matrix, 5.3 ms for caroli in f64 on 14 threads, and 2.5 ms in f32 on the CPU or the GPU; caroli runs rings of 25 nodes (\(1.7 \cdot 10^9\) amplitudes). The scan of the paper's Fig. 21, 8192 walks of 2000 steps, takes 4.4 h for the SciPy version on one process, 6.7 min for caroli in f64 (39 times less) and 3.7 min in f32 with the GPU joining the 14 threads (70 times less); the Kolmogorov–Smirnov distances agree to \(4 \cdot 10^{-16}\) in f64 and \(2 \cdot 10^{-5}\) in f32 (benchmarks/results/walk-report-2026-10-12-c660c96.md). The full tables are in Quantum walks.
Continuous integration
Every push to main and every pull request runs three jobs on GitHub Actions, with warnings treated as errors (RUSTFLAGS = -D warnings):
| Job | Runs |
|---|---|
| fmt and clippy (Linux) | cargo fmt --check; Clippy on the whole workspace and all targets; Clippy on caroli-gpu with the cuda feature, which builds without a GPU or a toolkit since its libraries load at run time |
| test (Linux, faer) | cargo test --workspace with the ci profile: optimised, with debug assertions and overflow checks, because the in-house dense kernels are unusably slow unoptimised |
| test (macOS, Accelerate) | Clippy on the workspace, for the Accelerate and Metal modules that exist only on macOS; then the same tests through Accelerate |
The tests include the 26 golden cases, the cross-checks and the physics above, and the tutorials. The tests of the Metal kernels run where a Metal device is present, those of the CUDA kernels with the cuda feature on a machine with an NVIDIA driver; elsewhere they are skipped, and the checked runs verify that they fall back to the CPU.
Memory safety
Every crate inherits the workspace's lints, which refuse unsafe code (unsafe_code = "deny"). Four modules are exempted, each by an #[allow(unsafe_code)] with a comment that says why: they call foreign libraries, which is unsafe by nature.
| Module | Calls into | Unsafe blocks |
|---|---|---|
caroli-dense, accelerate (macOS, feature accelerate) | Accelerate's LAPACK and BLAS | 21 |
caroli-gpu, metal and metal_walk (macOS) | Metal, through objc2 | 18 |
caroli-gpu, cuda (feature cuda) | The CUDA driver and NVRTC, through cudarc | 6 |
Every unsafe block carries a SAFETY comment that states why the call is sound (valid pointers and sizes, leading dimensions checked, buffers that outlive their commands, results read only after the commands completed). The lint clippy::undocumented_unsafe_blocks flags a block without one, and the CI's Clippy runs, on macOS for Accelerate and Metal and on Linux with the cuda feature, deny it. Everything else is safe Rust: the solvers, the dense kernels' in-house QR and reordering, and the quantum-walk kernels, whose sweeps hand disjoint mutable views of the state to the threads instead of raw pointers. Sizes are checked at the boundaries: a quantum-walk state of the wrong length is refused before anything is written, and a GPU upload refuses a problem whose indices do not fit the kernels' 32-bit integers, or a walk state larger than the largest Metal buffer.
In the code
| Where | What |
|---|---|
reference/baseline | The 26 cases (inputs), their golden outputs, the serial MPI shims and the README of the baseline |
crates/caroli-validation (not published) | The baseline tool; src/thesis.rs, the thesis set-ups; src/fortran.rs, the reader of Fortran records; the tests against the golden outputs; examples such as gamma_impact, nd_precision, rgf_precision |
crates/caroli/tests | Kwant's tutorials, the symmetries of graphene with magnetic impurities |
benchmarks, crates/caroli-bench (not published) | The benchmark problems, the drivers of Kwant, TBtrans, Quantica.jl and the Python walks, the reports |
Xoshiro256 | The random stream, with gfortran and seed_from_u64 |
.github/workflows/ci.yml | The CI |
References
- A. Demion, Transport électronique dans le graphène et les isolants topologiques 2D en présence de désordre magnétique, PhD thesis, Aix-Marseille Université (2015). The thesis whose codes give the golden cases.
- L. Raymond, A. D. Verga, A. Demion, Anomalous quantum Hall effect induced by disorder in topological insulators, arXiv:1505.07145 (2015).
- A. Demion, A. D. Verga, Nonlinear electric transport in graphene with magnetic disorder, Phys. Rev. B 90, 085412 (2014).
- B. A. Bernevig, T. L. Hughes, S.-C. Zhang, Quantum spin Hall effect and topological phase transition in HgTe quantum wells, Science 314, 1757 (2006). The BHZ model.
- X.-L. Qi, Y.-S. Wu, S.-C. Zhang, Topological quantization of the spin Hall effect in two-dimensional paramagnetic semiconductors, Phys. Rev. B 74, 085308 (2006). The Qi–Wu–Zhang model.
- D. Blackman, S. Vigna, Scrambled linear pseudorandom number generators, ACM Trans. Math. Softw. 47, 36 (2021). xoshiro256**.
- C. W. Groth, M. Wimmer, A. R. Akhmerov, X. Waintal, Kwant: a software package for quantum transport, New J. Phys. 16, 063065 (2014).
- P. R. Amestoy, I. S. Duff, J.-Y. L'Excellent, J. Koster, A fully asynchronous multifrontal solver using distributed dynamic scheduling, SIAM J. Matrix Anal. Appl. 23, 15 (2001). MUMPS, Kwant's solver.
- N. Papior, N. Lorente, T. Frederiksen, A. García, M. Brandbyge, Improvements on non-equilibrium and transport Green function techniques: the next-generation TranSIESTA, Comput. Phys. Commun. 212, 8 (2017). TBtrans.
- P. San-Jose, Quantica.jl, a Julia package for tight-binding models and quantum transport, https://github.com/pablosanjose/Quantica.jl.
- K. Sellapillay, A. D. Verga, Quantum walk on a graph of spins: magnetism and entanglement, Phys. Rev. E 103, 032123 (2021).