Repository navigation
nav: sample_starts_goals and from_occupancy's groups are the same on every standard library - #1118
Merged
Merged
Conversation
NavSimWorldAgents.EachPolicyDrivesItsOwnAgents failed on package-macos with pd.pos[2] == po.pos[2] == -5.26315784. scatter_free drew its cells with std::uniform_int_distribution, whose mapping each standard library picks for itself. libstdc++ and MSVC both use Lemire's multiply-and-reject on a 32-bit draw, so they agree. libc++ masks the low ceil(log2 n) bits and rejects. With seed 11, libc++ gave agent 1 a start and a goal in one column (45), so it drove straight along -y and its x stayed at -5.2631578 under both policies. Only y differed. #1095 loosened the check to the whole world's positions, which hid the different scene rather than fixing it. - sim_world.cpp: pick_below writes out Lemire's mapping, so a seed is one scene on every platform: the one Linux and Windows always drew. Their worlds are unchanged bit for bit; macOS and wasm (libc++) now draw them too. The colours stay std::uniform_real_distribution: it takes one draw on each library, so the picks after it stay in step. - nav_sim_world_test: ScatterFreePicksTheSameCellsOnEveryStandardLibrary pins seed 11's cells on an open field. - nav_sim_world_agents_test: the policies must drive agents 1 and 3 to different points, not merely to different whole worlds. A point, not one coordinate, since an agent driving along a column keeps its x.
…every standard library The rest of cvc::nav's seeded draws, written out the way #1114 wrote out scatter_free's. - detail/seeded_draw.h: pick_below (#1114's Lemire multiply and reject, moved out of sim_world.cpp and shared) and seeded_shuffle. - training_scene::sample_starts_goals: its three picks (goals anywhere, starts with a clearance, local goals) are pick_below. libstdc++ and MSVC map a 32-bit draw this way already, so Linux and Windows draw the routes they always drew; macOS and wasm (libc++, low bits and reject) now draw them too. - sim_world::from_occupancy, clustered: the k-means centres come from seeded_shuffle instead of std::shuffle. The three libraries all shuffle differently: libstdc++ takes two swaps from one Lemire draw while n * n fits in 32 bits, MSVC's std::shuffle maps each draw by its remainder (its older _Rng_from_urng, not uniform_int_distribution's Lemire), and libc++ swaps from the other end. seeded_shuffle is libstdc++'s written out, so Linux keeps its groups and Windows, macOS and wasm change: on the pinned field (twelve agents, three groups) MSVC's shuffle gave 34 of 40 seeds other groups. Checked against the libraries themselves with one program built by MSVC 19.44, g++ 13.2 (libstdc++) and em++ 21 (libc++, run under node): pick_below matches uniform_int_distribution<int> on libstdc++ and MSVC for every case (230000 picks, n from 1 to INT_MAX, the draw streams in step), seeded_shuffle matches libstdc++'s std::shuffle for every case (n up to 70001), and the written-out draws hash the same under all three. Tests: - NavCoefTrain.StartsAndGoalsAreTheSameOnEveryStandardLibrary pins seed 7's cells in each of the three ways on a 40 x 30 field with a wall. libc++'s own draw began {19, 4, 31, 13}. The clearance and the goal range sit at least 0.019 from every cell's square-root distance, so rounding moves no cell in or out. - NavSimWorld.ClusteredGroupsAreTheSameOnEveryStandardLibrary pins seed 20's groups of twelve; each agent is at least 15% nearer (squared) its own centre than the next at every step. - NavSimWorld.SeededShuffleIsTheSameOnEveryStandardLibrary pins odd, even and past-paired lengths. The gates loosened because macOS drew other routes: - DynBike.KinematicLimitFollowsBikeStep: the open-loop gap is gated at 0.1 rr again (#717 had moved it to 0.2 rr because each library drew other routes). It is 0.0107 on these routes, the same with the test compiled /fp:contract /arch:AVX2, which contracts its arithmetic to about 1260 fused multiply-adds as clang does on arm64. The closed-loop worst agent stays reported, not gated: on these same routes it parts by 1.80 normally and by 0.017 with the fused arithmetic, while the medians barely move (0.00045 / 0.17% against 0.00032 / 0.13%). - DiffExtForce / DiffExtRollout and the four-wheel ext checks keep their switch filter and quotas: the shared draws still put one to five cases on a switch, and the quotas were set over 100 swept seeds, not per library. Their comments, and NAV_TRAINING.md, no longer say the draws differ by library. Windows (MSVC, RelWithDebInfo): nav_sim_world 7/7, nav_sim_world_agents 17/17, nav_coef_train 31/31, nav_dyn_bike 23/23, nav_dyn_4w 23/23, nav_potential 17/17, nav 64/64. Every pre-existing test's output is identical to the base commit's, number for number.
… allowlist #1122 (room-call) added src/cvc/ariadne/conference/room_calls.cpp to libcvc. Its CI ran on a base from before #1107, so the scan never saw it, and every PR based on master now fails the package-linux scan step on its seven objects: the per-app client map clients() and its mutex, the once-per-app list in register_room_call_intrinsics and its mutex, and the message counter g_messages (like room_lane.cpp's g_lane_messages).
transfix
added a commit
that referenced
this pull request
Nov 11, 2026
…rary (#1121) plant_log_scene.cpp's three seeded picks were std::uniform_int_distribution<std::size_t>: the city's and the bundle's scatter, the bundle's route goals in the 5-15% ring, and the city's new goal at each arrival. They are nav::detail::pick_below now (#1118's), as cvc::nav's own are. Checked by running one program built by MSVC 19.44, g++ 13.2 (libstdc++) and em++ 21 (libc++, under node): - With a 32-bit mt19937, uniform_int_distribution<std::size_t> on 64-bit libstdc++ and MSVC still takes the 32-bit Lemire path while the range is below 2^32 (libstdc++'s urngrange == UINT32_MAX branch; MSVC's _Rng_from_urng_v2 with one 32-bit draw and a 128-bit product): 0 of 260000 picks differ from pick_below, n from 1 to 2^32 - 1, the streams in step. The same with a mersenne_twister_engine<uint64_t, 32, ...>, which is glibc's std::mt19937 (uint_fast32_t is 64 bits there). libc++ masks and rejects: 237086 of 260000 differ. - So Linux and Windows draw what they drew. On Windows the drives are bit for bit the same before and after (every sample of the Humvee's and the RoboRacer's swerve and city, seeds 7, 100 and 101, 20 s), and so is physics_plant_log_test's output, the power fits included. - The speeds and the swerve's gates stay std::uniform_real_distribution<double>: libstdc++ and libc++ agree bit for bit, and MSVC's P0952R2 generate_canonical truncates where they round, at most 2^-53 of the canonical apart. It is two draws each on all three, and none of 160000 floats of the kind plant_log keeps from them differ. Tests: - PlantLogScene.CityStartsAreTheSameOnEveryStandardLibrary pins seed 7's eight Humvee starts as city cells, read back from the rear axles after the settle (each within 0.02 of a cell's centre). It passes against the library before this change too: these are the cells Windows drew. libc++'s draw began (5, 55), (57, 5), (20, 75). - No gate was loosened for macOS's plant-log draws. PlantLogPowerConvergence's collision filter (#875) is for Linux's and Windows' floating point, and stays. The bundle scene's ring pick is not driven by a test: it needs a city bundle.
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.
The rest of cvc::nav's seeded draws, written out the way #1114 wrote out
scatter_free's, so a seed is one scene on Linux, Windows, macOS and wasm.Builds on #1114 (merged), whose
pick_belowmoves into the shared header.It also carries #1133's commit (
tools/singleton_scan/allowlist.txtonly, the same change byte for byte), sopackage-linux / libcvc-release-grpc's writable-data scan passes here while master's allowlist is missing #1122's objects. Once #1133 merges, that commit adds nothing. This PR adds no process-wide state of its own:pick_belowandseeded_shuffleare stateless inline functions.What changes
inc/cvc/nav/detail/seeded_draw.h:pick_below(nav: scatter_free picks the same cells on every standard library #1114's Lemire multiply-and-reject, moved out ofsim_world.cppand shared) andseeded_shuffle.training_scene::sample_starts_goals: its three picks (goals anywhere, starts with a clearance, local goals) arepick_below. libstdc++ and MSVC already map a 32-bit draw this way, so Linux and Windows draw exactly the routes they always drew. macOS and wasm (libc++ masks the low bits and rejects) now draw the same routes.sim_world::from_occupancy, clustered: the k-means centres come fromseeded_shuffleinstead ofstd::shuffle.The shuffle: the three libraries all disagree
std::shuffleon a 32-bitmt19937_Rng_from_urng, not the Lemire thatuniform_int_distributionuses)seeded_shuffleis libstdc++'s written out, so Linux keeps its clustered groups. Windows, macOS and wasm change. On the pinned test field (twelve agents, three groups), MSVC's shuffle grouped 34 of 40 seeds differently. I kept libstdc++'s because it uses the same Lemire mapping aspick_below, and because the one platform whose groups change is Windows, where every test using clustered mode can be run locally. All of them pass, and their output is unchanged.Checked against the libraries themselves
I built one program with MSVC 19.44, g++ 13.2 (libstdc++) and em++ 21 (libc++, run under node):
pick_belowvsuniform_int_distribution<int>: 0 of 230000 picks differ on libstdc++ and MSVC, with the draw streams in step (n from 1 to INT_MAX); 206608 differ on libc++.seeded_shufflevs libstdc++'sstd::shuffle: 0 of 3800 orders differ (n up to 70001, across the paired/unpaired switch).Tests
NavCoefTrain.StartsAndGoalsAreTheSameOnEveryStandardLibrarypins seed 7's cells for all three ways of drawing, on a 40 x 30 field with a wall. libc++'s own draw began {19, 4, 31, 13}. Each cell's clearance and distance is the square root of a whole number. The 2.5 clearance and the 3.5..6.5 range sit at least 0.019 from every such value, so rounding can't move a cell in or out of range.NavSimWorld.ClusteredGroupsAreTheSameOnEveryStandardLibrarypins seed 20's groups. At every k-means step, each agent's squared distance to its own centre is at least 15% below its next nearest, so float rounding can't regroup an agent.NavSimWorld.SeededShuffleIsTheSameOnEveryStandardLibrarypins an odd length, an even length, and one past the paired draws.Gates that were loosened because macOS drew other routes
DynBike.KinematicLimitFollowsBikeStep: the open-loop gap is gated at 0.1 rr again. nav: train through the dynamic vehicle, with checkpoint selection on Jolt reach (P8b) #717 raised it to 0.2 rr only because each library drew other routes. It measures 0.0107 on these routes. It measures the same with the test built/fp:contract /arch:AVX2, which turns about 1260 of its operations into fused multiply-adds, as clang does on arm64.DiffExtForce/DiffExtRolloutand the four-wheel ext checks keep their switch filter and quotas. The shared draws still put one to five cases on a switch, and the quotas were validated over 100 swept seeds, not per library. Only the comments change, plusdocs/NAV_TRAINING.md, which no longer say the draws differ by library.Test results
Windows (MSVC, RelWithDebInfo): nav_sim_world 7/7, nav_sim_world_agents 17/17, nav_coef_train 31/31, nav_dyn_bike 23/23, nav_dyn_4w 23/23, nav_potential 17/17, nav 64/64. Every test that existed before this change prints exactly the same output as on the base commit, number for number. The macOS and wasm results will come from this PR's CI.
Not in this PR
src/cvc/physics/plant_log_scene.cpp(cvc::physics) has threestd::uniform_int_distribution<std::size_t>picks with the same libc++ divergence.