pub struct CycleModel {Show 18 fields
pub calibrated: bool,
pub c_kernel: f64,
pub c_sem_setup: f64,
pub c_site_setup: f64,
pub c_mac: f64,
pub f_hifi3: f64,
pub f_hifi2: f64,
pub f_lofi: f64,
pub f_fp32: f64,
pub c_acq: f64,
pub c_reload: f64,
pub c_pack: f64,
pub c_drain: f64,
pub c_dram_tile: f64,
pub c_dram_shared: f64,
pub c_cb: f64,
pub c_mcast_block: f64,
pub c_noc_tile: f64,
}Expand description
Per-cycle-model constants. Names mirror the terms of CycleModel::cycles.
Fields§
§calibrated: boolFitted against measured points (true) or structural placeholders (false).
c_kernel: f64§c_sem_setup: f64Per-semaphore set-up. Collinear with c_kernel in the LOSS — and restoring it anyway, because
n_sems is what separates a multicast plan from a non-multicast one, so this is the only term that
prices the choice. Dropping it on loss-redundancy grounds moved the 512³ GEMM off its measured
multicast plan and cost 4% of its cycles. See the note on unexercised.
c_site_setup: f64§c_mac: f64Cycles per tile-MAC at HiFi4; the other fidelities scale it.
f_hifi3: f64§f_hifi2: f64§f_lofi: f64§f_fp32: f64§c_acq: f64§c_reload: f64§c_pack: f64Cycles the packer spends per tile. The packer and the math unit are separate pipelines that overlap across sub-blocks, so the engine’s time is the LONGER of the two, not their sum.
c_drain: f64Cycles a packer-accumulate drain round-trip costs the compute engine.
c_dram_tile: f64Cycles of shared DRAM occupancy per tile of WHOLE-PROGRAM traffic.
★ This looks ~87x too small against Wormhole’s DRAM roof
(Roofs::wormhole: a 2048 B tile against 288 B/cycle is ~7.1
cycles/tile, not 0.08), and pricing it that way makes the planner prefer a multicast plan moving 768
tiles over the blocked one it picks today at 4,352 — a 5.7x traffic difference.
It is deliberately NOT changed, because the multicast plan that pricing selects DOES NOT RUN: forced at 128³ it fails to complete under ttsim in nine minutes, where the blocked plan at the same shape finishes in seconds at PCC 1.0. This constant was fitted to MEASUREMENTS, so what looks like mispricing is partly the fit correctly encoding that our multicast lowering is catastrophic.
Fix the multicast hang first; then bandwidth-derived pricing is safe and unlocks roughly 4x less DRAM traffic than ttnn.
c_cb: f64§c_mcast_block: f64Per-multicast-block synchronization: the semaphore round trip and the multicast set-up, which the model can only ever charge TOGETHER — a block pays both or neither, so no measurement can separate them and carrying two constants would leave one direction of the fit unconstrained.
c_noc_tile: f64Implementations§
Source§impl CycleModel
impl CycleModel
Sourcepub const DETERMINED_MARGIN: f64 = 1e-3
pub const DETERMINED_MARGIN: f64 = 1e-3
How much worse the data term must get when a constant is frozen wrong, for that constant to count as MEASURED. Below this, the rest of the model absorbs it and its value is an artifact of the search.
Sourcepub const JACKKNIFE_FOLDS: usize = 6
pub const JACKKNIFE_FOLDS: usize = 6
How many contiguous folds the ledger is split into for the stability report, and how far a constant may move when one fold is withheld before it is worth mentioning.
pub const STABLE_MARGIN: f64 = 0.25
Sourcepub fn uncalibrated() -> CycleModel
pub fn uncalibrated() -> CycleModel
Structural placeholder constants (never asserted absolutely).
Sourcepub fn wormhole_ttsim() -> CycleModel
pub fn wormhole_ttsim() -> CycleModel
The Wormhole model, fitted by fit over the Wormhole rows of
benchmarks/silicon/tenstorrent_gemm.json at the knobs the compiler emits (HiFi4, fp32 accumulate
on and off). These constants reproduce NINETEEN OF TWENTY of the ledger’s compiler-chosen plans,
which is the property that actually matters — see the note on
unexercised for why a lower-loss set of constants is not automatically a
better model.
f_hifi3, f_hifi2, f_lofi, c_mcast_block and c_noc_tile sit at their structural priors and
must stay there: every measured row is HiFi4, and steady is a max whose synchronization branch
never binds on any of them, so nothing in this ledger can see those five.
spatial_cost_identifiability_lock enforces it.
Sourcepub fn constants(&self) -> Vec<(&'static str, f64)>
pub fn constants(&self) -> Vec<(&'static str, f64)>
The constants by name, in the fit’s index order.
Sourcepub fn with_constant(&self, i: usize, v: f64) -> CycleModel
pub fn with_constant(&self, i: usize, v: f64) -> CycleModel
Constant i changed to v — the perturbation the identifiability lock searches with.
Sourcepub fn compute_cycles(&self, q: &PlanQuantities) -> f64
pub fn compute_cycles(&self, q: &PlanQuantities) -> f64
The compute engine’s time for a plan: the math unit and the packer pipeline against each other across sub-blocks, so the engine runs at the pace of the busier one; only the FIRST sub-block’s math has nothing to overlap with, which is what makes many small sub-blocks beat few large ones. The acquire/release handshake belongs to the PACK side: when a sub-block fits in half the register file the two halves pipeline and the handshake hides behind the math, and when it does not the whole thing serialises and every handshake is exposed.
Sourcepub fn move_cycles(&self, q: &PlanQuantities) -> f64
pub fn move_cycles(&self, q: &PlanQuantities) -> f64
The movement engines’ time: they run concurrently, so the busier one sets the pace, not their sum.
Sourcepub fn explain(&self, q: &PlanQuantities) -> CostBreakdown
pub fn explain(&self, q: &PlanQuantities) -> CostBreakdown
Predicted whole-program device cycles for a candidate plan. The model’s terms, named — what the plan spends and which resource sets its pace.
A spatial plan’s cost is not one number but a pipeline: each engine has a rate, and the slowest of them is the initiation interval the steady state runs at. Reporting the terms is what lets the compiler say a plan is movement-bound on its second engine rather than merely quoting a total.
pub fn cycles(&self, q: &PlanQuantities) -> f64
Sourcepub fn loss(&self, points: &[(PlanQuantities, u64)]) -> f64
pub fn loss(&self, points: &[(PlanQuantities, u64)]) -> f64
Sum of squared relative errors over measured points.
Sourcepub fn reference(points: &[(PlanQuantities, u64)]) -> CycleModel
pub fn reference(points: &[(PlanQuantities, u64)]) -> CycleModel
The canonical point at which identifiability is judged: the unconstrained minimizer of the data term. Determinedness is a property of a model AND a point — asking the question at two different points gives two different answers — so every caller must ask it here.
Sourcepub fn unstable(&self, points: &[(PlanQuantities, u64)]) -> Vec<&'static str>
pub fn unstable(&self, points: &[(PlanQuantities, u64)]) -> Vec<&'static str>
The constants a withheld fold of the ledger moves by more than Self::STABLE_MARGIN — a DIAGNOSTIC,
reported by spatial_cost_identifiability_lock rather than enforced by it.
Fold spread is real information about how thin the evidence for a constant is. It is deliberately
not a gate: the objective is piecewise (that max), so refits on different subsets legitimately
land in different basins, and gating on it demotes constants that carry the ledger’s plan decisions.
Sourcepub fn unexercised(&self, points: &[(PlanQuantities, u64)]) -> Vec<&'static str>
pub fn unexercised(&self, points: &[(PlanQuantities, u64)]) -> Vec<&'static str>
★ A LOSS-BASED redundancy test used to live here, and it measured the wrong thing. Recorded because the mistake is an easy one to make twice.
It asked whether freezing a constant at a wrong value could be absorbed by refitting the rest, and
by that criterion six of these sixteen constants looked undetermined. Returning those to their
priors and re-pinning changed almost nothing about predicted CYCLES — and changed TEN OF TWENTY
measured plan DECISIONS, the calibrated 512³ GEMM among them. The objective’s valley is flat in
loss and is NOT flat in the choices the compiler makes inside it, so loss-redundancy says nothing
about whether a constant matters. The operational question is the one
spatial_cost_model_lock::the_synchronization_terms_are_load_bearing already asks: does changing
it change a DECISION?
What survives from that work, because it is provable rather than empirical, is
unexercised — the constants no measured row can see at all.
The constants NO measured row can see — the ones whose term never binds the pace on any point, so
the loss is flat along them. A value the data cannot determine is not a measurement, and fit
leaves these at their structural prior rather than reporting whatever the search last touched.
This is a property of the model AND the measurements together: a constant becomes exercised the
moment a row is measured whose plan it paces. spatial_cost_identifiability_lock requires every
unexercised constant to still equal its prior, so a structural guess can never be published as a fit.
Sourcepub fn fit(points: &[(PlanQuantities, u64)]) -> CycleModel
pub fn fit(points: &[(PlanQuantities, u64)]) -> CycleModel
Deterministic fit of the constants to measured points. The objective is the sum of squared relative
errors, plus a ranking hinge over every pair of points that share a problem (tile shape, fp32_acc,
fidelity) so the model orders measured alternatives as the simulator did, plus a small ridge toward
the structural priors that pins the constants no point constrains.
A constant no measured row can SEE cannot move from its prior here, because nothing in the objective
responds to it — see unexercised, which names them, and
spatial_cost_identifiability_lock, which requires the published model to leave them alone.
Same points → same constants, bit for bit.
Sourcepub fn fit_data(
points: &[(PlanQuantities, u64)],
start: &CycleModel,
hold: &[usize],
) -> CycleModel
pub fn fit_data( points: &[(PlanQuantities, u64)], start: &CycleModel, hold: &[usize], ) -> CycleModel
The minimizer of the DATA term alone, from start, optionally holding constant hold fixed.
The regularized fit is what the compiler ships, but identifiability is a question
about what the MEASUREMENTS determine — and the ridge exists precisely to pull unconstrained
directions back to the prior, so probing under it would measure the regularizer instead of the data.
spatial_cost_identifiability_lock uses this entry, and hold is how it asks whether the rest of
the model can absorb a constant it has been denied.
Sourcepub fn refit_from(
points: &[(PlanQuantities, u64)],
start: &CycleModel,
hold: &[usize],
) -> CycleModel
pub fn refit_from( points: &[(PlanQuantities, u64)], start: &CycleModel, hold: &[usize], ) -> CycleModel
One descent on the data term from start, holding hold fixed — the probe both the model and
spatial_cost_identifiability_lock judge identifiability with.
Single-start on purpose: the multi-start in fit_data exists to FIND the basin,
and identifiability is a question asked inside it. Probing with a second multi-start lets the two
sides of the comparison land in different basins, so the answer reports which search got lucky
rather than whether the constant carries information.
Trait Implementations§
Source§impl Clone for CycleModel
impl Clone for CycleModel
Source§fn clone(&self) -> CycleModel
fn clone(&self) -> CycleModel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CycleModel
impl Debug for CycleModel
Source§impl<'de> Deserialize<'de> for CycleModel
impl<'de> Deserialize<'de> for CycleModel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CycleModel
impl PartialEq for CycleModel
Source§impl Serialize for CycleModel
impl Serialize for CycleModel
impl StructuralPartialEq for CycleModel
Auto Trait Implementations§
impl Freeze for CycleModel
impl RefUnwindSafe for CycleModel
impl Send for CycleModel
impl Sync for CycleModel
impl Unpin for CycleModel
impl UnsafeUnpin for CycleModel
impl UnwindSafe for CycleModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.