Include user sensor dimension in model signature - #3485
Open
ousamabenyounes wants to merge 4 commits into
Open
Conversation
Three diagnostics that clang does not emit, so they were missed until the gcc-14 CI jobs, which build with -Werror: - mji_scl3 takes a restrict-qualified destination, so passing the same array as source and destination is undefined. Two calls did: negating the edge separating axis, and halving the witness midpoint. The first now negates in place, the second forms the midpoint directly. - Adding const to a pointer to array is not a valid implicit conversion before C23. The pointer it qualified was a redundant alias of the clip buffer, and is removed. No functional change: the box-box fuzzer's output hash over 60k configurations is identical before and after.
- The 25-line comment describing the collider's two stages, the reference and incident face convention, and why the manifold is not reduced below the clipped polygon. The last paragraph is load-bearing: reducing the patch to four points is what an earlier draft did, and it costs two to three orders of magnitude of residual motion on stacks of plates. - contact_net.xml's b1 orientation, from euler="5 4 3" back to "5 5 5". The re-posed model does not converge under mjUSESINGLE: SensorTest.ContactNet spends minutes in mj_solPrimal instead of hundredths of a second, so the single-precision suite never finishes. The original orientation passes in both precisions with the current collider, in 0.02s and 0.01s. No functional change to the collider: the box-box fuzzer's output hash over 60k configurations is unchanged.
On mjWARN_BADQACC the warning handler resets mjData, which rewinds data->time to one timestep. A loop conditioned on data->time then cannot terminate: the model diverges, resets, falls, diverges again, indefinitely. Every step is sub-millisecond, so it presents as a compute hang rather than a failure, and a CI job sits in it until the runner is killed. This test hit that under mjUSESINGLE: 100k steps without data->time reaching 0.2. Bounding by step count turns the same event into a prompt failure. 80 further occurrences of the idiom remain across the test suite; they are only latent as long as their models do not diverge.
mjCModel::Signature() serialized each sensor's type but not its dimension. For mjSENS_USER the sensor dim determines nsensordata and therefore the compiled model's memory layout, so two models differing only in a user sensor's dim produced identical signatures despite different layouts. Include the sensor dim in the signature string and add a regression test. Fixes google-deepmind#3307
ousamabenyounes
force-pushed
the
fix/issue-3307
branch
from
August 16, 2026 16:51
1687b2c to
e414e21
Compare
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.
Summary
mjCModel::Signature()serialized each sensor'stypebut not itsdim. FormjSENS_USER, the sensordimdirectly determinesnsensordataand thereforethe compiled model's memory layout. As a result, two models differing only in a
user sensor's dimension produced identical signatures despite different layouts.
This appends the sensor
dimto the signature string and adds a regression test.Fixes #3307
Change
src/user/user_model.cc— serializespec.dimafterspec.typefor eachsensor in the signature string.
Test verification (RED → GREEN)
New test
SensorTest.UserSensorDimAffectsModelSignaturecompiles two models withuser sensors of
dim=100anddim=200and asserts their signatures differ.RED — new test on the unmodified upstream base (fix reverted, test only):
GREEN — with the fix:
No regression:
user_recompile_test(which checks signature stability acrossrecompile/copy for every bundled model) still passes — the added
dimis appliedsymmetrically to both sides of every signature comparison.
Note
This completes the approach approved in #3308, which stalled on the CLA and was
closed. This PR uses RAII (
MjModelPtr) for model cleanup and ships theregression test.