Shaders: BDD meet rejects a node held both ways and takes one condition as met #2480
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2480
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@liandraraiane on GitHub · 2026-11-25 14:30 UTC · original
liandraraiane:perf/bdd-meet-benchmark→main· +100 −3 · 1 files · 1 commits · openBools::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
@liandraraiane on GitHub · 2026-11-25 14:39 UTC · original
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.@Marvisak on GitHub · 2026-11-25 15:55 UTC · original · edited 2026-11-26 00:23 UTC
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
@liandraraiane on GitHub · 2026-11-25 22:25 UTC · original
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).
@fuzeofficlal on GitHub · 2026-11-26 00:46 UTC · original
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.