[ci] add scripts/check-ir-determinism.sh for latent non-determinism detection#669
Merged
[ci] add scripts/check-ir-determinism.sh for latent non-determinism detection#669
Conversation
Compiles a .ts file to LLVM IR twice in independent processes, diffs byte-for-byte. Any divergence = latent non-determinism in codegen (Map iteration order, Set order, unseeded PRNG, etc.) — each of which can produce arch-divergent IR under -O2 optimization. Investigative, not a CI gate. Once known sources are fixed, this becomes the gate. Result on arm64 macOS for src/chad-native.ts: bit-identical at 44MB (deterministic). x86-64 Linux result pending. Part of the #658 architectural-hygiene plan: ship visibility tools before attempting further gate-loosening.
Contributor
Benchmark Results (Linux x86-64)
CLI Tool Benchmarks
|
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.
Before
No way to catch codegen non-determinism (Map iteration order, Set order, unstable sort, etc.). Non-determinism can produce arch-divergent IR under `-O2` optimization — suspected contributor to cases like the #662 x86-64-only break.
After
`bash scripts/check-ir-determinism.sh [target]` compiles a .ts file to LLVM IR twice in independent processes and diffs byte-for-byte.
First data point: `src/chad-native.ts` is bit-identical across runs on arm64 macOS (44,617,573 bytes). x86-64 verification pending.
Description
Investigative tool, not a CI gate yet (per the first-ship-observability plan).
If the tool finds non-determinism in the future, root causes get their own PRs (iteration order, seeded randomness, stable sort). Only once known sources are clean does this become a CI gate.
Part of the #658 architectural-hygiene track: before attempting more typeOf-cache gate-loosening, ship visibility tools that tell us which changes are safe.
Known CLI nit (unrelated)
`node dist/chad-node.js ir -o ` ignores `-o` and writes to `.build/src/.ll` regardless. Worked around; file separately if desired.
Refs #658.