Skip to main content

engine.solvers.interconnect

engine.solvers.interconnect

Interconnect solvers: transfer bounds across link tiers, alpha-beta messages, bisection cuts, incast, and fits to measured collectives.

Domain implementations behind mlsysim.solvers (the public import path, derived from engine.solvers.__init__); kept per-domain so the logic stays reviewable.

Classes

Name Description
AlphaBetaModel Point-to-point message time under the alpha-beta model on several paths.
BisectionModel A ring AllReduce whose every edge crosses the bisection, on a full and an oversubscribed cut.
CommunicationIntensityModel Communication intensity of one data-parallel worker step against fabric balance.
GradientSyncModel One data-parallel step: local compute, then a ring AllReduce of the gradients.
IncastModel Many senders converge on one egress port (incast).
TensorParallelCommModel Activation AllReduces of one tensor-parallel training step.
TransferLadderModel Moves one payload over each tier of a bandwidth hierarchy.

AlphaBetaModel

engine.solvers.interconnect.AlphaBetaModel()

Point-to-point message time under the alpha-beta model on several paths.

Each message of n bytes pays a fixed startup alpha (NIC, switch hops, error correction, software) plus n / beta on the wire. The two terms are equal at n* = alpha * beta: below it a lower alpha helps, above it only a higher beta does.

Literature Source: Hockney (1994), “The communication challenge for MPP”.

Methods

Name Description
solve Evaluate startup and wire time for named messages and paths.
solve
engine.solvers.interconnect.AlphaBetaModel.solve(alphas, bandwidths, messages)

Evaluate startup and wire time for named messages and paths.

Parameters
Name Type Description Default
alphas Dict[str, Quantity] Mapping of path names to nonnegative startup times. required
bandwidths Dict[str, Quantity] Mapping of path names to positive bandwidths in byte/s. required
messages Dict[str, Quantity] Mapping of message names to nonnegative byte quantities. required
Returns
Name Type Description
AlphaBetaResult Per-path message times and wire times in seconds, with crossover bytes. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: time = alpha + message_bytes / bandwidth; crossover_bytes = alpha * bandwidth.

Assumptions: Every alpha path has a bandwidth entry; both terms are constant per path.

Excludes: Congestion, packetization, and throughput variation.

References

Derivation: time = alpha + message_bytes / bandwidth; crossover_bytes = alpha * bandwidth. This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import AlphaBetaModel
>>> AlphaBetaModel().solve({'p': Q_('1 ms')}, {'p': Q_('1 GB/s')}, {'m': Q_('1 MB')}).times['p']['m'].to('ms').magnitude == 2
True

BisectionModel

engine.solvers.interconnect.BisectionModel()

A ring AllReduce whose every edge crosses the bisection, on a full and an oversubscribed cut.

With ranks placed alternately in the two halves, each of the N/2 ring edges in one direction crosses the cut and carries 2(N-1)/N times the per-device payload (ReduceScatter then AllGather). The cut carries N/2 links, divided by the oversubscription ratio. Only the communication fraction of the step stretches, so relative throughput is 1 / ((1 - f) + f r); the lost share of a cluster’s capital cost is its equivalent idle capacity. This placement is the worst case.

Methods

Name Description
solve Bound collective traffic through a worst-case bisection placement.
solve
engine.solvers.interconnect.BisectionModel.solve(
    n_devices,
    link_bandwidth,
    oversubscription_ratio,
    payload_per_device,
    communication_fraction,
    cluster_cost,
)

Bound collective traffic through a worst-case bisection placement.

Parameters
Name Type Description Default
n_devices int Even device count at least two. required
link_bandwidth Quantity Positive link bandwidth in byte/s. required
oversubscription_ratio float Positive full-cut to available-cut bandwidth ratio. required
payload_per_device Quantity Positive collective payload per device in bytes. required
communication_fraction float Fraction of baseline step spent communicating, between zero and one. required
cluster_cost Quantity Nonnegative capital cost in currency units. required
Returns
Name Type Description
BisectionResult Cut bandwidths, crossing GB, communication seconds, slowdown and throughput ratios, and idle-equivalent capital cost. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: crossing = floor(N/2) * payload * ring_factor; cut_bandwidth = floor(N/2) * link_bandwidth / oversubscription; throughput = 1 / (1-f+f*r).

Assumptions: Even device groups with alternating placement across the cut and positive traffic.

Excludes: Alternative rank placement, overlap changes, and monetary accounting beyond idle-capacity equivalence.

References

Derivation: crossing = floor(N/2) * payload * ring_factor; cut_bandwidth = floor(N/2) * link_bandwidth / oversubscription; throughput = 1 / (1-f+f*r). This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import BisectionModel
>>> BisectionModel().solve(4, Q_('100 GB/s'), 2, Q_('1 GB'), 0.5, Q_('100 USD')).slowdown == 2
True

CommunicationIntensityModel

engine.solvers.interconnect.CommunicationIntensityModel()

Communication intensity of one data-parallel worker step against fabric balance.

CI is bytes sent over the network per FLOP done locally. The fabric’s balance point is link bandwidth over peak arithmetic rate: below it the step is set by compute, above it by the network.

Methods

Name Description
solve Compare gradient bytes per FLOP with the fabric balance.
solve
engine.solvers.interconnect.CommunicationIntensityModel.solve(
    model,
    sequences_per_worker,
    link_bandwidth,
    peak_flops,
    precision='fp16',
)

Compare gradient bytes per FLOP with the fabric balance.

Parameters
Name Type Description Default
model object Workload with parameter count, dimensions, and weight size. required
sequences_per_worker object Positive sequences processed per worker per step. required
link_bandwidth object Positive link bandwidth in byte/s. required
peak_flops object Positive arithmetic rate in FLOP/s. required
precision str Weight precision name used to size one gradient replica. 'fp16'
Returns
Name Type Description
CommunicationIntensityResult Local tokens, sent bytes, training FLOPs, byte/FLOP intensity and balance magnitudes, and ideal compute time in seconds. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: tokens = sequences_per_worker * context_length; intensity = ring_factor * model_bytes / training_FLOPs; balance = bandwidth / peak_FLOPs.

Assumptions: Parameter-dominated dense training and the registry ring factor.

Excludes: Attention work, collective startup, overlap, and achieved compute efficiency.

References

Derivation: tokens = sequences_per_worker * context_length; intensity = ring_factor * model_bytes / training_FLOPs; balance = bandwidth / peak_FLOPs. This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import CommunicationIntensityModel
>>> CommunicationIntensityModel().solve(Models.Language.Llama3_8B, 1, Q_('100 GB/s'), Q_('100 TFLOP/s')).intensity > 0
True

GradientSyncModel

engine.solvers.interconnect.GradientSyncModel()

One data-parallel step: local compute, then a ring AllReduce of the gradients.

Each worker sends about 2x the gradient bytes per step (the ring factor for large N). With no overlap the step is compute plus transfer, so the compute fraction shows how much of the step the accelerator works. Energy charges each transferred bit once at the fabric’s energy per bit.

Methods

Name Description
solve Compare gradient synchronization time and energy across fabrics.
solve
engine.solvers.interconnect.GradientSyncModel.solve(
    model,
    precision,
    links,
    compute_time,
    energy_per_bit=None,
    steps=1,
    compute_speedup=1.0,
)

Compare gradient synchronization time and energy across fabrics.

Parameters
Name Type Description Default
model object Workload with parameter count, dimensions, and weight size. required
precision str Weight or KV precision name; gradient synchronization also accepts bytes per element. required
links object Mapping of path names to positive bandwidth quantities in byte/s. required
compute_time object Nonnegative local compute time, convertible to seconds. required
energy_per_bit object Optional nonnegative joules per transferred bit. None
steps object Nonnegative number of steps for total energy. 1
compute_speedup object Positive dimensionless local compute multiplier. 1.0
Returns
Name Type Description
GradientSyncResult Synchronization bytes, transfer and step times in seconds per link, compute fractions, and per-step and total energy in joules. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: sync_bytes = ring_factor * model_bytes; step_i = compute_time / speedup + sync_bytes / bandwidth_i; energy = sync_bits * energy_per_bit.

Assumptions: The registry ring factor approximates large groups; transfers serialize after compute.

Excludes: Finite-rank correction, overlap, reduction compute, and network retransmission.

References

Derivation: sync_bytes = ring_factor * model_bytes; step_i = compute_time / speedup + sync_bytes / bandwidth_i; energy = sync_bits * energy_per_bit. This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import GradientSyncModel
>>> GradientSyncModel().solve(Models.Language.Llama3_8B, 'fp16', {'link': Q_('100 GB/s')}, Q_('1 s')).transfer_times['link'].magnitude > 0
True

IncastModel

engine.solvers.interconnect.IncastModel()

Many senders converge on one egress port (incast).

The offered load is the senders’ combined rate; the buffer fills at the offered load less what the egress drains, and a full buffer holds buffer / egress of waiting. The bandwidth-delay product is the data in flight on the egress link during one feedback round trip, which is what end-to-end congestion control must absorb before it can react.

Methods

Name Description
solve Estimate buffer fill and drain under sustained incast.
solve
engine.solvers.interconnect.IncastModel.solve(
    n_senders,
    sender_bandwidth,
    egress_bandwidth,
    buffer,
    feedback_rtt,
)

Estimate buffer fill and drain under sustained incast.

Parameters
Name Type Description Default
n_senders int Positive number of simultaneous senders. required
sender_bandwidth Quantity Positive bandwidth offered by each sender in byte/s. required
egress_bandwidth Quantity Positive shared egress bandwidth in byte/s. required
buffer Quantity Positive buffer capacity in bytes. required
feedback_rtt Quantity Nonnegative feedback round-trip time. required
Returns
Name Type Description
IncastResult Offered and net fill bandwidths, dimensionless oversubscription, fill/drain microseconds, and bandwidth-delay product in KB. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: offered = senders * sender_bandwidth; fill_time = buffer / (offered-egress); drain_time = buffer / egress; BDP = egress * RTT.

Assumptions: Offered load exceeds positive egress bandwidth; constant rates during the burst.

Excludes: Congestion control reactions, dropped packets, and finite burst termination.

References

Derivation: offered = senders * sender_bandwidth; fill_time = buffer / (offered-egress); drain_time = buffer / egress; BDP = egress * RTT. This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import IncastModel
>>> IncastModel().solve(2, Q_('1 GB/s'), Q_('1 GB/s'), Q_('1 MB'), Q_('1 ms')).oversubscription == 2
True

TensorParallelCommModel

engine.solvers.interconnect.TensorParallelCommModel()

Activation AllReduces of one tensor-parallel training step.

Each Transformer layer sums an activation-sized partial result across the tensor-parallel group once in the forward pass and once in the backward pass. A ring AllReduce over N devices moves 2(N-1)/N times the payload per device. The bound is bandwidth-only and assumes no overlap with the stated compute time, so the fractions are a diagnostic, not a forecast.

Literature Source: 1. Shoeybi et al. (2019), “Megatron-LM” (two AllReduces per layer per pass). 2. Patarasuk and Yuan (2009), ring AllReduce bandwidth factor.

Methods

Name Description
solve Account for repeated activation collectives in a tensor-parallel step.
solve
engine.solvers.interconnect.TensorParallelCommModel.solve(
    model,
    tp_size,
    microbatch,
    link_bandwidth,
    compute_time,
    seq_len=None,
    collectives_per_layer=2,
)

Account for repeated activation collectives in a tensor-parallel step.

Parameters
Name Type Description Default
model TransformerWorkload Workload with parameter count, dimensions, and weight size. required
tp_size int Positive number of tensor-parallel ranks. required
microbatch int Positive sequences per microbatch. required
link_bandwidth Quantity Positive link bandwidth in byte/s. required
compute_time Quantity Nonnegative local compute time, convertible to seconds. required
seq_len int Positive tokens per sequence; None uses model context length. None
collectives_per_layer int Nonnegative collectives per layer per modeled step. 2
Returns
Name Type Description
TensorParallelCommResult Payload and per-rank traffic in bytes; per-collective, communication, compute, and total step times in milliseconds; dimensionless time shares. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: payload = microbatch * sequence * hidden_dim * FP16_bytes; traffic = 2(N-1)/N * payload; step = compute + layers * collectives_per_layer * traffic / bandwidth.

Assumptions: FP16 activations and serialized bandwidth-only ring collectives; the caller chooses collective count.

Excludes: Startup latency, collective overlap, contention, and model residency.

References

Derivation: payload = microbatch * sequence * hidden_dim * FP16_bytes; traffic = 2(N-1)/N * payload; step = compute + layers * collectives_per_layer * traffic / bandwidth. This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import TensorParallelCommModel
>>> TensorParallelCommModel().solve(Models.Language.Llama3_8B, 2, 1, Q_('100 GB/s'), Q_('1 s'), seq_len=8).communication_time.magnitude > 0
True

TransferLadderModel

engine.solvers.interconnect.TransferLadderModel()

Moves one payload over each tier of a bandwidth hierarchy.

The time on each tier is the bandwidth-only lower bound, bytes / bandwidth; per-message startup latency (the alpha term) is excluded. The ratios between tiers are the bandwidth staircase that decides where each kind of parallel traffic may run.

Methods

Name Description
solve Evaluate bandwidth-only transfer time on each named link.
solve
engine.solvers.interconnect.TransferLadderModel.solve(payload, links)

Evaluate bandwidth-only transfer time on each named link.

Parameters
Name Type Description Default
payload Quantity Nonnegative payload size in bytes. required
links Dict[str, Quantity] Mapping of path names to positive bandwidth quantities in byte/s. required
Returns
Name Type Description
TransferLadderResult Payload bytes, bandwidths, and transfer times in milliseconds per link. Bounds are conditional on the stated assumptions, not deployment guarantees.
Notes

Equation: t_i = payload / bandwidth_i.

Assumptions: Each link carries the same complete payload at constant bandwidth.

Excludes: Startup, contention, protocol overhead, and overlap.

References

Derivation: t_i = payload / bandwidth_i. This combines the supplied quantities by conservation of traffic or residence time; it is an analytical accounting model.

Examples
>>> from mlsysim import Models
>>> from mlsysim.core.units import Q_
>>> from mlsysim.solvers import TransferLadderModel
>>> TransferLadderModel().solve(Q_('1 GB'), {'link': Q_('1 GB/s')}).times['link'].to('s').magnitude == 1
True
Back to top