advanced25 min studyLesson 364 in Engineering

Topology and affinity constraints

Treat device locality, communication, and failure-domain requirements as explicit constraints with measurable tradeoffs.

On this page

What you’ll understand

  • Distinguish hard placement requirements from soft preferences.
  • Check topology-domain capacity rather than cluster-wide totals.
  • Explain why colocation and spreading optimize different concerns.

Four free accelerators do not necessarily form the four-accelerator placement a training job needs. Devices may span hosts, interconnect islands, racks, or incompatible generations. Meanwhile an inference service may deliberately spread replicas across failure domains. Scheduling must encode which locality properties are required and which are preferences, then evaluate the resulting performance and resilience tradeoff rather than treating every free device as interchangeable.

Capacity lives inside domains

A topology hierarchy can include device, NUMA domain, host, rack, and zone. A workload may require all workers in one domain or a particular distribution across several domains. Count compatible available resources within those boundaries. Cluster-wide totals are necessary in many cases but insufficient: four free GPUs split two per rack cannot satisfy a four-GPU single-rack requirement. Storage and network-device attachment can introduce another placement restriction even when accelerator and CPU counts fit.

Hard affinity or selection rules exclude placements; soft preferences rank otherwise feasible candidates. The difference matters during shortages. A preferred rack may be relaxable by policy, while a required device capability cannot be ignored without changing the workload contract. Keep labels authoritative and inspect which component maintains them. An incorrectly labeled node can satisfy the scheduler’s symbolic test while violating the actual hardware requirement. Explain pending decisions using both the requested domain and the inventory the scheduler observed.

∃d∈D:∑n∈dgn≥G\exists d\in\mathcal D:\quad\sum_{n\in d}g_n\geq G
For a job requiring G compatible GPUs inside one allowed domain d, the summed available count g_n must meet that need. This is only a necessary domain-capacity condition; per-worker placement, other resources, and connectivity can still prevent admission.↔ Scroll wide equations horizontally.

Locality and resilience pull in different directions

Colocating tightly communicating training workers can reduce cross-domain traffic, but the actual improvement depends on the collective pattern, interconnect, and competing workloads. Spreading inference replicas can reduce exposure to one node or zone failure while increasing communication or data-access cost. A topology-spread rule expresses distribution, not a universal availability proof. Shared dependencies can still fail across every chosen domain, and a healthy replica may lack enough capacity to absorb displaced traffic.

Co-scheduled jobs can interfere through links, host memory bandwidth, storage, and device sharing. Model communication demand separately from GPU count when it is material. Measure placement-sensitive iteration time or request latency under representative contention before hardening a preference into a requirement. A rigid constraint can strand substantial capacity, while a soft rule may allow performance variance. Document which degradation is acceptable and whether the application can adapt its parallelism when the ideal topology is unavailable.

Ttransfer≥DBeffT_{\mathrm{transfer}}\geq\frac{D}{B_{\mathrm{eff}}}
Transferring D bytes across a bottleneck with sustained effective bandwidth B_eff bytes per second takes at least D/B_eff seconds in this ideal bound. Startup, protocol, synchronization, and contention can add time; bandwidth is not implied solely by a rack label.↔ Scroll wide equations horizontally.

Test topology failures rather than only totals

Exercise missing labels, one unavailable interconnect island, local storage restricted to a host, and affinity rules that contradict one another. A placement failure can be a correct rejection of inconsistent requirements rather than a scheduler bug. Verify replacement behavior when a replica fails: surviving capacity must satisfy the same relevant domain rules, or the recovery policy must explicitly relax them. Track how long jobs wait for preferred topology and whether that preference improves the intended workload metric enough to justify the delay.

The reliability lab deliberately omits topology. Reset, set replica count to 5 and unavailable count to 2, predict the remaining count, then Step. Repeat from Reset with both replica count at 5 and unavailable count at 3. The majority indicator reflects counts only. Describe two possible placements of the same available replicas across zones and explain why their correlated-failure exposure can differ. The instrument draws neither zones nor links and cannot validate affinity, network performance, or a failure-domain guarantee.

Count GPUs in the required rack

A job needs four compatible GPUs within one rack. Rack A has three free and rack B has two free. No migration, cross-rack execution, or preemption is allowed. Later, one compatible GPU in A becomes free.

  1. Initially total free capacity is 3 + 2 = 5 GPUs, exceeding the job’s four-GPU total demand. That aggregate count does not satisfy the single-rack rule.

  2. A has only three and B only two, so neither allowed domain reaches four. The correct initial decision is to wait or reject under the stated contract.

  3. After the release, A has four and the domain-count test passes there. Verify per-worker host fit, memory, and interconnect requirements before concluding the whole job is feasible.

The result

Topology can block a job despite sufficient cluster-wide capacity. Passing a domain-count check remains only part of placement feasibility.

Explore the model

Interactive lab

Interactive lab · reliability

Counts omit failure domains

Reset, set replica count n = 5 and unavailable count k = 2, predict available replicas, then Step. Compare a fresh Reset with both n = 5 and k = 3. The instrument has no zones or interconnects; its majority count does not validate topology.

Counts omit failure domainsA replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Current readings: Available replicas: 4 of 5; Majority needed: 3; Majority available?: Yes. All parameters are adjustable with the labeled controls below.Majority available · need 3 of 5Playback highlights fixed statesR1 · upR2 · upR3 · upR4 · upR5 · downCyan mark: majority threshold
AvailableUnavailableMajority threshold
Available replicas
4 of 5
Majority needed
3
Majority available?
Yes
t = 0 s

A replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forEqual availability counts can conceal very different placements and correlated-failure risks.

Check your understanding

A training job requires four compatible GPUs in one rack. Two racks each have two free GPUs. Which conclusion is justified?

Try it yourself

A workload moves 8 GB of decimal data across an effective 40 GB/s bottleneck. Compute the ideal transfer lower bound. If a different placement provides only 20 GB/s, recompute and name two costs omitted from both estimates.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use bytes with the same decimal prefix so the ratio is seconds.

Compare with the solution

The lower bounds are 8/40 = 0.2 seconds and 8/20 = 0.4 seconds. Startup latency, collective synchronization, protocol overhead, and interference can add time. These are bottleneck movement bounds, not measured job runtimes or guarantees that a topology label provides the assumed bandwidth.

Take it with you

  • Placement feasibility depends on capacity inside required topology domains.
  • Hard constraints, soft preferences, colocation, and spreading serve different policies.
  • Counts and labels need validation against real hardware, dependencies, and workload behavior.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.