Majid Al-RaimiReference sheetالورقة المرجعية

COE 592Lecture 5.1المحاضرة 5.1Referenceالمرجع

Reference sheetالورقة المرجعية

Quantization (I) compressed onto one page: the definitions, formulas and numbers to have in your head before a quiz or exam.محاضرة «التكميم (Quantization) الجزء الأول» مضغوطة في صفحة واحدة: التعريفات والمعادلات والأرقام التي يجب أن تكون حاضرة في ذهنك قبل الاختبار القصير أو الامتحان.

Energy per operationالطاقة لكل عملية

Horowitz, 45 nm, 0.9 V, in pJ. Last column: fp32 over int8. Part 01: Bits, integers and fixed point

أرقام Horowitz عند 45 nm و0.9 V، بوحدة pJ. العمود الأخير: نسبة fp32 إلى int8. الجزء 01: البتات والأعداد الصحيحة والفاصلة الثابتة

Operationالعملية8b intint 8b32b intint 32b16b floatfloat 16b32b floatfloat 32bRatioالنسبة
ADDالجمع (ADD)0.030.030.10.10.40.40.90.930x30x
MULTالضرب (MULT)0.20.23.13.11.11.13.73.718.5x18.5x
Energy in pJالطاقة بوحدة pJ
Eadd(n)∝n,Emult(n)∝n2E_{\text{add}}(n) \propto n, \qquad E_{\text{mult}}(n) \propto n^{2}
int8 to int32: ADD ≈3.3x, MULT ≈15.5xمن int8 إلى int32: الجمع ADD ≈3.3x، والضرب MULT ≈15.5x
  • One fp32 MAC 3.7 + 0.9 = 4.6 pJ, one int8 MAC 0.2 + 0.03 = 0.23 pJ: 20x.عملية MAC واحدة بـfp32 تكلف 3.7 + 0.9 = 4.6 pJ، وعملية MAC واحدة بـint8 تكلف 0.2 + 0.03 = 0.23 pJ: أي 20x.
  • A 32-bit DRAM read is about 640 pJ (SRAM about 5 pJ), so 640 / 3.1 ≈ 206 int32 multiplies. Fewer bits help twice: cheaper arithmetic and less traffic.قراءة 32-bit من DRAM تكلف نحو 640 pJ (وSRAM نحو 5 pJ)، أي ما يعادل 640 / 3.1 ≈ 206 عملية ضرب int32. تقليل البتات يفيد مرتين: حساب أرخص ونقل بيانات أقل.

Integers and fixed pointالأعداد الصحيحة والفاصلة الثابتة

Two's complement negation: invert, add 1. Top bit weighs -2^(n-1). Part 01: Bits, integers and fixed point

النفي في two's complement: اقلب البتات ثم أضف 1. البت الأعلى وزنه -2^(n-1). الجزء 01: البتات والأعداد الصحيحة والفاصلة الثابتة

Formatالصيغةn-bit rangeالمدى بـ n بت8 bits8 بتات4 bits4 بتاتZerosعدد الأصفار-49-49
Unsignedبدون إشارة (Unsigned)[0, 2^n - 1][0, 2^n - 1][0, 255][0, 255][0, 15][0, 15]OneواحدNot representableغير قابل للتمثيل
Sign-magnitudeالإشارة والمقدار (Sign-magnitude)[-(2^(n-1) - 1), 2^(n-1) - 1][-(2^(n-1) - 1), 2^(n-1) - 1][-127, 127][-127, 127][-7, 7][-7, 7]Twoاثنان1011000110110001
Two's complementالمتمم الثنائي (Two's complement)[-2^(n-1), 2^(n-1) - 1][-2^(n-1), 2^(n-1) - 1][-128, 127][-128, 127][-8, 7][-8, 7]Oneواحد1100111111001111
Ranges, zeros, and -49 in 8 bitsالمديات والأصفار وتمثيل -49 في 8 بتات
v=q⋅2−fv = q \cdot 2^{-f}
Fixed point: stored integer q times an implicit scale; linear quantization with S = 2^-f, Z = 0الفاصلة الثابتة: العدد الصحيح المخزن q مضروبًا في مقياس ضمني؛ أي تكميم خطي مع S = 2^-f وZ = 0

The slide's 8-bit fixed-point formatصيغة الفاصلة الثابتة ذات 8 بتات في الشريحة

Formatالصيغة
sign + 3 integer + 4 fraction bits (Q3.4, TI convention)بت إشارة + 3 بتات للجزء الصحيح + 4 بتات للكسر (Q3.4، حسب اصطلاح TI)
Decodeفك الترميز
0011.0001 = 49 × 2^-4 = 3.0625
Resolutionالدقة (حجم الخطوة)
2^-4 = 0.0625
Rangeالمدى
[-128, 127] × 2^-4 = [-8, 7.9375]
Encode 2.7ترميز 2.7
round(2.7 / 0.0625) = 43, stored 2.6875, error 0.0125round(2.7 / 0.0625) = 43، والقيمة المخزنة 2.6875، والخطأ 0.0125
Negativeقيمة سالبة
1100.1111 = -49 × 2^-4 = -3.0625

IEEE 754 FP32IEEE 754 FP32

1 sign, 8 exponent, 23 fraction bits, bias 127 = 2^(8-1) - 1. Part 02: IEEE FP32

بت إشارة واحد (1)، و8 بتات للأس، و23 بتًا للكسر، والإزاحة (bias) تساوي 127 = 2^(8-1) - 1. الجزء 02: IEEE FP32

x=(−1)s×(1+Fraction)×2E−127x = (-1)^{s}\times(1+\text{Fraction})\times 2^{E-127}
Normal, E = 1 to 254طبيعي، E من 1 إلى 254
x=(−1)s×Fraction×21−127x = (-1)^{s}\times \text{Fraction}\times 2^{1-127}
Subnormal, E = 0: no hidden 1, forced 1 - 127 keeps the step 2^-149 continuousدون طبيعي، E = 0: لا يوجد 1 مخفي، والقيمة المفروضة 1 - 127 تبقي الخطوة 2^-149 متصلة
ExponentالأسFraction = 0الكسر = 0Fraction ≠ 0الكسر ≠ 0Valueالقيمة
00h = 000h = 0±0±0subnormalدون طبيعي (subnormal)(−1)s×Fraction×21−127(-1)^{s}\times \text{Fraction}\times 2^{1-127}(−1)s×Fraction×21−127(-1)^{s}\times \text{Fraction}\times 2^{1-127}
01h to FEh = 1 to 25401h إلى FEh = 1 إلى 254normalطبيعي (normal)normalطبيعي (normal)(−1)s×(1+Fraction)×2Exponent−127(-1)^{s}\times (1+\text{Fraction})\times 2^{\text{Exponent}-127}(−1)s×(1+Fraction)×2Exponent−127(-1)^{s}\times (1+\text{Fraction})\times 2^{\text{Exponent}-127}
FFh = 255FFh = 255±INF±INFNaNNaNno numeric valueلا قيمة عددية
Exponent classesفئات الأس

Values to know coldقيم يجب أن تحفظها جيدًا

Smallest subnormalأصغر قيمة دون طبيعية
0 00000000 000...01 = 2^-23 × 2^-126 = 2^-149 ≈ 1.4 × 10^-45
Largest subnormalأكبر قيمة دون طبيعية
0 00000000 111...11 = (1 - 2^-23) × 2^-126 = 2^-126 - 2^-149
Smallest normalأصغر قيمة طبيعية
0 00000001 000...00 = 2^-126 ≈ 1.18 × 10^-38
Largest normalأكبر قيمة طبيعية
0 11111110 111...11 = (2 - 2^-23) × 2^127 ≈ 3.4 × 10^38
Zeroالصفر
+0 and -0: exponent 0, fraction 0, either sign+0 و-0: الأس 0 والكسر 0، بأي إشارة
0.265625
0 01111101 0001000... = 0x3E880000 = 1.0625 × 2^-2
-6.5
1 10000001 1010000... = 0xC0D00000 = -1.625 × 2^2

FP16, BF16, FP8 and FP4FP16 وBF16 وFP8 وFP4

Exponent width sets range, fraction width sets precision. Part 03: FP16, BF16, FP8 and FP4

عرض الأس يحدد المدى، وعرض الكسر يحدد الدقة. الجزء 03: FP16 وBF16 وFP8 وFP4

v=(−1)S×(1.f)2×2 E−bias,bias=2e−1−1v = (-1)^{S} \times (1.f)_2 \times 2^{\,E - \text{bias}}, \qquad \text{bias} = 2^{e-1} - 1
Any IEEE-style format with e exponent bitsأي صيغة على نمط IEEE ذات e بت للأس
PropertyالخاصيةFP32FP32FP16FP16BF16BF16
Sign / exponent / fractionالإشارة / الأس / الكسر1 / 8 / 231 / 8 / 231 / 5 / 101 / 5 / 101 / 8 / 71 / 8 / 7
Biasالإزاحة (Bias)1271271515127127
Largest normalأكبر قيمة طبيعية≈ 3.40 × 10^38≈ 3.40 × 10^386550465504≈ 3.39 × 10^38≈ 3.39 × 10^38
Smallest normalأصغر قيمة طبيعية2^-1262^-1262^-14 ≈ 6.10 × 10^-52^-14 ≈ 6.10 × 10^-52^-1262^-126
Smallest subnormalأصغر قيمة دون طبيعية2^-1492^-1492^-24 ≈ 5.96 × 10^-82^-24 ≈ 5.96 × 10^-82^-1332^-133
Gap after 1.0الفجوة بعد 1.02^-232^-232^-10 ≈ 0.000982^-10 ≈ 0.000982^-7 ≈ 0.00782^-7 ≈ 0.0078
Sixteen-bit formatsصيغ الـ 16 بت
  • FP16 1 10001 1100000000 = -1.75 × 2^(17-15) = -7.في FP16: 1 10001 1100000000 = -1.75 × 2^(17-15) = -7.
  • BF16 2.5 = 1.25 × 2^1: 0 10000000 0100000 = 0x4020. BF16 is FP32's top 16 bits after rounding.في BF16: 2.5 = 1.25 × 2^1 تُكتب 0 10000000 0100000 = 0x4020. وBF16 هي أعلى 16 بتًا من FP32 بعد التقريب.
PropertyالخاصيةE4M3E4M3E5M2E5M2
Exponent / mantissaالأس / الجزء العشري (mantissa)4 / 34 / 35 / 25 / 2
Biasالإزاحة (Bias)771515
Infinityاللانهاية (Infinity)Noneلا يوجدS.11111.00S.11111.00
NaNNaNS.1111.111 onlyS.1111.111 فقطS.11111.01, .10, .11S.11111.01, .10, .11
Largest normalأكبر قيمة طبيعية1.75 × 2^8 = 4481.75 × 2^8 = 4481.75 × 2^15 = 573441.75 × 2^15 = 57344
Smallest normalأصغر قيمة طبيعية2^-62^-62^-142^-14
Smallest subnormalأصغر قيمة دون طبيعية2^-92^-92^-162^-16
UseالاستخدامForward weights and activationsالأوزان والتنشيطات (activations) في المرور الأماميBackward gradientsالتدرجات في المرور العكسي
FP8FP8
FormatالصيغةBiasالإزاحةValuesالقيمSpacingالتباعد
INT4INT4noneلا يوجد0, 1, 2, 3, 4, 5, 6, 70, 1, 2, 3, 4, 5, 6, 7Even, step 1متساوٍ، بخطوة 1
E1M2E1M2000, 0.5, 1, 1.5, 2, 2.5, 3, 3.50, 0.5, 1, 1.5, 2, 2.5, 3, 3.5Even, step 0.5متساوٍ، بخطوة 0.5
E2M1E2M1110, 0.5, 1, 1.5, 2, 3, 4, 60, 0.5, 1, 1.5, 2, 3, 4, 6Step doubles every two codesالخطوة تتضاعف كل رمزين
E3M0E3M0330, 0.25, 0.5, 1, 2, 4, 8, 160, 0.25, 0.5, 1, 2, 4, 8, 16Every code doublesكل رمز يضاعف القيمة
Four-bit positive values (no INF, no NaN)القيم الموجبة في صيغ الـ 4 بت (بلا INF وبلا NaN)

Quantization and the three approachesالتكميم والأساليب الثلاثة

Quantization constrains an input from a continuous or otherwise large set of values to a discrete set. Part 04: What quantization is

التكميم (quantization) يقيّد المدخل من مجموعة قيم متصلة أو كبيرة جدًا إلى مجموعة منفصلة. الجزء 04: ما هو التكميم

e=x−Q(x),∣e∣≤Δ/2 for round-to-neareste = x - Q(x), \qquad |e| \le \Delta / 2 \text{ for round-to-nearest}
Quantization error, keep the signخطأ التكميم، احتفظ بالإشارة
Floating pointالفاصلة العائمةK-meansK-meansLinearالخطيBinary / ternaryالثنائي / الثلاثي
StorageالتخزينFloating-point weightsأوزان عشريةInteger weights; floating-point codebookأوزان صحيحة؛ كتاب رموز عشريInteger weightsأوزان صحيحةLecture 05-3المحاضرة 05-3
ComputationالحسابFloating-point arithmeticحساب عشريFloating-point arithmeticحساب عشريInteger arithmeticحساب صحيحLecture 05-3المحاضرة 05-3
Running exampleالمثال المستمر64 B64 B4 B + 16 B = 20 B4 B + 16 B = 20 B4 B + S + Z4 B + S + ZNot coveredغير مغطى
Storage and computation, completed on slide 43التخزين والحساب، كما اكتمل الجدول في الشريحة 43
  • Palettization: a 16-colour palette is the codebook, each pixel stores a 4-bit index.لوحة الألوان (palettization): لوحة من 16 لونًا هي كتاب الرموز، وكل بكسل يخزن فهرسًا بطول 4-bit.
  • Weight sharing on the running example: 2.09, 2.12, 1.92, 1.87 → 2.00, errors +0.09, +0.12, -0.08, -0.13.مشاركة الأوزان (weight sharing) على المثال المستمر: 2.09, 2.12, 1.92, 1.87 → 2.00، والأخطاء +0.09, +0.12, -0.08, -0.13.

K-means quantizationتكميم K-means

Lloyd: assign to the nearest centroid, move each centroid to its cluster mean, repeat. Linear initialization. Part 05: K-means, codebook and fine-tuning

خوارزمية Lloyd: أسند كل وزن إلى أقرب مركز، ثم انقل كل مركز إلى متوسط عنقوده، وكرر. التهيئة خطية (linear initialization). الجزء 05: K-means وكتاب الرموز والتدريب الدقيق

IndexالفهرسCentroidالمركزMembersالأعضاءMeanالمتوسط
332.002.002.09, 2.12, 1.92, 1.872.09, 2.12, 1.92, 1.878.00 / 48.00 / 4
221.501.501.48, 1.53, 1.491.48, 1.53, 1.494.50 / 34.50 / 3
110.000.000.09, 0.05, -0.14, 0, 00.09, 0.05, -0.14, 0, 00.00 / 50.00 / 5
00-1.00-1.00-0.98, -1.08, -0.91, -1.03-0.98, -1.08, -0.91, -1.03-4.00 / 4-4.00 / 4
Slide 27 clustering, k = 4التجميع في الشريحة 27، k = 4
ratio=32MNM+32⋅2N  →  M≫2N    32N\text{ratio} = \dfrac{32M}{NM + 32\cdot 2^{N}} \;\xrightarrow{\;M \gg 2^N\;}\; \dfrac{32}{N}
N-bit indexes, M weights, FP32 codebookفهارس من N بت، وM وزنًا، ودفتر رموز FP32
ItemالبندGeneralالصيغة العامةSlide example (N = 2, M = 16)مثال الشريحة (N = 2, M = 16)
Original weightsالأوزان الأصلية32M bit32M bit32 × 16 = 512 bit = 64 B32 × 16 = 512 bit = 64 B
IndexesالفهارسNM bitNM bit2 × 16 = 32 bit = 4 B2 × 16 = 32 bit = 4 B
Codebookكتاب الرموز32 × 2^N bit32 × 2^N bit32 × 4 = 128 bit = 16 B32 × 4 = 128 bit = 16 B
Ratioالنسبة32M / (NM + 32 × 2^N)32M / (NM + 32 × 2^N)64 / 20 = 3.2x64 / 20 = 3.2x
Storage billفاتورة التخزين
Ck←Ck−lr⋅∑Iij=k∂L∂WijC_k \leftarrow C_k - \text{lr}\cdot \sum_{I_{ij}=k} \frac{\partial L}{\partial W_{ij}}
Index map frozen; group gradients by index, sum, stepخريطة الفهارس مجمدة؛ جمّع التدرجات حسب الفهرس، واجمعها، ثم خذ خطوة
IndexالفهرسGrouped gradient sumمجموع التدرجات المجمّعةNew centroidالمركز الجديد
33-0.03 + 0.12 + 0.02 - 0.07 = 0.04-0.03 + 0.12 + 0.02 - 0.07 = 0.042.00 - 0.04 = 1.962.00 - 0.04 = 1.96
220.03 + 0.01 - 0.02 = 0.020.03 + 0.01 - 0.02 = 0.021.50 - 0.02 = 1.481.50 - 0.02 = 1.48
110.02 - 0.01 + 0.01 + 0.04 - 0.02 = 0.040.02 - 0.01 + 0.01 + 0.04 - 0.02 = 0.040.00 - 0.04 = -0.040.00 - 0.04 = -0.04
00-0.01 - 0.02 - 0.01 + 0.01 = -0.03-0.01 - 0.02 - 0.01 + 0.01 = -0.03-1.00 + 0.03 = -0.97-1.00 + 0.03 = -0.97
Slide 29 fine-tuning, lr = 1التدريب الدقيق في الشريحة 29، lr = 1

How far compression goesإلى أي حد يصل الضغط

AlexNet on ImageNet: x-axis model size as a percent of the original, y-axis accuracy loss. Part 06: Accuracy and bit choice

AlexNet على ImageNet: المحور الأفقي حجم النموذج كنسبة مئوية من الأصل، والمحور الرأسي خسارة الدقة. الجزء 06: الدقة واختيار عدد البتات

  • Pruning only and quantization only each hold about 0% loss down to roughly 8% of the size.التقليم وحده والتكميم وحده يحافظ كل منهما على خسارة نحو 0% حتى حوالي 8% من الحجم.
  • Pruning plus quantization holds down to about 3% (3.7% before Huffman, 2.88% after).التقليم مع التكميم يصمد حتى نحو 3% (3.7% قبل Huffman و2.88% بعده).
  • Histogram: continuous with a pruning hole at 0, then at most 2^b spikes; retraining shifts positions, never heights.المدرج التكراري (histogram): متصل مع فجوة تقليم عند 0، ثم يصبح على الأكثر 2^b قممًا؛ إعادة التدريب تزيح مواقع القمم ولا تغيّر ارتفاعاتها أبدًا.
size ratio≈fraction kept×bweight+bindex32\text{size ratio} \approx \text{fraction kept} \times \dfrac{b_{\text{weight}} + b_{\text{index}}}{32}
AlexNet: 0.11 × 9.4 / 32 ≈ 3.2%AlexNet: 0.11 × 9.4 / 32 ≈ 3.2%
PropertyالخاصيةConvConvFCFC
Weights in AlexNetعدد الأوزان في AlexNetabout 2.3Mنحو 2.3Mabout 59M (≈96%)نحو 59M (≈96%)
Kept after pruningالمتبقي بعد التقليم35% to 84%35% إلى 84%9% to 25%9% إلى 25%
Uses per weight per imageمرات استخدام الوزن الواحد لكل صورة169 to 3,025169 إلى 3,025Onceمرة واحدة
Knee on slide 36نقطة الانعطاف في الشريحة 364 bits4 بتات2 bitsبتّان (2 bits)
One step below the kneeخطوة واحدة تحت نقطة الانعطافtop-1 about 25% at 3 bitsدقة top-1 نحو 25% عند 3 بتاتnear 0% at 1 bitقرابة 0% عند بت واحد
Deep Compression usedما استخدمه Deep Compression8 bits (256 centroids)8 بتات (256 مركزًا)5 bits (32 centroids)5 بتات (32 مركزًا)
Conv versus FC in AlexNetطبقات Conv مقابل FC في AlexNet

Huffman coding and Deep Compressionترميز Huffman وDeep Compression

Prefix code, frequent symbols short, lossless. Probabilities 0.5, 0.25, 0.125, 0.125 give codes 0, 10, 110, 111. Part 07: Huffman coding and Deep Compression

ترميز بادئة (prefix code): الرموز المتكررة تأخذ رموزًا قصيرة، وهو ضغط بلا فقد (lossless). الاحتمالات 0.5, 0.25, 0.125, 0.125 تعطي الرموز 0, 10, 110, 111. الجزء 07: ترميز Huffman وDeep Compression

Lˉ=∑ipiℓi=0.5(1)+0.25(2)+0.125(3)+0.125(3)=1.75 bits\bar{L} = \sum_i p_i \ell_i = 0.5(1) + 0.25(2) + 0.125(3) + 0.125(3) = 1.75 \text{ bits}
Against 2 bits fixed lengthمقارنةً بطول ثابت قدره 2 بت
StageالمرحلةReducesما تقللهCumulativeالنسبة التراكميةRetrainsإعادة التدريب
Pruningالتقليم (Pruning)Number of weightsعدد الأوزان9x to 13x9x to 13xYesنعم
K-means quantizationتكميم K-meansBits per weightعدد البتات لكل وزن27x to 31x27x to 31xYes, centroid fine-tuningنعم، بالتدريب الدقيق للمراكز
Huffman codingترميز HuffmanAverage code lengthمتوسط طول الرمز35x to 49x35x to 49xNo, lossless encodingلا، ترميز بلا فقد
Pipeline, cumulative ratio, same accuracy at every stageمراحل الخط، والنسبة التراكمية، والدقة نفسها في كل مرحلة

AlexNet through the pipelineAlexNet عبر مراحل الخط

Originalالأصلي
61M weights, 240 MB61M وزن، 240 MB
Prunedبعد التقليم
11% kept, 9x fewer weightsيبقى 11%، أي أوزان أقل بـ9x
Quantizedبعد التكميم
conv 8 bits, FC 5 bits, plus a 4-bit relative index, 27xconv بـ8 بتات، وFC بـ5 بتات، مع فهرس نسبي بطول 4-bit، 27x
Huffman codedبعد ترميز Huffman
6.9 MB, 35x, same accuracy6.9 MB، 35x، بالدقة نفسها
Size estimateتقدير الحجم
0.11 × 9.4 / 32 ≈ 3.2%
  • VGGNet 550 MB → 11.3 MB (49x, paper: 552 MB); GoogleNet 10x, ResNet-18 11x: compact networks have less redundancy.VGGNet من 550 MB → 11.3 MB (49x، وفي الورقة: 552 MB)؛ GoogleNet 10x، وResNet-18 11x: الشبكات المدمجة فيها تكرار أقل.
  • Huffman codes two streams: cluster indexes and relative sparse indexes, saving 20 to 30 percent.Huffman يرمّز تيارين: فهارس العناقيد والفهارس المتفرقة النسبية (relative sparse indexes)، ويوفر من 20 إلى 30 بالمئة.
LayerالطبقةCountطريقة العدWeightsالأوزان
3x3 conv, 64 to 1283x3 conv، من 64 إلى 12864 × 128 × 964 × 128 × 973,72873,728
1x1 squeeze, 64 to 161x1 squeeze، من 64 إلى 1664 × 1664 × 161,0241,024
1x1 expand, 16 to 641x1 expand، من 16 إلى 6416 × 6416 × 641,0241,024
3x3 expand, 16 to 643x3 expand، من 16 إلى 6416 × 64 × 916 × 64 × 99,2169,216
Fire module totalمجموع Fire module1,024 + 1,024 + 9,2161,024 + 1,024 + 9,21611,264 (≈6.5x fewer)11,264 (أقل بنحو 6.5x)
Fire module weightsأوزان Fire module
NetworkالشبكةCompressionالضغطSizeالحجمvs AlexNetمقارنة بـ AlexNetAccuracyالدقة
AlexNetAlexNetnoneبدون240 MB240 MB1x1x57.2% / 80.3%57.2% / 80.3%
AlexNetAlexNetSVDSVD48 MB48 MB5x5x56.0% / 79.4%56.0% / 79.4%
AlexNetAlexNetDeep CompressionDeep Compression6.9 MB6.9 MB35x35x57.2% / 80.3%57.2% / 80.3%
SqueezeNetSqueezeNetnoneبدون4.8 MB4.8 MB50x50x57.5% / 80.3%57.5% / 80.3%
SqueezeNetSqueezeNetDeep CompressionDeep Compression0.47 MB0.47 MB510x510x57.5% / 80.3%57.5% / 80.3%
SqueezeNet and Deep Compression (top-1 / top-5)SqueezeNet و Deep Compression (top-1 / top-5)

K-means at runtime and the linear previewK-means وقت التشغيل ولمحة عن التكميم الخطي

uint indexes plus the float codebook go into decode; everything after decode is float. Part 08: K-means at runtime and linear quantization

فهارس uint مع كتاب الرموز العشري تدخل إلى خطوة فك الترميز (decode)؛ وكل ما بعد فك الترميز عشري (float). الجزء 08: K-means وقت التشغيل والتكميم الخطي

CostالتكلفةFP32FP32K-means, N = 2K-means، N = 2
Weight words from DRAMكلمات الأوزان المقروءة من DRAM16161 index word + 4 codebook words = 5كلمة فهارس واحدة + 4 كلمات لكتاب الرموز = 5
DRAM energy at 640 pJطاقة DRAM عند 640 pJ10,240 pJ10,240 pJ3,200 pJ (3.2x less)3,200 pJ (أقل بـ3.2x)
16 FP32 MULT + ADD16 عملية FP32 MULT + ADD59.2 + 14.4 = 73.6 pJ59.2 + 14.4 = 73.6 pJ73.6 pJ (unchanged)73.6 pJ (دون تغيير)
Codebook lookupsعمليات البحث في كتاب الرموزnoneلا يوجد16 extra on-chip reads16 قراءة إضافية داخل الشريحة (on-chip)
The 16-weight example per inferenceمثال الأوزان الـ 16 لكل عملية استدلال
r=S (q−Z),S=1.07,Z=−1r = S\,(q - Z), \qquad S = 1.07,\quad Z = -1
Linear (affine) quantization, slide 43التكميم الخطي (affine)، الشريحة 43
qqr = S(q - Z)r = S(q - Z)K-means centroidمركز K-means
-2-2-1 × 1.07 = -1.07-1 × 1.07 = -1.07-1.00-1.00
-1-10 × 1.07 = 00 × 1.07 = 00.000.00
001 × 1.07 = 1.071 × 1.07 = 1.071.501.50
112 × 1.07 = 2.142 × 1.07 = 2.142.002.00
Linear levels against K-means centroidsالمستويات الخطية مقابل مراكز K-means
  • Mean squared error over all 16 weights: K-means about 0.006, linear about 0.047. Worst linear error: 1.53 → 1.07, 0.46.متوسط مربع الخطأ (MSE) على كل الأوزان الـ16: في K-means نحو 0.006، وفي الخطي نحو 0.047. أسوأ خطأ في الخطي: 1.53 → 1.07، أي 0.46.
  • The uniform grid fits worse but buys integer-only arithmetic, the subject of lecture 05-2.الشبكة المنتظمة تطابق الأوزان بشكل أسوأ لكنها تشتري حسابًا بالأعداد الصحيحة فقط، وهذا موضوع المحاضرة 05-2.

Slide errataأخطاء الشرائح

Answer with the corrected fact and name the slide. Part 01, Part 02, Part 03, Part 05, Part 06, Part 07, Part 08

أجب بالمعلومة المصححة واذكر رقم الشريحة. الجزء 01، الجزء 02، الجزء 03، الجزء 05، الجزء 06، الجزء 07، الجزء 08

What the slides get wrongما تخطئ فيه الشرائح

Slide 3الشريحة 3
The 16x label matches int32 MULT (3.1 / 0.2 = 15.5x), but its guide line sits at fp32 MULT (18.5x). The axis is energy relative to an 8-bit int ADD, not pJ.التسمية 16x تطابق ضرب int32 (3.1 / 0.2 = 15.5x)، لكن خطها الإرشادي يقع عند ضرب fp32 (18.5x). المحور يمثل الطاقة نسبةً إلى جمع int بطول 8-bit، وليس بوحدة pJ.
Slide 7الشريحة 7
Fixed-point place-value labels left above the exponent bits. Exponent bits form one unsigned integer E.تسميات القيمة المكانية للفاصلة الثابتة بقيت فوق بتات الأس. بتات الأس تشكّل عددًا صحيحًا واحدًا بلا إشارة E.
Slide 9الشريحة 9
Normal numbers need exponent ≠ 0 and ≠ 255.الأعداد الطبيعية تتطلب أن يكون الأس ≠ 0 و≠ 255.
Slide 15الشريحة 15
Number line not to scale: the gap below 2^-126 is one step of 2^-149.خط الأعداد ليس بمقياس حقيقي: الفجوة تحت 2^-126 خطوة واحدة مقدارها 2^-149.
Slide 20الشريحة 20
E2M1 0111 = 1.5 × 2^2 = 6, not 1.في E2M1: 0111 = 1.5 × 2^2 = 6، وليست 1.
Slide 29الشريحة 29
The learning rate is not stated; the numbers imply lr = 1.معدل التعلم غير مذكور؛ الأرقام تفترض lr = 1.
Slide 33الشريحة 33
The "before quantization" weights are already pruned, hence the hole at 0.الأوزان المعنونة "قبل التكميم" (before quantization) مقلّمة أصلًا، ولذلك توجد فجوة عند 0.
Slide 39الشريحة 39
LeNet rows are MNIST top-1, ImageNet rows are top-5. VGG-16 is 552 MB in the paper; 49x holds.صفوف LeNet هي دقة top-1 على MNIST، وصفوف ImageNet هي top-5. حجم VGG-16 في الورقة 552 MB؛ ونسبة 49x تبقى صحيحة.
Slide 42الشريحة 42
Codebook colours of 1.50 and 0.00 swapped. Values and indexes are right.ألوان كتاب الرموز للقيمتين 1.50 و0.00 متبادلة. القيم والفهارس صحيحة.
Slide 44الشريحة 44
Mostly pruning references; Deep Compression and SqueezeNet are missing.معظمها مراجع عن التقليم؛ Deep Compression وSqueezeNet غير موجودين.