old-runtime regression fix: a stage's reconvergence note only on from_queries' profile; the old runtime's extra kind goes

6e08f5aaef made every stage of implementation-defined reconvergence
record PrecisionNote::DeviceReconvergence on the shared translator
path. The old runtime (Device::new) then announced a second kind,
Degradation::DeviceReconvergence ("device-reconvergence"), for a
tangled stage on a device without maximal reconvergence. Before that
commit it announced ImplementationDefinedReconvergence alone, from the
stage's reconvergence field.

Route (a) of the planner's two: the note is a third profile fact.
- ProfileFacts gains reconvergence_note: ReconvergenceNote::Field for
  Device::new (ROWS), ReconvergenceNote::Noted for
  Device::from_queries (EVERY).
- pipeline::compile records the note only where the profile notes it.
- A Device::new stage again carries the field alone, its notes as
  before 6e08f5aaef.
- The fingerprint renders the facts only off ROWS, so no Device::new
  fingerprint moves.

The old runtime's Degradation::DeviceReconvergence kind is deleted: no
Device::new stage records the note. Its catalogue entry in API.md and
its API-table row go with it. from_precision_note maps the note, which
none of its stages hold, onto ImplementationDefinedReconvergence, as the
closed match requires. The note stays in the translator's vocabulary,
codec and validation allowance for metal2vulkan-rt, which forwards it
through ComputePipelineState::precision_notes.

Tests:
- engine_simd's reconvergence_follows_the_profile and
  uniform_control_flow_mode_without_maximal_reconvergence assert the
  field alone through Device::new and the note through
  Device::from_queries; the guaranteed stage records none.
- the_profiles_facts_follow_its_constructor covers the third fact.

SEMANTICS_VERSION 2155.
This commit is contained in:
Anees Iqbal committed 2026-11-17 10:57:34 -08:00
1 parent e0f567a8bc
commit aa8d6ac6f5
9 files changed
+69 -27

No files matched your search

@@ -12,8 +12,10 @@
//! [`PrecisionNote`] a pipeline stage records, named alike, which the macro maps both
//! ways, so a note without a kind (or two kinds of one note) does not compile. The note a
//! sampler state carries, `CappedLodBias`, maps to the runtime kind of its name, which
//! announces it where the device makes the state. docs/API.md's catalogue lists every code,
//! closed both ways by a test.
//! announces it where the device makes the state. `DeviceReconvergence`, which only a profile
//! `Device::from_queries` built records and so no stage of this runtime holds, maps to
//! `ImplementationDefinedReconvergence`, which this runtime announces from the stage's
//! reconvergence. docs/API.md's catalogue lists every code, closed both ways by a test.
//! - **Codes are a contract.** `metal2vulkan-degrade-<kind>`, never renamed; a new degradation is
//! a new kind. A kind that no longer fires is removed, with its code.
//! - **The payload.** The object degraded (the first one the device met), the reason (with that
@@ -244,6 +246,9 @@ macro_rules! degradations {
match note {
$(PrecisionNote::$note => Degradation::$note,)*
PrecisionNote::CappedLodBias => Degradation::CappedLodBias,
PrecisionNote::DeviceReconvergence => {
Degradation::ImplementationDefinedReconvergence
}
}
}
}
@@ -2937,9 +2942,6 @@ degradations! {
/// device's, where Metal reads `0x7FC00000`. Not bounded: a NaN in a sum makes the sum a
/// NaN.
NativeFloat8 = "native-float8";
/// Class: reconvergence. The stage's reconvergence after divergence is the device's, where
/// Metal's is maximal; announced beside `ImplementationDefinedReconvergence`.
DeviceReconvergence = "device-reconvergence";
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2154;
pub const SEMANTICS_VERSION: u32 = 2155;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
+21
View File
@@ -101,6 +101,11 @@ impl DeviceProfile {
self.facts.half_pair_note
}
/// Whether a stage of implementation-defined reconvergence records it as a note.
pub(crate) fn reconvergence_note(&self) -> ReconvergenceNote {
self.facts.reconvergence_note
}
/// The profile's fields: internal; the profile is opaque to consumers, who compare
/// [`DeviceProfile::fingerprint`] and read its facts through the accessors.
pub(crate) fn fields(&self) -> &ProfileFields {
@@ -529,6 +534,8 @@ pub(crate) struct ProfileFacts {
pub(crate) stage_bound: StageBound,
/// Where a `half` rounded through the conversion pair under the float controls is noted.
pub(crate) half_pair_note: HalfPairNote,
/// Whether a stage of implementation-defined reconvergence records it as a note.
pub(crate) reconvergence_note: ReconvergenceNote,
}
impl ProfileFacts {
@@ -536,15 +543,29 @@ impl ProfileFacts {
pub(crate) const ROWS: ProfileFacts = ProfileFacts {
stage_bound: StageBound::Defects,
half_pair_note: HalfPairNote::Fused,
reconvergence_note: ReconvergenceNote::Field,
};
/// `Device::from_queries`': each fact the same on every device.
pub(crate) const EVERY: ProfileFacts = ProfileFacts {
stage_bound: StageBound::Every,
half_pair_note: HalfPairNote::Every,
reconvergence_note: ReconvergenceNote::Noted,
};
}
/// Whether a stage whose reconvergence is implementation-defined (`Reconvergence::ImplementationDefined`:
/// a tangled instruction on a device without maximal reconvergence) records
/// `PrecisionNote::DeviceReconvergence`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum ReconvergenceNote {
/// No note: the artifact's `reconvergence` field alone says it, which `metal2vulkan-runtime`
/// announces as `ImplementationDefinedReconvergence`: `Device::new`'s profile.
Field,
/// The note, beside the field, a static note of the stage: `Device::from_queries`' profile.
Noted,
}
/// Where a module records `PrecisionNote::NativeHalfConversion` for a `half` it rounds through the
/// device's conversion and its widening under the 16-bit float controls
/// (`QuantizeForm::Controlled`), Metal's `half(float)` by the Vulkan spec.
@@ -1225,15 +1225,18 @@ fn large_module_defects_are_keyed_on_anv() {
}
}
/// The stage bound and the controlled `half` pair's note are facts of the profile, on every
/// committed profile: `Device::new` bounds a stage only where its driver's identity names a
/// stage-size defect (`StageBound::Defects`) and notes the pair only where its driver fuses
/// arithmetic into the narrowing (`HalfPairNote::Fused`); `Device::from_queries` bounds every
/// stage (`StageBound::Every`) and notes every pair (`HalfPairNote::Every`). The facts key the
/// The stage bound and two notes are facts of the profile, on every committed profile:
/// `Device::new` bounds a stage only where its driver's identity names a stage-size defect
/// (`StageBound::Defects`), notes the controlled `half` pair only where its driver fuses arithmetic
/// into the narrowing (`HalfPairNote::Fused`) and records implementation-defined reconvergence as
/// the stage's field alone (`ReconvergenceNote::Field`); `Device::from_queries` bounds every stage,
/// notes every pair and notes the reconvergence (`Every`, `Every`, `Noted`). The facts key the
/// fingerprint: a profile of the same fields with another fact is another profile.
#[test]
fn the_stage_bound_and_the_half_note_are_facts_of_the_profile() {
use crate::device::profile::{DeviceProfile, HalfPairNote, ProfileFacts, StageBound};
fn the_profiles_facts_follow_its_constructor() {
use crate::device::profile::{
DeviceProfile, HalfPairNote, ProfileFacts, ReconvergenceNote, StageBound,
};
for (stem, text) in committed_profiles() {
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
let old = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
@@ -1245,6 +1248,12 @@ fn the_stage_bound_and_the_half_note_are_facts_of_the_profile() {
queries.profile().half_pair_note(),
);
assert_eq!(notes, (HalfPairNote::Fused, HalfPairNote::Every), "{stem}");
let notes = (
old.profile().reconvergence_note(),
queries.profile().reconvergence_note(),
);
let want = (ReconvergenceNote::Field, ReconvergenceNote::Noted);
assert_eq!(notes, want, "{stem}");
let fields = queries.profile().fields().clone();
let facts = ProfileFacts {
stage_bound: StageBound::Defects,
+3 -1
View File
@@ -2394,7 +2394,9 @@ pub enum PrecisionNote {
/// may see other lanes active than Metal's. Under subgroup-uniform control flow
/// (`shaderSubgroupUniformControlFlow`) the lanes reconverge where control flow is uniform.
/// Static per stage: recorded for any tangled instruction in the entry, as the stage's
/// `reconvergence` is.
/// `reconvergence` is, on a device `Device::from_queries` made. A device `Device::new` made
/// records the field alone (`metal2vulkan-runtime` announces it as
/// `ImplementationDefinedReconvergence`).
///
/// Validation derives no tolerance from it: a difference stays a mismatch, which the note
/// explains.
+3 -1
View File
@@ -3338,9 +3338,11 @@ fn compile_bounded<K>(
}
}
// Implementation-defined where a tangled instruction runs without maximal reconvergence
// (`lower::simd` chooses the entry's reconvergence mode), which the stage's note records.
// (`lower::simd` chooses the entry's reconvergence mode), which the stage's note records on a
// profile that notes it (`ReconvergenceNote::Noted`).
let reconvergence = crate::lower::simd::reconvergence(&plan);
if reconvergence == Reconvergence::ImplementationDefined
&& p.reconvergence_note() == crate::device::profile::ReconvergenceNote::Noted
&& !precision.contains(&PrecisionNote::DeviceReconvergence)
{
precision.push(PrecisionNote::DeviceReconvergence);
+18 -3
View File
@@ -624,7 +624,8 @@ fn the_estimate_bounds_every_simd_kernel() {
/// A kernel with a tangled instruction declares `MaximallyReconvergesKHR` where the profile has
/// maximal reconvergence (reconvergence guaranteed), and records `ImplementationDefined` where it
/// has neither mode.
/// has neither mode: as its field alone through `Device::new`, and beside
/// `PrecisionNote::DeviceReconvergence` through `Device::from_queries`.
#[test]
fn reconvergence_follows_the_profile() {
let Some(bc) = assemble("simd_ops") else {
@@ -649,8 +650,16 @@ fn reconvergence_follows_the_profile() {
&& !text.contains("SubgroupUniformControlFlowKHR")
);
assert_eq!(a.reconvergence, Reconvergence::ImplementationDefined);
// The stage records the device's reconvergence as a note.
// Through `Device::new`, the field alone, which the old runtime announces.
assert!(!a.precision.contains(&PrecisionNote::DeviceReconvergence));
// Through `Device::from_queries`, the stage records the device's reconvergence as a note.
let desc = crate::pipeline::testing::description("nvidia-pascal-linux").expect("description");
let queries = Device::from_queries(desc, DevicePolicy::default()).expect("device");
let a = compile(&bc, "simd_vote_k", queries.profile()).expect("compile");
assert_eq!(a.reconvergence, Reconvergence::ImplementationDefined);
assert!(a.precision.contains(&PrecisionNote::DeviceReconvergence));
let a = compile(&bc, "simd_vote_k", &maximal).expect("compile");
assert!(!a.precision.contains(&PrecisionNote::DeviceReconvergence));
}
/// Float sums record the device's association order.
@@ -984,7 +993,8 @@ fn sixty_four_bit_group_operations_are_not_metal() {
/// committed `moltenvk-m3` description with `shaderMaximalReconvergence` cleared), a kernel with a
/// tangled instruction declares `SubgroupUniformControlFlowKHR`, requires that feature and its
/// extensions, passes L3, and records `ImplementationDefined` (the mode does not define
/// reconvergence after divergence).
/// reconvergence after divergence): as its field alone through `Device::new`, and beside
/// `PrecisionNote::DeviceReconvergence` through `Device::from_queries`.
#[test]
fn uniform_control_flow_mode_without_maximal_reconvergence() {
let Some(bc) = assemble("simd_ops") else {
@@ -1002,6 +1012,7 @@ fn uniform_control_flow_mode_without_maximal_reconvergence() {
"the description names shaderMaximalReconvergence"
);
let desc = DeviceDescription::from_khronos_json(&cleared, None).expect("description");
let queries = Device::from_queries(desc.clone(), DevicePolicy::default()).expect("device");
let p = Device::new(desc, DevicePolicy::default())
.expect("device")
.profile()
@@ -1026,6 +1037,10 @@ fn uniform_control_flow_mode_without_maximal_reconvergence() {
.extensions
.contains(&VkExtension::KhrShaderSubgroupUniformControlFlow));
assert_eq!(a.reconvergence, Reconvergence::ImplementationDefined);
// The field alone through `Device::new`; beside the note through `Device::from_queries`.
assert!(!a.precision.contains(&PrecisionNote::DeviceReconvergence));
let a = compile(&bc, "simd_vote_k", queries.profile()).expect("compile");
assert_eq!(a.reconvergence, Reconvergence::ImplementationDefined);
assert!(a.precision.contains(&PrecisionNote::DeviceReconvergence));
}
@@ -6236,7 +6236,6 @@ macro-member metal2vulkan-runtime::Degradation::DeviceNanEncoding DeviceNanEncod
macro-member metal2vulkan-runtime::Degradation::DevicePackConversion DevicePackConversion = "device-pack-conversion";
macro-member metal2vulkan-runtime::Degradation::DevicePointSize DevicePointSize = "device-point-size";
macro-member metal2vulkan-runtime::Degradation::DeviceRayIntersection DeviceRayIntersection = "device-ray-intersection";
macro-member metal2vulkan-runtime::Degradation::DeviceReconvergence DeviceReconvergence = "device-reconvergence";
macro-member metal2vulkan-runtime::Degradation::DeviceRecovered DeviceRecovered = "device-recovered", Performance,
macro-member metal2vulkan-runtime::Degradation::DeviceRoundedResolve DeviceRoundedResolve = "device-rounded-resolve", Precision,
macro-member metal2vulkan-runtime::Degradation::DeviceSampleLevel DeviceSampleLevel = "device-sample-level";
Can't render this file because it is too large.
-8
View File
@@ -5366,14 +5366,6 @@ bound.
reads them, and records none. An `air.convert` from `f8e4m3fn` or `f8e5m2` and a
simdgroup-matrix cell of those formats widen through the same type there and record none: their
formats are OCP's own, and Metal on Apple M3 does not compile them.
- `metal2vulkan-degrade-device-reconvergence` (precision). `PrecisionNote::DeviceReconvergence`: A
stage holds a simdgroup or quad operation, or a barrier whose lanes depend on reconvergence, on a
device without maximal reconvergence (`Reconvergence::ImplementationDefined`): after divergent
control flow the device decides which lanes run it together, where Metal's reconverge maximally,
so the operation may see other lanes active than Metal's. With
`shaderSubgroupUniformControlFlow` the lanes reconverge where control flow is uniform. Recorded
for any such instruction in the stage's entry; `metal2vulkan-runtime` also announces
`ImplementationDefinedReconvergence` there.
- `metal2vulkan-degrade-device-pack-conversion` (precision). `PrecisionNote::DevicePackConversion`:
Native device maths (a conversion): `air.pack` or `air.unpack` of a normalized format is the
device's: `GLSL.std.450`'s `Pack`/`Unpack` `Unorm4x8`, `Snorm4x8`, `Unorm2x16` and `Snorm2x16`,