Skip to main content

vyre_spec/
lib.rs

1#![deny(missing_docs)]
2#![forbid(unsafe_code)]
3#![cfg_attr(
4    not(test),
5    deny(
6        clippy::unwrap_used,
7        clippy::expect_used,
8        clippy::todo,
9        clippy::unimplemented,
10        clippy::panic
11    )
12)]
13//! vyre-spec is the machine-checkable frozen data contract for the vyre GPU
14//! compute IR. Any backend may depend on vyre-spec alone to prove conformance
15//! without depending on vyre itself.
16//!
17//! This crate is intentionally data-only. It has no dependency on downstream
18//! crates; backend vendors can use these types as the stable contract
19//! for conformance proofs. Example: a conformance runner can read an
20//! [`OpSignature`] and verify the byte width expected by a backend primitive.
21
22/// Adversarial input descriptors  -  hostile payloads every op must reject or handle.
23/// Specification element.
24pub mod adversarial_input;
25/// Algebraic law primitives  -  associativity, identity, commutativity declarations.
26/// Specification element.
27pub mod algebraic_law;
28/// Canonical catalog of every algebraic law tagged to operations.
29/// Specification element.
30pub mod all_algebraic_laws;
31#[macro_use]
32mod op_wire;
33/// Versioned cross-engine analysis fact records.
34pub mod analysis;
35/// Atomic operation enum  -  the bounded set of read-modify-write primitives.
36/// Specification element.
37pub mod atomic_op;
38/// Binary operator enum  -  all element-wise two-operand primitives.
39/// Specification element.
40pub mod bin_op;
41/// Buffer access mode (ReadOnly / WriteOnly / ReadWrite) + enforcement helpers.
42/// Specification element.
43pub mod buffer_access;
44/// Iterator returning op ids grouped by their `Category`.
45/// Specification element.
46pub mod by_category;
47/// Reverse index from op id string to its canonical descriptor.
48/// Specification element.
49pub mod by_id;
50/// Conformance invariant: the op catalog enumerates every known id.
51/// Specification element.
52pub mod catalog_is_complete;
53mod catalog_slices;
54/// Category enum (A/B/C) + backend-availability predicates.
55/// Specification element.
56pub mod category;
57/// Collective communication operators and communicator handles.
58/// Specification element.
59pub mod collective_op;
60/// Calling conventions between CPU host and GPU kernels.
61/// Specification element.
62pub mod convention;
63/// Primitive data-type enum (U32/F32/Bool/etc.) + size helpers.
64/// Specification element.
65pub mod data_type;
66/// Invariants the engine itself must preserve (wire round-trip, CSE stability, …).
67/// Specification element.
68pub mod engine_invariant;
69/// Frozen catalog of core `Expr` variant names used by coverage tests.
70/// Specification element.
71pub mod expr_variant;
72/// Dialect extension descriptor  -  marks non-core ops carried by extensions.
73/// Specification element.
74pub mod extension;
75/// Floating-point type subset (F16/F32/F64) with associated properties.
76/// Specification element.
77pub mod float_type;
78/// Golden reference samples  -  tiny fixtures every backend must reproduce exactly.
79/// Specification element.
80pub mod golden_sample;
81/// Table of hardware intrinsics exposed by vyre-intrinsics.
82/// Specification element.
83pub mod intrinsic_table;
84/// Abstract invariant type + provenance tracking.
85/// Specification element.
86pub mod invariant;
87/// Classification buckets grouping related invariants (numeric, memory, …).
88/// Specification element.
89pub mod invariant_category;
90/// Catalog of invariants every registered op is checked against.
91/// Specification element.
92pub mod invariants;
93/// Known-answer test vector type  -  deterministic input/output pairs.
94/// Specification element.
95pub mod kat_vector;
96/// Canonical catalog of algebraic laws exposed via `law_catalog()`.
97/// Specification element.
98pub mod law_catalog;
99/// Layer enum (IR / backend / runtime)  -  coarse module placement.
100/// Specification element.
101pub mod layer;
102/// Metadata classification for `OpMetadata` entries.
103/// Specification element.
104pub mod metadata_category;
105/// Monotonicity direction (increasing / decreasing / none) for op outputs.
106/// Specification element.
107pub mod monotonic_direction;
108/// Operation contract: capability requirements, determinism, cost hints.
109/// Specification element.
110pub mod op_contract;
111/// Op metadata struct  -  human-facing description and discoverability hooks.
112/// Specification element.
113pub mod op_metadata;
114/// Op signature  -  stable type profile every backend lowers against.
115/// Specification element.
116pub mod op_signature;
117/// Packed graph node kinds for language-agnostic analysis.
118/// Specification element.
119pub mod pg_node_kind;
120/// Canonical semiring selector for dataflow and algebraic kernels.
121pub mod semiring;
122/// Soundness markers and precision contracts for cross-engine analysis data.
123pub mod soundness;
124/// Subgroup (warp) reduction operator enum  -  add/mul/min/max/and/or/xor.
125/// Specification element.
126pub mod subgroup_reduce_op;
127/// Ternary operator enum  -  select, FMA, mask-merge.
128/// Specification element.
129pub mod ternary_op;
130/// Structured test descriptor  -  op id, input sampler, expected shape.
131/// Specification element.
132pub mod test_descriptor;
133#[cfg(test)]
134mod tests;
135/// Unary operator enum  -  single-operand element-wise primitives.
136/// Specification element.
137pub mod un_op;
138/// Conformance verification driver  -  runs the law + invariant battery.
139/// Specification element.
140pub mod verification;
141
142/// See [`adversarial_input::AdversarialInput`].
143/// Specification element.
144pub use adversarial_input::AdversarialInput;
145/// See [`algebraic_law::AlgebraicLaw`].
146/// Specification element.
147pub use algebraic_law::{AlgebraicLaw, LawCheckFn};
148/// See [`all_algebraic_laws::all_algebraic_laws`].
149/// Specification element.
150pub use all_algebraic_laws::all_algebraic_laws;
151/// See [`atomic_op::AtomicOp`].
152/// Specification element.
153pub use atomic_op::AtomicOp;
154/// See [`bin_op::BinOp`].
155/// Specification element.
156pub use bin_op::BinOp;
157/// See [`buffer_access::BufferAccess`].
158/// Specification element.
159pub use buffer_access::BufferAccess;
160/// See [`by_category::by_category`].
161/// Specification element.
162pub use by_category::by_category;
163/// See [`by_id::by_id`].
164/// Specification element.
165pub use by_id::by_id;
166/// See [`catalog_is_complete::catalog_is_complete`].
167/// Specification element.
168pub use catalog_is_complete::catalog_is_complete;
169/// See [`category::Category`] + backend-availability helpers.
170/// Specification element.
171pub use category::{BackendAvailability, BackendAvailabilityPredicate, Category};
172/// See [`collective_op::{CollectiveOp, CommGroup}`].
173/// Specification element.
174pub use collective_op::{CollectiveOp, CommGroup};
175/// See [`convention::Convention`].
176/// Specification element.
177pub use convention::Convention;
178/// See [`data_type::DataType`].
179/// Specification element.
180pub use data_type::{DataType, QuantizationScale, QuantizationZeroPoint, TypeId};
181/// See [`engine_invariant::EngineInvariant`].
182/// Specification element.
183pub use engine_invariant::{EngineInvariant, InvariantId};
184/// See [`expr_variant::expr_variants`].
185/// Specification element.
186pub use expr_variant::expr_variants;
187/// See [`float_type::FloatType`].
188/// Specification element.
189pub use float_type::FloatType;
190/// See [`golden_sample::GoldenSample`].
191/// Specification element.
192pub use golden_sample::GoldenSample;
193/// See [`intrinsic_table::IntrinsicTable`].
194/// Specification element.
195pub use intrinsic_table::{IntrinsicLowering, IntrinsicTable};
196/// See [`invariant::Invariant`].
197/// Specification element.
198pub use invariant::Invariant;
199/// See [`invariant_category::InvariantCategory`].
200/// Specification element.
201pub use invariant_category::InvariantCategory;
202/// See [`invariants::invariants`].
203/// Specification element.
204pub use invariants::{empty_test_family, invariants};
205/// See [`kat_vector::KatVector`].
206/// Specification element.
207pub use kat_vector::KatVector;
208/// See [`law_catalog::law_catalog`].
209/// Specification element.
210pub use law_catalog::law_catalog;
211/// See [`layer::Layer`].
212/// Specification element.
213pub use layer::Layer;
214/// See [`metadata_category::MetadataCategory`].
215/// Specification element.
216pub use metadata_category::MetadataCategory;
217/// See [`monotonic_direction::MonotonicDirection`].
218/// Specification element.
219pub use monotonic_direction::MonotonicDirection;
220/// See [`op_contract::OperationContract`] and its component types.
221pub use op_contract::{
222    CapabilityId, CostHint, DeterminismClass, OperationContract, SideEffectClass,
223};
224/// See [`op_metadata::OpMetadata`].
225/// Specification element.
226pub use op_metadata::OpMetadata;
227/// See [`op_signature::OpSignature`].
228/// Specification element.
229pub use op_signature::OpSignature;
230/// See [`pg_node_kind::PgNodeKind`].
231/// Specification element.
232pub use pg_node_kind::PgNodeKind;
233/// See [`semiring::Semiring`].
234pub use semiring::Semiring;
235/// See [`subgroup_reduce_op::SubgroupReduceOp`].
236/// Specification element.
237pub use subgroup_reduce_op::SubgroupReduceOp;
238/// See [`ternary_op::TernaryOp`].
239/// Specification element.
240pub use ternary_op::TernaryOp;
241/// See [`test_descriptor::TestDescriptor`].
242/// Specification element.
243pub use test_descriptor::TestDescriptor;
244/// See [`un_op::UnOp`].
245/// Specification element.
246pub use un_op::UnOp;
247/// See [`verification::Verification`].
248/// Specification element.
249pub use verification::Verification;
250
251/// Intrinsic descriptors.
252/// Specification element.
253pub mod intrinsic_descriptor;
254/// See [`intrinsic_descriptor::IntrinsicDescriptor`] and its identifying types.
255pub use intrinsic_descriptor::{Backend, BackendId, CpuFn, IntrinsicDescriptor};