Repository navigation
nav tests: build nav_material_ext_test without FMA contraction, as the rollouts are - #750
Merged
Merged
Conversation
…e rollouts are NavMaterialExt.ACallbackGivingThePatchIsThePatch has failed on recipe / macos-latest / Release since #734. For the dynamic vehicle, the outputs, the coefficient gradients and dL/dF_ext of the patch source and of a callback giving the same patch came out 1-2 ulp apart. Both sources sample with the same inline functions (detail/material_rollout.h's patch_sample_channel and patch_sample_channel_grad), but in different TUs. The rollouts' TU, material_bike_rollout.cpp, is built with -ffp-contract=off. The test's TU, where patch_callback is, was built with the compiler's default. On aarch64 that turns the sampler's bilinear sum into 3 FMAs and each Jacobian sum into 1, so the callback's F and J were not the patch's. x86-64 with no -march has no FMA and MSVC does not contract, so Linux and Windows were exact. macOS Debug inlines nothing, so most likely both sides called one copy of the sampler there. The design promises bit for bit here (#734 and docs/NAV_MATERIAL.md's table), and the library side already is. So the test TU is now built as the rollouts are, with -ffp-contract=off (/fp:precise on MSVC), as tests/CMakeLists.txt already does for det_math.cpp. No tolerance. How this was checked (there is no macOS here): - clang 18 on the test TU with its own flags: by default, 3 fmuladd in patch_sample_channel and 2 in patch_sample_channel_grad; none with -ffp-contract=off. Compiled for arm64-apple-macosx, the callback has 6 fmadd by default and none with the flag. - On Linux, a copy of the test whose callback does those FMAs with std::fma fails the same three assertions, for the dynamic vehicle only, by 1-2 ulp. One gradient pair is the macOS log's exactly (-0.126325145 vs -0.12632513). The surrogate's and the bicycle's callback F and J are an ulp off at many samples too, but those ulps round away where F_ext joins larger sums. - Linux Release and Debug: nav_material_ext_test passes (11/11).
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.
NavMaterialExt.ACallbackGivingThePatchIsThePatch(added by #734) has failedrecipe / macos-latest / Releaseon every PR since: run 39470314473 on #746 and run 39478176362 on #725. The failures are all for the dynamic vehicle: the outputs, the coefficient gradients (gpvsgc) and dL/dF_ext (fpvsfc) of the patch source and of a callback giving the same patch came out 1-2 ulp apart.Cause
Both sources sample with the same inline functions,
detail::patch_sample_channelandpatch_sample_channel_grad, but in different TUs:material_bike_rollout.cpp, which is built with-ffp-contract=off.patch_callbacksamples innav_material_ext_test.cpp, which was built with the compiler's default.On aarch64 the default turns the sampler's bilinear sum into 3 FMAs and each Jacobian sum into 1, so the callback's F and J were not the patch's.
The other lanes were exact for these reasons:
-marchhas no FMA instructions.Fix
The design promises bit for bit here: #734's table and
docs/NAV_MATERIAL.mdsay "A callback giving the patch's own values and J: the patch, bit for bit". The library side already is. So the test TU is now built as the rollouts are, with-ffp-contract=off(/fp:preciseon MSVC), the same waytests/CMakeLists.txtalready buildsdet_math.cpp. There is no tolerance, and the library is unchanged.The doc's table row now says the callback is bit for bit when it is built as the rollouts are.
How this was checked (there is no macOS here)
patch_sample_channelhas 3fmuladdandpatch_sample_channel_gradhas 2. With-ffp-contract=offthere are none.arm64-apple-macosx. It has 6fmaddby default and none with the flag.std::fmafails the same three assertions, for the dynamic vehicle only, by 1-2 ulp. One gradient pair is exactly the macOS log's (-0.126325145vs-0.12632513). The surrogate's and the bicycle's callback F and J are an ulp off at many samples too, but those ulps round away where F_ext joins larger sums.nav_material_ext_testpasses (11/11), and the compile line has-ffp-contract=off.NavMaterialExt.Golden. It compares at 1e-5 relative, so it is unaffected.recipe / macos-latest / Releaseon this PR is the check that matters.