Repository navigation
Conversation
solve_dke_tokamak_batch solves many flux surfaces or scan points that share the grids and options at once. All cases take their Krylov steps together (lockstep GMRES), and the matrices of the two-level preconditioner are assembled for all cases from fixed maps of per-case ingredients, then factored and solved as batches. - array-generic batched operator, GMRES and preconditioner in src/batch, running on host arrays and, through the CUDA + CUDSS weak-dependency extension, on the device (device = :cuda) - coarse matrices, and plane matrices from 6000 unknowns up, by dense block elimination in batched cuBLAS kernels; smaller planes by cuDSS uniform batches - cases are chunked to fit device memory; a case whose batched factorization fails is solved again on the host - tests against the single-case solver in the default suite; GPU tests opt-in with YANCC_TEST_GPU=1; throughput benchmarks in benchmark/ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dense block elimination now handles block-banded chains, so the plane matrices can take one pitch angle (with its poloidal ring) per block, coupled to the blocks within the stencil reach either side, instead of block tridiagonal blocks of two. The batched inverses, the slowest kernels, then do a quarter of the work. The coarse matrices keep block tridiagonal blocks. Whole batched solves on one A100 go from 10.1 to 13.1 solves/s at 257 x 61 x 6 x 3 (cuDSS for the planes: 6.0) and from 45 to 57 at 129 x 41; at 65 x 41 blocks now match cuDSS, so the GPU uses them from 2500 unknowns a plane up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… chunks The host work of each chunk limited the GPU throughput, most of it not physics: - each chunk now frees its device memory (operator, preconditioner factors including cuDSS's, Krylov basis) as it finishes, so a young collection replaces the full garbage collection that took a fifth of a chunk - the right hand sides, row scalings and moment constraints are products of factors in pitch angle, theta and speed; they are formed on the device from small per-case tables instead of full arrays per case on the host (the batched path no longer calls DKEBorder or dke_rhs; tests check them against those) A chunk takes 0.62 s instead of 0.92 s at 65 x 41 (95 cases) and 0.84 s instead of 1.10 s at 257 x 61 (12 cases). A GPU node solves 644 and 72 cases per second with one process per GPU, 743 and 80 with two under MPS (was 473 and 55). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts in Project.toml, README.md and test/runtests.jl resolved by keeping both sides: the CUDA and ForwardDiff extensions, the GPU and automatic differentiation rows and sections, and both test files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
…tension GMRES: an exhausted Krylov space, no iterations, a right hand side and a residual that are not finite, stagnation under a preconditioner that changes between calls. Host seams: batched GEMM, default solvers, device selection, chunks over threads; the preconditioner built from the operators. CI runs the tests on two threads so that the threaded loops run, and Codecov ignores ext/YanccCUDAExt.jl, which needs a GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lver Rounding differs with the number of threads (CI now runs on two) and can move a case across rtol, as the plane block tests already allow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d run The defaults of the solvers were folded at compile time in the test, so it now calls them through an inference barrier. The local declarations and the closing lines of threaded and timed blocks are counted as code by Julia 1.11 but never marked as run; they carry COV_EXCL_LINE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds
solve_dke_tokamak_batch(ops; device=:cpu | :cuda | :auto), which solves many flux surfaces or scan points at once. The cases must share the grids, stencils and operator options; the field, the plasma and the electric field may differ. The single-case API is unchanged, and the batched solver takes plainFloat64operators only (no dual numbers).How it works
src/batch/batched_gmres.jl): all cases take their Krylov steps together and the small Hessenberg problems stay on the host. Converged cases are frozen. A case that meets a non-finite number stops as:failedand is solved again bysolve_dke_tokamak.src/batch/batched_operator.jl): array-generic (broadcasts,mul!, batched GEMM), so the same code runs onArrayandCuArray. The right-hand sides, row scalings and constraints are formed on the device from small per-case tables.src/batch/batched_preconditioner.jl,assembly_maps.jl,block_coarse.jl): the two-level preconditioner ofsolve_dke_tokamak.ext/YanccCUDAExt.jl,CUDA+CUDSS). CI and the CPU package never load it. Cases are chunked to fit device memory, and each chunk frees its device memory when it finishes.Results
Solves per second for D + C + e,
nx = 6,rtol = 1e-6, 6–7 iterations per case, on a Perlmutter GPU node (one process per GPU) and a CPU node:nalpha×nthetaTwo processes per GPU under CUDA MPS raise the node numbers to 743 and 80.
The GPU numbers leave out building the operators on the host (about 1.4 s per 1024 cases on 32 threads). A solve on its own does not gain from a GPU. On a CPU, one
solve_dke_tokamakper core is faster thandevice = :cpu, which is there for testing.benchmark/reproduces the table, and the README has a new section on this.Tests and CI
test/test_batch.jlruns in the default suite. It checks the batched operator, the assembled matrices, the block solvers, the GMRES edge cases and whole batched solves against the single-case code.test/test_cuda_ext.jlis opt-in withYANCC_TEST_GPU=1. It compares every device result with the host path, with scalar indexing forbidden.Pkg.test(): 1388/1388. Full suite with the GPU tests on an A100: 1519/1519.codecov.ymlleavesext/YanccCUDAExt.jlout of coverage, since CI has no GPU. A few lines that Julia counts but never marks as run carryCOV_EXCL_LINE.Master (the ForwardDiff extension) is merged in.
🤖 Generated with Claude Code