Repository navigation
Keep calc_forces!' per-panel loads out of line so Julia 1.12 gets linearize's ForwardDiff Jacobian right on AVX-512 Zen - #396
Open
1-Bort-1 wants to merge 8 commits into
Conversation
…il's The ram-air wing's tip sections are ~70%-thick slices (#361) on which NeuralFoil returns Cd=1 at every alpha, and those outputs differ with the runner's CPU, so the LOOP solve lands on one of two different solutions depending on the runner. Tables that are affine in (alpha, delta) make the bilinear interpolation exact, keep every panel attached, and are the same bits on every machine. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ide it Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ompiles for Dual{10} on Zen 4/5
panel_body_loads (@noinline) now returns panel_loads plus the moment about the
reference point, for calc_forces! and for the body_aerodynamics results loop,
which carried the same moment line. The POLAR_MATRICES testset also checks that
the Jacobian does not depend on the ForwardDiff chunk size.
Refs #360, #379
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…bounds=yes Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…OLAR_MATRICES wing again The affine tables come out: the ForwardDiff check runs on main's ram-air wing, with the chunk-size testset kept on it. The changelog entry moves to Unreleased, since v6.0.0 went out without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Member
|
Does this affect performance? |
This branch has not been deployed
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.
TL;DR
On Julia 1.12 with
--check-bounds=yes(asPkg.testruns), LLVM 18's SLP vectorizer miscompilescalc_forces!'s per-panel force assembly for 10-partial Duals on AMD Zen 4/5 CPUs with AVX-512 (JuliaLang/julia#62368).linearize's default ForwardDiff Jacobian came out about 5% off there, and whether CI drew such a runner was the whole #360 flake. The loads and body moment now come from a@noinlinepanel_body_loads, which keeps the Jacobian exact there, and a new check makes sure the Jacobian does not depend on the ForwardDiff chunk size.This replaces #378, cut down as asked on #360: only the workaround and the chunk-size test. The POLAR_MATRICES check stays on main's ram-air wing; the affine tables are gone.
What was wrong
Diagnostic CI ran
repro379.jl(in #379) againstmainon 16 Julia 1.12.7 runners per round. It computeslinearize's Jacobian with chunk 10 and with chunk 5, which must agree to rounding:--check-bounds=yes--check-bounds=yes, SLP off+avx512fJULIA_LLVM_ARGS=-vectorize-slp=falsemakes it exact, which places it in Julia 1.12 and LLVM 18 vectorization defect JuliaLang/julia#62368. That issue has the LLVM fix identified (llvm/llvm-project@5d7cf504), still waiting on a backport to Julia 1.12's LLVM.--check-bounds=yes, are not affected. The finite-difference Jacobian was right everywhere.Dual{10}solve with two stitchedDual{5}solves put the first wrong value atsol.f_body_3Dincalc_forces!. Recompiling copies of it with single statements removed: leaving out either themoment_dist[i]line or them_body_3Dstore fixes it. The same loop in a function of its own, or in a standalone script, compiles correctly, so there is no package-free reproducer.What changed
panel_body_loads(axes, dirs, q_dyn, cl, cd, cm, c_span, arm)(src/panel_aerodynamics.jl,@noinline) returnspanel_loadsplusbody_moment, the moment about the reference point.calc_forces!andcalculate_resultsboth call it;calculate_resultscarried the same moment line, so the formula has one source now. Results do not move:norm_fwdwas bit-identical with and without the change.test/solver/test_forwarddiff.jl: a nested testset on the POLAR_MATRICES case,AutoForwardDiff(chunksize=5)matches the default chunk to 1e-12. That is the class this bug belongs to, checked with no finite-difference noise.Where I would push back
@noinlineworks around the bug and does not fix it. Other code with the same shape could hit the same SLP bug, and the chunk-size testset catches that only on an AVX-512 Zen runner, and only for this case. Julia 1.12's LLVM SLP vectorizer miscompiles calc_forces! for Dual{10} on AVX-512 Zen 4/5 under --check-bounds=yes (JuliaLang/julia#62368) #379 tracks removing it once Julia 1.12 ships the LLVM backport.Verification
0.04894348185682458 < 0.0001. Control runs onmain(35730023185, 35736962099):repro379.jlrel. 0.042 / 0.050 on every AVX-512 Zen runner.repro379.jlrel. 0 under--check-bounds=yes. That run carried the affine test; thesrc/change is the same one here.main(e62fc15): the 11 solver and body-aerodynamics test files, 5243/5243 pass locally (juliaserver, Julia 1.13.0). There is no local red: this box's i5-13500 has no AVX-512.agent ci-local, Julia 1.13): started · GitHub CI: runningmain--check-bounds=yeswould show.Scope
+34 / −10 across 6 files.
src/is +21 / −10: the new 13-line function, and its two callers trading their inline moment line for the call. The test gains the 8-line chunk-size testset; the docs page and the changelog take one entry each.Closes #360
🤖 Generated with Claude Code