Majid Al-RaimiTrain, prune, fine-tune: what pruning achievesتدريب ثم تقليم ثم ضبط دقيق: ماذا يحقق التقليم

COE 592Lecture 4.1المحاضرة 4.1Part 02الجزء 02

Train, prune, fine-tune: what pruning achievesتدريب ثم تقليم ثم ضبط دقيق: ماذا يحقق التقليم

The Han et al. pipeline of training connectivity, pruning and retraining, how iterative pruning pushes the pruning ratio past 90 percent without accuracy loss, the resulting parameter and MAC reductions, and hardware support for sparsity.خط عمل Han et al.: تدريب الاتصالات ثم التقليم ثم إعادة التدريب، وكيف يدفع التقليم التكراري نسبة التقليم إلى ما يتجاوز 90 بالمئة دون فقدان في الدقة، والتخفيضات الناتجة في المعاملات وعمليات MAC، ودعم العتاد للتناثر.

Conceptsالمفاهيم
6
Slidesالشرائح
7-13
Readingمدة القراءة
36 min36 دقيقة
Understoodما فهمته
0/6 conceptsمفاهيم

Why this part mattersلماذا يهمّ هذا الجزء

Part 01 ended with the reason to prune: a 32-bit DRAM access costs about 640 pJ, roughly 200 times a multiply, so a model that fits in on-chip memory wins on energy before it wins on anything else. This part is where the lecture proves that pruning actually delivers: AlexNet loses 9x of its parameters and VGG-16 loses 12x with no accuracy loss at all.

The proof comes as one chart built up over four slides, a five-row reduction table, a set of image captions and a slide of hardware. Along the way it exposes the two traps that catch most first attempts: pruning without retraining, which throws away several percent of accuracy for nothing, and assuming that fewer parameters means faster inference, which is only true when the hardware knows how to skip zeros. The pipeline chart and the reduction table are classic exam material, and the hardware slide is the bridge to the granularity discussion in Part 03.

انتهى الجزء 01 بسبب التقليم: الوصول إلى ذاكرة DRAM لقراءة كلمة بطول 32-bit يكلّف نحو 640 pJ، أي ما يقارب 200 ضعف عملية ضرب واحدة، لذلك فالنموذج الذي يتسع في الذاكرة الموجودة على الشريحة (on-chip) يكسب في الطاقة قبل أن يكسب في أي شيء آخر. في هذا الجزء تثبت المحاضرة أن التقليم يحقق ذلك فعلاً: يفقد AlexNet ما مقداره 9x من معاملاته، ويفقد VGG-16 ما مقداره 12x، دون أي فقدان في الدقة على الإطلاق.

يأتي الإثبات في صورة مخطط واحد يُبنى تدريجياً عبر أربع شرائح، وجدول تخفيض من خمسة صفوف، ومجموعة من الأوصاف النصية للصور (captions)، وشريحة عن العتاد. وفي الطريق يكشف الفخين اللذين يقع فيهما معظم من يجرّب لأول مرة: التقليم دون إعادة تدريب، وهو ما يضيّع عدة نقاط مئوية من الدقة بلا مقابل، وافتراض أن قلة المعاملات تعني استدلالاً أسرع، وهذا لا يصح إلا إذا كان العتاد يعرف كيف يتخطى الأصفار. مخطط المسار وجدول التخفيض مادة امتحانية كلاسيكية، وشريحة العتاد هي الجسر إلى نقاش الدقة الحبيبية (granularity) في الجزء 03.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Explain the train, prune, retrain pipeline and why retraining is the step the paper calls critical.تشرح مسار التدريب ثم التقليم ثم إعادة التدريب، ولماذا تصف الورقة إعادة التدريب بأنها الخطوة الحاسمة.
  2. Read accuracy loss and reduction factor off the pruning-ratio chart for one-shot, retrained and iterative pruning.تقرأ فقدان الدقة ومعامل التخفيض من مخطط نسبة التقليم (pruning ratio) لكل من التقليم دفعة واحدة، والتقليم مع إعادة التدريب، والتقليم التكراري.
  3. Explain from layer tables why parameter reduction and MAC reduction differ across AlexNet, VGG-16, GoogleNet, ResNet-50 and SqueezeNet.تشرح من جداول الطبقات لماذا يختلف تخفيض المعاملات عن تخفيض عمليات MAC في AlexNet وVGG-16 وGoogleNet وResNet-50 وSqueezeNet.
  4. State what hardware needs, a 2:4 pattern or a sparse engine, before sparsity turns into speed.تحدد ما يحتاجه العتاد، نمط 2:4 أو محركاً مخصصاً للمصفوفات المتفرقة، قبل أن تتحول الندرة (sparsity) إلى سرعة.

Take AlexNet as Han, Pool, Tran and Dally trained it for their NeurIPS 2015 paper: 57.2% top-1 and 80.3% top-5 on ImageNet. Its first fully connected layer alone holds 38 million weights, and if you histogram them you get a narrow bell centered on zero, almost all of it inside [-0.015, 0.015] by the paper's own account. Now pick a threshold that removes the smallest half of every layer. Nothing happens to accuracy. Remove three quarters, and top-5 accuracy falls by about 2.2%. Remove four fifths, and it falls by about 4%. That single experiment is the whole of slides 7 and 8.

خذ AlexNet كما درّبه Han وPool وTran وDally في ورقتهم في NeurIPS 2015: دقة top-1 قدرها 57.2% وtop-5 قدرها 80.3% على ImageNet. طبقته الأولى المتصلة بالكامل (fully connected) وحدها تحمل 38 million وزن، وإذا رسمت مدرجها التكراري (histogram) حصلت على جرس ضيق متمركز عند الصفر، يقع معظمه داخل [-0.015, 0.015] بحسب الورقة نفسها. الآن اختر عتبة تحذف النصف الأصغر من كل طبقة. لا يحدث شيء للدقة. احذف ثلاثة أرباع الأوزان، فتنخفض دقة top-5 بنحو 2.2%. احذف أربعة أخماسها، فتنخفض بنحو 4%. هذه التجربة الواحدة هي كل محتوى الشريحتين 7 و8.

The rule behind it is a two-step recipe. Step one is ordinary training, but Han reads it differently: the dense network is not trained to learn final weights, it is trained to learn which connections are important. Step two removes every weight whose magnitude falls below a threshold, which the paper sets as a quality parameter times the standard deviation of that layer's weights. A dense layer becomes a sparse layer. This is Pruning at its simplest, Synapse pruning in the vocabulary of Part 01, and it is the plainest form of Magnitude-based pruning: importance is |w| and nothing else. Once connections are gone, some neurons are left with no surviving input or no surviving output. Those neurons contribute nothing and are removed too, so Neuron pruning falls out of synapse pruning for free.

القاعدة وراء ذلك وصفة من خطوتين. الخطوة الأولى تدريب عادي، لكن Han يقرؤه بطريقة مختلفة: الشبكة الكثيفة لا تُدرَّب لتتعلم أوزانها النهائية، بل لتتعلم أي الوصلات مهمة. الخطوة الثانية تحذف كل وزن تقل قيمته المطلقة عن threshold (عتبة)، وتحددها الورقة بأنها معامل جودة مضروب في الانحراف المعياري لأوزان تلك الطبقة. هكذا تتحول الطبقة الكثيفة إلى طبقة متفرقة (sparse). هذا هو pruning في أبسط صوره، وهو Synapse pruning بمصطلحات الجزء 01، وأوضح أشكال Magnitude-based pruning: الأهمية هي |w| ولا شيء غيرها. وبعد حذف الوصلات تبقى بعض العصبونات بلا أي مدخل باقٍ أو بلا أي مخرج باقٍ. هذه العصبونات لا تساهم بشيء فتُحذف هي أيضاً، فيأتي Neuron pruning نتيجة مجانية لتقليم الوصلات.

The bell of a trained layer. On hover the weights inside ±t collapse from the center outward, leaving the gap that is the visual signature of magnitude pruning. The bell is a model with sigma = 0.03 drawn on the slide inset's ±0.1 axis, not the paper's fc6 histogram.جرس الأوزان لطبقة مدرَّبة. عند تمرير المؤشر تنهار الأوزان الواقعة داخل ±t من المركز نحو الخارج، تاركة الفجوة التي هي البصمة المرئية للتقليم بحسب القيمة المطلقة. هذا الجرس نموذج توضيحي بانحراف معياري sigma = 0.03 مرسوم على محور ±0.1 الخاص بالرسم المصغر في الشريحة، وليس المدرج التكراري الفعلي لطبقة fc6 في الورقة.

The right-hand inset of slide 8 shows exactly that gap: the same bell with its center cut out, a hole of width 2t around zero, and nothing else changed. The paper's discussion of its Figure 7 describes the distribution as "centered around zero with tails dropping off quickly" before pruning, then "the center of the distribution" removed. The weights that survive have not moved. They will move in the next concept, and that movement is what retraining does.

الرسم المصغر على يمين الشريحة 8 يُظهر تلك الفجوة بالضبط: الجرس نفسه وقد قُطع مركزه، أي ثقب عرضه 2t حول الصفر، ولم يتغير أي شيء آخر. تصف الورقة في نقاشها لشكلها 7 التوزيع قبل التقليم بأنه «متمركز حول الصفر وأطرافه تهبط بسرعة»، ثم بأن «مركز التوزيع» قد أُزيل. الأوزان الباقية لم تتحرك. ستتحرك في المفهوم التالي، وهذه الحركة هي ما تفعله إعادة التدريب.

Reading the prune-only curveقراءة منحنى التقليم وحده

The chart on slide 8 plots top-5 accuracy loss against the Pruning ratio, the fraction of parameters pruned away, from 40% to 100% on the x axis and from +0.5% to -4.5% on the y axis. The dashed purple curve is what happens with no retraining. It sits at zero up to 50%, which the paper calls a "free lunch of reducing 2x the connections without losing accuracy even without retraining". It reaches about -1% at 67%, about -2.2% at 75%, about -4% at 80%, and leaves the chart just past 82%. Without retraining, the paper says, accuracy "begins dropping much sooner", once only a third of the connections remain.

يرسم مخطط الشريحة 8 فقدان دقة top-5 مقابل Pruning ratio (نسبة التقليم)، أي نسبة المعاملات المحذوفة، من 40% إلى 100% على المحور الأفقي ومن +0.5% إلى -4.5% على المحور الرأسي. المنحنى البنفسجي المتقطع هو ما يحدث دون إعادة تدريب. يبقى عند الصفر حتى 50%، وهو ما تسميه الورقة «وجبة مجانية تخفض الوصلات 2x دون فقدان في الدقة حتى بلا إعادة تدريب». ثم يصل إلى نحو -1% عند 67%، ونحو -2.2% عند 75%، ونحو -4% عند 80%، ويخرج من المخطط بعد 82% بقليل. وتقول الورقة إنه بدون إعادة تدريب «تبدأ الدقة في الانخفاض أبكر بكثير»، أي بمجرد أن يبقى ثلث الوصلات فقط.

The x axis counts what is removed, so you have to translate it into a reduction factor before you can compare with a table that reports "9x". Keeping a fraction 1 - r of the weights makes the model 1 / (1 - r) times smaller.

المحور الأفقي يعدّ ما حُذف، لذلك عليك أن تحوّله إلى reduction factor (معامل التخفيض) قبل أن تقارن بجدول يذكر «9x». الاحتفاظ بنسبة 1 - r من الأوزان يجعل النموذج أصغر بمقدار 1 / (1 - r) مرة.

k=11−rr=1−1kk = \frac{1}{1 - r} \qquad r = 1 - \frac{1}{k}
Reduction factor k from pruning ratio r, and backمعامل التخفيض k من نسبة التقليم r، والعكس

Anchor points to memorizeنقاط مرجعية للحفظ

50% prunedتقليم 50%
2x2x
67% prunedتقليم 67%
3x3x
75% prunedتقليم 75%
4x4x
80% prunedتقليم 80%
5x5x
87.5% prunedتقليم 87.5%
8x8x
88.9% prunedتقليم 88.9%
9x9x
90% prunedتقليم 90%
10x10x

Where the threshold comes fromمن أين تأتي العتبة

Because the criterion is magnitude, the threshold and the pruning ratio are two views of the same cut. If the weights of a layer are roughly Gaussian with standard deviation sigma, removing a fraction r means removing everything inside ±t where the Gaussian mass inside ±t equals r. That is an inverse normal lookup: t = sigma × z with z = 0.674 for 50%, z = 1.282 for 80% and z = 1.645 for 90%.

بما أن المعيار هو القيمة المطلقة، فالعتبة ونسبة التقليم وجهان للقطع نفسه. إذا كانت أوزان الطبقة قريبة من التوزيع الطبيعي (Gaussian) بانحراف معياري sigma، فإن حذف نسبة r يعني حذف كل ما يقع داخل ±t بحيث تساوي كتلة التوزيع داخل ±t القيمة r. هذا بحث في معكوس التوزيع الطبيعي: t = sigma × z حيث z = 0.674 لنسبة 50%، وz = 1.282 لنسبة 80%، وz = 1.645 لنسبة 90%.

Worked exampleمثال محلول

Threshold for a Gaussian layer with sigma = 0.03العتبة لطبقة أوزانها طبيعية التوزيع بانحراف sigma = 0.03

  1. Half the weightsنصف الأوزان

    t = 0.03 × 0.674 = 0.020. Everything with |w| < 0.020 goes. The model is 2x smaller and, on AlexNet, loses nothing.
    t = 0.03 × 0.674 = 0.020. يُحذف كل وزن يحقق |w| < 0.020. النموذج أصغر بـ 2x، وفي AlexNet لا يخسر شيئاً.
  2. Four fifthsأربعة أخماس

    t = 0.03 × 1.282 = 0.038. This is the cut in the visual above: 5x smaller, about -4% top-5 without retraining.
    t = 0.03 × 1.282 = 0.038. هذا هو القطع في الرسم أعلاه: أصغر بـ 5x، ونحو -4% في top-5 دون إعادة تدريب.
  3. Nine tenthsتسعة أعشار

    t = 0.03 × 1.645 = 0.049. 10x smaller. Prune-only is off the chart here, one-shot retraining loses about 1.7%, and only the iterative recipe of the third concept holds zero loss.
    t = 0.03 × 1.645 = 0.049. أصغر بـ 10x. منحنى التقليم وحده خارج المخطط هنا، وإعادة التدريب لمرة واحدة تخسر نحو 1.7%، والوصفة التكرارية في المفهوم الثالث وحدها تحافظ على فقدان صفري.
  4. The threshold scales with sigma, the ratio does notالعتبة تتغير مع sigma، أما النسبة فلا

    Han sets t per layer as a quality parameter times that layer's standard deviation, so a layer with wider weights gets a proportionally wider cut and the same share removed.
    يحدد Han العتبة t لكل طبقة على حدة بأنها معامل جودة مضروب في الانحراف المعياري لتلك الطبقة، فالطبقة ذات الأوزان الأوسع تحصل على قطع أوسع بالتناسب، وتُحذف منها الحصة نفسها.

Recall

What does the x axis of the pruning chart measure, and how do you turn 80 percent into a reduction factor?ماذا يقيس المحور الأفقي في مخطط التقليم، وكيف تحوّل 80 بالمئة إلى معامل تخفيض؟

The share of parameters pruned away. Keeping 1 - 0.8 = 0.2 of the weights makes the model 1 / 0.2 = 5x smaller.
حصة المعاملات المحذوفة. الاحتفاظ بـ 1 - 0.8 = 0.2 من الأوزان يجعل النموذج أصغر بـ 1 / 0.2 = 5x.

Return to the AlexNet that lost 4% at 80% pruned. Keep the mask fixed, so the removed weights stay at zero, and train the survivors again with a learning rate one hundredth of the original. The loss comes back to 0.0%. That run took 173 hours on a Titan X against 75 hours for the original training, which is why the paper says pruning is "not used when iteratively prototyping the model, but rather used for model reduction when the model is ready for deployment".

عُد إلى AlexNet الذي خسر 4% عند تقليم 80%. ثبّت mask (القناع) بحيث تبقى الأوزان المحذوفة عند الصفر، ثم درّب الأوزان الباقية من جديد بمعدل تعلم يساوي جزءاً من مئة من المعدل الأصلي. يعود الفقدان إلى 0.0%. استغرقت تلك الجولة 173 hours على بطاقة Titan X مقابل 75 hours للتدريب الأصلي، ولهذا تقول الورقة إن التقليم «لا يُستخدم أثناء بناء النموذج وتجريبه بشكل متكرر، بل يُستخدم لتصغير النموذج عندما يكون جاهزاً للنشر».

This is step three of the pipeline, and the paper is blunt about its status: retraining "learns the final weights for the remaining sparse connections. This step is critical. If the pruned network is used without retraining, accuracy is significantly impacted." The lecture calls it Fine-tuning. The green curve on slide 9 shows what it buys. It stays at zero, or a hair above, all the way to 80%, then bends: about -0.25% at 84%, about -0.9% at 88%, about -1.7% at 90%, about -4% at 93%. The paper summarizes the same curve as "with retraining we are able to reduce connections by 9x".

هذه هي الخطوة الثالثة في المسار، والورقة صريحة في وصف مكانتها: إعادة التدريب «تتعلم الأوزان النهائية للوصلات المتفرقة الباقية. هذه الخطوة حاسمة. إذا استُخدمت الشبكة المقلّمة دون إعادة تدريب، تتأثر الدقة بشكل كبير». وتسميها المحاضرة Fine-tuning (الضبط الدقيق). المنحنى الأخضر في الشريحة 9 يُظهر ما تشتريه. يبقى عند الصفر، أو فوقه بشعرة، حتى 80%، ثم ينحني: نحو -0.25% عند 84%، ونحو -0.9% عند 88%، ونحو -1.7% عند 90%، ونحو -4% عند 93%. وتلخص الورقة المنحنى نفسه بقولها «مع إعادة التدريب نستطيع تقليل الوصلات بمقدار 9x».

The prune-only curve is the dashed line. On hover the retrained curve draws itself along the zero line and the accuracy that retraining gives back is shaded between them.منحنى التقليم وحده هو الخط المتقطع. عند تمرير المؤشر يُرسم منحنى إعادة التدريب على طول خط الصفر، وتُظلَّل بينهما الدقة التي تستعيدها إعادة التدريب.

Two of the green points sit slightly above zero. The authors do not treat that as noise: "We believe this accuracy improvement is due to pruning finding the right capacity of the network and hence reducing overfitting." In other words, Pruning behaves like a regularizer, and an over-parameterized network can lose most of its weights and generalize a little better for it.

نقطتان من النقاط الخضراء تقعان فوق الصفر بقليل. لا يعدّ المؤلفون ذلك ضجيجاً: «نعتقد أن هذا التحسن في الدقة سببه أن التقليم يجد السعة المناسبة للشبكة، وبالتالي يقلل الإفراط في التخصيص (overfitting)». بعبارة أخرى، يتصرف pruning كأداة تنظيم (regularizer)، ويمكن لشبكة ذات معاملات زائدة أن تفقد معظم أوزانها وتعمّم أفضل قليلاً بسبب ذلك.

What retraining does to the weightsماذا تفعل إعادة التدريب بالأوزان

The third inset on slide 9 is the most informative picture in this part. After pruning, the histogram was a bell with a hole. After retraining it is two smooth lobes, one on each side of zero, and the whole distribution is wider. The paper's text on Figure 7 states the numbers: the original weights lived inside [-0.015, 0.015]; after retraining "the parameters form a bimodal distribution and become more spread across the x-axis, between [-0.025, 0.025]". The survivors have grown in magnitude to take over the work of the connections that were removed. Nothing has been restored; the mask still holds the pruned weights at zero.

الرسم المصغر الثالث في الشريحة 9 هو أغنى صورة في هذا الجزء. بعد التقليم كان المدرج التكراري جرساً فيه ثقب. وبعد إعادة التدريب أصبح فصّين ناعمين، واحداً على كل جانب من الصفر، والتوزيع كله أعرض. نص الورقة عن الشكل 7 يذكر الأرقام: الأوزان الأصلية كانت تعيش داخل [-0.015, 0.015]؛ وبعد إعادة التدريب «تشكل المعاملات توزيعاً ثنائي القمة (bimodal) وتصبح أكثر انتشاراً على المحور الأفقي، بين [-0.025, 0.025]». الأوزان الباقية كبرت في قيمتها المطلقة لتتولى عمل الوصلات التي حُذفت. لم يُستعَد أي شيء؛ القناع ما زال يُبقي الأوزان المقلّمة عند الصفر.

Three rules the paper gives for retrainingثلاث قواعد تعطيها الورقة لإعادة التدريب

  • Keep the surviving weights; do not reinitialize them. The paper argues that networks contain "fragile co-adapted features" that gradient descent finds when the network is first trained but cannot find again from scratch on a sparse layout.احتفظ بالأوزان الباقية؛ لا تُعِد تهيئتها. تحتج الورقة بأن الشبكات تحتوي على «سمات هشة متكيفة فيما بينها» (fragile co-adapted features) يجدها الانحدار التدرجي (gradient descent) عند تدريب الشبكة أول مرة، لكنه لا يستطيع إيجادها مجدداً من الصفر على بنية متفرقة.
  • Shrink dropout. Pruning has already removed capacity, so the retraining dropout D_r is scaled from the original D_o by the square root of the fraction of connections kept.قلّل الـ dropout. التقليم أزال جزءاً من السعة أصلاً، لذلك يُحسب dropout إعادة التدريب D_r من القيمة الأصلية D_o بضربها في الجذر التربيعي لنسبة الوصلات المحتفَظ بها.
  • Choose the regularizer for the stage. L1 pushes more weights toward zero and gives better accuracy straight after pruning, but L2 gives better accuracy once the survivors are retrained, so the paper uses L2 for the curves on these slides.اختر أداة التنظيم المناسبة للمرحلة. L1 يدفع أوزاناً أكثر نحو الصفر ويعطي دقة أفضل مباشرة بعد التقليم، لكن L2 يعطي دقة أفضل بعد إعادة تدريب الأوزان الباقية، لذلك تستخدم الورقة L2 في منحنيات هذه الشرائح.
Dr=DoCirCioD_r = D_o \sqrt{\frac{C_{ir}}{C_{io}}}
Dropout for retraining (Han et al. 2015, equation 2): C_io connections before, C_ir afterDropout لإعادة التدريب (Han et al. 2015، المعادلة 2): C_io من الاتصالات قبل، وC_ir بعد

Worked exampleمثال محلول

Dropout for a fully connected layer kept at 9 percentقيمة dropout لطبقة متصلة بالكامل بقي منها 9 بالمئة

  1. Fraction of connections keptنسبة الوصلات المحتفَظ بها

    AlexNet's fc6 keeps 9% of its weights, so C_ir / C_io = 0.09.
    طبقة fc6 في AlexNet تحتفظ بـ 9% من أوزانها، إذن C_ir / C_io = 0.09.
  2. Scale the original dropoutاضرب قيمة dropout الأصلية في المعامل

    With D_o = 0.5: D_r = 0.5 × sqrt(0.09) = 0.5 × 0.3 = 0.15.
    مع D_o = 0.5: D_r = 0.5 × sqrt(0.09) = 0.5 × 0.3 = 0.15.
  3. Resultالنتيجة

    Retrain with dropout 0.15, not 0.5. A sparse layer already regularizes itself.
    أعد التدريب بـ dropout قدره 0.15، لا 0.5. الطبقة المتفرقة تنظّم نفسها بنفسها أصلاً.

One more observation from the paper's sensitivity study (Figure 6) matters for your own experiments: convolutional layers are more sensitive to pruning than fully connected ones, and the first convolutional layer is the most sensitive of all, because its input has only three channels and there is little redundancy to remove. That is why the per-layer keep rates in the next concepts are so uneven.

ملاحظة أخرى من دراسة الحساسية في الورقة (الشكل 6) تهمك في تجاربك الخاصة: الطبقات الالتفافية أكثر حساسية للتقليم من الطبقات المتصلة بالكامل، والطبقة الالتفافية الأولى هي الأكثر حساسية على الإطلاق، لأن مدخلها له ثلاث قنوات فقط ولا يوجد فيه إلا القليل من التكرار القابل للحذف. ولهذا السبب تتفاوت نسب الاحتفاظ لكل طبقة في المفاهيم التالية تفاوتاً كبيراً.

Quick checkاختبار سريع

In Han's three-step pipeline, which step does the paper call critical because skipping it makes accuracy drop significantly?في مسار Han ذي الخطوات الثلاث، أي خطوة تصفها الورقة بأنها حاسمة لأن تخطيها يجعل الدقة تنخفض بشكل كبير؟

Recall

State the three steps of Han's pipeline and say which one the paper calls critical.اذكر الخطوات الثلاث في مسار Han، وحدد أيها تصفه الورقة بأنه حاسم.

Train the dense network to learn connectivity, prune the connections below a magnitude threshold, retrain the survivors. Retraining is the critical step: without it accuracy drops significantly, about 4% top-5 at 80% pruned.
درّب الشبكة الكثيفة لتتعلم بنية الوصلات، ثم قلّم الوصلات التي تقل عن magnitude threshold (عتبة القيمة المطلقة)، ثم أعد تدريب الأوزان الباقية. إعادة التدريب هي الخطوة الحاسمة: بدونها تنخفض الدقة بشكل كبير، نحو 4% في top-5 عند تقليم 80%.

Start from the retrained network at 80% pruned, the last green point still on the zero line, a 5x model with no loss. Now prune it again, using the retrained magnitudes, and fine-tune again. The paper describes what happens: "The leftmost dot on this curve corresponds to the point on the green line at 80% (5x pruning) pruned to 8x. There's no accuracy loss at 9x. Not until 10x does the accuracy begin to drop sharply." The red curve on slide 10 is that experiment: flat through 90%, about -0.5% at 92%, -1% at 93%, -2% at 94%, and about -4% between 95% and 96%.

ابدأ من الشبكة المعاد تدريبها عند تقليم 80%، وهي آخر نقطة خضراء ما زالت على خط الصفر، نموذج أصغر بـ 5x بلا أي فقدان. الآن قلّمها مرة أخرى باستخدام القيم المطلقة بعد إعادة التدريب، ثم طبّق fine-tune مرة أخرى. تصف الورقة ما يحدث: «النقطة الأولى من اليسار على هذا المنحنى تقابل النقطة على الخط الأخضر عند 80% (تقليم 5x) بعد تقليمها إلى 8x. لا يوجد فقدان في الدقة عند 9x. ولا تبدأ الدقة في الانخفاض الحاد إلا عند 10x». المنحنى الأحمر في الشريحة 10 هو تلك التجربة: مستوٍ حتى 90%، ثم نحو -0.5% عند 92%، و-1% عند 93%، و-2% عند 94%، ونحو -4% بين 95% و96%.

This is Iterative pruning, and the paper states the rule and the payoff in one breath: "Pruning followed by a retraining is one iteration, after many such iterations the minimum number connections could be found. Without loss of accuracy, this method can boost pruning rate from 5x to 9x on AlexNet compared with single-step aggressive pruning." Each iteration is a greedy search. VGG-16 used five rounds; ResNet-50 in Han's thesis used three. The left side of slide 10 draws the loop: train connectivity, prune connections, train weights, and an arrow from train weights back to prune.

هذا هو Iterative pruning (التقليم التكراري)، والورقة تذكر القاعدة والمكسب في نَفَس واحد: «التقليم متبوعاً بإعادة تدريب يمثل تكراراً واحداً، وبعد تكرارات كثيرة من هذا النوع يمكن إيجاد أقل عدد من الوصلات. ودون فقدان في الدقة، يمكن لهذه الطريقة أن ترفع معدل التقليم من 5x إلى 9x على AlexNet مقارنة بالتقليم الحاد بخطوة واحدة». كل تكرار هو بحث جشع (greedy search). استخدم VGG-16 خمس جولات؛ واستخدم ResNet-50 في أطروحة Han ثلاث جولات. الجانب الأيسر من الشريحة 10 يرسم الحلقة: تدريب بنية الوصلات، ثم تقليم الوصلات، ثم تدريب الأوزان، مع سهم يعود من تدريب الأوزان إلى التقليم.

Train connectivityدرّب الاتصالية
dense networkشبكة كثيفة

Learn which connections matter.

تعلّم أي الاتصالات مهمة.

magnitudesالمقادير
Prune connectionsقلّم الاتصالات
below thresholdتحت العتبة

Cut a fraction of the survivors.

اقطع جزءًا من الأوزان الباقية.

mask fixedالقناع مثبّت
Train weightsدرّب الأوزان
fine-tuningالضبط الدقيق

Survivors redistribute, then loop back to prune.

تعيد الأوزان الباقية توزيع نفسها، ثم نعود إلى التقليم.

The prune and retrain loop. The return arrow is what lifts AlexNet from 5x to 9x.حلقة التقليم وإعادة التدريب. سهم العودة هو ما يرفع AlexNet من 5x إلى 9x.

Why several small cuts beat one big cutلماذا تتفوق عدة قطعات صغيرة على قطعة واحدة كبيرة

A single cut to 90% judges every weight by the magnitude it had in the dense network. But the previous concept showed that retraining changes those magnitudes: the survivors grow and the distribution becomes bimodal. Weights that looked expendable in the dense network may become load-bearing after the first round, and weights that looked important may shrink once their neighbours take over. Iterating lets each cut use the freshest evidence. Frankle and Carbin reach the same conclusion in a different setting: iterative pruning over n rounds, each removing p^(1/n) of what remains, "finds winning tickets that match the accuracy of the original network at smaller sizes than does one-shot pruning". The price, which they also state, is that repeated retraining is expensive.

القطع الواحد إلى 90% يحكم على كل وزن بالقيمة المطلقة التي كانت له في الشبكة الكثيفة. لكن المفهوم السابق بيّن أن إعادة التدريب تغيّر هذه القيم: الأوزان الباقية تكبر والتوزيع يصبح ثنائي القمة. أوزان بدت قابلة للاستغناء في الشبكة الكثيفة قد تصبح حاملة للحمل بعد الجولة الأولى، وأوزان بدت مهمة قد تصغر بعد أن تتولى جاراتها عملها. التكرار يتيح لكل قطع أن يعتمد على أحدث دليل. ويصل Frankle وCarbin إلى الاستنتاج نفسه في سياق مختلف: التقليم التكراري على n جولة، تحذف كل منها p^(1/n) مما تبقى، «يجد تذاكر رابحة (winning tickets) تطابق دقة الشبكة الأصلية بأحجام أصغر مما يجده التقليم دفعة واحدة». والثمن، الذي يذكرانه أيضاً، أن إعادة التدريب المتكررة مكلفة.

Worked exampleمثال محلول

Compounding a pruning scheduleتراكم جدول التقليم عبر الجولات

  1. Equal halvesأنصاف متساوية

    Three rounds that each remove half of the survivors leave 0.5 × 0.5 × 0.5 = 12.5%, an 8x model. Four rounds leave 6.25%, which is 16x.
    ثلاث جولات تحذف كل منها نصف الأوزان الباقية تترك 0.5 × 0.5 × 0.5 = 12.5%، أي نموذجاً أصغر بـ 8x. وأربع جولات تترك 6.25%، أي 16x.
  2. Hitting a target in equal roundsالوصول إلى هدف بجولات متساوية

    To reach 90% overall in three equal rounds, each round must keep 0.1^(1/3) = 0.464 of what remains, so it removes 53.6% of the current survivors.
    للوصول إلى 90% إجمالاً في ثلاث جولات متساوية، يجب أن تحتفظ كل جولة بـ 0.1^(1/3) = 0.464 مما تبقى، أي أنها تحذف 53.6% من الأوزان الباقية حالياً.
  3. Han's actual pathالمسار الفعلي عند Han

    80% in one round (5x), then re-pruned to 8x, then 9x, all at zero loss. The drop only starts past 10x.
    80% في جولة واحدة (5x)، ثم إعادة تقليم إلى 8x، ثم 9x، وكل ذلك بلا فقدان. ولا يبدأ الهبوط إلا بعد 10x.
Pruning ratioنسبة التقليمPrune onlyالتقليم وحدهPrune + fine-tuneالتقليم مع الضبط الدقيقIterativeالتكراري
80% (5x)80% (5x)about -4%نحو -4%0%0%starting point: the retrained 80% modelنقطة البداية: نموذج 80% المعاد تدريبه
90% (10x)90% (10x)off the chartخارج المخططabout -1.7%نحو -1.7%about 0%نحو 0%
93% (14x)93% (14x)off the chartخارج المخططabout -4%نحو -4%about -1%نحو -1%
Top-5 accuracy loss for the three recipes, read from slides 8 to 10فقدان دقة top-5 للوصفات الثلاث، مقروءاً من الشرائح 8 إلى 10
SimulatorمحاكيPruning curve explorer: prune, fine-tune, iterateمستكشف منحنى التقليم: قلّم، اضبط بدقة، كرّر
80% pruned away
+0.5%0.0%-1.0%-2.0%-3.0%-4.0%-4.5%40%50%60%70%80%90%100%pruning ratio (parameters pruned away), AlexNet top-5 accuracy loss80% pruned: -4.05%
-0.10-0.050.000.050.10after the cut: the bell with its center removedgrey: dense reference, dashed: ±t = ±0.038
Top-5 lossانخفاض دقة Top-5-4.05%read off the active curveمقروءة من المنحنى النشط
Reduction5.0xsmaller1 / (1 - ratio)
AlexNet left12.2M weights61 M × (1 - ratio)
Threshold t0.038sigma = 0.03, Gaussian weights

Slide to 80% and switch recipes: prune-only sits near -4%, both retrained recipes sit at zero. Slide to 90%: only the iterative loop is still at zero. The red curve begins at the 80% retrained model, as on slide 10, so below that it has no data. The histogram is a model, not the paper's data: a zero-mean Gaussian with sigma = 0.03, cut at the threshold that removes the chosen share, then redrawn as two lobes once retraining lets the survivors grow.حرّك المنزلق إلى 80% وبدّل بين الطرق: التقليم وحده يقف قرب -4%، والطريقتان المعاد تدريبهما تقفان عند الصفر. حرّكه إلى 90%: الحلقة التكرارية وحدها ما زالت عند الصفر. يبدأ المنحنى الأحمر من النموذج المعاد تدريبه عند 80%، كما في الشريحة 10، لذلك لا بيانات له تحت هذه القيمة. المدرج التكراري نموذج تقريبي وليس بيانات الورقة: توزيع غاوسي متوسطه صفر مع sigma = 0.03، يُقطع عند العتبة التي تزيل النسبة المختارة، ثم يُعاد رسمه على هيئة فصّين بعد أن تسمح إعادة التدريب للأوزان الباقية بالنمو.

Quick checkاختبار سريع

Reading slide 10, roughly how far can iterative prune-and-retrain go before top-5 loss exceeds half a percent?بقراءة الشريحة 10، إلى أي حد تقريباً يمكن أن يصل التقليم وإعادة التدريب بالتكرار قبل أن يتجاوز فقدان top-5 نصف نقطة مئوية؟

Recall

At 80 percent pruned, what top-5 loss do prune-only and prune-plus-retrain give, where does the iterative curve begin, and what reduction factor is that?عند تقليم 80 بالمئة، ما فقدان top-5 الذي يعطيه التقليم وحده والتقليم مع إعادة التدريب، وأين يبدأ المنحنى التكراري، وما معامل التخفيض المقابل؟

About -4% and 0%. The iterative curve has no separate value there: its leftmost dot is the retrained 80% model pruned further, so it starts from that 0% point. Keeping 20% of the weights is a 5x reduction factor.
نحو -4% و0%. ليس للمنحنى التكراري قيمة منفصلة هناك: نقطته الأولى من اليسار هي نموذج 80% المعاد تدريبه بعد تقليمه أكثر، لذلك يبدأ من نقطة 0% تلك. الاحتفاظ بـ 20% من الأوزان يعني reduction factor (معامل تخفيض) قدره 5x.

Recall

Why did iterative pruning lift AlexNet from 5x to 9x with no loss?لماذا رفع التقليم التكراري AlexNet من 5x إلى 9x دون فقدان؟

After each retraining the surviving weights redistribute (bimodal, wider), so the next magnitude cut removes weights judged small under the new assignment. A greedy search over several rounds finds a smaller network than one aggressive cut.
بعد كل إعادة تدريب تعيد الأوزان الباقية توزيع نفسها (ثنائية القمة وأعرض)، فيحذف القطع التالي بحسب القيمة المطلقة أوزاناً صغيرة وفق التوزيع الجديد. والبحث الجشع على عدة جولات يجد شبكة أصغر مما يجده قطع حاد واحد.

Look at AlexNet layer by layer, as the paper's Table 4 does. Its first fully connected layer, fc6, holds 38 M weights but costs only 75 M FLOPs, because each weight is used once per image. Its second convolutional layer, conv2, holds 307 K weights but costs 448 M FLOPs, because each weight is reused at every spatial position. Add the layers up and the network splits into two worlds: the three FC layers hold 58.6 M of the 61 M parameters (96.2%, which the paper rounds to 59 M) but only about 117 M of 1.45 G FLOPs (8%), while the five conv layers hold 2.3 M parameters (3.8%) but 1.33 G FLOPs (92%).

انظر إلى AlexNet طبقة طبقة كما يفعل الجدول 4 في الورقة. طبقته الأولى المتصلة بالكامل، fc6، تحمل 38 M وزن لكنها تكلف 75 M عملية FLOP فقط، لأن كل وزن يُستخدم مرة واحدة لكل صورة. وطبقته الالتفافية الثانية، conv2، تحمل 307 K وزن لكنها تكلف 448 M عملية FLOP، لأن كل وزن يُعاد استخدامه في كل موضع مكاني. اجمع الطبقات فتنقسم الشبكة إلى عالمين: طبقات FC الثلاث تحمل 58.6 M من أصل 61 M معامل (96.2%، وتقرّبها الورقة إلى 59 M) لكنها لا تكلف إلا نحو 117 M من أصل 1.45 G عملية FLOP (8%)، بينما تحمل الطبقات الالتفافية الخمس 2.3 M معامل (3.8%) لكنها تكلف 1.33 G عملية FLOP (92%).

That split explains the table on slide 11 before you read it. Pruning fc6 to 9% deletes 34.6 M parameters but only 68 M FLOPs by weight count (73 M once zero activations are skipped as well, which is how Han counts). Pruning conv2 to 38% deletes only 190 K parameters but 278 M FLOPs by weight count (300 M by Han's count). Parameter reduction is a story about FC layers; MAC reduction is a story about conv layers, and the two are pruned to very different depths.

هذا الانقسام يفسر جدول الشريحة 11 قبل أن تقرأه. تقليم fc6 إلى 9% يحذف 34.6 M معامل لكنه لا يحذف إلا 68 M عملية FLOP بحساب عدد الأوزان (73 M إذا تخطينا التفعيلات الصفرية أيضاً، وهي طريقة Han في العدّ). وتقليم conv2 إلى 38% لا يحذف إلا 190 K معامل لكنه يحذف 278 M عملية FLOP بحساب عدد الأوزان (300 M بطريقة Han). تخفيض المعاملات قصة طبقات FC؛ وتخفيض MAC قصة الطبقات الالتفافية، والنوعان يُقلَّمان إلى أعماق مختلفة جداً.

AlexNet's parameters live in FC layers, its MACs live in conv layers. On hover both bars drain to what pruning leaves: 11 percent of the parameters but 30 percent of the MACs.معاملات AlexNet تعيش في طبقات FC، وعمليات MAC فيه تعيش في الطبقات الالتفافية. عند تمرير المؤشر يفرغ العمودان إلى ما يتركه التقليم: 11 بالمئة من المعاملات لكن 30 بالمئة من عمليات MAC.
NetworkالشبكةParameters beforeالمعاملات قبل التقليمAfterبعدهParameter reductionتخفيض المعاملاتMAC reductionتخفيض MACFC share of parametersحصة طبقات FC من المعاملات
AlexNetAlexNet61 M61 M6.7 M6.7 M9x9x3x3x96.2%96.2%
VGG-16VGG-16138 M138 M10.3 M10.3 M12x12x5x5x89.9%89.9%
GoogleNetGoogleNet7 M7 M2.0 M2.0 M3.5x3.5x5x5xabout 14%نحو 14%
ResNet-50ResNet-5026 M26 M7.47 M7.47 M3.4x3.4x6.3x6.3xabout 8%نحو 8%
SqueezeNetSqueezeNet1 M1 M0.38 M0.38 M3.2x3.2x3.5x3.5x0%0%
Slide 11 with one extra column: how much of each network's parameter count sits in fully connected layersالشريحة 11 مع عمود إضافي: كم من عدد معاملات كل شبكة يقع في الطبقات المتصلة بالكامل

Why the over-parameterized nets compress moreلماذا تنضغط الشبكات ذات المعاملات الزائدة أكثر

AlexNet and VGG-16 get 9x and 12x; GoogleNet, ResNet-50 and SqueezeNet get about 3.2x to 3.5x. The extra column is the reason. VGG-16's fc6 alone holds 103 M of its 138 M weights, and the paper prunes fc6 and fc7 to 4% of their size while conv layers keep 22% to 58%. GoogleNet has one FC layer of about 1 M in 7 M, ResNet-50 one of about 2 M in 25.5 M, and SqueezeNet has none at all, ending in global average pooling. Han's thesis says it directly: the pruning ratio of GoogleNet is smaller than AlexNet and VGG-16 "because convolutional layers dominate GoogleNet, and convolutional layers are much more efficient than fully connected layers". The three conv-dominated networks land in the same place, about 30% of parameters nonzero (GoogleNet 29%, SqueezeNet 31%, ResNet 29%), which is the 3.4x in the table. Their FC rows, where Neuron pruning would delete whole rows of a weight matrix, are too small to matter.

يحصل AlexNet وVGG-16 على 9x و12x؛ بينما يحصل GoogleNet وResNet-50 وSqueezeNet على نحو 3.2x إلى 3.5x. العمود الإضافي هو السبب. طبقة fc6 في VGG-16 وحدها تحمل 103 M من أصل 138 M وزن، والورقة تقلّم fc6 وfc7 إلى 4% من حجمهما بينما تحتفظ الطبقات الالتفافية بما بين 22% و58%. أما GoogleNet فله طبقة FC واحدة بنحو 1 M من أصل 7 M، وResNet-50 طبقة واحدة بنحو 2 M من أصل 25.5 M، وSqueezeNet ليس فيه أي طبقة FC، إذ ينتهي بـ global average pooling. وأطروحة Han تقولها صراحة: نسبة تقليم GoogleNet أصغر من AlexNet وVGG-16 «لأن الطبقات الالتفافية تهيمن على GoogleNet، والطبقات الالتفافية أكفأ بكثير من الطبقات المتصلة بالكامل». الشبكات الثلاث التي تهيمن عليها الطبقات الالتفافية تنتهي في المكان نفسه، نحو 30% من المعاملات غير صفرية (GoogleNet 29%، وSqueezeNet 31%، وResNet 29%)، وهذا هو الـ 3.4x في الجدول. أما صفوف طبقات FC فيها، حيث يحذف Neuron pruning صفوفاً كاملة من مصفوفة الأوزان، فهي أصغر من أن تُحدث فرقاً.

Why MAC reduction is not parameter reductionلماذا لا يساوي تخفيض MAC تخفيض المعاملات

Two mechanisms separate the two columns. The first is the split above: parameters concentrate in FC layers, which are pruned hardest, and MACs concentrate in conv layers, which are pruned least. That is how AlexNet gets 9x on parameters but 3x on MACs, and VGG-16 12x against 5x. The second is how Han counts. A multiply-accumulate is only counted as saved when it is really skipped, and it is skipped when either the weight or the input activation is zero. ReLU produces plenty of zero activations, so the FLOP column in Table 4 is roughly the weight density times the density of the layer's input activations.

آليتان تفصلان العمودين. الأولى هي الانقسام المذكور أعلاه: المعاملات تتركز في طبقات FC، وهي التي تُقلَّم بأشد قدر، وعمليات MAC تتركز في الطبقات الالتفافية، وهي التي تُقلَّم بأقل قدر. وهكذا يحصل AlexNet على 9x في المعاملات لكن 3x فقط في عمليات MAC، ويحصل VGG-16 على 12x مقابل 5x. والثانية هي طريقة Han في العدّ. لا تُحسب عملية الضرب والجمع التراكمي (multiply-accumulate) موفَّرة إلا إذا تُخطّيت فعلاً، وهي تُتخطى عندما يكون الوزن أو تفعيل المدخل صفراً. ودالة ReLU تنتج كثيراً من zero activations (التفعيلات الصفرية)، لذلك فعمود FLOP في الجدول 4 يساوي تقريباً كثافة الأوزان مضروبة في كثافة تفعيلات مدخل الطبقة.

FLOP%≈Weight%×Act%in\text{FLOP\%} \approx \text{Weight\%} \times \text{Act\%}_{\text{in}}
Han's remaining-compute rule: a MAC survives only if both operands are nonzeroقاعدة Han للحوسبة المتبقية: تبقى عملية MAC فقط إذا كان المعاملان كلاهما غير صفريين

Worked exampleمثال محلول

Checking the rule against AlexNet's Table 4التحقق من القاعدة مقابل الجدول 4 لـ AlexNet

  1. conv2conv2

    Weights kept 38%, input activations (the output of conv1) 88% nonzero: 0.38 × 0.88 = 33%. The table says 33%.
    الأوزان المحتفَظ بها 38%، وتفعيلات المدخل (أي مخرج conv1) غير صفرية بنسبة 88%: 0.38 × 0.88 = 33%. والجدول يقول 33%.
  2. fc6fc6

    Weights kept 9%, input activations (the output of conv5) 34% nonzero: 0.09 × 0.34 = 3%. The table says 3%.
    الأوزان المحتفَظ بها 9%، وتفعيلات المدخل (أي مخرج conv5) غير صفرية بنسبة 34%: 0.09 × 0.34 = 3%. والجدول يقول 3%.
  3. ResNet-50, whole network, run backwardsResNet-50، الشبكة كاملة، بالاتجاه المعاكس

    The thesis reports 29% of weights kept (3.4x) and about 16% of FLOPs remaining (6.25x, rounded to 6.3x on the slide). The rule then implies an average input activation density near 0.16 / 0.29 = 55%, which is a plausible ReLU figure. This step derives the density from the two reported numbers rather than checking a third.
    تذكر الأطروحة أن 29% من الأوزان محتفَظ بها (3.4x) وأن نحو 16% من عمليات FLOP متبقية (6.25x، مقرّبة إلى 6.3x في الشريحة). عندئذ تستلزم القاعدة أن متوسط كثافة تفعيلات المدخل قريب من 0.16 / 0.29 = 55%، وهو رقم معقول لـ ReLU. هذه الخطوة تستنتج الكثافة من الرقمين المذكورين بدلاً من التحقق من رقم ثالث.
  4. Compute can fall faster than parametersالحساب قد ينخفض أسرع من المعاملات

    For conv-heavy networks the activation zeros from ReLU are a second source of Sparsity, which is why ResNet-50 and GoogleNet cut MACs by more than they cut parameters.
    في الشبكات التي تغلب عليها الطبقات الالتفافية، تكون التفعيلات الصفرية الناتجة عن ReLU مصدراً ثانياً لـ sparsity، ولهذا يخفض ResNet-50 وGoogleNet عمليات MAC بأكثر مما يخفضان المعاملات.

Even where MACs barely fall, the parameter count is worth cutting. A 6.7 M parameter AlexNet fits in on-chip SRAM, and the paper's point from Part 01 stands: at 640 pJ per DRAM access, the energy of fetching weights dominates the energy of multiplying them.

حتى حيث تكاد عمليات MAC لا تنخفض، يستحق عدد المعاملات أن يُخفَّض. نموذج AlexNet بـ 6.7 M معامل يتسع في ذاكرة SRAM على الشريحة، وتبقى فكرة الورقة من الجزء 01 قائمة: عند 640 pJ لكل وصول إلى DRAM، فإن energy of fetching weights (طاقة جلب الأوزان) تطغى على طاقة ضربها.

Quick checkاختبار سريع

AlexNet's parameters fall 9x after pruning but its MACs fall only 3x. Why?تنخفض معاملات AlexNet بمقدار 9x بعد التقليم لكن عمليات MAC فيه لا تنخفض إلا بمقدار 3x. لماذا؟

Recall

AlexNet: 9x fewer parameters but only 3x fewer MACs. Give both reasons.AlexNet: معاملات أقل بـ 9x لكن عمليات MAC أقل بـ 3x فقط. اذكر السببين.

Parameters are 96.2% in FC layers, which are pruned hardest, while 92% of MACs are in conv layers, which are pruned less. And Han's FLOP count only removes a MAC when both the weight and the input activation are nonzero, so activation sparsity shifts the MAC column independently.
المعاملات موجودة بنسبة 96.2% في طبقات FC، وهي التي تُقلَّم بأشد قدر، بينما 92% من عمليات MAC في الطبقات الالتفافية، وهي التي تُقلَّم أقل. كما أن عدّ Han لعمليات FLOP لا يحذف عملية MAC إلا إذا كان الوزن أو تفعيل المدخل صفراً، فندرة التفعيلات تغيّر عمود MAC بشكل مستقل.

Everything so far was an image classifier with a huge fully connected tail. NeuralTalk, Karpathy and Fei-Fei's image captioner, is a different animal: a CNN feature extractor feeding an LSTM that writes a sentence one word at a time. Han froze the CNN, pruned every LSTM weight matrix except the word-embedding table to 10% nonzeros, retrained with the original weight decay and batch size, and measured BLEU-1 to BLEU-4 on Flickr-8K. The thesis reports: "Not until pruning away 90% of the parameters does the BLEU score begin to drop sharply."

كل ما سبق كان مصنّفات صور بذيل ضخم من الطبقات المتصلة بالكامل. أما NeuralTalk، مولّد الأوصاف النصية للصور الذي بناه Karpathy وFei-Fei، فهو كائن مختلف: مستخرج سمات من نوع CNN يغذي شبكة LSTM تكتب جملة كلمةً كلمة. جمّد Han شبكة CNN، وقلّم كل مصفوفات أوزان LSTM ما عدا جدول تضمين الكلمات (word embedding) إلى 10% من القيم غير الصفرية، وأعاد التدريب بمعامل اضمحلال الأوزان (weight decay) وحجم الدفعة الأصليين، وقاس BLEU-1 إلى BLEU-4 على Flickr-8K. تقول الأطروحة: «لا تبدأ درجة BLEU في الانخفاض الحاد إلا بعد تقليم 90% من المعاملات».

The recipe did not change. Train, cut the small weights, retrain the survivors: the same three steps, the same knee near 90%, and the same dependence on Fine-tuning, which the thesis says "plays a very important role" when it compares the retrained curve with the one that skips retraining. Slide 12 shows the qualitative check that a BLEU number cannot: the captions themselves.

الوصفة لم تتغير. درّب، اقطع الأوزان الصغيرة، أعد تدريب الباقي: الخطوات الثلاث نفسها، والانحناءة نفسها قرب 90%، والاعتماد نفسه على Fine-tuning، الذي تقول الأطروحة إنه «يؤدي دوراً مهماً جداً» حين تقارن المنحنى المعاد تدريبه بالمنحنى الذي يتخطى إعادة التدريب. وتعرض الشريحة 12 التحقق النوعي الذي لا يستطيعه رقم BLEU: الأوصاف نفسها.

ImageالصورةBaselineالنموذج الأساسيPrunedالنموذج المقلّمPruning ratioنسبة التقليمVerdictالحكم
Basketballكرة السلةa basketball player in a white uniform is playing with a ballلاعب كرة سلة بزي أبيض يلعب بالكرةa basketball player in a white uniform is playing with a basketballلاعب كرة سلة بزي أبيض يلعب بكرة السلة90%90%Same meaning, more specific nounالمعنى نفسه، باسم أكثر تحديداً
Dogالكلبa brown dog is running through a grassy fieldكلب بني يركض عبر حقل معشبa brown dog is running through a grassy areaكلب بني يركض عبر منطقة معشبة90%90%Synonymمرادف
Surferراكب الأمواجa man is riding a surfboard on a waveرجل يركب لوح تزلج على موجةa man in a wetsuit is riding a wave on a beachرجل يرتدي بدلة غوص يركب موجة على شاطئ90%90%Different but valid descriptionوصف مختلف لكنه صحيح
Soccerكرة القدمa soccer player in red is running in the fieldلاعب كرة قدم بالأحمر يركض في الملعبa man in a red shirt and black and white black shirt is running through a fieldرجل بقميص أحمر وقميص أسود وأبيض أسود يركض عبر حقل95%95%Drift: repeated phrase, lost the word soccerانحراف: عبارة مكررة، وضاعت كلمة كرة القدم
Captions from the baseline LSTM and the pruned LSTM (slide 12)أوصاف من LSTM الأساسي و LSTM المقلّم (الشريحة 12)

At 90% the pruned model "sometimes produces the same caption, sometimes produces a different word to describe the same thing", and sometimes describes the scene differently but still correctly. Replacing "ball" with "basketball" is arguably an improvement. The fourth image is the warning. At 95% pruned, a 20x model, the sentence starts to stutter: "a red shirt and black and white black shirt" repeats a phrase and loses the word "soccer". That is what crossing the knee of the Pruning ratio curve looks like in a language model: not silence, but drift.

عند 90% فإن النموذج المقلّم «يُنتج أحياناً الوصف نفسه، وأحياناً كلمة مختلفة لوصف الشيء نفسه»، وأحياناً يصف المشهد بطريقة مختلفة لكنها تبقى صحيحة. واستبدال «ball» بـ «basketball» يمكن اعتباره تحسناً. الصورة الرابعة هي التحذير. عند تقليم 95%، أي نموذج أصغر بـ 20x، تبدأ الجملة في التلعثم: «a red shirt and black and white black shirt» تكرر عبارة وتفقد كلمة «soccer». هذا هو شكل تجاوز انحناءة منحنى Pruning ratio في نموذج لغوي: ليس صمتاً، بل انحرافاً.

Recall

Name a non-CNN case where the prune-and-retrain recipe worked, and give its pruning ratio.اذكر حالة من غير شبكات CNN نجحت فيها وصفة التقليم وإعادة التدريب، واذكر نسبة تقليمها.

The NeuralTalk LSTM captioner: all LSTM weights except the word embedding pruned to 10% density (90% pruned), with BLEU flat until then and captions nearly identical. At 95% the captions start to repeat phrases.
مولّد الأوصاف NeuralTalk المبني على LSTM: كل أوزان LSTM ما عدا تضمين الكلمات قُلّمت إلى كثافة 10% (تقليم 90%)، وبقيت BLEU ثابتة حتى تلك النقطة والأوصاف شبه متطابقة. وعند 95% تبدأ الأوصاف في تكرار العبارات.

Take fc6 of AlexNet pruned to 9% and run it with an ordinary dense matrix kernel on a GPU. The kernel does not know the zeros are zeros. It multiplies all 38 M weight-activation pairs, 34.6 M of them by zero, and finishes in exactly the time the dense layer took. Nine times fewer parameters, zero speedup. The reduction table of two concepts ago counted what could be skipped; it did not promise that anything would be. Skipping needs either a custom engine that understands sparse formats or a sparsity pattern that commodity hardware is built for. Slide 13 shows both.

خذ fc6 من AlexNet بعد تقليمها إلى 9% وشغّلها بنواة ضرب مصفوفات كثيفة عادية (dense kernel) على GPU. النواة لا تعرف أن الأصفار أصفار. فهي تضرب كل أزواج الوزن والتفعيل البالغة 38 M، منها 34.6 M مضروبة في صفر، وتنتهي في الزمن نفسه تماماً الذي استغرقته الطبقة الكثيفة. معاملات أقل بتسع مرات، وتسريع صفري. جدول التخفيض قبل مفهومين عدّ ما يمكن تخطيه؛ لم يعد بأن شيئاً سيُتخطى فعلاً. والتخطي يحتاج إما محركاً مخصصاً يفهم الصيغ المتفرقة، وإما نمط ندرة صُمم العتاد التجاري الشائع من أجله. والشريحة 13 تعرض الاثنين.

The commodity route: NVIDIA A100 and 2:4الطريق التجاري: NVIDIA A100 ونمط 2:4

The Ampere whitepaper defines 2:4 sparsity as a structure "that allows two non-zero values in every four-entry vector". Every group of four contiguous weights along a row keeps at most two, so the matrix is exactly half zeros, stored as the nonzero values plus a 2-bit index per survivor. That compression cuts storage and bandwidth "by almost 2x", and the Sparse Tensor Core has a matrix multiply instruction that reads the indices, gathers only the matching activations, and finishes a tile in N/2 cycles instead of N: "a 2x speedup". This is the special case N = 2, M = 4 of N:M sparsity.

تعرّف الورقة البيضاء لمعمارية Ampere 2:4 sparsity بأنها بنية «تسمح بقيمتين غير صفريتين في كل متجه من أربعة عناصر». كل مجموعة من أربعة أوزان متجاورة على طول الصف تحتفظ بوزنين على الأكثر، فتكون المصفوفة نصفها أصفار بالضبط، وتُخزَّن على شكل القيم غير الصفرية مع 2-bit index (فهرس من بتّين) لكل وزن باقٍ. هذا الضغط يخفض التخزين وعرض النطاق «بما يقارب 2x»، ولدى Sparse Tensor Core تعليمة ضرب مصفوفات تقرأ الفهارس، وتجمع التفعيلات المطابقة فقط، وتُنهي البلاطة (tile) في N/2 دورة بدلاً من N: «تسريع 2x». هذه هي الحالة الخاصة N = 2, M = 4 من N:M sparsity.

A 4 by 8 dense block. On hover two weights in every group of four fade, the survivors slide left into a packed 4 by 4 block, and the 2-bit index strip that tells the Tensor Core where each survivor came from appears below.كتلة كثيفة بحجم 4 في 8. عند تمرير المؤشر يتلاشى وزنان من كل مجموعة من أربعة، وتنزلق الأوزان الباقية إلى اليسار لتشكل كتلة مضغوطة بحجم 4 في 4، ويظهر في الأسفل شريط فهارس البتّين الذي يخبر Tensor Core من أين جاء كل وزن باقٍ.

How does a model get into that pattern? The whitepaper's recipe is the pipeline of this part with one constraint added: the network is "first trained using dense weights, then fine-grained structured pruning is applied, and finally the remaining non-zero weights are fine-tuned". NVIDIA's developer blog reports BERT-Large keeping its SQuAD F1 of 91.9 dense and sparse. The magnitude criterion, the mask and the retraining are all Han's; the only change is that the two smallest of every four are cut instead of the smallest 50% of the layer.

كيف يصل النموذج إلى هذا النمط؟ وصفة الورقة البيضاء هي مسار هذا الجزء مع قيد واحد إضافي: الشبكة «تُدرَّب أولاً بأوزان كثيفة، ثم يُطبَّق تقليم منظم دقيق الحبيبات (fine-grained structured pruning)، وأخيراً تخضع الأوزان غير الصفرية الباقية للضبط الدقيق». وتذكر مدونة المطورين في NVIDIA أن BERT-Large يحافظ على درجة SQuAD F1 البالغة 91.9 في النسختين الكثيفة والمتفرقة. معيار القيمة المطلقة والقناع وإعادة التدريب كلها من Han؛ والتغيير الوحيد أنك تقطع أصغر وزنين من كل أربعة بدلاً من أصغر 50% من الطبقة.

What the A100 asks for and what it deliversما يطلبه A100 وما يقدّمه

Pattern requiredالنمط المطلوب
2 nonzeros in every 4 contiguous weights (50% sparsity)قيمتان غير صفريتين في كل 4 أوزان متجاورة (ندرة 50%)
Storage and bandwidthالتخزين وعرض النطاق
almost 2x smaller: half the values plus 2-bit indicesأصغر بما يقارب 2x: نصف القيم مع فهارس من 2-bit
Peak Tensor Core throughputإنتاجية Tensor Core في الذروة
up to 2x: Sparse MMA finishes a tile in N/2 cyclesحتى 2x: تعليمة Sparse MMA تُنهي البلاطة في N/2 دورة
Measured, BERT-Large GEMM layers (cuSPARSELt on A100)المقيس على طبقات GEMM في BERT-Large (cuSPARSELt على A100)
1.3x (projection), 1.4x (QKV, FC1), 1.6x (FC2)1.3x (الإسقاط projection)، 1.4x (QKV وFC1)، 1.6x (FC2)
Slide's summaryتلخيص الشريحة
1.5x measured BERT speedupتسريع مقيس قدره 1.5x على BERT

The gap between 2x and 1.5x is the gap between a peak instruction rate and a whole layer. The whitepaper says "up to 2x". NVIDIA's cuSPARSELt measurements on BERT-Large GEMM layers on an A100 give 1.3x for the projection, 1.4x for QKV and FC1, and 1.6x for FC2 over dense cuBLAS, because memory traffic for activations, the non-GEMM parts of the layer and kernel launch costs do not halve. The slide's "1.5X measured BERT speedup" is Han's summary of those numbers. Treat 1.5x as the realistic middle and 2x as the ceiling.

الفجوة بين 2x و1.5x هي الفجوة بين معدل تعليمة في الذروة وطبقة كاملة. الورقة البيضاء تقول «حتى 2x». وقياسات NVIDIA باستخدام cuSPARSELt على طبقات GEMM في BERT-Large على A100 تعطي 1.3x لطبقة الإسقاط (projection)، و1.4x لـ QKV وFC1، و1.6x لـ FC2 مقارنة بـ cuBLAS الكثيف، لأن حركة الذاكرة الخاصة بالتفعيلات والأجزاء غير المتعلقة بـ GEMM في الطبقة وتكاليف إطلاق النوى لا تنخفض إلى النصف. وعبارة الشريحة «1.5X measured BERT speedup» هي تلخيص Han لهذه الأرقام. اعتبر 1.5x القيمة الواقعية في المنتصف و2x السقف.

The custom route: engines built to skip zerosالطريق المخصص: محركات مبنية لتخطي الأصفار

Before 2:4 existed, the way to profit from unstructured sparsity was to build the hardware yourself. The four papers cited on slide 13 are all from Han and his students, and each makes a different thing sparse. EIE, the Efficient Inference Engine, holds the compressed model in on-chip SRAM, so the 640 pJ DRAM access from Part 01 disappears, and it skips both zero weights and the zero activations that ReLU produces, which its authors say "saves another 3x". ESE moves the same idea onto an FPGA for pruned speech-recognition LSTMs, the same recipe the previous concept applied to NeuralTalk. SpArch accelerates multiplying two sparse matrices, and SpAtten prunes tokens and attention heads at run time instead of weights.

قبل ظهور نمط 2:4، كانت طريقة الاستفادة من الندرة غير المنتظمة أن تبني العتاد بنفسك. الأوراق الأربع المذكورة في الشريحة 13 كلها من Han وطلابه، وكل منها يجعل شيئاً مختلفاً متفرقاً. EIE، أي Efficient Inference Engine، يحتفظ بالنموذج المضغوط في ذاكرة SRAM على الشريحة، فيختفي وصول DRAM بتكلفة 640 pJ المذكور في الجزء 01، ويتخطى الأوزان الصفرية وzero activations (التفعيلات الصفرية) التي تنتجها ReLU معاً، وهو ما يقول مؤلفوه إنه «يوفر 3x أخرى». وينقل ESE الفكرة نفسها إلى FPGA لشبكات LSTM المقلّمة الخاصة بالتعرف على الكلام، وهي الوصفة نفسها التي طبقها المفهوم السابق على NeuralTalk. ويسرّع SpArch ضرب مصفوفتين متفرقتين، بينما يقلّم SpAtten الرموز (tokens) ورؤوس الانتباه (attention heads) أثناء التشغيل بدلاً من الأوزان.

SystemالنظامVenueمكان النشرWhat is sparseما الذي يكون متفرقاًHeadlineالادعاء الرئيسي
EIEEIEISCA 2016ISCA 2016Weights and activations of pruned FC layers, model held in on-chip SRAMأوزان وتفعيلات طبقات FC المقلّمة، والنموذج محفوظ في SRAM على الشريحة189x faster than CPU, 13x faster than GPU, 24000x more energy efficient than CPUأسرع بـ 189x من CPU، وأسرع بـ 13x من GPU، وأكفأ في الطاقة بـ 24000x من CPU
ESEESEFPGA 2017FPGA 2017Pruned LSTM weights for speech recognitionأوزان LSTM المقلّمة للتعرف على الكلام43x faster than a Core i7, 3x faster than a Pascal Titan X, 282 GOPS on the compressed modelأسرع بـ 43x من Core i7، وأسرع بـ 3x من Pascal Titan X، و282 GOPS على النموذج المضغوط
SpArchSpArchHPCA 2020HPCA 2020Sparse matrix times sparse matrix (outer product with merge)ضرب مصفوفة متفرقة في مصفوفة متفرقة (الضرب الخارجي مع الدمج)2.8x fewer DRAM accesses, 4x over OuterSPACEوصول إلى DRAM أقل بـ 2.8x، و4x مقارنة بـ OuterSPACE
SpAttenSpAttenHPCA 2021HPCA 2021Tokens and heads of attention, pruned in a cascadeالرموز (tokens) ورؤوس الانتباه، مقلّمة على مراحل متتالية10x less DRAM traffic, 162x over a Titan Xpحركة بيانات مع DRAM أقل بـ 10x، و162x مقارنة بـ Titan Xp
A100 Sparse Tensor CoreA100 Sparse Tensor CoreNVIDIA 2020NVIDIA 2020Any weight matrix in the 2:4 patternأي مصفوفة أوزان بنمط 2:4up to 2x peak, 1.3x to 1.6x measured per BERT-Large layerحتى 2x في الذروة، و1.3x إلى 1.6x مقيسة لكل طبقة في BERT-Large
Hardware support for sparsity on slide 13, with each system's headline claim from its abstractدعم العتاد للندرة في الشريحة 13، مع الادعاء الرئيسي لكل نظام من ملخص ورقته

Worked exampleمثال محلول

The same pruned layer on three targetsالطبقة المقلّمة نفسها على ثلاثة أنواع من العتاد

  1. Dense GPU kernelنواة GPU كثيفة

    fc6 at 9% density still executes all 38 M MACs (75 M FLOPs). Speedup 1x. Memory footprint is smaller only if you store it sparse and decompress it, which costs time too.
    طبقة fc6 بكثافة 9% ما زالت تنفّذ كل عمليات MAC البالغة 38 M (75 M عملية FLOP). التسريع 1x. ولا تصغر مساحة الذاكرة إلا إذا خزّنتها بصيغة متفرقة ثم فككت ضغطها، وهذا يكلّف وقتاً أيضاً.
  2. EIEEIE

    Work is proportional to nonzero weight times nonzero activation pairs, roughly 3% of the dense count for fc6, and the weights never leave SRAM. This is where the MAC column of the reduction table becomes real time and real energy.
    العمل يتناسب مع عدد أزواج الوزن غير الصفري والتفعيل غير الصفري، أي نحو 3% من العدد الكثيف في fc6، والأوزان لا تغادر SRAM أبداً. هنا يتحول عمود MAC في جدول التخفيض إلى وقت حقيقي وطاقة حقيقية.
  3. A100 Sparse Tensor CoreSparse Tensor Core في A100

    You must prune exactly half in the 2:4 pattern, no more and no less, and you get at most 2x. The 9% density of fc6 cannot be expressed, so you either settle for 50% or lose the hardware path.
    يجب أن تقلّم النصف بالضبط بنمط 2:4، لا أكثر ولا أقل، وتحصل على 2x على الأكثر. كثافة fc6 البالغة 9% لا يمكن التعبير عنها، فإما أن تقبل بـ 50% وإما أن تخسر مسار العتاد.
  4. Speed is a property of the pairالسرعة خاصية للزوج: المصفوفة والعتاد معاً

    The same sparse matrix is a 1x, a 2x or a 30x win depending on what executes it. Parameter count alone predicts none of those.
    المصفوفة المتفرقة نفسها مكسب بمقدار 1x أو 2x أو 30x بحسب ما ينفّذها. وعدد المعاملات وحده لا يتنبأ بأي من هذه القيم.

Quick checkاختبار سريع

What must a weight matrix satisfy before A100 sparse Tensor Cores can double its throughput?ما الشرط الذي يجب أن تحققه مصفوفة الأوزان قبل أن تستطيع Sparse Tensor Cores في A100 مضاعفة إنتاجيتها؟

Recall

What does the A100 require of a pruned matrix, and what does it deliver?ماذا يتطلب A100 من المصفوفة المقلّمة، وماذا يقدّم؟

Two zeros in every four contiguous weights (50%, the 2:4 pattern). It delivers up to 2x Tensor Core throughput and almost 2x less storage and bandwidth; measured BERT-Large layer speedups are 1.3x to 1.6x.
صفران في كل أربعة أوزان متجاورة (50%، نمط 2:4). ويقدّم حتى 2x في إنتاجية Tensor Core، وتخفيضاً يقارب 2x في التخزين وعرض النطاق؛ أما التسريع المقيس لطبقات BERT-Large فهو 1.3x إلى 1.6x.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • Train, prune below a magnitude threshold, retrain the survivors. The retraining step is critical.درّب، ثم قلّم الأوزان التي تقل قيمتها المطلقة عن العتبة، ثم أعد تدريب الأوزان الباقية. خطوة إعادة التدريب حاسمة.
  • Prune-only: free lunch at 50 percent, about -1 percent at 67 percent, about -4 percent at 80 percent pruned.التقليم وحده: مكسب مجاني عند 50 بالمئة، ونحو -1 بالمئة عند 67 بالمئة، ونحو -4 بالمئة عند تقليم 80 بالمئة.
  • Prune plus retrain: zero loss to about 80 percent, 9x on AlexNet. Weights become bimodal and spread from ±0.015 to ±0.025.التقليم مع إعادة التدريب: لا فقدان حتى نحو 80 بالمئة، أي 9x على AlexNet. تصبح الأوزان ثنائية القمة (bimodal) وتتسع من ±0.015 إلى ±0.025.
  • Iterative prune and retrain: zero loss to about 90 percent, 5x lifted to 9x, sharp drop only past 10x.التقليم وإعادة التدريب بالتكرار: لا فقدان حتى نحو 90 بالمئة، فيرتفع التخفيض من 5x إلى 9x، ولا يحدث الهبوط الحاد إلا بعد 10x.
  • Reduction factor = 1 / (1 - pruning ratio): 80 percent is 5x, 90 percent is 10x.معامل التخفيض = 1 / (1 - نسبة التقليم): تقليم 80 بالمئة يعني 5x، و90 بالمئة يعني 10x.
  • AlexNet is 9x smaller but only 3x cheaper: FC layers hold 96.2 percent of parameters, conv layers hold 92 percent of MACs. FLOP% ≈ weight density × input activation density.AlexNet أصغر بـ 9x لكنه أرخص حساباً بـ 3x فقط: طبقات FC تحمل 96.2 بالمئة من المعاملات، وطبقات الالتفاف (conv) تحمل 92 بالمئة من عمليات MAC. نسبة FLOP المتبقية ≈ كثافة الأوزان × كثافة تفعيلات المدخل.
  • Fully convolutional nets (GoogleNet, ResNet-50, SqueezeNet) all keep about 30 percent, so about 3.4x.الشبكات الالتفافية بالكامل (GoogleNet وResNet-50 وSqueezeNet) تحتفظ كلها بنحو 30 بالمئة من أوزانها، أي نحو 3.4x.
  • The NeuralTalk LSTM pruned 90 percent keeps BLEU flat and captions nearly identical. 95 percent starts to drift.LSTM الخاص بـ NeuralTalk بعد تقليم 90 بالمئة يبقي BLEU ثابتاً والأوصاف (captions) شبه متطابقة. عند 95 بالمئة يبدأ الانحراف.
  • Sparsity is speed only with hardware support: EIE, ESE, SpArch, SpAtten, or the A100 2:4 pattern (up to 2x peak, about 1.3x to 1.6x measured on BERT-Large layers).الندرة لا تصبح سرعة إلا بدعم من العتاد: EIE أو ESE أو SpArch أو SpAtten، أو نمط 2:4 في A100 (حتى 2x في الذروة، ونحو 1.3x إلى 1.6x مقيسة على طبقات BERT-Large).

Sourcesالمصادر