LESSON READING // 07
RACK-SCALE INFERENCE
Combine four-bit quantization, prefill/decode placement, KV-cache routing, and failure recovery into a rack-scale inference system with explicit state boundaries.
Write down answers as you go; the estimate includes code tracing and practice.
PLAY THE INTERACTIVE LESSON→- 01ORIENT + OBJECTIVES05 MIN
- 02MENTAL MODEL08 MIN
- 03DEEP DIVES15 MIN
- 04CODE TRACE12 MIN
- 05HISTORY + ECOSYSTEM08 MIN
- 06PRACTICE + REVIEW12 MIN
Extend accelerated applications into workflows, networking, and AI infrastructure so analysis covers compute, movement, and orchestration.
This systems synthesis goes beyond CUDA basics: NVFP4 addresses representation, prefill/decode addresses phases, and KV routing/migration addresses networked state.
- Lessons 03, 05, and 06
- KV-cache concepts
- Basic routing and health checks
- Dynamo or TensorRT-LLM (optional)
- Nsight Systems
- Prometheus / request logs
- NIXL / RDMA (advanced)
ORIENT + OBJECTIVES
REMEMBER THIS FIRST
Compression needs scales, placement needs phase awareness, and recovery needs a map of state.
BY THE END, YOU SHOULD BE ABLE TO
- 01
Explain NVFP4 E2M1 values, E4M3 microblock scales, and the FP32 tensor scale.
- 02
Compare aggregated and disaggregated prefill/decode serving on benefit, cost, and workload fit.
- 03
Design cache-, load-, and topology-aware routing decisions.
- 04
Separate worker, token, KV-cache, endpoint, and retry state for recovery.
BUILD THE MENTAL MODEL
- 01COMPRESS
NVFP4 stores E2M1 values, shares an E4M3 scale per 16 values, and adds an FP32 tensor scale for global range.
- 02PLACE
Prefill processes prompts and creates KV cache; decode uses that cache to emit tokens. Their scaling pressures differ.
- 03RECOVER
Worker health, emitted tokens, KV cache, endpoint discovery, and retries are separate state boundaries.
CONCEPT DEEP DIVES
LOW BITS NEED LOCAL RANGE
With only a global scale, outliers squeeze other values. Microblock scales use E2M1's range more effectively.
DISAGGREGATION ADDS A KV PATH
Independent prefill/decode scaling requires explicit KV transfer or exposure; benefits must be benchmarked on real traffic.
REQUEST STATE IS NOT KV CACHE
Migration can preserve emitted tokens and retry metadata, while KV survival depends on backend and fault type.
TWO-LEVEL SCALING SEPARATES LOCAL AND GLOBAL RANGE
E2M1 represents very few values, so a raw cast creates heavy saturation and rounding. NVFP4 uses an E4M3 scale per 16 consecutive values, limiting each outlier's effect to a microblock, then adds an FP32 tensor scale for global range beyond the micro-scales.
Finer scales add metadata, quantization logic, and layout constraints. Quality still depends on distributions, calibration or training, and operator support. Four-bit storage can reduce movement without becoming a validation-free replacement.
PAUSE AND REASONWhy add an FP32 tensor scale beyond the E4M3 scale per 16 values?+
REFERENCE ANSWERE4M3 micro-scales have limited range; the FP32 level covers the tensor's global scale and avoids scale overflow.
PREFILL AND DECODE HAVE DIFFERENT RESOURCE CURVES
Prefill processes prompt tokens in larger matrix work and creates KV cache. Decode emits small numbers of tokens repeatedly while reading accumulated KV state, making concurrency, output length, and cache capacity central. Aggregated workers are simple, but long prompts can interfere with ongoing decode.
Disaggregation independently sizes the pools and parallelism, but adds KV transfer to the critical path. It wins only when phase isolation and scaling outweigh movement and orchestration. Benchmark real prompt/output distributions against an aggregated baseline.
PAUSE AND REASONIs disaggregation always faster for short prompts, short outputs, and low single-node load?+
REFERENCE ANSWERNo. KV transfer and routing add fixed cost, so a simple aggregated worker may be better.
RECOVERY STARTS WITH A STATE MAP
A streaming request can include the original prompt, sampling parameters, emitted tokens, random state, KV location, current worker, and retry count. Some state lives at the frontend, some in cache services, and some only in failed VRAM. Recovery must name the source of each item.
Request migration can move emitted-token and request metadata to a healthy worker. KV may survive remotely, require transfer, or need recomputation. Health checks must remove bad endpoints, and retry limits prevent failure storms and duplicate output.
PAUSE AND REASONDo saved emitted tokens guarantee cost-free decode recovery?+
REFERENCE ANSWERNo. The new worker still needs matching KV cache; without it, the system must transfer or recompute prefill.
PUT IT BACK INTO CODE
01prefill = router.pick_prefill(prompt, cache_overlap)02kv_meta = prefill.run(prompt)03decode = router.pick_decode(load, topology)04stream = decode.resume(kv_meta, emitted_tokens)05if decode.unhealthy():06 migrate(request_state, healthy_worker, retry_limit)TRACE THE CODE
- 01PREFILLSELECT BY CACHE OVERLAP + LOAD
Prefix overlap can save work, but queue depth and topology remain part of estimated completion time.
- 02KV METAPASS LOCATION AND FORMAT
Metadata names blocks, endpoints, model version, dtype, and layout so decode can receive compatible state.
- 03DECODEBALANCE LOAD AND TOPOLOGY
The emptiest worker may still be poor if the KV path crosses an expensive link.
- 04MIGRATEMOVE REQUEST STATE WITH A RETRY LIMIT
Remove the bad endpoint, preserve emitted position, recover KV, and prevent duplicated stream fragments.
KNOWLEDGE ATLAS
OPTIONAL REFERENCE · REVISIT AS NEEDED · OUTSIDE THE CORE 60 MINUTES
CORE VOCABULARY
- NVFP4
- A 4-bit floating recipe for Blackwell Tensor Core paths, using fine local scales plus a higher-level scale to manage range.
- Prefill
- Processes the prompt and produces state and KV cache; it is typically more compute intensive.
- Decode
- Reuses KV cache to generate tokens iteratively and is often constrained by memory capacity, bandwidth, and concurrency.
- KV Cache
- Stored key/value state per layer that prevents recomputing the full context for every new token.
- TTFT / ITL
- Time to first token and inter-token latency, capturing startup experience and ongoing generation cadence.
WORKED EXAMPLE
- 01SUBSTITUTE
2 × 32 × 8 × 128 × 4,096 × 2 = 536,870,912 bytes.
- 02CONVERT CAPACITY
That is about 512 MiB per request; eight equal requests need about 4 GiB before overhead.
- 03BOUND TRANSFER
At an effective 100 GB/s, the ideal lower bound for 512 MiB is about 5 ms; reality is slower.
DIAGNOSTIC PLAYBOOK
High TTFT while prefill GPUs are idle
- INSPECT FIRST
- Queueing, routing, cache misses, transfer path, and network fallback
- EVIDENCE
- A request-ID trace from queue → prefill → transfer → decode
ITL degrades rapidly with concurrency
- INSPECT FIRST
- Decode batch, KV capacity/bandwidth, fairness, and output length
- EVIDENCE
- ITL by concurrency/output bucket, KV use, and batch duration
Disaggregated throughput loses to baseline
- INSPECT FIRST
- KV bytes, fabric bandwidth, cross-domain path, and pool ratio
- EVIDENCE
- Same-traffic comparison plus the actual transfer protocol and bandwidth
HARDWARE → ECOSYSTEM
- 01AGGREGATED INFERENCE
Prefill, KV state, and decode shared one worker.
The path was simple but phases could not scale independently. - 02PAGED KV + CACHE-AWARE ROUTING
KV became block-managed and routing considered locality plus active load.
Scheduling became central to avoiding repeated prefill and memory waste. - 03RACK-SCALE DISAGGREGATION
Prefill/decode pools move KV through paths such as NIXL.
Compute, memory, fabric, discovery, and recovery jointly determine experience.
HARDWARE + ECOSYSTEM COORDINATE
Blackwell introduced FP4 acceleration paths and finer-grained scaling; NVL72 organizes multiple compute trays into a rack-scale NVLink domain. Software such as Dynamo and TensorRT-LLM handles routing, cache movement, parallel configuration, and recovery.
PRACTICE + REVIEW
A decode worker fails after emitting three tokens. Which two state categories must recovery distinguish?
- A. Emitted tokens and KV cache
- B. CSS and fonts
- C. Block count and CPU core count
REVEAL ANSWER+
Tokens prevent duplicate output, while KV cache may need rebuilding or retransmission. They are not the same recovery object.
With a few large outliers, which more strongly compresses ordinary small values: one global scale or microblock scales?
HINT+
Which values set the whole range?
REFERENCE ANSWER+
One global scale. Outliers control every value's range, while microblock scales localize their influence.
Prefill is idle and decode saturated. Does adding prefill workers help?
HINT+
Identify the bottleneck phase.
REFERENCE ANSWER+
Usually not. Scale or optimize decode, routing, batching, parallelism, or KV capacity instead.
Worker A has 80% prefix cache but high load; B has no cache and is idle. Always choose A?
HINT+
This is a multi-objective estimate.
REFERENCE ANSWER+
No. Compare saved prefill work with queue delay and KV/topology cost; route by estimated completion, not one score.
Decode fails after three tokens. List at least five recovery steps.
HINT+
Endpoint, request, token cursor, KV, retry.
REFERENCE ANSWER+
Remove the endpoint; freeze request/token cursor; choose a healthy worker; locate, transfer, or rebuild KV; restore sampling/retry state; deduplicate output; fail clearly at the retry limit.
OPTIONAL HANDS-ON LAB
OUTSIDE THE CORE 60 MINUTES · REQUIRES A SUITABLE CUDA / GPU ENVIRONMENT
LAB GOAL
BUILD AN OBSERVABLE PREFILL→KV→DECODE REQUEST TRACE
Compare aggregated and disaggregated serving across queue, prefill, KV transfer, decode, and recovery state.PROCEDURE
- 01
Capture aggregated baseline TTFT, ITL, total latency, and KV use by prompt/output length.
- 02
When supported, separate pools and log workers, cache overlap, KV bytes, and transfer time.
- 03
Inject a decode-worker failure and record discovery removal, token cursor, KV handling, and retries.
- 04
Compare short/long prompt and output groups rather than one average.
Submit one complete trace, an aggregated/disaggregated table, and a recovery-state map; a deterministic simulator is acceptable without serving GPUs.
Design a routing score combining cache overlap, queue delay, and transfer cost, then test three counterexamples.