Shaders: BDD meet rejects a node held both ways and takes one condition as met #2478
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2480"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by liandraraiane on 2026-11-25T14:30:55Z.
Bools::meet(crates/victory-shader/src/structure.rs) searches by splitting on variables until every condition is decided. Two cases now end that search early, at every level of it:MAX_MEETit gave up and answered yes. The check also catches functions that only become the same node after a split.The
refutedset now uses the module's Fx hasher like the other tables. It was the only one still on SipHash.The case
maingets wrongmeet_rejects_opposite_facts_about_the_same_functionnow uses 15 pairs instead of 8. That runsmainpastMAX_MEET, so it fails onmain(answerstrue) and passes here. Its second half covers two different nodes that become the same one only after a split.Measurement
cargo test --release -p victory-shader bench_meet -- --ignored --nocapture --test-threads=1, synthetic diagrams, median of 3 runs. For "main",main'smeet/meet_inwas copied into this branch, so both columns run the same benchmark:All runs gave the same answers on both sides.
bench_bools(same command,bench_bools; median of 3 runs, current implementation's column) measuresvarsandgiven, which this PR does not touch, so it is unchanged within noise:varsmainvarsthis PRgivenmaingiventhis PRDo these cases reach
meetin translation? I counted the search steps (calls ofmeet_in) over the crate's own lib tests, which lower synthetic shaders. The counters were temporary and are not in the diff. Themeet_*tests themselves were skipped.meetcallsOf those, 50 steps ended on a node held both ways, and 93 calls had a single condition.
Correctness
meetagainst brute force over every assignment: all equal.cargo test -p victory-shader: 174 passed, 3 ignored (lib), plusresource_tracking3 passed, 1 ignored.cargo xtask policy: 190 files ok.Not tested
emit/lower.rswere gated locally as in #2766; that change is not part of this PR.clippy -D warningsshows nothing instructure.rs; its other findings off Windows are already onmain(emit/mod.rs,emit/lower.rs).AI use
Claude Code (Claude Opus 5.5) wrote the change, the tests and the measurements, and drafted this description. A person reviewed it and opened the PR.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:34:22Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:structure.rsis clean and passes all structure tests.cargo test -p victory-shader structure::tests: 12/12 passed on RTX 5090, 12/12 passed on WARP (includingmeet_rejects_opposite_facts_about_the_same_function).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:57:33Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 145 passed, 0 failed, 3 ignored (Windows-gated hardware execution tests not run here). Approving — contradictory BDD facts short-circuited.Imported from Marvisak/VIctory. Originally posted by liandraraiane on 2026-11-25T14:39:15Z.
Summary
Bools::meet_inwhen it finds contradictory facts about the same canonical BDD.Validation
cargo test -p victory-shader— 145 passed, 3 ignored.cargo clippy -p victory-shader --all-targets— passed.git diff --check— passed.cargo fmt --all -- --checkreports formatting differences in existing workspace files.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:55:04Z.
Automated triage for the maintainers.
Merge candidate. Re-reviewed at
7dec75e.Bools::meet_in(crates/victory-shader/src/structure.rs) now returnsfalsewhen one node is held both ways andtruewhen only one condition is left. Both rules are exact for this diagram.mknever builds a node withlo == hiand hash-conses throughunique, so equal functions are equal ids and every non-constant node is satisfiable both ways. Underoverflowthe callers already fail.refutedmoves to the module's FxSet.On your reply: both requests are answered. With 15 pairs,
meet_rejects_opposite_facts_about_the_same_functionrunsmainpastMAX_MEET, somainanswerstruethere and this branch answersfalse. The second case covers nodes that only become equal after a split.bench_meetnumbers are in the description, and the search steps over the crate's lowering tests drop by 28 %. The gain on real title shaders is still unmeasured, but the change is small and sound, and it makesmeetmore precise. CI:checkpassing.Generated by Claude Code
[PR #2480] Shaders: short-circuit contradictory BDD factsto [PR #2480] Shaders: BDD meet rejects a node held both ways and takes one condition as metImported from Marvisak/VIctory. Originally posted by liandraraiane on 2026-11-25T22:25:39Z.
Thanks for the review. Updated to
7dec75e. Point by point:mainfails.meet_rejects_opposite_facts_about_the_same_functionnow uses 15 pairs, which runsmainpastMAX_MEET, somainanswerstrueand the test fails there; it passes here. A second case covers two different nodes that become the same one only after a split (onmainthat answerstrueas well).bench_meetandbench_boolsbefore/after are in the description (median of 3). Contradictions drop from 115 / 459 / 1,947 µs to 0.04 µs (n = 8 / 10 / 12).bench_boolsis unchanged within noise, as expected: it measuresvarsandgiven, which this PR does not touch.meetin translation? I have no title shaders, so I could not measure a real translation. Over the crate's own lib tests, which lower synthetic shaders, 50 ofmain's 1,734 search steps ended on a node held both ways. The PR also adds a second early exit (one non-constant condition left is always met) and movesrefutedto the Fx hasher. Together they bring those 426meetcalls from 1,734 to 1,250 search steps (−28 %), with the same answers. A differential test against brute force (24,000 random queries, not in the diff) agreed on every one.If a count on real shaders is needed before this can go in, I would welcome a run from someone who has the title files.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:46:34Z.
Code review and RTX 5090 + WARP + DXIL verification at head
7dec75e31fd6merged cleanly ontomain(63bcca43c6a0):crates/victory-shader/src/structure.rs:295-342):fails) and tautologies and sorting/deduping,all.windows(2).any(|pair| pair[0].0 == pair[1].0)catches opposite polarity(b, false)/(b, true)inO(n log n)before expanding intoMAX_MEETbudget exhaustion.if all.len() <= 1 { return true; }holds strictly under the ROBDD reduction invariant (Bools::mkeliminateslo == hiandoverflowreturns constantBool::FALSE, already filtered out), so any single non-constant node is satisfiable for both polarities.Vec<(Bool, bool)>keys only when!metguarantees budget-exhaustion optimistictruereturns never poisonrefuted.dxil.dll10.0.26100.0, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningsstructure::: 15/15 passed (2 ignored benchmarks), includingmeet_rejects_opposite_facts_about_the_same_functionandmeet_takes_one_condition_as_metflow_tests(1/1) and--test resource_tracking(3/3, 1 ignored): passed on both RTX 5090 and WARP.Sound and clean; LGTM.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:49:23Z.
Review: APPROVED
Reviewed at
7dec75e31fd64105efb145bcb7306c72b1f6a648— APPROVE.Verification
cargo xtask policy(191 files ok),cargo clippy -p victory-shader --all-targets --all-features -- -D warnings, andrustfmt --edition 2024 --check(zero new formatting diffs) all passed.Bools::meet_in(crates/victory-shader/src/structure.rs:311-318): after filtering constants and sorting/deduping, opposite constraints(b, false)and(b, true)on the same reduced OBDD node are adjacent and immediately refuted before hittingMAX_MEET; conversely, zero or one non-constant reduced OBDD node is always satisfiable without consuming budget or hittingrefuted. Differential checking against a truth-table oracle across 200,746 inputs matched with zero mismatches.structure::(15/15, 2 benchmarks ignored, includingmeet_rejects_opposite_facts_about_the_same_functionandmeet_takes_one_condition_as_met) andemit::lower::tests(33/33).Non-blocking note
meet_takes_one_condition_as_met(structure.rs:1926) passes even under the old search (which finds a witness withinMAX_MEET); asserting directly viameet_inthatbudgetstays untouched would pin theall.len() <= 1fast path itself.Pull request closed