Skip to main content

vyre_runtime/megakernel/planner/
programs.rs

1//! Program builders surfaced through the megakernel planner.
2
3/// for callers that need the full iterative-balance variant rather
4/// than the dispatch-clustering simplification.
5#[must_use]
6#[allow(clippy::too_many_arguments)]
7pub fn build_sinkhorn_full_clustering_program(
8    k: &str,
9    k_t: &str,
10    a: &str,
11    b: &str,
12    u_curr: &str,
13    u_next: &str,
14    v: &str,
15    kv: &str,
16    ktu: &str,
17    changed: &str,
18    m: u32,
19    n: u32,
20    max_iterations: u32,
21) -> vyre_foundation::ir::Program {
22    vyre_self_substrate::sinkhorn_full_clustering::sinkhorn_full_clustering_program(
23        k,
24        k_t,
25        a,
26        b,
27        u_curr,
28        u_next,
29        v,
30        kv,
31        ktu,
32        changed,
33        m,
34        n,
35        max_iterations,
36    )
37}
38
39/// Build a multi-word scallop-provenance Program. Wraps
40/// [`vyre_self_substrate::scallop_provenance_wide::scallop_provenance_wide_program`]
41/// for >32-rule lineage tracking (W=8 → 256 rules max).
42#[must_use]
43pub fn build_scallop_provenance_wide_program(
44    state: &str,
45    next: &str,
46    join_rules: &str,
47    changed: &str,
48    n: u32,
49    w: u32,
50    max_iterations: u32,
51) -> vyre_foundation::ir::Program {
52    vyre_self_substrate::scallop_provenance_wide::scallop_provenance_wide_program(
53        state,
54        next,
55        join_rules,
56        changed,
57        n,
58        w,
59        max_iterations,
60    )
61}
62/// Bellman tensor-network ordering Program builder. Wraps
63/// [`vyre_self_substrate::bellman_tn_order::bellman_tn_order_program`].
64#[must_use]
65#[allow(clippy::too_many_arguments)]
66pub fn build_bellman_tn_order_program(
67    src: &str,
68    dst: &str,
69    weight: &str,
70    dist: &str,
71    next_dist: &str,
72    changed: &str,
73    n_nodes: u32,
74    n_edges: u32,
75    max_iterations: u32,
76) -> vyre_foundation::ir::Program {
77    vyre_self_substrate::bellman_tn_order::bellman_tn_order_program(
78        src,
79        dst,
80        weight,
81        dist,
82        next_dist,
83        changed,
84        n_nodes,
85        n_edges,
86        max_iterations,
87    )
88}
89
90/// KFAC autotune-step Program builder. Wraps
91/// [`vyre_self_substrate::kfac_autotune_step::kfac_autotune_step_program`].
92#[must_use]
93pub fn build_kfac_autotune_step_program(
94    blocks_out: &str,
95    blocks_in: &str,
96    scratch: &str,
97    num_blocks: u32,
98    n: u32,
99) -> vyre_foundation::ir::Program {
100    vyre_self_substrate::kfac_autotune_step::kfac_autotune_step_program(
101        blocks_out, blocks_in, scratch, num_blocks, n,
102    )
103}
104
105/// Build a sinkhorn dispatch-clustering Program. Wraps
106/// [`vyre_self_substrate::sinkhorn_dispatch_clustering::sinkhorn_clustering_program`].
107#[must_use]
108pub fn build_sinkhorn_clustering_program(
109    m: u32,
110    n: u32,
111    d: u32,
112    iters: u32,
113    eps: f32,
114) -> vyre_foundation::ir::Program {
115    vyre_self_substrate::sinkhorn_dispatch_clustering::sinkhorn_clustering_program(
116        m, n, d, iters, eps,
117    )
118}
119/// Build a persistent-fixpoint Program around a caller-supplied
120/// transfer body. Replaces a host-side `loop { dispatch(); check }`
121/// pattern with a single GPU-side dispatch that ping-pongs
122/// `current ↔ next` until `changed[0] == 0` or `max_iterations`.
123///
124/// P-DRIVER-9: every host fixpoint loop should migrate to this
125/// substrate Program. Caller supplies `transfer_body` that reads
126/// `current` and writes `next`; the wrapper handles the convergence
127/// flag and ping-pong copy.
128#[must_use]
129pub fn build_persistent_fixpoint_program(
130    transfer_body: Vec<vyre_foundation::ir::Node>,
131    current: &str,
132    next: &str,
133    changed: &str,
134    words: u32,
135    max_iterations: u32,
136) -> vyre_foundation::ir::Program {
137    vyre_self_substrate::persistent_fixpoint_program::persistent_fixpoint_program(
138        transfer_body,
139        current,
140        next,
141        changed,
142        words,
143        max_iterations,
144    )
145}