6.2.12 · D1 · HinglishGPU Architecture

FoundationsTensor cores and matrix operations

2,950 words13 min read↑ Read in English

6.2.12 · D1 · Hardware › GPU Architecture › Tensor cores and matrix operations

Parent note padhne se pehle, tumhe har woh symbol khud banana hoga jo woh tumhe deta hai. Hum unhe yahaan order mein banate hain, har ek pehle wale pe lean karta hua. Koi assumption nahi.


1. Ek number sirf ek value hai — lekin kitne bits?

Parent note baar baar FP16, FP32, INT8, TF32 kehta hai. Ye formats hain — ek number ko fixed on/off switches (bits) mein store karne ki recipes.

Figure — Tensor cores and matrix operations

Figure dekho. Har bar ek number ka bits ka "budget" hai, teen kamon mein baanta gaya:

  • Sign bit (slate, hamesha exactly 1 bit) decide karta hai positive ya negative: matlab , matlab . Yahi tarika hai jis se har floating-point format ek negative value store karta hai — bilkul shuru mein ek dedicated switch.
  • Exponent bits (lavender) decide karte hain ki number kitna bada ya chhota ho sakta hai — range.
  • Mantissa bits (mint) decide karte hain kitne decimal places ki detailprecision.

Table se pehle, iske do entries theek se samjho:

Format Layout (sign · exp · mantissa) Total bits Kya milta hai
FP32 1 · 8 · 23 32 full range + full detail (safe default)
FP16 1 · 5 · 10 16 aadhi memory, chhoti range
BF16 1 · 8 · 7 16 FP32 ki range, coarse detail
TF32 1 · 8 · 10 (internal, 19) 19 FP32 range, FP16-jaisi detail
INT8 1 sign · 7 value (two's-complement) 8 whole numbers , FP32 se 4× chhota

Ise apni pocket mein rakho — yeh parent ke poore "Precision Modes" section ko power karta hai, aur 8.3.4-Mixed-precision-training aur 8.4.2-Quantization-techniques se link karta hai.


2. Matrix numbers ki ek grid hai

Parent A, B, C, D likhta hai aur unhe "4×4 tiles" ya "1024×1024 matrices" kehta hai. Ek matrix simply rows aur columns mein arranged numbers ka ek rectangle hai.

Figure — Tensor cores and matrix operations

Figure mein, red pointer ko tak follow karo — row (doosri row neeche), column (teesra column across). Ek symbol, ek cell. Jab ye click kare, parent mein C[i][j] scary nahi lagega — yeh bas "output grid ka ek cell" hai.


3. Matrix multiplication: dot product disguise mein

Yahi sab kuch ka dil hai. Parent ka central formula hai

Hume isme har symbol earn karna hoga.

3a. Multiply-add (yahi ek core karta hai)

3b. Summation symbol

Chhota worked example: . hamesha bas yahi karta hai.

3c. Ab poora formula, pictures mein

Figure — Tensor cores and matrix operations

Ab formula zor se padho: " equals the sum, jaise se tak jaata hai, -in-row--column- times -in-row--column- ka." Har symbol ab kuch aisa hai jise tum picture mein point kar sakte ho.


4. Ek cell se poore tile tak: D = A×B + C

Parent ka Tensor Core operation hai jahan charon chhoti grids hain.

4a. Jab sizes evenly divide nahi hoti

Parent ke tiled loops (ya ) at a time aage badhte hain. Lekin agar ho, jo ka multiple nahi hai? Aakhri chunk matrix ke edge se baahar chala jayega.

Figure — Tensor cores and matrix operations

5. Kaam kahan hota hai: SM, warp, thread

Parent kehta hai ki 32 threads ka ek warp cooperate karta hai, groups mein baanta gaya. Do hardware words define karne hain.

Numbers ko slow memory se in engines tak bhi travel karna hota hai — woh path 6.2.8-Memory-hierarchy-in-GPUs hai, aur isliye FP16 ka chhota size (section 1) speed ke liye matter karta hai.


6. Speed count karna: FLOP, FLOPS, throughput

Yeh parent ke performance math aur 9.1.5-Roofline-model ki vocabulary hai. Parent ke khud ke numbers pe quick self-check: FMAs, aur tile-ops, ratio deta hai. Iska har piece ab ek aisa symbol hai jis par tumhara ownership hai.


Prerequisite map

Bits sign exp mantissa

Mixed precision FP16 FP32 INT8

Matrix as a grid

Matrix multiply

Indexing A i j

Row major vs column major

Summation symbol

Fused multiply add

Tile multiply accumulate D equals AB plus C

Partial tiles and padding

Thread warp SM

Cooperative fragment execution

Tensor Cores and matrix operations

FLOP and FLOPS

Upar ki sab cheez parent topic 6.2.12 Tensor cores and matrix operations (Hinglish) aur uske companions 7.3.6-cuBLAS-and-cuDNN aur 8.3.4-Mixed-precision-training mein flow karti hai.


Equipment checklist

Dayi taraf cover karo aur khud test karo. Agar koi bhi jawab surprise kare, uska section dobara padho.

Bit kya hai, aur sign, exponent, aur mantissa bits mein se har ek kya control karta hai?
Bit ek on/off switch hai; sign bit positive/negative set karta hai, exponent bits range set karte hain, mantissa bits precision set karte hain.
Ek floating-point format negative number kaise store karta hai?
Ek dedicated sign bit ke saath shuru mein — matlab , matlab .
BF16 ka layout kya hai aur yeh training ke liye kyun accha hai?
1 sign + 8 exponent + 7 mantissa; yeh FP32 ka exponent copy karta hai isliye same wide range tak pahunchta hai, detail ki jagah range leta hai — gradients ke liye ideal.
INT8 kya range cover karta hai aur negatives kaise store hote hain?
se tak, 1 sign bit + 7 value bits two's-complement mein use karke.
Ek matrix ke liye shape ka matlab kya hai?
rows neeche jaate hue, columns across jaate hue.
kis number ko refer karta hai (0-indexed)?
Doosri row, teesre column mein entry.
Row-major aur column-major storage mein kya fark hai?
Row-major row 0 phir row 1 lay out karta hai (entry at ); column-major column 0 phir column 1 lay out karta hai (entry at ).
Alfaz mein, tumhe kya karne kehta hai?
ko se tak step karo, har ke liye term compute karo, aur unhe add karo.
FMA kya hai, aur yeh kitne FLOPs ka hai?
Ek fused multiply-add, ; yeh 2 FLOPs count hota hai.
Ek output cell ka formula likho.
.
aur ka inner dimension kyun match karna chahiye?
Yeh us row aur column ki length hai jis par tum saath saath slide karte ho; unmatched lengths ko pair nahi kiya ja sakta.
mein, kya kaam karta hai?
Yeh accumulator hai — yeh running total hold karta hai taaki partial products add hote rahen.
Tiling ko actually koun si properties correct banati hain?
Addition ki associativity aur scalar multiplication ki -sum par distributivity — matrix-multiply associativity nahi, aur matrix multiply commutative nahi hai.
Partial tile kya hai aur ise kaise handle karte hain?
Edge tile jo sirf partly real data se bhara hai; missing cells ko se pad karo (jo kuch contribute nahi karte) aur extra output rows/columns ignore karo.
8 ya 16 ke multiples wale dimensions fastest kyun run karte hain?
Woh partial tiles avoid karte hain, isliye koi hardware cycles padded arithmetic par waste nahi hoti.
FLOP aur FLOPS mein kya fark hai?
FLOP ek operation hai (ek kaam); FLOPS operations per second hai (ek rate).
Chhote formats jaise FP16 Tensor Cores ko faster kyun banate hain?
Fewer bits matlab zyada numbers chip par fit hote hain aur memory se faster move karte hain, jabki wide FP32 accumulator accuracy preserve karta hai.
Recall Quick fire — summation drill

compute karo. ::: . matrices ke liye, compute karne mein kitne FMAs lagte hain? ::: .