Repository navigation
Evaluate long raw symbolic sources once per quadrature point - #64
Merged
Merged
Conversation
compile_coeffs rejected a long raw :source because expand(ex - linear) does not cancel a/b^p - a/b^p term by term, so the kernel evaluated f once per quadrature point and test function. For :source, also accept ex(w = 0) == 0: the next check makes the coefficients free of the test slots, so ex is affine in them and a zero constant term makes it linear. Agent-Harness: Claude Code 2.1.318 Agent-Model: claude-sonnet-5-5 Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…est slots A function such as sign has a zero derivative and vanishes at 0 without being linear, so the ex(w = 0) == 0 fallback now also requires that every call depending on the test slots is a +, * or /. Agent-Harness: Claude Code 2.1.318 Agent-Model: claude-sonnet-5-5 Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Documenter fails the build with :missing_docs on a docstring for an internal function that is not in the manual (FiniteElementMethod.arithmetic_in), as in the Documentation check on the PR. Internal helpers in this file use comments. Agent-Harness: Claude Code 2.1.312 Agent-Model: claude-sonnet-5-5 Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.com>
This was referenced Nov 5, 2026
xtalax-droid
pushed a commit
that referenced
this pull request
Nov 5, 2026
Resolve the test/Kernels/kernels.jl import conflict by keeping both sides: build from this branch and AssemblyContext, assemble_linear and the expanded Ferrite and LinearAlgebra imports from master (#64). Agent-Harness: Claude Code 2.1.318 Agent-Model: claude-haiku-5-5 Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c Agent-Review: unreviewed Co-authored-by: Claude Code <agent@noreply.juliahub.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.
A long raw symbolic
:source(for example the strong residual of a manufactured solution) was evaluated by the per-shape-function fallback kernel, once per quadrature point and per test function, becausecompile_coeffsrejected it as non-linear.Cause: the linearity check
isequal(expand(ex - linear), 0)comparesf*Vwith(∂ex/∂V)*V, andexpanddoes not cancela/b^p - a/b^pterm by term, so a source of a few hundred terms leaves a residue of thousands of characters,source.coeffs === nothing, and the fallback runs (src/assembly.jl:499). A source registered with@register_symbolicis opaque and never reaches the check.Fix (
src/kernels.jl): for:sourceonly, also acceptex(w = 0) == 0, provided every call inexthat depends on the test slots is a+,*or/. Soundness: for a sourceexis the whole integrand (f*V) andwthe test slots. The existingdependscheck on the coefficients, which follows immediately, rejects unless every∂ex/∂w_iis free ofwand of the trial slots, soex = ex(w=0) + Σ (∂ex/∂w_i) w_iexactly, and a zero constant term makes it linear. Nonlinear forms (V^2,V*W,V*U,V*X + 1) are still rejected by that check. The arithmetic-only walk exists because Symbolics givessign(V)a zero derivative andsign(0) = 0(a Codex finding), so a hand-builtV + sign(V)would otherwise be accepted with a wrong coefficient; it cannot occur in sources built byweak_form, whereVonly appears asf*V.Tests (
test/Kernels/kernels.jl): a manufactured-solution residual source (K = 4 terms) hascoeffs !== nothingand its assembled load vector matches thecoeffs = falsepath to 1e-12; on master it fails withsource.coeffs !== nothingevaluatingnothing !== nothing. A second testset pins the rejected forms, including thesigncase, which fails without the guard.Measured with a long-source reproducer (heat equation, P2 triangles, manufactured solution with K = 8 terms, 112 additive terms, 11,814 characters; A raw source, B registered with
cse = true, C ordinary source), same session and box:n = 4: A rhs 2.5 ms to 0.4 ms, solve 0.56 s to 0.10 s, error 1.903e-3 unchanged. C (ordinary source) is unchanged.
benchmarks/assembly_cost.jlcases (i) and (iii) (ratios 1.6 and 1.3 before and after) andbenchmarks/construction.jlare unchanged within noise. The remaining A/B gap is raw expression evaluation against CSE'd code, which the follow-up (cse = truein the codegen) addresses.Gates (Julia 1.12): Perf 28/28 (all four gates, uninstrumented, including gate 2, no per-cell allocation), Kernels 355, Assembly 55 + 14, Integration 304, Frontend 753, Convergence 26; Kernels and Assembly also pass on lts. Runic 1.13 clean; Codex approved (round 1 found the
signhole, closed in the second commit).Risks: the arithmetic-only walk calls
dependsper node on the source tree (not measurable at 11.8k characters; a pathologically deep tree would pay a quadratic cost, only after the cheapexpandcheck has failed); the fallback is:sourceonly,:massand:bilinearare untouched.🤖 Posted by an AI agent · harness: Claude Code 2.1.318 · model: claude-sonnet-5-5
Review: unreviewed
Session: 43e03fde-3384-4386-bae9-03e81f19ba7c