Pidoku

Fault Tolerance and Failure Modes

Module 23 Lesson 23.e 1h 15m Difficulty 4/5

Prerequisites 20.e, 9.h


Before you start: words you need#

WordPlain meaning
Blast radiusHow much breaks when one thing fails: one GPU, one replica, one node, the whole service.
Xid errorA numbered error the NVIDIA driver writes to the kernel log when a GPU hits a problem. The number says what kind.
ECCError-correcting code in GPU memory. It fixes single-bit errors; a double-bit error cannot be fixed.
CollectiveAn operation all GPUs in a group must join, such as all-reduce (9.f). If one GPU never arrives, the rest wait.
HangA process that is alive but makes no progress. It holds its GPUs and answers nothing.
WatchdogA timer that kills a process when it stops reporting progress.
Circuit breakerA switch in front of a dependency that stops calling it after repeated failures, then tries again later.
CordonMark a Kubernetes node so no new work is scheduled on it.

1. What is it?#

Fault tolerance is keeping the service inside its SLO (23.a) while parts of it fail. For an inference fleet that means knowing the failure modes, limiting how much each one breaks, detecting it fast, and recovering automatically, within limits.

FAILURE                        HOW OFTEN*   BLAST RADIUS              DETECTION
GPU Xid error                  weeks        1 GPU → its TP group      kernel log, DCGM
GPU falls off the bus (Xid 79) months       1 node                    nvidia-smi fails
uncorrectable ECC (Xid 48)     months       1 GPU                     DCGM, kernel log
driver or GSP hang             months       1 node                    every CUDA call hangs
collective hang (one rank)     weeks        1 TP/PP group             timeout, watchdog
out of memory                  days–weeks   1 replica                 exception or SIGKILL
model fails to load            per deploy   1 replica                 readiness never passes
network partition (multi-node) months       1 instance                NCCL error or hang
spot node reclaimed            hours        1 node                    cloud notice
bad deployment                 per deploy   everything                canary (23.g)
quality regression             per deploy   everything                hard (23.g, 23.h)
dependency down (auth, Redis)  varies       varies                    circuit breaker
traffic beyond capacity        weekly       everything                queue wait (23.d)

* order of magnitude for a fleet of a few hundred GPUs; measure your own

The two that are specific to LLM serving and do the most damage are collective hangs and quality regressions. Both are hard to see, and both keep holding resources while broken.


2. Why does it matter?#

  • GPUs fail more than CPUs. Large training runs report hardware interruptions every few hours across tens of thousands of GPUs. Inference fleets see the same hardware, spread over more, smaller jobs.
  • A replica is big. One TP=8 replica is 8 GPUs; one wide-EP MoE deployment may be dozens. When one GPU fails, all of them stop serving.
  • Silent failures are the expensive ones. A crashed process is restarted in a minute. A hung one can hold 8 GPUs for hours while the load balancer keeps sending it traffic.

3. Simple analogy#

A rowing eight. If one rower faints, the boat stops, however fit the other seven are; that is a tensor-parallel group. If the boat simply drifts because the cox has fallen asleep, nobody on shore notices for a long time; that is a hang. The coach needs a rule (“if the boat has not moved in two minutes, go and get them”) and a spare boat, not eight spare rowers.


4. Tiny example: why the rate limiter should fail open#

The gateway checks every request against a quota store in Redis. Redis restarts and is down for 40 seconds.

FAIL CLOSED   every request rejected for 40 s → 40 s of total outage
FAIL OPEN     every request allowed for 40 s, with a conservative local limit
              → a few tenants briefly go over quota; nobody is refused

Over-quota traffic for 40 seconds is a small cost. A full outage is not. The decision is the reverse for authentication: allowing unauthenticated traffic for 40 seconds is a security incident. Each dependency needs its own written decision.


5. Technical explanation#

Design principles#

1. FAIL FAST, NOT SLOW      a hung process holding 8 GPUs is worse than a crashed one
                            → timeouts and watchdogs everywhere
2. LIMIT THE BLAST RADIUS   data-parallel replicas fail alone; a TP group fails together
                            → more, smaller replicas where latency allows (14.a)
3. DEGRADE, DON'T COLLAPSE  shed load on purpose (23.d) instead of queueing until everything fails
4. MAKE FAILURE VISIBLE     a slow, sick replica is worse than a dead one: it still gets traffic
5. RECOVER AUTOMATICALLY,   restart with backoff, and stop after N restarts in M minutes
   BUT BOUNDED
6. FAIL REQUESTS CLEANLY    an in-band error, not a stream that silently stops

GPU failures#

Shell
# where to look
dmesg -T | grep -i xid
nvidia-smi -q -d ECC,ROW_REMAPPER
dcgmi health -c          # DCGM health check; DCGM_FI_DEV_XID_ERRORS in the exporter

NVIDIA’s Xid catalog gives each code a recommended action. The common ones:

XidMeaningNVIDIA’s immediate actionWhat it usually means for you
13, 31graphics engine exception; GPU memory page faultrestart the applicationusually a software bug (bad kernel, bad address)
43GPU stopped processingnone; GPU stays healthyan application fault
48double-bit ECC errorGPU reset or node reboothardware: the GPU needs attention
63row-remapping eventnonememory repaired a bad row; track the count
64row-remapping failurereset the GPU, contact supportmemory is degrading: plan replacement
74NVLink errorreset or reboota link, cable or switch problem
79GPU has fallen off the busreboot the machine, contact supportnode unusable until repaired
94 / 95contained / uncontained memory errorrestart the app / reset the GPU95 affects every process on the GPU
119, 120GSP timeout / GSP errorreset the GPUfirmware or driver; check versions
154GPU recovery action changedfollow the accompanying Xidnvidia-smi reports the action needed (none, reset, reboot)

The response splits three ways:

software (13, 31, 43, 94)       restart the process; investigate the bug
hardware (48, 64, 74, 79, 95)   cordon the node, drain it, reset or repair
degrading (63 count rising, 92: high single-bit error rate) schedule replacement; keep watching

Automate the cordon. A node with uncorrectable errors will keep failing, and every failure is another incident. 21.l covers node health checks and the cordon-repair-return cycle.

Collective hangs: the LLM-specific one#

SYMPTOM   a TP or PP group stops producing tokens. No error, no crash.
          every rank sits inside a collective, waiting for one that never arrives.
          8 or 16 GPUs are held indefinitely; queue depth grows; throughput is zero.

CAUSES    one rank crashed (the rest wait forever)
          one rank is descheduled or throttled (CPU limits, 3.j)
          a network partition between nodes
          a driver or GSP problem on one GPU
          mismatched collective order (a code bug)

Detection, from inside out:

1. collective timeout   PyTorch process groups take a timeout (minutes by default). With
                        TORCH_NCCL_ASYNC_ERROR_HANDLING (default 3 in current PyTorch) the
                        watchdog aborts the communicators and tears the process down on timeout.
2. watchdog of the      TORCH_NCCL_ENABLE_MONITORING with TORCH_NCCL_HEARTBEAT_TIMEOUT_SEC
   watchdog             kills the process if the NCCL watchdog thread itself gets stuck.
3. engine step          an application watchdog: no engine step in N seconds → exit.
   watchdog             Needed because inference engines replay CUDA graphs and use custom
                        all-reduce kernels, where a hang may never reach a PyTorch timeout.
4. from outside         health check that sends a tiny generation, not just "is the port open";
                        alert on queue growing while tokens/s is zero.

Response: kill every rank of the group (there is no partial recovery for a broken communicator), restart the group, and cordon the node if it happens again on the same hardware.

Go
// StepWatchdog: the engine loop calls Beat after every step. If no step completes
// within the timeout, the process exits hard and the supervisor restarts the whole group.
type StepWatchdog struct {
	last    atomic.Int64 // unix nanoseconds of the last engine step
	timeout time.Duration
}

func NewStepWatchdog(timeout time.Duration) *StepWatchdog {
	w := &StepWatchdog{timeout: timeout}
	w.Beat()
	go func() {
		for range time.Tick(10 * time.Second) {
			if idle := time.Since(time.Unix(0, w.last.Load())); idle > w.timeout {
				slog.Error("watchdog: no engine step, aborting", "idle", idle)
				os.Exit(1) // hard exit: a hung process may not shut down cleanly
			}
		}
	}()
	return w
}

func (w *StepWatchdog) Beat() { w.last.Store(time.Now().UnixNano()) }

Only beat when there was work: an idle engine with an empty queue is not hung. Set the timeout above your slowest legitimate step (a long chunked prefill at full batch), not at the median.

In-flight requests when a replica dies#

the client sees    a connection reset (non-streaming)
                   a stream that stops part-way (streaming) ← worse: partial output

mitigations
  1. send an in-band error before exiting, when you can:
       data: {"error": {"message": "replica failed", "type": "server_error"}}
  2. clients treat a stream with no final event ([DONE] or finish_reason) as failed
  3. do not silently retry a streamed request: the user has already seen part of it
  4. a non-streaming request may be retried once the original is known to be dead,
     within the retry budget (20.e)

Moving a live generation to another replica needs its KV cache, or a re-prefill of the prompt plus the tokens generated so far. The gateway knows both, so “continue on another replica” can be built; KV transfer machinery exists for disaggregation (14.k), but it is rarely wired up for failover. For most services, fail the request cleanly and let the client retry.

Dependencies and circuit breakers#

A gateway depends on several services. Decide, for each, what happens when it is down:

auth             fail CLOSED, with a short-lived cache of recent validations to ride out blips
rate-limit store fail OPEN with a conservative local limit, and alert
model registry   cache aggressively; it changes rarely
safety filter    a policy decision: fail closed for high-risk use, or fall back to a cheaper
                 local check
an engine        circuit-break it, route elsewhere
retrieval / RAG  serve without context, or fail: depends on whether the answer is useful without it

A circuit breaker stops calling a dependency after repeated failures (open), fails those calls immediately, and after a cooldown lets one trial call through (half-open). Success closes it; failure opens it again. The router’s version of this is outlier ejection: take a replica out of the pool after consecutive errors or slow responses, and send its traffic to the others (20.f covers the balancing itself).

Testing failure: game days#

Practise each of these on purpose, in a test environment first:

1. kill one replica under load
     expect: removed from the pool, its requests fail cleanly, no cascade
2. freeze one rank of a TP group (kill -STOP)
     expect: watchdog fires within N seconds, all ranks restart, readiness gates traffic
3. send max-length requests until the KV cache is full
     expect: preemption, then admission rejections (503/429), no OOM
4. saturate the network between nodes
     expect: slower collectives, then the watchdog, or graceful slowdown
5. stop the rate-limit store
     expect: fail open with the local limit; an alert
6. deploy a deliberately broken model
     expect: readiness never passes; the rollout halts; no traffic moved
7. send 3× capacity
     expect: fast 429/503 with Retry-After; served requests keep their SLO; full recovery when load
     drops, with no metastable state (20.e)

Few teams have ever run 2 or 7, and those are the ones behind real incidents.


6. Under the hood#

A circuit breaker with all three states, driven by a replica that fails between t=10 s and t=70 s.

Go
// breaker.go — a circuit breaker in front of one replica: closed, open, half-open.
package main

import (
	"errors"
	"fmt"
	"time"
)

var errOpen = errors.New("circuit open: not calling the replica")

type state int

const (
	closed   state = iota // calls go through
	open                  // calls fail fast without touching the replica
	halfOpen              // one trial call decides whether to close again
)

func (s state) String() string { return [...]string{"closed", "open", "half-open"}[s] }

type breaker struct {
	st        state
	failures  int
	threshold int           // consecutive failures that open the circuit
	cooldown  time.Duration // how long to stay open before a trial call
	openedAt  time.Time
}

// call runs fn unless the circuit is open. now is passed in so the demo is deterministic.
func (b *breaker) call(now time.Time, fn func() error) error {
	if b.st == open {
		if now.Sub(b.openedAt) < b.cooldown {
			return errOpen
		}
		b.st = halfOpen // cooldown over: allow one trial
	}
	if err := fn(); err != nil {
		b.failures++
		if b.st == halfOpen || b.failures >= b.threshold {
			b.st, b.openedAt = open, now
		}
		return err
	}
	b.st, b.failures = closed, 0
	return nil
}

func main() {
	b := &breaker{threshold: 3, cooldown: 30 * time.Second}
	start := time.Date(2026, 11, 12, 10, 0, 0, 0, time.UTC)

	// The replica is broken (e.g. a hung engine returning 503) from t=10s until t=70s.
	healthy := func(t time.Duration) bool { return t < 10*time.Second || t >= 70*time.Second }

	for t := time.Duration(0); t <= 110*time.Second; t += 5 * time.Second {
		called := false
		err := b.call(start.Add(t), func() error {
			called = true
			if !healthy(t) {
				return errors.New("503 from replica")
			}
			return nil
		})
		result := "ok"
		if err != nil {
			result = err.Error()
		}
		fmt.Printf("t=%3.0fs  replica called: %-5v  %-38s state=%v\n", t.Seconds(), called, result, b.st)
	}
}

Output:

t=  0s  replica called: true   ok                                     state=closed
t=  5s  replica called: true   ok                                     state=closed
t= 10s  replica called: true   503 from replica                       state=closed
t= 15s  replica called: true   503 from replica                       state=closed
t= 20s  replica called: true   503 from replica                       state=open
t= 25s  replica called: false  circuit open: not calling the replica  state=open
t= 30s  replica called: false  circuit open: not calling the replica  state=open
t= 35s  replica called: false  circuit open: not calling the replica  state=open
t= 40s  replica called: false  circuit open: not calling the replica  state=open
t= 45s  replica called: false  circuit open: not calling the replica  state=open
t= 50s  replica called: true   503 from replica                       state=open
t= 55s  replica called: false  circuit open: not calling the replica  state=open
t= 60s  replica called: false  circuit open: not calling the replica  state=open
t= 65s  replica called: false  circuit open: not calling the replica  state=open
t= 70s  replica called: false  circuit open: not calling the replica  state=open
t= 75s  replica called: false  circuit open: not calling the replica  state=open
t= 80s  replica called: true   ok                                     state=closed
t= 85s  replica called: true   ok                                     state=closed
t= 90s  replica called: true   ok                                     state=closed
t= 95s  replica called: true   ok                                     state=closed
t=100s  replica called: true   ok                                     state=closed
t=105s  replica called: true   ok                                     state=closed
t=110s  replica called: true   ok                                     state=closed

Three failures open the circuit. The trial at t=50 s fails, so it opens again for another 30 seconds. The replica recovered at t=70 s, but traffic returns only at t=80 s, on the next trial: the cooldown trades a little lost capacity for not hammering a sick replica. In a real router, the requests refused here go to another replica rather than to the user.


7. Performance implications#

  • Bigger groups, bigger blast radius. A TP=8 replica loses all 8 GPUs to one fault; wide expert parallelism across dozens of GPUs loses all of them. Use the smallest parallel group that meets the latency target (14.a, 14.m).
  • Recovery time is cold-start time. A restarted group must reload weights and warm up (20.h); that is the real MTTR.
  • Spare capacity is performance insurance. N+1 (23.b) is what keeps the SLO while a group restarts.
  • Health checks cost a little. A real generation every 10 seconds per replica is cheap; a port check that misses hangs is expensive.

8. Production implications#

  • Set collective timeouts and an engine-step watchdog. Hangs are worse than crashes.
  • Automate cordoning on hardware Xids (21.l).
  • Use the smallest blast radius latency allows.
  • Write down fail-open or fail-closed for every dependency.
  • Fail in-flight requests cleanly, with an in-band error.
  • Run game days quarterly on the seven scenarios.
  • Track MTTR per failure mode, not just availability.
  • Cap restarts: a replica restarted 5 times in 10 minutes should stay down and page someone.
  • Keep driver, firmware and engine versions consistent across the fleet; mixed versions turn one bug into many different-looking failures.

9. Common mistakes#

  1. No collective timeout or watchdog. A hang holds 8–16 GPUs indefinitely.
  2. Restarting one rank of a TP group. The others still hang.
  3. Port-only health checks. A hung engine still accepts connections.
  4. Leaving failed nodes in the pool. Repeat incidents from the same hardware.
  5. Silently retrying streamed requests. Duplicate or garbled output.
  6. Fail-closed rate limiter. A Redis blip becomes a full outage.
  7. Never testing failure. The first run of the recovery path is during an incident.
  8. Unbounded crash loops. GPUs cycling forever, and alert noise.

10. Hands-on exercise#

  1. Run breaker.go. Change the cooldown to 10 s, then 60 s. How many trial failures and how many lost seconds of a healthy replica does each give?
  2. Add the step watchdog to an engine or a toy loop. Freeze it with kill -STOP and check that it exits within the timeout.
  3. Write a script or DaemonSet that watches for hardware Xids and cordons the node. Test it with a simulated log line.
  4. For a service you know, list every dependency with its fail-open or fail-closed decision and the reason.
  5. Kill an engine mid-stream and check that the client receives a structured error, not a silent stop.
  6. Compare the requests lost when one GPU fails in one TP=8 replica versus eight TP=1 replicas of a model that fits on one GPU.

11. Interview questions#

  1. What happens when one rank of a TP group fails? How do you handle it?
  2. Why is a hang worse than a crash for a GPU workload, and how do you detect one?
  3. What is an Xid error? Which ones mean hardware, and what do you do?
  4. Should the rate limiter fail open or closed? Should auth?
  5. Can you move an in-flight generation to another replica? What would it take?
  6. Design a game day for an inference service.
  7. How does the parallelism strategy change the blast radius?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in