6.5.6 · D4 · HinglishAdvanced & Emerging Architectures

ExercisesDomain-specific accelerators

3,352 words15 min read↑ Read in English

6.5.6 · D4 · Hardware › Advanced & Emerging Architectures › Domain-specific accelerators

Shuru karne se pehle, ek figure do woh pictures fix kar deta hai jis par har problem tikti hai. Hum ise directly reuse karte hain: pie Exercise 1.1 aur 2.1 (energy per op) ke peeche ki picture hai, aur roofline Exercises 2.2, 2.3, 3.3 aur 5.1 (which wall) ke peeche ki picture hai.

Figure — Domain-specific accelerators

Left picture ko aise padho: actual add (teal sliver) tiny hai; fetch / decode / control (orange) bulk hai — yahi wo waste hai jo Exercise 2.1 quantify karta hai. Right picture ko aise padho: aapka kernel ek dot hai jo apni intensity ke hisaab se placed hai; agar wo slanted line ke neeche baitha hai to wo memory-bound hai ( orange dot of Ex 2.2), aur par vertical line Ex 2.3 ka ridge point hai jahan dono ceilings cross karti hain.


Level 1 — Recognition

Recall Solution 1.1

Answer: (c) performance-per-watt. Jab Dennard scaling khatam hua (~2006), voltage har shrink ke saath aur nahi gir sakta tha, toh power density badhne lagi. Hum transistors fit kar sakte hain par unhe power nahi de sakte (Dark silicon). Isliye binding constraint energy per useful operation hai, raw clock nahi — figure ki energy pie ko dobara dekho: teal ALU sliver hi ek aisa hissa hai jo useful hai. GHz (a) heat se limited hai; transistor count (b) power se limited hai; cache (d) ek means hai, goal nahi.

Recall Solution 1.2

False. Ek systolic array typically CPU se lower clock par chalta hai. Iska win hai massive parallelism ( MAC cells har cycle mein fire karte hain), deleted control overhead, lower precision, aur data reuse (har loaded value kaafi baar use hoti hai — Ex 3.2 mein quantify kiya gaya hai). Clock speed lever nahi hai.


Level 2 — Application

Recall Solution 2.1

Efficiency ratio .

  • Humne kya kiya: CPU ka energy-per-op accelerator ke energy-per-op se divide kiya.
  • Kyun: ops/joule , toh energies ka ratio hi efficiencies ka ratio hai (pJ ki units cancel ho jaati hain). Ye sahi metric hai kyunki energy/op binding constraint hai (Exercise 1.1), aur figure ki pie dikhati hai kyun CPU number itna bada hai — uske zyaadatar joules orange overhead pe jaate hain jo ek DSA delete kar deta hai.
Recall Solution 2.2

Pehle units convert karo taaki dono ceilings ops/second mein hon: Bytes cancel ho jaate hain, ops/s = TOPS bachta hai. Phir Kyunki , aap memory-bound ho — figure mein orange dot slanted line ke neeche baitha hai. Peak ka sirf hi usable hai.

  • Ye step kyun: Roofline aapko bottleneck optimize karne se pehle bata deta hai — yahan zyaada MACs idle rahenge (assumption: compute aur memory perfectly overlap karte hain; real machine sirf worse ho sakti hai); fix hai badhana (fuse layers, larger tiles).
Recall Solution 2.3

Dono ceilings equal set karo: , toh ("Per second" upar aur neeche cancel ho jaata hai, ops/byte bachta hai.) ops/byte se neeche aap memory-bound ho; uske barabar ya upar compute-bound. Hamare kernel ka bahut se neeche hai — deeply memory-bound. Ye figure mein vertical line hai.


Level 3 — Analysis

Recall Solution 3.1

(a) MACs/cycle (har cell mein har cycle mein ek multiply-add). (b) Har loaded weight ek axis ke saath saari activations ke past stream karta hai, toh reuse factor array dimension . (c) ka "why": output ek matrix hai, toh uske output entries hain. Har output entry length ka dot product hai, jisme multiply-adds lagte hain. Total . Yahan : total MACs .

Recall Solution 3.2

Naive: total ops (Ex 3.1c se). Agar har operand memory se refetch hota hai, bytes moved (har MAC ke liye do reads + ek write). Systolic: aap data grid mein ek baar load karte ho aur har value baar reuse karte ho, toh bytes moved jabki ops hi rehte hain: Concretely: ; . Double width, double intensity.

  • Kyun matter karta hai: intensity ab array size ke saath badhti hai, toh Roofline par aap ridge point ke past right slide karte ho aur compute-bound ban jaate ho — yahi design ka poora point hai.
Recall Solution 3.3

New memory ceiling TOPS. Kyunki (Ex 2.3), aapne ridge cross kar liya: Un-fused TOPS ke upar speedup: . Note karo ki ye win sirf data reuse se aaya, hardware khareedne se nahi. Edge case : aur zyaada badhana (maan lo ) kuch nahi deta — aap flat TOPS compute ceiling par pin ho; ab sirf zyaada MACs help kar sakte hain.


Level 4 — Synthesis

Recall Solution 4.1

Parallel fraction aur us fraction par speedup ke saath: accelerator ke bawajood overall sirf milta hai kyunki untouched ab dominate karta hai (immovable stub). Lesson: DSAs narrow hote hain; aapko serial/irregular parts orchestrate karne ke liye CPU chahiye. Real systems heterogeneous hote hain — CPU + DSA — sirf DSA nahi.

Recall Solution 4.2

Starting attainable TOPS. Option A (double MACs): badhata hai lekin kernel memory-bound hai, toh TOPS — koi change nahi. Paisa waste. Option B (INT8): operands chhote hain, toh effective se ops/byte ho jaata hai. New ceiling TOPS = improvement. B chunno. Quantization actual bottleneck (bytes moved) par attack karta hai; MACs add karna nahi karta.


Level 5 — Mastery

Recall Solution 5.1

(a) TOPS TOPS ⇒ memory-bound, peak ka use ho raha hai. (b) Ridge point ops/byte. Aapko ko se tak badhana hoga — reuse mein increase. (c) Decision: scratchpad par spend karo (option ii). Array already starved hai; bada array (flat ceiling) badhata hai jabki kernel slanted ceiling par pinned hai — extra MACs idle rahenge. Zyaada scratchpad bade tiles / operand reuse enable karta hai, ko ridge ki taraf rightward push karta hai, jo peak ko attainable throughput mein convert karne ka ek aur tarika hai. Edge case to respect: agar cold/too-small cache effective ghatata hai, toh aap slanted ceiling par neeche slide karte ho aur woh TOPS bhi kho dete ho — ye ek aur reason hai ki reuse (scratchpad) fix sahi lever hai.

Recall Solution 5.2

Scheme: Mixed precision training. Sensitive parts ko — master weights aur gradient accumulation — higher precision (FP32) mein rakho, jabki bulk matmuls (forward/backward) low precision (bfloat16/FP16) mein karo. Loss scaling chhote gradients ko underflow hone se bachata hai. Ye kyun kaam karta hai (domain tolerance): neural nets statistical hain; forward-pass ke millions of MACs rounding noise ko average kar dete hain, toh wahan low precision almost free hai (inference ki tarah). Lekin tiny gradients ka accumulation ek aisa sum hai jahan rounding errors compound hoti hain — woh step high precision rakhta hai. Aap precision exactly wahan spend karte ho jahan domain intolerant hai, aur use wahan bachate ho jahan domain tolerant hai. Woh selective placement hi domain-specific design ka essence hai.

Recall Solution 5.3

Pollack's Rule: single-core performance ke saath badhti hai. Area double karne par milta hai, nahi — monolithic core se diminishing returns. Contrast: DSA instead us area ko bahut saare chhote, identical MAC cells par spend karta hai jinka aggregate throughput roughly area ke saath linearly scale karta hai (data-level parallelism), aur per-op control overhead delete karta hai. Toh same transistors se far more useful ops/mm² milti hain — provided arithmetic intensity unhe fed rakhti hai (Roofline caveat from Exercise 5.1).


Recall Self-check: kaunsa lever kaunsa symptom fix karta hai?

Memory-bound kernel, MACs idle ::: Arithmetic intensity badhao — bade tiles, fused ops, zyaada scratchpad, lower-precision operands. Serial fraction total time dominate kar raha hai ::: Amdahl limit — orchestrate karne ke liye CPU rakho; heterogeneous system, sirf DSA nahi. Gradient INT8 mein diverge karta hai ::: Mixed precision — high precision sirf sensitive accumulation ke liye. "Core area double karna = 2x speed" ::: Pollack's Rule se False; monolithic core ke liye . Kernel already ridge ke right mein hai () ::: Compute-bound — zyaada reuse waste hai; ab sirf zyaada MACs throughput badhate hain.