6.5.8 · D4 · HinglishAdvanced & Emerging Architectures

ExercisesNeural processing units (NPUs)

2,225 words10 min read↑ Read in English

6.5.8 · D4 · Hardware › Advanced & Emerging Architectures › Neural processing units (NPUs)

Shuru karne se pehle, ek shared reference card taaki koi bhi symbol unexplained na rahe:


Level 1 — Recognition

L1.1

Kaunsi single operation neural-network inference runtime ka roughly 90% banati hai, aur wo kis atomic hardware operation se bani hoti hai?

Recall Solution

Kya: Neural-net inference mein matrix multiplication dominant hai. Kyun: fully-connected aur convolution layers dono par reduce ho jaate hain, aur har output element ek dot product hai. The atom: har dot product multiply-accumulate (MAC) operations ki ek chain hai — ek pair multiply karo, running sum mein add karo. Toh poora workload "billions of MACs" hai.

L1.2

Har term ko uske ek-line meaning se match karo: (a) PE, (b) systolic array, (c) weight-stationary, (d) on-chip SRAM.

Recall Solution
  • (a) PE — Processing Element: ek MAC unit jo compute karta hai.
  • (b) Systolic array — PEs ki ek 2-D grid jahan data rhythmically neighbouring PEs ke beech flow karta hai (har step par koi global memory read nahi hoti).
  • (c) Weight-stationary — weights ek baar load hote hain aur har PE ke andar hold rehte hain jabki activations stream karte hain.
  • (d) On-chip SRAM — compute ke paas fast scratchpad memory jo weights/activations hold karti hai taaki DRAM ka expensive trip avoid ho.

Level 2 — Application

L2.1

Ek matmul matrix ko matrix se multiply karta hai. Kitne MACs lagte hain?

Recall Solution

Formula: jahan yahan , , . Yeh formula kyun: har outputs mein se har ek length ka dot product hai, yaani multiplies each.

L2.2

Ek array PEs ka hai jo GHz par run karta hai. Iska peak TOPS do.

Recall Solution

Formula: . Yeh har MAC mein multiply aur add dono count karta hai. Yeh kaisa dikhta hai: neeche figure dekho — jeet grid ka area hai ( MACs har single tick), clock speed nahi.

Figure — Neural processing units (NPUs)

L2.3

Wohi array ek matmul run karta hai ke saath perfectly (fill/drain ignore karo). Kitne clock cycles, aur GHz par microseconds mein kitna time?

Recall Solution

Total MACs: . MACs per cycle: poora grid per cycle karta hai. Time: cycles . Exactly kyun: weight-stationary grid ke saath jo poori weight matrix hold karta hai, tum saari activation rows stream karte ho — fill ke baad har cycle mein ek row — toh result rows cycles mein.


Level 3 — Analysis

L3.1

Ek layer array par map hoti hai lekin sirf of the columns aur of the rows use karti hai. Fill/drain ignore karte hue, utilisation aur effective TOPS kya hogi agar peak ( GHz par) TOPS hai?

Recall Solution

Peak check: TOPS. ✓ Busy PEs: out of . Effective TOPS: TOPS. Kyun: idle columns silicon hain jo kuch nahi kar rahe — peak number assume karta hai ki har PE har cycle fire karta hai, jo ek mismatched layer shape tod deta hai.

L3.2

Naïve dataflow har MAC ke liye dono operands DRAM se load karta hai. Ek DRAM read pJ aur ek MAC pJ. MACs ke liye (L2.1 se), total energy compute karo (a) naïve — 2 reads per MAC — vs (b) ek ideal reuse case jahan dono operands mein se har ek sirf ek baar read hota hai aur poore traversal ke liye reuse hota hai. Maan lo reuse case mein DRAM reads per PE-load hain lekin hum sirf arithmetic count karte hain jo MACs par dominate hai. Ratio do (naïve DRAM energy) : (MAC arithmetic energy).

Recall Solution

Naïve memory energy: reads/MAC pJ pJ. Arithmetic energy: pJ . Ratio: . Iska matlab: naïvely, memory movement 6400× arithmetic energy jalata hai — yahi woh number hai jo poori systolic reuse machine ko justify karta hai. factor bas "do DRAM reads har ek pJ ka vs ek pJ MAC" hai.


Level 4 — Synthesis

L4.1

Tumhe ek silicon budget diya gaya hai aur bataya gaya hai: ek fp32 multiplier area occupy karta hai. Multiplier area roughly (bit-width)² scale karta hai. (a) Ek int8 multiplier kitna chota hai? (b) Agar tum saare fp32 MACs ko int8 se swap karo, toh same area mein kitne zyada MACs fit honge? (c) Peak TOPS gain kya hai (same clock par)?

Recall Solution

(a) Area ratio: , toh Ek int8 multiplier 16× chota hai. (b) Same area ⇒ 16× zyada MAC units. (c) Peak TOPS ; zyada PEs ke saath (bada effective ) aur unchanged , peak bhi 16× scale karta hai. Kyun NN ise accept karte hain: networks quantisation noise ke liye robust hoti hain (Quantization and int8 inference) — noise ke saath trained aur tolerant nonlinearities use karte hue — toh int8 par inference typically <1% accuracy khoata hai jabki yeh 16× density milti hai.

L4.2

Design choice: tumhe back-to-back chhote matmuls ki ek stream run karni hai. Utilisation ke liye tum array ya array choose karoge, aur kyun? (Estimate ke liye fill/drain differences ignore karo; ek layer ek region par map hoti hai.)

Recall Solution

Mapping: ek weight matrix sirf block of PEs occupy karta hai. array par: busy PEs out of array par: busy PEs out of 100% utilisation. Conclusion: chhotey array ki small layers ke liye utilisation kaafi better hai. Yahan giant array ka peak TOPS waste marketing hai — zyaattar PEs idle baithe hain. Yahi reason hai ki real designs chhote layers tile/batch karte hain ya array size ko typical layer shapes ke matmul shapes se match karne ke liye choose karte hain (Domain-specific architectures, Dataflow and data reuse).


Level 5 — Mastery

L5.1

Ek weight-stationary array GHz par ek matmul run karta hai , , ke saath. Pipeline fill latency cycles hai pehla full column aane se pehle, phir columns ke liye ek result column per cycle. (a) Fill samet total cycles. (b) Fill ignore karte hue ideal cycles. (c) Utilisation as (ideal / actual). (d) Effective TOPS.

Recall Solution

Weight matrix exactly hai, toh yeh poore grid ko tile karta hai — har PE ek weight hold karta hai, steady state mein sab busy. (a) Fill: cycles. Steady state: activation rows stream karo ⇒ cycles. Total: (b) Ideal (fill nahi): useful work result columns hai ek per cycle cycles. (Equivalently .) ✓ (c) Utilisation: (d) Effective TOPS: peak TOPS. Yeh kaisa dikhta hai: fill/drain neeche figure mein ramp hai — array cycles tak "warm up" karta hai partial work karte hue phir full rhythm pe aata hai. Bade ke saath yeh overhead shrink hoti hai; tiny ke saath yeh dominate kar leti hai.

Figure — Neural processing units (NPUs)

L5.2

Same array aur clock. Ab tumhare paas choice hai: upar wali layer run karo (bada ) ya ek layer ke saath (same ). case ke liye utilisation compute karo (-cycle fill ke saath) aur ek sentence mein explain karo Roofline model se tie karte hue ki batching kyun help karta hai.

Recall Solution

Actual cycles: . Ideal useful cycles: . Batching kyun help karta hai: tiny ke saath fixed -cycle fill cycles ke real work ko overwhelm kar deta hai, toh array 97% idle rahta hai — badhana (batching) fill ko amortise karta hai aur tumhe roofline ke compute-bound ridge ki taraf push karta hai, jahan tum actually TOPS exploit karte ho.


Recall Har numeric answer ki ek-nazar summary

L2.1 MACs · L2.2 TOPS · L2.3 cycles · L3.1 , TOPS · L3.2 ratio · L4.1 · L4.2 vs · L5.1 cycles, , TOPS · L5.2 .