From 702916d9d3bc359b1d2de0092da52fd3812f48ff Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 03:26:58 -0800 Subject: [PATCH] Validation: helper-thread words and ordered fetch are answer gaps a row's words decide FragmentSimdgroupGrouping, QuadsSplitByClipping and UnorderedFetchWithinDraw only record a device behaviour now: none of them excuses a word. The cases whose differing words they reach turned from noted differences into mismatches, and nothing held them open, so a round's public leg would read them as new mismatches. Two answer gaps now hold them open. Both are decided by structure (the note and the words its operations reach), never by case id: - HelperThreadWords (helper_thread_words): every unexcused word is reached by FragmentSimdgroupGrouping, or every one by QuadsSplitByClipping. - OrderedFetchWithinDraw (ordered_fetch_within_draw): every unexcused word is reached by UnorderedFetchWithinDraw. How: - For each only-recorded note, the word judge counts the unexcused words that note reaches (Judgement::recorded). - AnswerGap::held_by_words picks the gap one of whose notes reaches every unexcused word of a mismatch, where both outputs have one length. The engine's difference_status calls it for a mismatching verdict, and the batch-run line names the gap (held_open_by=). - Every device has both gaps, since why the device's words differ is not read yet. The reviewed list refuses an entry under either gap. - A row's content check accepts such a gap only on differing bytes from a run that recorded one of its notes, and status_holds re-derives the gap from the row's words. - C3 names a word gap as a mismatch's reason after a deferral and after a listed gap. - docs/VALIDATION.md states both gaps. ENGINE_EXECUTOR_ABI stays vulkan-engine-v215, above development's v214. The three figures, public cases (1,168): noted cases / cases that match only within bounds / mismatches, then how many mismatches an answer gap holds and how many are new. - lavapipe (Mesa 26.2.4 image): - before, development 965e707277, job m3-max-83220: 188 / 0 / 5; 5 held, 0 new. - after, job m3-max-83166: 151 / 27 / 15; 15 held (5 clipped_primitive_split, 10 helper_thread_words), 0 new. - Radeon 780M (RADV PHOENIX, Mesa 26.2.6, the device pinned alone): - before, development 22861fde72, jobs m3-max-82940 and m3-max-82966: 206 / 0 / 5; 5 held, 0 new. - after, job m3-max-83177: 166 / 24 / 21; 21 held (5 clipped_primitive_split, 8 helper_thread_words, 8 ordered_fetch_within_draw), 0 new. The after runs ran this commit's library code. Only a C3 test changed after them. Verified (tests at this tree): - gate A, m3-max-83232: fmt check, clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, and rustdoc each exit 0. - gate B, m3-max-83236: the validation suite exits 0, 1337 passed, 3 skipped. Each red check exits 100 with its fix reverted: the engine's word-gap hold, the judge's recorded-note count, the denormal boundary, the note reach, the recorded rule-5 notes and the recorded review notes. --- crates/metal2vulkan-validation/src/c3.rs | 99 +++++++++++++++++-- .../metal2vulkan-validation/src/c3/tests.rs | 20 +++- .../src/candidate/engine.rs | 22 +++-- .../src/candidate/engine/tests.rs | 88 ++++++++++++++++- .../src/observation.rs | 53 +++++++--- .../src/observation_contract/words.rs | 21 +++- .../src/observation_contract/words/tests.rs | 58 +++++++++++ docs/VALIDATION.md | 6 +- 8 files changed, 331 insertions(+), 36 deletions(-) diff --git a/crates/metal2vulkan-validation/src/c3.rs b/crates/metal2vulkan-validation/src/c3.rs index 2828d7772..b25c95174 100644 --- a/crates/metal2vulkan-validation/src/c3.rs +++ b/crates/metal2vulkan-validation/src/c3.rs @@ -99,6 +99,7 @@ use crate::cutover::{List, Review, SignOff}; use crate::index::EvidenceState; use crate::metal::ORACLE_ABI; use crate::observation::{validate_hash, CandidateObservation, CandidateStatus, MetalObservation}; +use crate::observation_contract::words::Judgement; use crate::observation_contract::ComparisonClass; use crate::refusal::{Refusal, RefusalClass, RefusalObservation}; use crate::source::public_sources; @@ -285,14 +286,31 @@ pub enum AnswerGap { /// which extends past the viewport, whose function runs a quad or simdgroup operation over /// its active lanes (`GroupOp::reads_active_lanes`). QuadsSplitByClipping, + /// Helper-thread words differ from Metal: a fragment function whose answer reads which + /// threads share its simdgroup or quad records `PrecisionNote::FragmentSimdgroupGrouping`, and + /// one whose quad or simdgroup operation reads its active lanes under a primitive the device + /// may clip records `PrecisionNote::QuadsSplitByClipping`, on every device; the words it writes + /// differ from Metal's where one of those notes reaches each differing word. Neither note + /// excuses a word. Why the device's words differ is not yet read, so every device has the gap. + /// A row's own words decide it ([`Self::held_by_words`]): the list holds no case under it. + HelperThreadWords, + /// Ordered fetch and blend inside one draw: a fragment function that reads a color attachment + /// records `PrecisionNote::UnorderedFetchWithinDraw`, on every device, and the words it writes + /// differ from Metal's where that note reaches each differing word (the note reaches every + /// word). The note excuses none of them. Why the device's words differ is not yet read, so + /// every device has the gap. A row's own words decide it ([`Self::held_by_words`]): the list + /// holds no case under it. + OrderedFetchWithinDraw, } impl AnswerGap { /// Every gap. - pub const ALL: [AnswerGap; 3] = [ + pub const ALL: [AnswerGap; 5] = [ AnswerGap::FragmentSubgroupUnderTwoQuads, AnswerGap::ClippedPrimitiveSplit, AnswerGap::QuadsSplitByClipping, + AnswerGap::HelperThreadWords, + AnswerGap::OrderedFetchWithinDraw, ]; pub fn as_str(self) -> &'static str { @@ -300,14 +318,53 @@ impl AnswerGap { Self::FragmentSubgroupUnderTwoQuads => "fragment_subgroup_under_two_quads", Self::ClippedPrimitiveSplit => "clipped_primitive_split", Self::QuadsSplitByClipping => "quads_split_by_clipping", + Self::HelperThreadWords => "helper_thread_words", + Self::OrderedFetchWithinDraw => "ordered_fetch_within_draw", } } + /// The notes whose words hold a mismatch under the gap, for a gap a row's words decide + /// ([`Self::held_by_words`]); none for a gap the list holds a case under. + pub fn notes(self) -> &'static [PrecisionNote] { + match self { + Self::FragmentSubgroupUnderTwoQuads + | Self::ClippedPrimitiveSplit + | Self::QuadsSplitByClipping => &[], + Self::HelperThreadWords => &[ + PrecisionNote::FragmentSimdgroupGrouping, + PrecisionNote::QuadsSplitByClipping, + ], + Self::OrderedFetchWithinDraw => &[PrecisionNote::UnorderedFetchWithinDraw], + } + } + + /// Whether a row's words decide the gap ([`Self::held_by_words`]), so the list holds no case + /// under it. + pub fn decided_by_words(self) -> bool { + !self.notes().is_empty() + } + + /// The gap a note of which reaches every unexcused word of `judgement`, a mismatch of outputs + /// of one length: the first of [`Self::ALL`] with a note ([`Self::notes`]) that the run + /// recorded and that reaches each word no note excuses (`Judgement::recorded`). `None` for any + /// other judgement, a match or a noted difference included. + pub fn held_by_words(judgement: &Judgement) -> Option { + if judgement.lengths_differ || judgement.unexcused == 0 { + return None; + } + Self::ALL.into_iter().find(|gap| { + gap.notes() + .iter() + .any(|note| judgement.recorded.get(note) == Some(&judgement.unexcused)) + }) + } + /// Whether a device of `description`, from which the product derives `profile`, has the /// gap. The subgroup gap: the fragment stage runs subgroups, and the smallest it may run one /// with (the product's subgroup model: the pinnable range, else the API size) holds fewer /// than two quads. The clipped-primitive split: the device does not draw through Metal (its - /// driver is not MoltenVK). The split quads: the driver is lavapipe's. + /// driver is not MoltenVK). The split quads: the driver is lavapipe's. A gap a row's words + /// decide: every device. pub fn has(self, description: &DeviceDescription, profile: &DeviceProfile) -> bool { match self { Self::FragmentSubgroupUnderTwoQuads => { @@ -316,6 +373,7 @@ impl AnswerGap { } Self::ClippedPrimitiveSplit => description.driver_id != Some(DriverId::MOLTENVK), Self::QuadsSplitByClipping => description.driver_id == Some(DriverId::MESA_LLVMPIPE), + Self::HelperThreadWords | Self::OrderedFetchWithinDraw => true, } } @@ -331,12 +389,16 @@ impl AnswerGap { } /// Whether the case's structure decides whether its answer can meet the gap - /// ([`Self::met_by`]): the clipped-primitive split's and the split quads'. The subgroup gap is - /// held by the list's entry alone. + /// ([`Self::met_by`]): the clipped-primitive split's and the split quads'; and a gap a row's + /// words decide, which no case's structure meets. The subgroup gap is held by the list's + /// entry alone. pub fn decided_by_case(self) -> bool { match self { Self::FragmentSubgroupUnderTwoQuads => false, - Self::ClippedPrimitiveSplit | Self::QuadsSplitByClipping => true, + Self::ClippedPrimitiveSplit + | Self::QuadsSplitByClipping + | Self::HelperThreadWords + | Self::OrderedFetchWithinDraw => true, } } @@ -345,10 +407,12 @@ impl AnswerGap { /// passthrough vertex function's full-screen triangle, whose fragment function has a live /// `[[sample_mask]]` argument; for the split quads, a fragment case drawn by that triangle /// whose entry calls a quad or simdgroup operation over its active lanes. A gap - /// [`Self::decided_by_case`] does not decide is met by any case. + /// [`Self::decided_by_case`] does not decide is met by any case; a gap a row's words decide + /// ([`Self::held_by_words`]) by none. pub fn met_by>(self, checked: &CheckedCase) -> bool { match self { Self::FragmentSubgroupUnderTwoQuads => true, + Self::HelperThreadWords | Self::OrderedFetchWithinDraw => false, Self::QuadsSplitByClipping => { let shader = &checked.primary; shader.case.stage == Stage::Fragment @@ -535,6 +599,12 @@ impl List for ReviewedList { } entry_name(&gap.name).map_err(at)?; gap.review.check().map_err(at)?; + if gap.gap.decided_by_words() { + return Err(at(format!( + "is listed under {}, which a row's words decide, never a list entry", + gap.gap.as_str() + ))); + } if gap.review.sign_off.is_signed_off() { return Err(at(format!( "is signed off, but an answer gap ({}) stays open until an exact emulation \ @@ -762,7 +832,8 @@ pub enum OpenReason { /// rasterization-rate map of the case, so no Vulkan executor carries it. RateMapRefused(String), /// The reviewed list holds the case under an answer gap the venue's device has and the case's - /// structure meets ([`AnswerGapEntry`]), open until an exact emulation exists (the user's + /// structure meets ([`AnswerGapEntry`]), or the row's words hold it under a gap the venue's + /// device has ([`AnswerGap::held_by_words`]), open until an exact emulation exists (the user's /// decision of 2026-10-06). AnswerGap(AnswerGap), } @@ -1440,12 +1511,20 @@ pub fn report( if judged == Verdict::Match { report.matched.insert(case.case_id.clone()); } else { + let row = rows.get(&(case.case_id.as_str(), slot.as_str())); let reason = match judged { - Verdict::Mismatch => rows - .get(&(case.case_id.as_str(), slot.as_str())) + Verdict::Mismatch => row .and_then(|row| deferred_note(row)) .map(OpenReason::NearEquivalent) - .or_else(|| answer_gap(case, slot.as_str()).map(OpenReason::AnswerGap)), + .or_else(|| answer_gap(case, slot.as_str()).map(OpenReason::AnswerGap)) + .or_else(|| { + // A gap the row's words decide, which the row names. + row.and_then(|row| row.held_open_by) + .filter(|gap| { + gap.decided_by_words() && keys.has_gap(slot.as_str(), *gap) + }) + .map(OpenReason::AnswerGap) + }), Verdict::Missing | Verdict::Refused => rate_map_refusal(case), _ => None, }; diff --git a/crates/metal2vulkan-validation/src/c3/tests.rs b/crates/metal2vulkan-validation/src/c3/tests.rs index 7271cbe86..b8c0ab0f9 100644 --- a/crates/metal2vulkan-validation/src/c3/tests.rs +++ b/crates/metal2vulkan-validation/src/c3/tests.rs @@ -1232,6 +1232,8 @@ fn deferred_and_never_reviewed(note: PrecisionNote, label: &str) { if row.comparison != ComparisonClass::Exact { row.status = noted_if_different(row.status); } + // A mismatch names the answer gap its words decide, as the engine records it. + row.held_open_by = AnswerGap::held_by_words(&row.judgement(&sampled, &METAL, output)); assert!(row.class_holds()); row }; @@ -2378,8 +2380,8 @@ fn each_venue_keys_its_slots_with_its_profiles_key() { /// Each answer gap is decided from each venue's committed profile. Of the committed venues, arm64 /// lavapipe alone runs fragment subgroups of fewer than two quads (its 4-lane subgroups); x86 -/// lavapipe's 8 and the GPUs' hold two or more. Every venue has the clipped-primitive split. The -/// venue keys record each for the venue's slot. +/// lavapipe's 8 and the GPUs' hold two or more. Every venue has the clipped-primitive split, and +/// the two gaps a row's words decide. The venue keys record each for the venue's slot. #[test] fn each_answer_gap_is_decided_from_each_venues_profile() { let committed = Venues::load(&Venues::committed_path()).unwrap(); @@ -2399,6 +2401,8 @@ fn each_answer_gap_is_decided_from_each_venues_profile() { AnswerGap::QuadsSplitByClipping, BTreeSet::from(["gate-lavapipe", "gate-lavapipe-x86_64"]), ), + (AnswerGap::HelperThreadWords, all.clone()), + (AnswerGap::OrderedFetchWithinDraw, all.clone()), ] { let mut with = BTreeSet::new(); for venue in &committed.venues { @@ -2461,6 +2465,18 @@ fn a_subgroup_gap_names_a_mismatch_only_where_the_device_has_it() { ..ReviewedList::default() }; assert_eq!(list.check(), Ok(())); + // A gap a row's words decide is never listed. + for gap in [ + AnswerGap::HelperThreadWords, + AnswerGap::OrderedFetchWithinDraw, + ] { + let mut listed = list.clone(); + listed.answer_gaps[0].gap = gap; + assert!(listed + .check() + .unwrap_err() + .contains("which a row's words decide")); + } let mut keys = VenueKeys::default(); let judged = |input: &C3Input, keys: &VenueKeys, list: &ReviewedList| { report_of(input, list, &C1List::default(), &venues(), keys) diff --git a/crates/metal2vulkan-validation/src/candidate/engine.rs b/crates/metal2vulkan-validation/src/candidate/engine.rs index ca89ec0ac..51d32bb85 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine.rs @@ -54,7 +54,7 @@ use crate::observation::{ CandidateDependencies, CandidateObservation, CandidateStatus, CaseTiming, MetalObservation, RUNTIME_CRATE_FINGERPRINT, TRANSLATOR_FINGERPRINT, }; -use crate::observation_contract::words::Verdict; +use crate::observation_contract::words::{Judgement, Verdict}; use crate::observation_contract::ComparisonClass; use crate::refusal::{Refusal, RefusalObservation}; use crate::requirement::{Executor, ToolingRequirement}; @@ -1616,7 +1616,7 @@ pub fn execute_prepared( &run.output, run.census.out_of_bounds.as_ref(), ); - let (status, held_open_by) = difference_status(&checked, judgement.verdict(), || { + let (status, held_open_by) = difference_status(&checked, &judgement, || { ReviewedList::load(&ReviewedList::committed_path()) })?; let observation = CandidateObservation { @@ -1655,20 +1655,26 @@ pub fn execute_prepared( Ok(observation) } -/// The status of a run of `checked` whose words were judged `verdict`, and the answer gap that -/// holds it open: a match, a mismatch, or a noted difference unless the C3 reviewed list (`list`, -/// read only then) holds the case under an answer gap its structure meets +/// The status of a run of `checked` whose words were judged `judgement`, and the answer gap that +/// holds it open: a match; a mismatch, held open by the gap whose note reaches every word no note +/// excuses ([`AnswerGap::held_by_words`]), if one does; or a noted difference unless the C3 +/// reviewed list (`list`, read only then) holds the case under an answer gap its structure meets /// ([`AnswerGap::met_by`]), which keeps it a mismatch (the user's decision of 2026-10-06). Which /// venues' devices have the gap is C3's to judge; here the case's difference is a mismatch on every /// device, which hides none. pub fn difference_status( checked: &CheckedCase, - verdict: Verdict, + judgement: &Judgement, list: impl FnOnce() -> Result, ) -> Result<(CandidateStatus, Option), String> { - match verdict { + match judgement.verdict() { Verdict::Match => return Ok((CandidateStatus::Match, None)), - Verdict::Mismatch => return Ok((CandidateStatus::Mismatch, None)), + Verdict::Mismatch => { + return Ok(( + CandidateStatus::Mismatch, + AnswerGap::held_by_words(judgement), + )) + } Verdict::Noted => {} } let case_id = &checked.primary.case.case_id; diff --git a/crates/metal2vulkan-validation/src/candidate/engine/tests.rs b/crates/metal2vulkan-validation/src/candidate/engine/tests.rs index 77d7a95bb..db44586e1 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/tests.rs @@ -7,6 +7,7 @@ use crate::check::admission::NotSupported; use crate::requirement::ToolingRequirement; use metal2vulkan::device::{Device, DeviceDescription, DevicePolicy}; use metal2vulkan::metal::DataType; +use metal2vulkan::pipeline::PrecisionNote; mod argument_buffer_members; @@ -30,7 +31,7 @@ fn a_difference_under_notes_is_noted_unless_an_answer_gap_holds_its_case_open() let status = |case: &AuthoredCase, verdict: Verdict| { let checked = crate::check::check_case(&root, case.clone()) .unwrap_or_else(|errors| panic!("{}: {errors:?}", case.name)); - difference_status(&checked, verdict, || Ok(list.clone())).unwrap() + difference_status(&checked, &judged(verdict, &[]), || Ok(list.clone())).unwrap() }; let unexplained = (CandidateStatus::Mismatch, None); let mut public = 0; @@ -62,6 +63,91 @@ fn a_difference_under_notes_is_noted_unless_an_answer_gap_holds_its_case_open() assert_eq!(status(&unheld, Verdict::Mismatch), unexplained); } +/// A judgement of one word with `verdict`, its unexcused word (for a mismatch) reached by the +/// only-recorded notes `recorded`. +fn judged(verdict: Verdict, recorded: &[PrecisionNote]) -> Judgement { + let mut judgement = Judgement { + words: 1, + ..Judgement::default() + }; + match verdict { + Verdict::Match => judgement.exact = 1, + Verdict::Noted => { + judgement.noted.insert(PrecisionNote::DeviceArithmetic, 1); + } + Verdict::Mismatch => { + judgement.unexcused = 1; + judgement.recorded = recorded.iter().map(|note| (*note, 1)).collect(); + } + } + judgement +} + +/// A mismatch is held open by the answer gap a note of which reaches every word no note excuses, +/// for any case and without the list: the helper-thread words by `FragmentSimdgroupGrouping` or +/// `QuadsSplitByClipping`, the ordered fetch by `UnorderedFetchWithinDraw`. A word no such note +/// reaches leaves the mismatch unheld, as do outputs of different lengths; a noted difference or a +/// match is never held by words. +#[test] +fn a_mismatch_is_held_open_by_the_gap_whose_note_reaches_every_unexcused_word() { + let root = crate::source::corpus_root(); + let store = CorpusStore::new(&root); + let case = store + .read_all_cases() + .unwrap() + .into_iter() + .find(|case| case.public_source.is_some()) + .unwrap(); + let checked = crate::check::check_case(&root, case.clone()) + .unwrap_or_else(|errors| panic!("{}: {errors:?}", case.name)); + let empty = ReviewedList::default(); + let status = |judgement: &Judgement| { + difference_status(&checked, judgement, || Ok(empty.clone())).unwrap() + }; + let held = |gap| (CandidateStatus::Mismatch, Some(gap)); + let grouping = PrecisionNote::FragmentSimdgroupGrouping; + let fetch = PrecisionNote::UnorderedFetchWithinDraw; + assert_eq!( + status(&judged(Verdict::Mismatch, &[grouping])), + held(AnswerGap::HelperThreadWords) + ); + assert_eq!( + status(&judged( + Verdict::Mismatch, + &[PrecisionNote::QuadsSplitByClipping] + )), + held(AnswerGap::HelperThreadWords) + ); + assert_eq!( + status(&judged(Verdict::Mismatch, &[fetch])), + held(AnswerGap::OrderedFetchWithinDraw) + ); + // Another only-recorded note holds nothing. + assert_eq!( + status(&judged( + Verdict::Mismatch, + &[PrecisionNote::DevicePointSize] + )), + (CandidateStatus::Mismatch, None) + ); + // One of two unexcused words the note does not reach. + let mut partly = judged(Verdict::Mismatch, &[grouping]); + partly.words = 2; + partly.unexcused = 2; + assert_eq!(status(&partly), (CandidateStatus::Mismatch, None)); + let mut lengths = judged(Verdict::Mismatch, &[grouping]); + lengths.lengths_differ = true; + assert_eq!(status(&lengths), (CandidateStatus::Mismatch, None)); + assert_eq!( + status(&judged(Verdict::Noted, &[])), + (CandidateStatus::NotedDifference, None) + ); + assert_eq!( + status(&judged(Verdict::Match, &[])), + (CandidateStatus::Match, None) + ); +} + /// [`compute_case`] of a case whose entry declares no stage input: every case here but the /// stage-input ones, which map against their own interface. fn map_kernel(case: &AuthoredCase) -> Result { diff --git a/crates/metal2vulkan-validation/src/observation.rs b/crates/metal2vulkan-validation/src/observation.rs index e8a2eb546..7441a1b77 100644 --- a/crates/metal2vulkan-validation/src/observation.rs +++ b/crates/metal2vulkan-validation/src/observation.rs @@ -213,9 +213,11 @@ pub struct CandidateObservation { #[serde(default, skip_serializing_if = "Option::is_none")] pub timing: Option, pub status: CandidateStatus, - /// The C3 answer gap that keeps a difference its notes could explain a mismatch: the C3 - /// reviewed list holds the case under it and the case's structure meets it - /// (`candidate::engine::difference_status`). `None` for every other row. + /// The C3 answer gap that holds a difference open as a mismatch: one its notes could explain, + /// where the C3 reviewed list holds the case under the gap and the case's structure meets it; + /// or one no note excuses, where the gap's note reaches every differing word no note excuses + /// (`c3::AnswerGap::held_by_words`). Decided by `candidate::engine::difference_status`. + /// `None` for every other row. #[serde(default, skip_serializing_if = "Option::is_none")] pub held_open_by: Option, } @@ -407,8 +409,9 @@ impl CandidateObservation { let tolerated = self.census.as_ref().is_some_and(ExecutedCensus::bounds_any) || run.is_some_and(OutOfBoundsRun::tolerates_differences); // A noted difference is one that may be noted, and only such a difference is held open by - // an answer gap. A mismatch under notes without a gap is a row of an executor before the - // noted status, stale by its executor ABI. + // a gap the list holds; a gap a row's words decide holds differing bytes of a run that + // recorded its note. A mismatch under notes without a gap is a row of an executor before + // the noted status, stale by its executor ABI. let explains = self .census .as_ref() @@ -418,7 +421,16 @@ impl CandidateObservation { CandidateStatus::Match => (!hashes_match && !tolerated) || self.held_open_by.is_some(), CandidateStatus::Mismatch => { (hashes_match && !run.is_some_and(OutOfBoundsRun::escapes)) - || (self.held_open_by.is_some() && !noted) + || self.held_open_by.is_some_and(|gap| { + if gap.decided_by_words() { + hashes_match + || !self.census.as_ref().is_some_and(|census| { + census.all_notes().any(|note| gap.notes().contains(¬e)) + }) + } else { + !noted + } + }) } CandidateStatus::NotedDifference => !noted || self.held_open_by.is_some(), }; @@ -498,17 +510,22 @@ impl CandidateObservation { /// Whether the recorded status is the verdict on `golden`, the Metal output, for an /// observation of `case`: each word judged by the recorded notes that reach it /// ([`ExecutedCensus::judge`]), for a case with out-of-bounds targets after their containment - /// property over the recorded census; a noted verdict an answer gap holds open is a mismatch. + /// property over the recorded census; a noted verdict an answer gap holds open is a mismatch, + /// and a mismatch names the gap its words decide, if any (`c3::AnswerGap::held_by_words`). pub fn status_holds(&self, case: &AuthoredCase, golden: &[u8]) -> bool { let Ok(output) = base64::engine::general_purpose::STANDARD.decode(&self.output_b64) else { return false; }; - let verdict = self.judgement(case, golden, &output).verdict(); - match (self.status, verdict) { + let judgement = self.judgement(case, golden, &output); + match (self.status, judgement.verdict()) { (CandidateStatus::Match, Verdict::Match) => true, (CandidateStatus::NotedDifference, Verdict::Noted) => self.held_open_by.is_none(), - (CandidateStatus::Mismatch, Verdict::Noted) => self.held_open_by.is_some(), - (CandidateStatus::Mismatch, Verdict::Mismatch) => true, + (CandidateStatus::Mismatch, Verdict::Noted) => { + self.held_open_by.is_some_and(|gap| !gap.decided_by_words()) + } + (CandidateStatus::Mismatch, Verdict::Mismatch) => { + self.held_open_by == crate::c3::AnswerGap::held_by_words(&judgement) + } _ => false, } } @@ -1226,6 +1243,20 @@ mod tests { CandidateStatus::Mismatch, gap )); + + // A gap a row's words decide holds the differing bytes of a run that recorded one of its + // notes, a note no class is derived from; never equal bytes, nor a run without the note. + let mut grouped = census.clone(); + grouped.modules[0].precision = [PrecisionNote::FragmentSimdgroupGrouping].into(); + let held_by_words = |output: &[u8], census: &crate::coverage::ExecutedCensus| { + let mut row = row(output, census.comparison_class(), CandidateStatus::Mismatch); + row.held_open_by = Some(crate::c3::AnswerGap::HelperThreadWords); + row.census = Some(census.clone()); + row.validate_content().is_ok() + }; + assert!(held_by_words(&far, &grouped)); + assert!(!held_by_words(&golden, &grouped)); + assert!(!held_by_words(&far, &sampled)); } /// A recorded timing reaches no digest, no fingerprint and no verdict. diff --git a/crates/metal2vulkan-validation/src/observation_contract/words.rs b/crates/metal2vulkan-validation/src/observation_contract/words.rs index 78ad06e84..6bb5eb94f 100644 --- a/crates/metal2vulkan-validation/src/observation_contract/words.rs +++ b/crates/metal2vulkan-validation/src/observation_contract/words.rs @@ -364,6 +364,10 @@ pub struct Judgement { pub noted: BTreeMap, /// The differing words no reaching note excuses. pub unexcused: usize, + /// For each note whose allowance is only recorded ([`Allowance::Recorded`]), the unexcused + /// words it reaches: it excuses none of them, but an answer gap of the note holds them open + /// (`c3::AnswerGap::held_by_words`). + pub recorded: BTreeMap, /// The differing words the scan could not follow ([`Family::Unknown`]): every note reaches /// them. pub fallback: usize, @@ -465,16 +469,27 @@ pub fn judge( } } match (excused, noted, bounded) { - (false, ..) => { + // A word whose bytes differ has a differing lane, so a word no lane excuses is + // unexcused. + (false, ..) | (true, None, None) => { judgement.unexcused += 1; if judgement.first_unexcused.is_none() { judgement.first_unexcused = Some((index, bits(metal), bits(device))); } + let recorded = notes + .iter() + .filter(|recorded| { + allowance(recorded.note) == Allowance::Recorded + && reaches(**recorded, facts.fed_by) + }) + .map(|recorded| recorded.note) + .collect::>(); + for note in recorded { + *judgement.recorded.entry(note).or_default() += 1; + } } (true, Some(note), _) => *judgement.noted.entry(note).or_default() += 1, (true, None, Some(note)) => *judgement.bounded.entry(note).or_default() += 1, - // A word whose bytes differ has a differing lane. - (true, None, None) => judgement.unexcused += 1, } } judgement diff --git a/crates/metal2vulkan-validation/src/observation_contract/words/tests.rs b/crates/metal2vulkan-validation/src/observation_contract/words/tests.rs index 29cef8562..41fc602a9 100644 --- a/crates/metal2vulkan-validation/src/observation_contract/words/tests.rs +++ b/crates/metal2vulkan-validation/src/observation_contract/words/tests.rs @@ -417,3 +417,61 @@ fn a_recorded_note_excuses_no_word_it_reaches() { Verdict::Mismatch ); } + +/// For each only-recorded note, the judgement counts the unexcused words it reaches, once per +/// word whatever module recorded it: a note of the writing module only the words its operations +/// feed, a note of another module and a word the scan could not follow every one. A word equal to +/// Metal's, and a bounded note that excuses nothing, are not counted. +#[test] +fn the_judgement_counts_the_unexcused_words_each_recorded_note_reaches() { + let shape = |fed_by: &[Family]| WordFacts { + shape: WordShape::Opaque, + fed_by: Families::of(fed_by), + }; + let output = OutputWords { + words: vec![ + shape(&[Family::Group]), + shape(&[Family::FloatArithmetic]), + shape(&[Family::Unknown]), + shape(&[Family::Group]), + ], + written_words: None, + }; + let notes = [ + RecordedNote { + note: N::FragmentSimdgroupGrouping, + writer: true, + }, + RecordedNote { + note: N::FragmentSimdgroupGrouping, + writer: false, + }, + RecordedNote { + note: N::UnorderedFetchWithinDraw, + writer: true, + }, + RecordedNote { + note: N::DeviceDenormals, + writer: true, + }, + ]; + let metal = floats(&[1, 2, 3, 4]); + // The last word equals Metal's. + let device = floats(&[5, 6, 7, 4]); + let judgement = judge(¬es, None, &output, &metal, &device); + assert_eq!(judgement.unexcused, 3); + assert_eq!(judgement.verdict(), Verdict::Mismatch); + // The note another module recorded reaches every word. + assert_eq!( + judgement.recorded, + BTreeMap::from([ + (N::FragmentSimdgroupGrouping, 3), + (N::UnorderedFetchWithinDraw, 3) + ]) + ); + let only_writer = judge(¬es[..1], None, &output, &metal, &device); + assert_eq!( + only_writer.recorded, + BTreeMap::from([(N::FragmentSimdgroupGrouping, 2)]) + ); +} diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index d0d507577..b6a98fecd 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -627,7 +627,11 @@ cargo run -p metal2vulkan-validation --release --bin corpus-vulkan -- \ counted in its own `noted_difference` column; a word no reaching note excuses makes it a `Mismatch`. A difference of a case the C3 reviewed list holds under an answer gap its structure meets stays a `Mismatch`, its row and batch line naming the gap (`held_open_by`): the user's decision of - 2026-10-06 keeps answer gaps open until an exact emulation exists. + 2026-10-06 keeps answer gaps open until an exact emulation exists. Two gaps are decided by a + row's words, never listed by case: a mismatch whose every unexcused word is reached by + `FragmentSimdgroupGrouping`, or every one by `QuadsSplitByClipping`, is held open as + `helper_thread_words`, and one whose every unexcused word is reached by + `UnorderedFetchWithinDraw` as `ordered_fetch_within_draw`. None of these notes excuses a word. - **Batches.** `--batch --out OUT` runs every selected case, one process per case, each killed whole after `--run-timeout`, resuming from `OUT/done.tsv`; `--batch-report` and `--batch-install STORE` read and install the results. A batch starts no GPU run while the