Skip to main content

CycleModel

Struct CycleModel 

Source
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: bool

Fitted against measured points (true) or structural placeholders (false).

§c_kernel: f64§c_sem_setup: f64

Per-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: f64

Cycles 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: f64

Cycles 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: f64

Cycles a packer-accumulate drain round-trip costs the compute engine.

§c_dram_tile: f64§c_dram_shared: f64

Cycles 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: f64

Per-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: f64

Implementations§

Source§

impl CycleModel

Source

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.

Source

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.

Source

pub const STABLE_MARGIN: f64 = 0.25

Source

pub fn uncalibrated() -> CycleModel

Structural placeholder constants (never asserted absolutely).

Source

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.

Source

pub fn constants(&self) -> Vec<(&'static str, f64)>

The constants by name, in the fit’s index order.

Source

pub fn with_constant(&self, i: usize, v: f64) -> CycleModel

Constant i changed to v — the perturbation the identifiability lock searches with.

Source

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.

Source

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.

Source

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.

Source

pub fn cycles(&self, q: &PlanQuantities) -> f64

Source

pub fn loss(&self, points: &[(PlanQuantities, u64)]) -> f64

Sum of squared relative errors over measured points.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> CycleModel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CycleModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CycleModel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CycleModel

Source§

fn eq(&self, other: &CycleModel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CycleModel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CycleModel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,