Skip to main content

solvers.WeightStreamingModel

solvers.WeightStreamingModel()

Analyzes Wafer-Scale inference (e.g., Cerebras CS-3) using Weight Streaming.

Instead of holding weights in HBM and streaming activations (the GPU Memory Wall), this architecture holds massive activation batches on-wafer (SRAM) and streams the model weights from external MemoryX nodes.

The bottleneck shifts from Memory Bandwidth to Injection Interconnect Bandwidth.

Literature Source: 1. Lie et al. (2022), “Cerebras Architecture Deep Dive: First Look Inside the Hardware/Software Co-Design for Deep Learning.”

Methods

Name Description
solve Estimate layer-wise weight streaming time and on-device state capacity.

solve

solvers.WeightStreamingModel.solve(
    model,
    hardware,
    seq_len,
    batch_size=1,
    precision='fp16',
    efficiency=0.5,
    phase='decode',
)

Estimate layer-wise weight streaming time and on-device state capacity.

Parameters

Name Type Description Default
model TransformerWorkload Transformer with positive layer count, parameters, and head geometry. required
hardware HardwareNode Device supplying compute FLOP/s, resident memory bytes, dispatch time, and weight-injection interconnect bytes/s. Missing/zero injection bandwidth uses the fallback in engine.calibration. required
seq_len int Positive resident context length in tokens per request. required
batch_size int Positive simultaneous requests; default one. 1
precision str Weight and KV precision; default FP16. 'fp16'
efficiency float Compute utilization in (0, 1]; default 0.5. 0.5
phase str ‘prefill’ processes seq_len tokens; ‘decode’ processes one token. Other strings currently follow the decode branch. 'decode'

Returns

Name Type Description
WeightStreamingResult Layer compute/injection times, throughput in tokens/s, memory utilization, optimal linear-work batch, and feasibility. Feasibility checks KV state plus the declared activation allowance only.

Notes

Equation: T_layer = max(W_layer/BW_inject, F_layer/(eta*peak)+dispatch). T_step = layers*T_layer. Decode F_layer = 2P_layer*B. Prefill adds 2*H_query*S^2*d*B to 2P_layer*S*B under this model’s approximation. Resident storage is 1.1 times KV bytes; the extra tenth is a declared activation allowance. Weights stream from external storage.

Assumptions: uniform layers and complete injection/compute overlap. The optimal-batch estimate equates injection and linear compute time. Excludes: decode attention work, runtime workspace, detailed communication scheduling, and measured injection efficiency. Prefill uses the causal half-square attention convention matching ServingModel(causal=True).

References

Derivation: divide each layer’s weight bytes by injection bandwidth and its operation count by effective compute rate; the slower concurrent resource sets the layer time. The activation allowance is a heuristic.

Examples

>>> from mlsysim import Hardware, Models
>>> from mlsysim.solvers import WeightStreamingModel
>>> r = WeightStreamingModel().solve(Models.Language.Llama3_8B,
...     Hardware.Cloud.Cerebras_CS3, seq_len=128)
>>> bool(r.feasible and r.layer_compute_time.m_as("ms") > 0)
True
Back to top