Skip to main content

vyre_self_substrate/
lib.rs

1//! Self-substrate — vyre using its own primitives to compile/dispatch vyre.
2//!
3//! These modules realize the **recursion thesis** (#30): every Tier-2.5
4//! primitive shipped in `vyre-primitives` also has a vyre-self consumer
5//! here that uses the same Program at compile / dispatch time.
6//!
7//! # Layering (audit cleanup A10, 2026-04-30)
8//!
9//! Extracted from `vyre-driver/src/self_substrate/` into a dedicated
10//! crate so the substrate-self-uses live at a layer that depends only
11//! on `vyre-foundation` + `vyre-primitives` — eliminating the layering
12//! muddle where backend-specific dispatch code and substrate self-uses
13//! shared one home in `vyre-driver`.
14//!
15//! ```text
16//!   vyre-foundation
17//!         ↑
18//!   vyre-primitives
19//!         ↑
20//!   vyre-self-substrate          ← THIS CRATE (no driver deps)
21//!         ↑
22//!   vyre-driver / vyre-runtime / vyre-libs / vyre-driver-{cuda,wgpu}
23//! ```
24//!
25//! No cycles. Every consumer above this crate reaches the substrate
26//! via `vyre_self_substrate::*` directly.
27//!
28//! `vyre-foundation` cannot consume `self_substrate` from here because
29//! `self_substrate` depends on `vyre-primitives` which depends on
30//! `vyre-foundation` — that's the cycle that justifies the dedicated
31//! crate. Foundation has its own smaller substrate at
32//! `vyre_foundation::pass_substrate` (with the math kernels it needs
33//! inlined locally — same pattern Linux uses for arch-local libs vs
34//! `lib/`).
35//!
36//! # Module list
37//!
38//! - `dataflow_fixpoint` (#26) — Region-graph dataflow fixpoint via
39//!   `vyre-primitives::math::semiring_gemm` over the Region adjacency.
40//! - `cost_model` (#28) — probabilistic dispatch cost model via
41//!   `vyre-primitives::graph::sum_product_circuit` + conformal
42//!   intervals from `vyre-primitives::math::conformal`.
43//! - `vsa_fingerprint` (#29) — VSA op-cache key via
44//!   `vyre-primitives::hash::hypervector`.
45//! - `spectral_schedule` (#23) — spectral clustering of dispatch
46//!   graph via `vyre-primitives::graph::chebyshev_filter` +
47//!   `vyre-primitives::math::spectral_shape`.
48//! - `differentiable_autotune` (#27) — differentiable autotuner via
49//!   `vyre-primitives::math::differentiable`.
50//! - `polyhedral_fusion` (#19) — polyhedral / affine fusion via
51//!   `vyre-primitives::math::semiring_gemm` on the affine-dependency
52//!   adjacency.
53//! - `megakernel_schedule` (#22) — megakernel ILP relaxation via
54//!   `vyre-primitives::opt::homotopy` continuation.
55//! - `tensor_train_chain_fusion` (#6) — chain-shaped Region fusion via
56//!   `vyre-primitives::math::tensor_train::tt_contract_step` contraction.
57//! - `do_calculus_change_impact` (#36) — rule-graph change-impact analysis
58//!   via `vyre-primitives::graph::do_calculus` graph surgery.
59//! - `scallop_provenance` (#39) — GPU-resident rule provenance closure via
60//!   `vyre-primitives::math::scallop_join` Datalog fixpoint.
61//! - `matroid_megakernel_scheduler` (#46) — discrete fusion-grouping via
62//!   matroid intersection augmenting paths. Complements
63//!   `megakernel_schedule` (#22 homotopy continuous solver) with the
64//!   exact combinatorial selection.
65//! - `mori_zwanzig_region_coarsen` (#58) — Region-tree coarse-graining
66//!   via Mori-Zwanzig projection. Reduces O(N²) all-pairs analyses to
67//!   O(K²) at workspace scale with quantified projection error.
68//! - `fmm_polyhedral_compress` (#51) — FMM hierarchical compression of
69//!   #19 polyhedral fusion's all-pairs affinity. Drops cost from O(N²)
70//!   to O(N log N) at workspace scale.
71//! - `submodular_cache_eviction` (#45) — pipeline-cache eviction via
72//!   submodular maximization. Replaces LRU's heuristic with the
73//!   provably-(1-1/e) greedy approximation.
74//! - `qsvt_matrix_function_fusion` (#34) — transport-based fusion
75//!   analysis via QSVT-applied matrix functions. Computes Wasserstein
76//!   distances on dispatch graphs in O(K·N²) instead of O(N³).
77//! - `persistent_homology_loop_signature` (#15) — Region-tree loop
78//!   topology via Vietoris-Rips filtration. Fusion-vs-fission decision
79//!   informed by H₁ persistent features.
80//! - `adjustment_set_pass_dependency` (#37) — optimizer pass-ordering
81//!   validity via causal back-door analysis on the rewrite-precondition
82//!   graph.
83//! - `functorial_pass_composition` (#52) — IR transform passes as
84//!   categorical functors. Compositionality, equational reasoning, free
85//!   adjoint pairs — pass framework moves from hand-managed DAG to a
86//!   typed functor-category.
87//! - `string_diagram_ir_rewrite` (#53) — Vyre IR Region tree IS a
88//!   string diagram in Cat(GPU buffers, Programs). Optimizer rewrites
89//!   become string-diagram rewrites; coherence theorems give free
90//!   correctness proofs.
91//! - `planar_rewrite_pass_scheduler` (#11) — schedule batch IR rewrites
92//!   onto disjoint sub-trees via planar non-overlapping selection.
93//!   Drops dispatch count from O(N) sequential to O(log N) batched.
94
95pub mod adjustment_set_pass_dependency;
96pub mod alias_registry;
97pub mod amg_pass_solver;
98pub mod bellman_tn_order;
99pub mod bitset_summary;
100pub mod categorical_check;
101pub mod cost_model;
102pub mod csr_bidirectional;
103pub mod csr_forward_or_changed;
104pub mod dataflow_fixpoint;
105pub mod decision_telemetry;
106pub mod differentiable_autotune;
107pub mod dnnf_compile;
108pub mod do_calculus_change_impact;
109pub mod dominator_frontier;
110pub mod effect_signature_check;
111pub mod exploded;
112pub mod fmm_polyhedral_compress;
113pub mod functorial_pass_composition;
114pub mod kfac_autotune_step;
115pub mod knowledge_compile_pass_precondition;
116pub mod level_wave_pass;
117pub mod linear_type_check;
118pub mod matroid_exact_megakernel;
119pub mod matroid_megakernel_scheduler;
120pub mod megakernel_schedule;
121pub mod mori_zwanzig_region_coarsen;
122pub mod motif;
123pub mod multigrid_matroid_solver;
124pub mod natural_gradient_autotuner;
125pub mod observability;
126pub mod path_reconstruct;
127pub mod persistent_bfs;
128pub mod persistent_fixpoint_program;
129pub mod persistent_homology_loop_signature;
130pub mod planar_rewrite_pass_scheduler;
131pub mod polyhedral_fusion;
132pub mod qsvt_matrix_function_fusion;
133pub mod scallop_provenance;
134pub mod scallop_provenance_wide;
135pub mod shape_smt_check;
136pub mod sheaf_heterophilic_dispatch;
137pub mod sheaf_spectral_clustering;
138pub mod sinkhorn_dispatch_clustering;
139pub mod sinkhorn_full_clustering;
140pub mod spectral_schedule;
141pub mod string_diagram_ir_rewrite;
142pub mod submodular_cache_eviction;
143pub mod tensor_network_fusion_order;
144pub mod tensor_train_chain_fusion;
145pub mod tensor_train_compression;
146pub mod toposort;
147pub mod union_find_emit;
148pub mod vsa_fingerprint;
149pub mod zx_rewrite;