Worked examples — Neural processing units (NPUs)
6.5.8 · D3· Hardware › Advanced & Emerging Architectures › Neural processing units (NPUs)
Yeh page Neural processing units (NPUs) ko har possible case class ke through drill karti hai jo is topic mein aa sakti hai: full arrays, half-filled arrays, chote degenerate layers, pipeline fill/drain edge, memory-bound limit, aur precision trade-offs. Hum har number scratch se banate hain — koi bhi formula ya jargon tab tak use nahi hota jab tak hum uska matlab yahan, isi page par, explain na kar den.
The scenario matrix
Kuch bhi work karne se pehle, yeh map hai har case ka jo ek NPU throughput/efficiency problem mein aa sakti hai. Neeche har worked example ko us cell ke saath tag kiya gaya hai jo woh cover karta hai.
| Cell | Case class | Kya tricky banata hai | Example |
|---|---|---|---|
| A | Full array, perfect fit | "Textbook" peak — baseline | Ex 1 |
| B | Partial columns/rows used | Utilisation 100% se neeche girti hai | Ex 2 |
| C | Layer bigger than array (tiling) | Ek pass kaafi nahi; array ko loop karo | Ex 3 |
| D | Pipeline fill/drain overhead | Small layer → latency throughput pe dominate karti hai | Ex 4 |
| E | Degenerate input (, ya ) | Length 1 ka dot product; array mostly idle | Ex 5 |
| F | Memory-bound limit (roofline) | Compute fast hai par data aa nahi sakta | Ex 6 |
| G | Precision trade (int8 vs fp32) | Same silicon, alag MAC count | Ex 7 |
| H | Real-world word problem | Phone-chip spec ko numbers mein translate karo | Ex 8 |
| I | Exam twist (solve for unknown) | TOPS diya, missing clock/size nikalo | Ex 9 |
Teen quantities jo hum har jagah reuse karte hain
Har example inhi teen ideas mein plug hota hai. Hum har ek ko plain words mein state karte hain pehle, symbols use karne se pehle.
Ek dataflow jo hum Example 4 se pehle define karna chahte hain: weight-stationary
Ab scenarios.
Example 1 — Cell A: full array, perfect fit
Recall Forecast first
Padhne se pehle guess karo: kya yeh 1 TOPS, 100 TOPS, ya 10000 TOPS ke kareeb hai? Tumhara guess ::: Lagbhag 131 TOPS — width kaam karta hai, clock nahi.
Step 1 — PEs count karo. multiply-accumulators. Yeh step kyun? Peak throughput matlab "sab ek saath kaam karte hain," toh pehle hum count karte hain ki kitne calculators exist karte hain.
Step 2 — Ek MAC = do ops. Har PE 1 MAC/cycle = 2 ops/cycle karta hai. Yeh step kyun? TOPS operations count karta hai, aur ka factor mult + add se aata hai (upar define kiya).
Step 3 — Clock se multiply karo. Yeh step kyun? Clock matlab "cycles per second," toh ops/s = ops-per-cycle × cycles-per-second.
Step 4 — TOPS mein convert karo ( ops/s).
Recall Verify karo
Ek single-MAC CPU at 3 GHz ops/s karta hai. Ratio — array ~22000× wider-per-second hai. Units check: (PEs)(ops/PE/cycle)(cycles/s) = ops/s. ✓
Example 2 — Cell B: partial array (utilisation < 100%)
Recall Forecast
Agar aadhe PEs dead weight hain, effective throughput hona chahiye… ::: peak ka aadha.
Step 1 — Peak (sab PEs). Yeh step kyun? Peak hardware se fixed hai, layer se nahi — yeh ceiling hai.
Step 2 — Kitne PEs busy hain? Sirf 64 columns loaded hain → of PEs active. Yeh step kyun? Utilisation = busy ÷ total; ek unloaded column clock chahe kuch bhi ho zero MACs contribute karta hai.
Step 3 — Utilisation.
Step 4 — Effective TOPS. Yeh step kyun? Real speed = ceiling × ceiling ka woh fraction jo actually reach hoti hai.

Recall Verify karo
Figure mein 64 lit columns, 64 dark dikhte hain → lit fraction . Effective = 32.8 TOPS, exactly 65.5 ka aadha. ✓
Example 3 — Cell C: layer bigger than the array (tiling)
Recall Forecast
Output hai. Isme kitne output blocks fit hote hain? ::: tiles.
Step 1 — Formula se total MACs. Yahan : Yeh step kyun? Total arithmetic hardware se independent hai — yeh math ki property hai.
Step 2 — Output tiles. Output hai. Array ek residency mein output block produce karta hai. Tiles . Yeh step kyun? Jab matrix grid se bada hota hai, hum grid ko sub-blocks par loop karte hain (tiling). Har tile ek full array residency hai.
Step 3 — MACs per tile. Har output block () par sum karta hai: . Times 4 tiles . ✓ Step 1 se match karta hai. Yeh step kyun? Cross-check karo ki tiling total work nahi badlata — yeh sirf time mein split karta hai.
Recall Verify karo
, ke barabar. Tiling work conserve karta hai. ✓
Example 4 — Cell D: pipeline fill and drain on a small layer
Recall Forecast
Agar fill mein ~256 cycles lagte hain aur drain mein ~256 aur, lekin sirf 16 rows real data flow karta hai, toh kya array mostly kaam kar raha hai ya mostly start/stop ho raha hai? ::: Zyaadatar overhead — fill + drain 16 ko dwarf karte hain.
Step 1 — Fill latency. Data ko array width traverse karna hai: 256 cycles pehle full result aane se pehle. Yeh step kyun? Fill definition se: wavefront ko (array-width) hops chahiye far edge tak pahunchne ke liye.
Step 2 — Real data stream karna. Ek baar fill hone par, rows mein se har ek ka 1 aur cycle cost hoti hai: 16 cycles useful streaming ke. Yeh step kyun? Pipe full hone ke baad, throughput 1 row/cycle hai — yeh sirf "full speed" phase hai.
Step 3 — Drain latency. Last row inject hone ke baad, uske partial sums ko ab bhi far edge se bahar walk karna hai: 256 cycles drain. Yeh step kyun? Drain definition: wave ki tail ko exit karna hota hai pehle ki last answer complete ho. Isse ignore karna true latency ko undercount karta hai.
Step 4 — Total cycles aur overhead fraction. Yeh step kyun? Yeh honest "small layer" penalty hai: 97% cycles fill+drain hain, full-throughput work nahi.
Recall Verify karo
. Sanity: ek bada layer () overhead deta hai — negligible. Fill+drain sirf small layers ko hurt karta hai. ✓
Example 5 — Cell E: degenerate input (, aur )
Recall Forecast
ke saath, har output sirf ek multiply hai (koi accumulation nahi). Kya array ki depth (accumulation direction) madad karti hai? ::: Nahi — depth collapse ho ke 1 ho jaati hai, toh woh poora dimension waste hota hai.
Step 1 — Total MACs. : Yeh step kyun? Ek degenerate layer bhi har output ko ek baar touch karti hai.
Step 2 — Total cycles = fill + compute + drain. Inject karne ke liye sirf row of activation hai, toh useful streaming 1 cycle hai. Uske around 256-wide grid ka fill aur drain baitha hai: Yeh step kyun? Cycle count explicitly likhe bina neeche utilisation number kahin se aata nahi dikhega. Yahan "1 compute cycle" sirf productive tick hai; baaki sab pipe ka startup/shutdown hai.
Step 3 — Run ke dauran Utilisation. Grid could do MACs har cycle mein; 513 cycles mein uski capacity hai. Actual useful MACs : Yeh step kyun? Degenerate case worst utilisation expose karta hai — fill+drain single compute cycle ko swamp kar dete hain.
Recall Verify karo
. Truly degenerate () ko 65536 PEs par 1 MAC chahiye → apne 513-cycle run mein, . Tiny inputs array waste karte hain — exactly yahi wajah hai ki NPUs bade matmuls ke liye suit karte hain. ✓
Example 6 — Cell F: memory-bound limit (roofline)
Recall Forecast
Agar har byte par sirf 4 ops hote hain aur 100 billion bytes per second aate hain, toh bandwidth se math ceiling hai ::: ops/s = 0.4 TOPS — 131 TOPS se bahut neeche, toh memory-bound.
Step 1 — Bandwidth-limited compute. woh maximum operations per second hai jo bandwidth sustain kar sakti hai — woh throughput ceiling jo sirf is baat se set hoti hai ki bytes kitni fast arrive karti hain: Yeh step kyun? Throughput (bytes/s jo aate hain) × (ops done per byte) se zyaada nahi ho sakta. Yeh Roofline model ki slanted memory roof hai. Units: . ✓
Step 2 — Woh ceiling topline metric, TOPS, mein convert karo. Yeh step kyun? Har doosra example speed TOPS mein report karta tha; TOPS compute roof se compare karne ke liye hum memory ceiling ko same unit mein daalna chahte hain.
Step 3 — Classify: compute-bound ya memory-bound? Compute ceiling = TOPS; memory ceiling = TOPS. Kyunki , achievable throughput kam wala hai → memory-bound, TOPS par capped. Yeh step kyun? Roofline hamesha lower roof pick karta hai; yahan PEs nahi, bandwidth bottleneck hai.
Step 4 — Array ka effective utilisation. Yeh step kyun? Yeh dikhata hai ki peak TOPS ek fiction hai jab data starved ho — "peak TOPS speed batata hai" ka trap concretely demonstrate hota hai.

Recall Verify karo
ops/s TOPS; . Ridge: compute-bound hone ke liye chahiye, matlab ops/byte. Usse neeche, bandwidth ya reuse badhao, PEs nahi. ✓
Example 7 — Cell G: precision trade (int8 vs fp32)
Step 1 — Area ratio. Yeh step kyun? fp32 32 bits use karta hai, int8 8; abhi define kiya gaya square rule apply karo.
Step 2 — Naya PE count. fp32 grid: PEs. int8 fit karta hai: PEs → ek grid. Yeh step kyun? Same area ÷ 16× smaller multiplier = 16× count; toh har side quadruple hoti hai ().
Step 3 — Peak TOPS at 1 GHz. Yeh step kyun? Same silicon aur clock ke liye throughput multiplier confirm karta hai.
Recall Verify karo
. Accuracy caveat: int8 inference mein typically calibration ke saath <1% accuracy loss hoti hai — trade iske laayak hai (dekho Quantization and int8 inference aur Tensor cores, jo precisions mix karte hain). ✓
Example 8 — Cell H: real-world word problem
Recall Forecast
Chip ka MAC budget per second vs model ki demand — kaunsa bada hai? ::: Chip mein huge headroom hai; demand sirf ek slice chahti hai.
Step 1 — Chip MAC budget per second. Yeh step kyun? Hardware ko "MACs per second" ceiling mein convert karo (note: MACs, ops nahi — yahan ×2 nahi).
Step 2 — Model demand per second. Yeh step kyun? Frame rate per-frame work ko ek sustained rate mein badal deta hai jo hum compare kar sakte hain.
Step 3 — Fit hoga? → haan, bahut bade margin ke saath.
Step 4 — Required utilisation. Yeh step kyun? Batata hai ki chip 99%+ time idle hai → hum clock/voltage gira sakte hain battery bachane ke liye (Energy per operation).
Recall Verify karo
; . Battery insight: kyunki sirf 0.69% chahiye, ~150× giraa do → same 30 fps bahut kam power par. ✓
Example 9 — Cell I: exam twist (solve for the unknown)
Recall Forecast
ko ke liye rearrange karne mein square root chahiye. Roughly, kya 100, 200, ya 500 ke kareeb hai? ::: Lagbhag 200.
Step 1 — ke saath TOPS formula likho. Yeh step kyun? "Square array" matlab , toh PE count hai; ab ek unknown hai.
Step 2 — solve karo. Yeh step kyun? Pehle count isolate karo — mid-expression square root lene se zyaada clean hai.
Step 3 — Root lo. Yeh step kyun? ek side length hona chahiye, toh PE count ka square root lete hain.
Recall Verify karo
Forward-check: TOPS. ✓
Matrix, filled
Recall Kya har cell cover hua?
A→Ex1, B→Ex2, C→Ex3, D→Ex4, E→Ex5, F→Ex6, G→Ex7, H→Ex8, I→Ex9 ::: sab nau cells cover hue, full array se degenerate , memory-bound, precision, real-world, aur reverse-solve tak.