Skip to content

Fix #145: KernelAbstractions >= 0.10.3, drop the 320 B/launch CPU allocation allowance - #171

Merged
michel2323 merged 2 commits into
mainfrom
fix/145-ka-launch-allowance
Oct 30, 2026
Merged

michel2323 merged 2 commits into
mainfrom
fix/145-ka-launch-allowance

Conversation

@michel2323

Copy link
Copy Markdown
Member

Closes #145

Not a task PR: a test-infrastructure fix. The budgets of the CPU-backend allocation tests carried a fixed 320 B per kernel launch for KernelAbstractions 0.10, measured on 0.10.0; on the KA that CI resolves a launch allocates nothing, so every numeric- and solve-phase budget was ~40× too loose (~62 KB of headroom for one factorize! of random_spd(500, 0.01), which let the 32 KB per factorization of the old :ka fallbacks pass). T32 (#146) needs budgets that can see such allocations.

Measured (CPU backend, Julia 1.13.3, warmed launches of a trivial kernel and of one with 512 B @localmem, ndrange 64 and 65536): KA 0.10.0 96 B per launch (PR #133 had recorded ~230 B); KA 0.10.3 0 B, with and without --code-coverage=all; KA 0.10.4 0 B with 1 and 4 threads and --code-coverage=user, 100 launches back to back also 0 B. One factorize! (impl = :auto, Float64, SPD n = 500, nnz 5430): 512 B steady state, with or without coverage, within the 1024 B base.

What changed

  • Project.toml, test/Project.toml: KernelAbstractions = "0.10.3" (docs/ and bench/ carry no KA compat).
  • test/utils.jl: ka_cpu_alloc_budget drops the 320 * launches term and keeps the 1024 B base plus the coverage term (localmem_bytes + 64 B/launch); docstring and comment record the measurements and why the allowance went; a stale "on KA 0.9" remark in the ldlt_alloc_budget docstring removed.
  • AGENTS.md: the session-rules sentence describes the new state (KA ≥ 0.10.3, no per-launch allowance outside coverage runs).

Tests (CPU backend only, SDS_TEST_GPU=0 SDS_TEST_ELTYPES="Float64,ComplexF32", without coverage): test_numeric_cholesky_a,test_numeric_cholesky_b 1522 pass; test_numeric_cholesky_c,test_solve 584 pass; test_numeric_ldlt,test_numeric_lu 1656 pass; test_api 1129 pass; 0 fail, 0 broken. No budget failed under the tightened allowance, so no @test_broken was added. The coverage term is exercised by CI (julia-runtest with coverage); CUDA/AMDGPU/oneAPI: pending CI (the GPU budgets, fused_cycle_alloc_budget included, do not use ka_cpu_alloc_budget).

Deviations from PLAN.md / TASKS.md: none. Note: the 0.10.3 lower bound rests on the standalone launch measurement; the package tests ran against the resolved 0.10.4.

Follow-up issues opened: none.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MsLzHmUtWpQYEoF8pxgywZ

…ocation allowance

KA 0.10.3+ launches allocation-free on the CPU backend (measured 0 B for a
warmed trivial and @LocalMem kernel on 0.10.3 and 0.10.4, 1 and 4 threads,
with and without coverage; 0.10.0 allocates 96 B). The fixed 320 B/launch term
of `ka_cpu_alloc_budget` made the numeric/solve budgets ~40x too loose and hid
real allocations. Raise the compat bound (Project.toml, test/Project.toml),
keep the 1024 B base and the coverage term, update the docstrings and AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MsLzHmUtWpQYEoF8pxgywZ
@michel2323 michel2323 added claude:pr PR opened by the Claude implementer; handled by the Claude pipeline testing Test coverage, budgets or test infrastructure chore CI, tooling or bench upkeep; no package behaviour change labels Oct 30, 2026
Comment thread test/utils.jl Outdated
Comment on lines +272 to +279
that is 0: a warmed launch on the KernelAbstractions ≥ 0.10.3 CPU backend
allocates nothing (measured for #145 on KA 0.10.3 and 0.10.4, trivial and
`@localmem` kernels, 1 and 4 threads). With `--code-coverage` (CI's
`julia-runtest`) the `@localmem` `MArray`s may be heap-allocated (T09 review
round 1), hence `localmem_bytes` plus 64 B of header per launch. KA 0.10.0–0.10.2
heap-allocated on every launch (96 B measured with a trivial kernel, ~230 B in
PR #133), which a 320 B/launch allowance covered; that allowance hid real
allocations of the numeric phase (~40 KB of headroom for a 500×500 matrix), so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (non-blocking): two numbers here do not match the PR description. The description measures 1 and 4 threads on KA 0.10.4 only (0.10.3 was measured with and without --code-coverage=all), while the docstring folds both into "0.10.3 and 0.10.4 ... 1 and 4 threads". And the headroom for random_spd(500, 0.01) is "~62 KB" in the description but "~40 KB" (the issue's figure) here. Worth aligning so the docstring stays the record of the measurement.

Suggestion, also non-blocking: with the per-launch term gone, a future KA release that allocates per launch again would surface as scattered budget failures across the numeric and solve tests. A single guard test in test_api (or wherever the CPU backend is cheapest), asserting that a warmed trivial launch allocates 0 B, would point at the cause directly and could @test_broken with a note when KA regresses.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: APPROVE (head 9f18281)

Not a task PR: a test-infrastructure fix for #145 (labels claude:pr, chore, testing; no task, no milestone), reviewed against the issue, AGENTS.md and the diff.

Checked

  • Scope: four files only (Project.toml, test/Project.toml, test/utils.jl, AGENTS.md). PLAN.md and TASKS.md untouched, no Manifest.toml. The AGENTS.md edit only updates the session-rules sentence about the KA bound and the allocation budgets to the new state.
  • Compat: KernelAbstractions = "0.10.3" in both project files; 0.10.3 and 0.10.4 are registered in General. docs/ and bench/ carry no KA compat, so nothing else needs the bound.
  • ka_cpu_alloc_budget: the 320 * launches term is removed; the 1024 B base and the coverage term (localmem_bytes + 64 * launches) are unchanged, so the CI runs with julia-runtest coverage keep their allowance. All callers (numeric_alloc_budget, solve_alloc_budget, ldlt_alloc_budget) are unchanged and still pass launches and localmem_bytes; fused_cycle_alloc_budget and the GPU budgets do not use the helper, as the description says. No test was weakened: the change only tightens the budgets, and no @test_broken was added.
  • Docstrings: the stale "on KA 0.9" remark in ldlt_alloc_budget is gone; the ka_cpu_alloc_budget docstring records the measurements and the reason for the removal.
  • PR description vs diff: matches. The CPU test counts are plausible for the listed file subsets without coverage. CI (CPU with coverage, CUDA, AMDGPU, Aurora) is still pending at review time; the GPU legs do not use the helper, and the coverage leg is the one that exercises the remaining term. The owner handles pending checks.

Blocking findings: none.

Non-blocking: one inline nit on the ka_cpu_alloc_budget docstring (two figures differ from the PR description), with a suggestion for a guard test asserting that a warmed trivial launch allocates 0 B, so a future KA regression is attributed directly instead of appearing as scattered budget failures. PLAN.md risks table (line 482) still says the 0.10 backend allocates a fixed amount per launch; that is for the owner to update.

…er-launch allocation

The ka_cpu_alloc_budget docstring now records what was measured where (KA
0.10.3 with and without coverage, 0.10.4 with 1 and 4 threads) and the ~62 KB
of headroom the old allowance granted for random_spd(500, 0.01). test_helpers
asserts that a warmed trivial launch on the KA CPU backend allocates 0 B (64 B
under coverage), so a KA release that allocates per launch again names its
cause instead of failing budgets across the suite.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MsLzHmUtWpQYEoF8pxgywZ
@michel2323

Copy link
Copy Markdown
Member Author

Review nit of 9f18281 addressed in 0a653a7: the ka_cpu_alloc_budget docstring now matches the PR description (KA 0.10.3 with and without coverage, 0.10.4 with 1 and 4 threads; ~62 KB of headroom for random_spd(500, 0.01)), and the suggested guard is in test_helpers: a warmed trivial launch on the KA CPU backend must allocate 0 B (≤ 64 B under coverage). SDS_TEST_GPU=0 SDS_TEST_ONLY=test_helpers: 124/124 pass.

@michel2323
michel2323 merged commit 7e880c8 into main Oct 30, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore CI, tooling or bench upkeep; no package behaviour change claude:pr PR opened by the Claude implementer; handled by the Claude pipeline testing Test coverage, budgets or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ka_cpu_alloc_budget: the 320 B/launch KA 0.10 allowance is stale on KA 0.10.3 and hides allocations

1 participant