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

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

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

Quantization (III): PTQ granularity, range clipping, rounding, QAT, binary/ternary and mixed precision compressed onto one page: the definitions, formulas and numbers to have in your head before a quiz or exam.محاضرة «التكميم (Quantization) الجزء الثالث: دقة PTQ، وقص المدى، والتقريب، وQAT، والثنائي والثلاثي، والدقة المختلطة» مضغوطة في صفحة واحدة: التعريفات والمعادلات والأرقام التي يجب أن تكون حاضرة في ذهنك قبل الاختبار القصير أو الامتحان.

Symmetric quantization and granularityالتكميم المتماثل ودرجة التفصيل (granularity)

PTQ picks (S, Z) without retraining in three steps: granularity, range clipping, rounding. Part 01: Per-tensor vs per-channel

يختار PTQ القيم (S, Z) دون إعادة تدريب في ثلاث خطوات: درجة التفصيل (granularity)، ثم قص المدى (range clipping)، ثم التقريب (rounding). الجزء 01: Per-tensor مقابل per-channel

S=∣r∣max⁡qmax⁡,qmax⁡=2N−1−1,q=clip⁡ ⁣(round⁡ ⁣(WS),−qmax⁡,qmax⁡)S = \dfrac{|r|_{\max}}{q_{\max}},\qquad q_{\max} = 2^{N-1} - 1,\qquad q = \operatorname{clip}\!\left(\operatorname{round}\!\left(\dfrac{W}{S}\right), -q_{\max}, q_{\max}\right)
Symmetric, Z = 0; reconstruct with Ŵ = S qمتماثل، Z = 0؛ وإعادة البناء بـ Ŵ = S q
Si=max⁡j∣Wij∣qmax⁡,error=∥W−S⊙q∥FS_i = \dfrac{\max_j |W_{ij}|}{q_{\max}},\qquad \text{error} = \lVert \mathbf{W} - \mathbf{S} \odot \mathbf{q} \rVert_F
Per-channel: one scale per output channelلكل قناة: مقياس واحد لكل قناة إخراج
Granularityدرجة التفصيلValues sharing one scaleالقيم التي تتشارك scale واحدًاNumber of scalesعدد الـ scalesWeaknessنقطة الضعف
Per-tensorلكل موتر (per-tensor)The whole weight tensorموتر الأوزان كاملًا1One outlier sets the step size for everyoneقيمة شاذة واحدة تحدد حجم الخطوة للجميع
Per-channelلكل قناة (per-channel)One output channel (one row of W)قناة خرج واحدة (صف واحد من W)C_outHard to apply to activationsيصعب تطبيقه على التنشيطات
Groupبالمجموعات (group)A block of 16 to 64 elementsكتلة من 16 إلى 64 عنصرًا(total weights) / G(عدد الأوزان الكلي) / GMore scale storage and logicتخزين أكثر للـscales ومنطق أكثر
Granularity menuخيارات درجة التفصيل

Slides 9 to 13, the running 4 × 4 matrixالشرائح 9 إلى 13، مصفوفة 4 × 4 المستمرة

Per-tensor, 2 bits
q_max = 1, S = 2.12, error √5.219 = 2.28q_max = 1، S = 2.12، والخطأ √5.219 = 2.28
Per-channel, 2 bits
S = (2.09, 2.12, 1.92, 1.87), one code flips (-1.03 from 0 to -1), error √4.32 = 2.08S = (2.09, 2.12, 1.92, 1.87)، ويتغير رمز واحد (-1.03 من 0 إلى -1)، والخطأ √4.32 = 2.08
Why output channelsلماذا قنوات الخرج
y_i = S_i s_x Σ_j q_ij x_j: the scale factors out of the integer dot producty_i = S_i s_x Σ_j q_ij x_j: يخرج الـscale عاملًا مشتركًا من الضرب النقطي الصحيح

Group quantization, VS-Quant and MXالتكميم بالمجموعات (group quantization) وVS-Quant وMX

At 4 bits INT4 has only 15 symmetric levels, so one big weight zeroes most of its channel. Group scales confine the damage. Part 02: Group quantization

عند 4 بتات لا يملك INT4 إلا 15 مستوى متماثلًا، لذلك يكفي وزن كبير واحد ليحوّل معظم قناته إلى أصفار. الـscales على مستوى المجموعة تحصر هذا الضرر. الجزء 02: التكميم بالمجموعات

r=γ⋅Sq (q−Z),r=(q−z)⋅sl0⋅sl1⋯r = \gamma \cdot S_q\,(q - Z),\qquad r = (q - z)\cdot s_{l_0}\cdot s_{l_1}\cdots
VS-Quant: integer S_q per vector, FP γ per channel or tensorVS-Quant: قيمة S_q صحيحة لكل متجه، وγ بالفاصلة العائمة لكل قناة أو موتر
beff=belement+∑lbscale,lglb_{\text{eff}} = b_{\text{element}} + \sum_{l} \frac{b_{\text{scale},l}}{g_l}
g_l: elements sharing one level-l scaleg_l: العناصر التي تتشارك مقياسًا واحدًا من المستوى l
ApproachالطريقةElementالعنصرL0 scalescale المستوى L0L1 scalescale المستوى L1Effective bitsالبتات الفعلية
Per-channelلكل قناة (per-channel)INT4per channel, FP16لكل قناة، FP16noneلا يوجد4
VSQINT4UINT4 per 16UINT4 لكل 16FP16 per channelFP16 لكل قناة4 + 4/16 = 4.25
MX4S1M2 (3)E1M0 per 2E1M0 لكل 2E8M0 per 16E8M0 لكل 163 + 1/2 + 8/16 = 4
MX6S1M4 (5)E1M0 per 2E1M0 لكل 2E8M0 per 16E8M0 لكل 165 + 1/2 + 8/16 = 6
MX9S1M7 (8)E1M0 per 2E1M0 لكل 2E8M0 per 16E8M0 لكل 168 + 1/2 + 8/16 = 9
Slide 21 table (per-channel FP16 terms ignored)جدول الشريحة 21 (مع إهمال حدود FP16 لكل قناة)
FormatالصيغةDefined byالجهة المعرِّفةScalesالـ scalesEffective bitsالبتات الفعلية
MXFP4OCP MX v1.0E8M0 per 32E8M0 لكل 324 + 8/32 = 4.25
NVFP4NVIDIA BlackwellFP8 E4M3 per 16, FP32 per tensorFP8 E4M3 لكل 16، وFP32 لكل موترabout 4.5نحو 4.5
Industry formatsالصيغ المعتمدة في الصناعة

Activation range clippingقص مدى التنشيطات (activation range clipping)

Weights are fixed, so their range is read directly. Activations change with every input, so their range is estimated before deployment. Part 03: Activation range clipping

الأوزان ثابتة، لذلك يُقرأ مداها مباشرة. أما التنشيطات (activations) فتتغير مع كل مدخل، لذلك يُقدَّر مداها قبل النشر. الجزء 03: قص مدى التنشيطات

r^(t)=α r(t)+(1−α) r^(t−1)\hat r^{(t)} = \alpha\, r^{(t)} + (1 - \alpha)\,\hat r^{(t-1)}
EMA with α on the new value, so α is smallEMA مع α على القيمة الجديدة، لذلك تكون α صغيرة
E[(X−Q(X))2]=E[(∣X∣−∣r∣max⁡)2 1∣X∣>∣r∣max⁡]⏟clipping+Δ212⏟rounding,Δ=2∣r∣max⁡2M\mathbb{E}\big[(X - Q(X))^2\big] = \underbrace{\mathbb{E}\big[(|X| - |r|_{\max})^2\,\mathbf{1}_{|X| > |r|_{\max}}\big]}_{\text{clipping}} + \underbrace{\tfrac{\Delta^2}{12}}_{\text{rounding}},\qquad \Delta = \dfrac{2|r|_{\max}}{2^M}
Widening the range lowers clipping error and raises rounding errorتوسيع المدى يخفض خطأ القصّ ويرفع خطأ التقريب
DKL(P ∥ Q)=∑iP(xi) log⁡P(xi)Q(xi)D_{KL}(P\,\|\,Q) = \sum_{i} P(x_i)\,\log\dfrac{P(x_i)}{Q(x_i)}
KL calibration picks the threshold that loses the least informationمعايرة KL تختار الحد الذي يفقد أقل قدر من المعلومات
MethodالطريقةWhenمتىCharacterالطابع
EMA (type 1)EMA (النوع 1)During trainingأثناء التدريبSmooth observed min and max over stepsتنعيم القيم الصغرى والعظمى المرصودة عبر الخطوات
Mean of min/maxمتوسط min/maxCalibration batchesدفعات المعايرة (calibration batches)Cheap, ignores the shape of the bulkرخيص، ويتجاهل شكل الكتلة الرئيسية من القيم
Minimize MSEتقليل MSECalibration batchesدفعات المعايرةAnalytical for Laplace or Gaussian, OCTAV for any dataحل تحليلي لتوزيع Laplace أو Gaussian، وOCTAV لأي بيانات
Minimize KLتقليل KLCalibration batchesدفعات المعايرةCompares histograms, TensorRT entropy calibrationيقارن المدرجات التكرارية (histograms)، وهو معايرة الإنتروبيا في TensorRT
Ways to set the rangeطرق ضبط المدى
Bits Mعدد البتات MOptimal clipنقطة القص المثلىClip at b = 0.2القص عند b = 0.2Fraction clippedنسبة القيم المقصوصة
22.83b0.5665.9%
33.89b0.7782.0%
45.03b1.0060.65%
MSE-optimal clip for Laplace(0, b)نقطة القص المثلى وفق MSE لتوزيع Laplace(0, b)
  • EMA worked step with α = 0.1: max 6.0, then observe 8.0, giving 6.20; then observe 5.0, giving 6.08.خطوة محلولة لـEMA مع α = 0.1: القيمة العظمى 6.0، ثم نرصد 8.0 فنحصل على 6.20، ثم نرصد 5.0 فنحصل على 6.08.
  • OCTAV solves the MSE clip with Newton-Raphson in a few iterations. Laplace b = 1, 4 bits: 1.00, 2.00, 2.97, 3.88, 4.59, 4.96, 5.03.يحل OCTAV مسألة نقطة القص المثلى وفق MSE بطريقة Newton-Raphson في عدد قليل من التكرارات. لتوزيع Laplace مع b = 1 و4 بتات: 1.00, 2.00, 2.97, 3.88, 4.59, 4.96, 5.03.
NetworkالشبكةFP32FP32OCTAV int4OCTAV int4
ResNet-5076.0775.84
MobileNet-V271.7170.88
BERT-Large91.0087.09
OCTAV int4 top-1دقة top-1 لـ OCTAV بـ int4

AdaRound and PTQ resultsAdaRound ونتائج PTQ

Rounding to nearest minimizes each weight's own error, but correlated errors add up in Wx. Optimize the layer output instead. Part 04: AdaRound and PTQ results

التقريب إلى أقرب قيمة يقلل خطأ كل وزن بمفرده، لكن الأخطاء المترابطة تتراكم في Wx. لذلك حسّن خرج الطبقة بدلًا من ذلك. الجزء 04: AdaRound ونتائج PTQ

w~=⌊⌊w⌋+δ⌉,δ∈[0,1]\tilde{w} = \big\lfloor \lfloor w \rfloor + \delta \big\rceil,\qquad \delta \in [0, 1]
Floor or ceil per weightfloor أو ceil لكل وزن
arg⁡min⁡V  ∥Wx−⌊⌊W⌋+h(V)⌉ x∥F2+λfreg(V)\arg\min_{\mathbf{V}} \;\big\lVert \mathbf{W}\mathbf{x} - \big\lfloor \lfloor \mathbf{W} \rfloor + \mathbf{h}(\mathbf{V}) \big\rceil\,\mathbf{x} \big\rVert_F^2 + \lambda f_{reg}(\mathbf{V})
AdaRound: weight-only, layer by layer, a little unlabeled dataAdaRound: للأوزان فقط، طبقةً طبقة، مع قليل من البيانات غير الموسومة
h(V)=clip⁡(σ(V)(ζ−γ)+γ,  0,  1),freg(V)=∑i,j1−∣2h(Vi,j)−1∣βh(V) = \operatorname{clip}\big(\sigma(V)(\zeta - \gamma) + \gamma,\; 0,\; 1\big),\qquad f_{reg}(\mathbf{V}) = \sum_{i,j} 1 - \lvert 2h(V_{i,j}) - 1 \rvert^{\beta}

AdaRound essentialsأساسيات AdaRound

Slide 33 exampleمثال الشريحة 33
[0.3, 0.5, 0.7, 0.2]: nearest gives [0, 1, 1, 0], AdaRound may return [0, 0, 1, 0][0.3, 0.5, 0.7, 0.2]: التقريب إلى الأقرب يعطي [0, 1, 1, 0]، وقد يعيد AdaRound [0, 0, 1, 0]
V
A learnable continuous tensor shaped like W, optimized by gradient descent (not random)موتر مستمر قابل للتعلم بشكل W نفسه، يُحسَّن بالانحدار التدرجي (gradient descent) (وليس عشوائيًا)
h(V)
Rectified sigmoid into [0, 1], ζ = 1.1, γ = −0.1دالة sigmoid مقوَّمة (rectified sigmoid) إلى [0, 1]، مع ζ = 1.1 وγ = −0.1
f_reg
Pushes each h(V) to exactly 0 or 1, with β annealedيدفع كل h(V) ليصبح 0 أو 1 تمامًا، مع تخفيض β تدريجيًا (annealing)
Resultالنتيجة
4-bit ResNet-18: 23.99% (nearest) to 68.71%, FP 69.68%ResNet-18 بـ4 بتات: من 23.99% (التقريب إلى الأقرب) إلى 68.71%، وFP يعطي 69.68%
Knobمفتاح التحكمOptionsالخياراتQuestion it answersالسؤال الذي يجيب عنه
Zero pointنقطة الصفر (zero point)Asymmetric, symmetricغير متماثل، متماثلWhere real 0 sits on the gridأين يقع الصفر الحقيقي 0 على الشبكة
Granularityدرجة التفصيل (granularity)Per-tensor, per-channel, groupper-tensor، per-channel، groupHow many values share one Sكم قيمة تتشارك S واحدًا
Range clippingقص المدى (range clipping)EMA, KL, MSEEMA، KL، MSEWhich r_min and r_max set Sأي r_min وr_max يحددان S
Roundingالتقريب (rounding)Nearest, AdaRoundإلى الأقرب، AdaRoundWhich grid point each weight takesأي نقطة على الشبكة يأخذها كل وزن
The four PTQ knobsمفاتيح التحكم الأربعة في PTQ
NetworkالشبكةSym per-tensor W, KL actأوزان متماثلة per-tensor، وتنشيطات بمعايرة KLSym per-channel W, asym EMA actأوزان متماثلة per-channel، وتنشيطات غير متماثلة بـ EMA
GoogleNet−0.45%0%
ResNet-50−0.13%−0.6%
ResNet-152−0.08%−1.8%
MobileNetV1not reportedغير منشور−11.8%
MobileNetV2not reportedغير منشور−2.1%
INT8 PTQ top-1 drop (slide 37)انخفاض دقة top-1 مع PTQ بـ INT8 (الشريحة 37)

Quantization-aware trainingالتدريب الواعي بالتكميم (quantization-aware training)

Start from a pretrained FP model. Keep an FP copy of W so tiny updates can accumulate until a weight crosses a rounding boundary. Part 05: QAT, fake quantization and STE

ابدأ من نموذج FP مدرّب مسبقًا. احتفظ بنسخة FP من W حتى تتراكم التحديثات الصغيرة إلى أن يعبر الوزن حدًا من حدود التقريب. الجزء 05: QAT والتكميم الزائف وSTE

ck←ck−η∑i: Ii=k∂L∂Wic_k \leftarrow c_k - \eta \sum_{i:\,I_i = k} \frac{\partial L}{\partial W_i}
K-means QAT: centroid updateQAT مع K-means: تحديث المركز

K-means QATQAT مع K-means

Ruleالقاعدة
Group gradients by cluster index, sum, multiply by the learning rate, subtract from the centroidصنّف التدرجات حسب فهرس العنقود، ثم اجمعها، ثم اضربها في معدل التعلم، ثم اطرحها من المركز (centroid)
Slide 40, lr = 1الشريحة 40، lr = 1
[2.00, 1.50, 0.00, −1.00] becomes [1.96, 1.48, −0.04, −0.97][2.00, 1.50, 0.00, −1.00] تصبح [1.96, 1.48, −0.04, −0.97]
Tensor or operationالموتر أو العمليةWhat happensما يحدثValue usedالقيمة المستخدمة
Weights Wالأوزان WFP copy, updated by the optimizerنسخة FP يحدّثها المُحسِّن (optimizer)Q(W) = S_W q_W
Conv, batch norm, ReLUالالتفاف وbatch norm وReLURun in FP on fake-quantized valuesتعمل بدقة FP على قيم مكمَّمة تكميمًا زائفًاNot quantized insideغير مكمَّمة من الداخل
Layer output Yخرج الطبقة YFP result of the blockنتيجة الكتلة بدقة FPQ(Y) = S_Y (q_Y − Z_Y)
Linear QAT: fake quantizationQAT الخطي: التكميم الزائف
gW=∂L∂Q(W)⋅∂Q(W)∂W⏟= 0=0⟶gW≈∂L∂Q(W),gY←∂L∂Q(Y)g_W = \frac{\partial L}{\partial Q(W)}\cdot\underbrace{\frac{\partial Q(W)}{\partial W}}_{=\,0} = 0 \quad\longrightarrow\quad g_W \approx \frac{\partial L}{\partial Q(W)},\qquad g_Y \leftarrow \frac{\partial L}{\partial Q(Y)}
Straight-through estimator: treat Q as identity in the backward passالمقدِّر المباشر (straight-through estimator): عامِل Q على أنها دالة الهوية في المرور العكسي
NetworkالشبكةFPFPPTQ asym tensorPTQ غير متماثل per-tensorPTQ sym channelPTQ متماثل per-channelQAT asym tensorQAT غير متماثل per-tensorQAT sym channelQAT متماثل per-channel
MobileNetV170.90.159.170.070.7
MobileNetV271.90.169.870.971.1
NASNet-Mobile74.072.272.173.073.0
INT8 ImageNet top-1 (%), Krishnamoorthi 2018دقة top-1 على ImageNet بـ INT8 (%)، Krishnamoorthi 2018

Binary weightsالأوزان الثنائية (binary weights)

Weights of ±1 turn multiplies into additions and subtractions. Part 06: Binary weights

الأوزان التي قيمها ±1 تحوّل عمليات الضرب إلى عمليات جمع وطرح. الجزء 06: الأوزان الثنائية

σ(r)=min⁡ ⁣(max⁡ ⁣(r+12, 0), 1)\sigma(r) = \min\!\Big(\max\!\Big(\tfrac{r+1}{2},\,0\Big),\,1\Big)
Hard sigmoid for stochastic binarization; r = 0.4 gives p = 0.7hard sigmoid للتثنية العشوائية؛ r = 0.4 تعطي p = 0.7
DeterministicحتميStochastic (BinaryConnect)عشوائي (BinaryConnect)
Ruleالقاعدةq = sign(r)q = +1 with p = σ(r), else −1q = +1 باحتمال p = σ(r)، وإلا −1
At r = 0عند r = 0+1±1, each with p = 0.5±1، لكل منهما احتمال p = 0.5
Expected valueالقيمة المتوقعةsign(r)r for |r| ≤ 1r عندما |r| ≤ 1
HardwareالعتادRead the sign bitقراءة بت الإشارةNeeds random bits per weightيحتاج بتات عشوائية لكل وزن
Deterministic against stochasticالحتمي مقابل العشوائي
W≈α sign⁡(W),α=1n∥W∥1\mathbf{W} \approx \alpha\,\operatorname{sign}(\mathbf{W}),\qquad \alpha = \frac{1}{n}\lVert \mathbf{W} \rVert_1
BWN scale, from setting dJ/dα = 2αn − 2‖W‖₁ to zeroمقياس BWN، من مساواة dJ/dα = 2αn − 2‖W‖₁ بالصفر

Slide 54 numbersأرقام الشريحة 54

Σ|W|
16.78 over n = 16 weights16.78 على n = 16 وزنًا
α
16.78 / 16 = 1.04875 (about 1.05)16.78 / 16 = 1.04875 (نحو 1.05)
Squared errorالخطأ التربيعي
9.28 with sign only, 9.245 with α9.28 بالإشارة فقط، و9.245 مع α
Dot productالضرب النقطي
[8, −3, 5, −1] · [5, 2, 0, 1] = 33; with signs it is 2, no multiplies[8, −3, 5, −1] · [5, 2, 0, 1] = 33؛ وبالإشارات فقط يساوي 2، دون أي عملية ضرب

XNOR and popcountXNOR وpopcount

Encode +1 as bit 1 and −1 as bit 0. XNOR is then the product. Part 07: XNOR and popcount

رمّز +1 بالبت 1 و−1 بالبت 0. عندها تكون XNOR هي حاصل الضرب. الجزء 07: XNOR وpopcount

WxW × xXNOR
+1+1+11
+1−1−10
−1−1+11
−1+1−10
Product against XNOR of the bitsحاصل الضرب مقابل XNOR للبتات
y=m−(n−m)=2m−n=−n+(popcount⁡ ⁣(W xnor x)≪1)y = m - (n - m) = 2m - n = -n + \left(\operatorname{popcount}\!\left(W\ \text{xnor}\ x\right) \ll 1\right)
m matches out of nm تطابقًا من أصل n
  • Slide example: 1010 xnor 1101 = 1000, popcount 1, y = −4 + 2 = −2.مثال الشريحة: 1010 xnor 1101 = 1000، وpopcount يساوي 1، وy = −4 + 2 = −2.
  • Exercise n = 8: popcount 5, y = −8 + 10 = 2.تمرين مع n = 8: popcount يساوي 5، وy = −8 + 10 = 2.
  • Summing XNOR bits alone counts only matches and gives 1, not −2.جمع بتات XNOR وحدها يعدّ التطابقات فقط ويعطي 1، لا −2.
InputالمدخلWeightالوزنOperationsالعملياتMemoryالذاكرةComputationالحساب
RealحقيقيRealحقيقيmultiply and addضرب وجمع1x1x
RealحقيقيBinaryثنائيadd and subtractجمع وطرح≈32x lessأقل بنحو 32x≈2x lessأقل بنحو 2x
BinaryثنائيBinaryثنائيXNOR and popcountXNOR وpopcount≈32x lessأقل بنحو 32x≈58x lessأقل بنحو 58x
Memory and compute against FPالذاكرة والحساب مقارنة بـ FP
S=64 c NWc NW+64S = \frac{64\,c\,N_W}{c\,N_W + 64}
XNOR-Net speedup: 62.27x theoretical at c = 256, 3 × 3; 58x measuredتسريع XNOR-Net: 62.27x نظريًا عند c = 256 ونواة 3 × 3؛ و58x مقيسًا

Accuracy cost and ternary quantizationتكلفة الدقة والتكميم الثلاثي (ternary quantization)

Scale factors recover about 16 points between BNN and XNOR-Net. Binarizing activations is the expensive step. Part 08: Ternary, TWN and TTQ

تستعيد معاملات التحجيم (scale factors) نحو 16 نقطة بين BNN وXNOR-Net. أما تحويل التنشيطات إلى ثنائية فهو الخطوة المكلفة. الجزء 08: التكميم الثلاثي وTWN وTTQ

MethodالطريقةW bitsبتات WA bitsبتات AScale onالـ scale علىDeltaالفرق
BWN132Weights onlyالأوزان فقط+0.2
XNOR-Net11Weights and activationsالأوزان والتنشيطات−12.4
BNN11Noneلا شيء−28.7
AlexNet top-1 change (points)التغير في دقة top-1 لـ AlexNet (بالنقاط)
q={rt,r>Δ0,∣r∣≤Δ−rt,r<−ΔΔ=0.7 E(∣r∣),rt=E∣r∣>Δ(∣r∣)q = \begin{cases} r_t, & r > \Delta \\ 0, & |r| \le \Delta \\ -r_t, & r < -\Delta \end{cases} \qquad \Delta = 0.7\,\mathbb{E}(|r|),\quad r_t = \mathbb{E}_{|r| > \Delta}(|r|)
TWN; TTQ replaces r_t with trained w_p and w_nTWN؛ وTTQ تستبدل r_t بقيمتين متعلَّمتين w_p وw_n

Ternary on the running matrixالتكميم الثلاثي على المصفوفة المستمرة

Thresholdالعتبة
Δ = 0.7 × 16.78 / 16 = 0.73Δ = 0.7 × 16.78 / 16 = 0.73
Survivorsالأوزان الباقية
Eleven weights above Δ, r_t = 16.50 / 11 = 1.5, five become 0أحد عشر وزنًا فوق Δ، وr_t = 16.50 / 11 = 1.5، وخمسة أوزان تصبح 0
Squared errorالخطأ التربيعي
Ternary 2.09 against binary 9.25الثلاثي 2.09 مقابل الثنائي 9.25
ResNet-18 top-1دقة top-1 لـ ResNet-18
FP 69.6, BWN 60.8, TWN 65.3, TTQ 66.6FP 69.6، وBWN 60.8، وTWN 65.3، وTTQ 66.6
TWNTTQ
Valuesالقيم{-r_t, 0, +r_t}{-w_n, 0, +w_p}
ScaleالـscaleOne, computed from the weightsواحد، يُحسب من الأوزانTwo, trained by gradient descentاثنان، يُدرَّبان بالانحدار التدرجي (gradient descent)
ThresholdالعتبةΔ = 0.7 · E(|r|)Δ = t · max(|r|), t = 0.05
Storageالتخزين2 bits + 1 FP scale2 بت + scale واحد بدقة FP2 bits + 2 FP scales2 بت + اثنان من الـscales بدقة FP
ResNet-18 top-1دقة top-1 لـResNet-1865.366.6
TWN against TTQTWN مقابل TTQ
FamilyالعائلةStoredما يُخزَّنArithmeticالحسابBits per weightالبتات لكل وزن
Full precisionالدقة الكاملة (full precision)FP32 weightsأوزان FP32Floating pointفاصلة عائمة32
K-meansK-meansInteger indices plus FP codebookفهارس صحيحة مع دفتر رموز (codebook) بدقة FPFloating pointفاصلة عائمة2 plus codebook2 مع دفتر الرموز
Linearخطي (linear)Integer weights plus S and Zأوزان صحيحة مع S وZIntegerأعداد صحيحة2 to 8من 2 إلى 8
Binary or ternaryثنائي أو ثلاثي1 or 2 bit weights plus a scaleأوزان بـ1 أو 2 بت مع scaleBit operationsعمليات على البتات1 or 21 أو 2
The quantization familiesعائلات التكميم

Mixed precision and HAQالدقة المختلطة (mixed precision) وHAQ

Each layer picks its own weight and activation width. Part 09: Mixed precision and HAQ

كل طبقة تختار عرض البتات الخاص بها للأوزان وللتنشيطات. الجزء 09: الدقة المختلطة وHAQ

∣S∣=(Bw×Ba)n=64n=26n|\mathcal{S}| = (B_w \times B_a)^{n} = 64^{n} = 2^{6n}
MobileNetV1, 28 layers: 2^168 ≈ 3.7e50MobileNetV1، 28 طبقة: 2^168 ≈ 3.7e50
bk=round⁡(bmin⁡−0.5+ak (bmax⁡−bmin⁡+1)),bmin⁡=2, bmax⁡=8b_k = \operatorname{round}\big(b_{\min} - 0.5 + a_k\,(b_{\max} - b_{\min} + 1)\big),\quad b_{\min}=2,\ b_{\max}=8
HAQ action to bit widthتحويل فعل HAQ إلى عرض بتات

HAQHAQ

Agentالوكيل
DDPG actor-critic, one layer per stepنموذج actor-critic من نوع DDPG، طبقة واحدة في كل خطوة
Stateالحالة
A 10-feature description of the layerوصف للطبقة من 10 خصائص
Actionالفعل
Continuous a_k, rounded to a bit width in [2, 8]قيمة مستمرة a_k تُقرَّب إلى عرض بتات ضمن [2, 8]
Rewardالمكافأة
0.1 × (quantized accuracy − original accuracy)0.1 × (الدقة بعد التكميم − الدقة الأصلية)
Budgetالميزانية
Measured latency or energy on the accelerator; bits lowered until the budget is metزمن الاستجابة أو الطاقة المقيسة فعليًا على المسرّع؛ وتُخفَّض البتات حتى تتحقق الميزانية
Latencyزمن الاستجابةUniform 4-bit (PACT)4 بت موحد (PACT)HAQHAQ
≈45.5 ms62.44%67.40%
≈57.7 ms67.00%70.58%
≈70 ms70.46%71.20%
MobileNetV1 on the edge, top-1دقة top-1 لـ MobileNetV1 على الأجهزة الطرفية
Edge (BISMO)طرفي (BISMO)Cloud (BISMO)سحابي (BISMO)
Batch sizeحجم الدفعة (batch size)116
Latency limited byزمن الاستجابة محدود بـMemory traffic of depthwise layersحركة الذاكرة في طبقات depthwiseArithmetic of pointwise layersالعمليات الحسابية في طبقات pointwise
Depthwise layersطبقات depthwiseFewer activation bitsبتات أقل للتنشيطاتMore bitsبتات أكثر
Pointwise layersطبقات pointwiseMore bitsبتات أكثرFewer bitsبتات أقل
Edge against cloud policyسياسة الأجهزة الطرفية مقابل سياسة السحابة

Slide errataتصحيحات الشرائح

Answer with the corrected fact, and name the slide if a question depends on it. Each erratum is explained in its part: 01, 02, 03, 04, 05, 06, 07, 08, 09.

أجب بالمعلومة المصححة، واذكر رقم الشريحة إذا كان السؤال يعتمد عليها. كل تصحيح مشروح في الجزء الخاص به: 01، 02، 03، 04، 05، 06، 07، 08، 09.

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

Slides 7, 37الشريحتان 7 و37
"Markus et al." is a given name: cite Nagel et al., ICCV 2019."Markus et al." اسم أول وليس اسم عائلة: استشهد بـNagel et al., ICCV 2019.
Slide 16الشريحة 16
HGX B200 figures are sparse. FP4 is 144 | 72 PFLOPS (sparse | dense); the 2x ratio holds.أرقام HGX B200 هي أرقام الحساب المتناثر (sparse). أداء FP4 هو 144 | 72 PFLOPS (sparse | dense)؛ ونسبة 2x تبقى صحيحة.
Slides 20, 21الشريحتان 20 و21
Drawings are shrunk. Use the table group sizes: L0 16, L1 16.الرسوم مصغّرة. استخدم أحجام المجموعات من الجدول: L0 يساوي 16، وL1 يساوي 16.
Slide 24الشريحة 24
α weights the new value, so it must be small (PyTorch 0.01). Jacob et al. say close to 1 for the old value. State your convention.α هو وزن القيمة الجديدة، لذلك يجب أن يكون صغيرًا (PyTorch يستخدم 0.01). أما Jacob et al. فيقولون إنه قريب من 1 لأنهم يجعلونه وزن القيمة القديمة. صرّح بالاصطلاح الذي تستخدمه.
Slide 29الشريحة 29
"incpetion" is inception_5a/5x5 and inception_3a/pool."incpetion" المقصود بها inception_5a/5x5 وinception_3a/pool.
Slide 35الشريحة 35
V is learned, not random. h() maps into [0, 1], not (0, 1).V متعلَّم وليس عشوائيًا. وh() تنقل القيم إلى [0, 1] وليس إلى (0, 1).
Slides 37, 38الشريحتان 37 و38
Typos: "Asymmertric", "presumabley". Per-channel row labels are approximate.أخطاء إملائية: "Asymmertric" و"presumabley". وتسميات صفوف per-channel تقريبية.
Slide 47الشريحة 47
NASNet-Mobile FP is 74.0% in the whitepaper, not 74.9%.دقة FP لـNASNet-Mobile هي 74.0% في الورقة البيضاء (whitepaper)، وليست 74.9%.
Slide 54الشريحة 54
Error is 9.2452, so 9.25, not 9.24. BWN is +0.2 points, a gain.الخطأ 9.2452، أي 9.25 وليس 9.24. ونتيجة BWN هي +0.2 نقطة، أي تحسن وليست خسارة.
Slide 55الشريحة 55
By slide 53, input 0 binarizes to +1, not −1.وفق الشريحة 53، يتحول المدخل 0 إلى +1 لا إلى −1.
Slides 59, 60الشريحتان 59 و60
Write −n + (popcount ≪ 1). Without brackets C gives (−4 + 1) × 2 = −6.اكتب −n + (popcount ≪ 1). فبدون الأقواس تحسب لغة C القيمة (−4 + 1) × 2 = −6.
Slide 61الشريحة 61
Deltas are percentage points. BWN 56.8 vs FP 56.6 is a gain.الفروق بالنقاط المئوية. وBWN بقيمة 56.8 مقابل FP بقيمة 56.6 تحسن.
Slide 62الشريحة 62
The T on W^T means ternary. TWN 65.3 is ResNet-18B; standard ResNet-18 is 61.8.الحرف T في W^T يعني ثلاثي (ternary). ونتيجة TWN البالغة 65.3 هي لـResNet-18B؛ أما ResNet-18 القياسي فيعطي 61.8.
Slide 64الشريحة 64
The 0/1 matrix is the binary sign matrix: read 0 as −1.مصفوفة 0/1 هي مصفوفة الإشارات الثنائية: اقرأ 0 على أنها −1.
Slides 73, 74الشريحتان 73 و74
The text describes MobileNet-V1; the pictured policy is MobileNet-V2 (HAQ Figure 4).النص يصف MobileNet-V1؛ أما السياسة المرسومة فهي لـMobileNet-V2 (الشكل 4 في HAQ).