Majid Al-RaimiWhere we are: the pruning problem so farأين وصلنا: مسألة التقليم حتى الآن

COE 592Lecture 4.2المحاضرة 4.2Part 01الجزء 01

Where we are: the pruning problem so farأين وصلنا: مسألة التقليم حتى الآن

A compact recap of lecture 04-1: pruning as constrained optimization, the granularity spectrum, magnitude as the default criterion and neuron or channel pruning as coarse-grained weight pruning, setting up the two open questions this lecture answers.مراجعة موجزة للمحاضرة 04-1: التقليم بوصفه تحسينًا مقيدًا، وطيف الدقة (granularity)، والمقدار بوصفه المعيار الافتراضي، وتقليم العصبونات أو القنوات بوصفه تقليمًا خشنًا للأوزان، تمهيدًا للسؤالين المفتوحين اللذين تجيب عنهما هذه المحاضرة.

Conceptsالمفاهيم
3
Slidesالشرائح
1-7
Readingمدة القراءة
18 min18 دقيقة
Understoodما فهمته
0/3 conceptsمفاهيم

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

Every method in this lecture, from sensitivity curves and AMC to NetAdapt, iterative fine-tuning, EIE and 2:4 tensor cores, is either a way of choosing how many nonzeros each layer may keep or a way of exploiting the zeros that choice creates. None of it makes sense unless the pruning problem itself is crisp in your head.

This part is a bridge, not a second lecture. The first seven slides of the deck repeat lecture 04-1 almost word for word, so the aim here is to compress what that lecture settled into one page you can reproduce under exam conditions: the formulation with every symbol defined, the reason the constraint cannot be optimized directly, the magnitude criterion on a 2 x 2 matrix, and the granularity ladder from single weights to whole channels. Expect to be asked for the formulation and for what ||W_P||_0 means, and the edge deployment in your research project starts by deciding a nonzero budget per layer, which is exactly the symbol N below.

كل طريقة في هذه المحاضرة، من منحنيات الحساسية (sensitivity curves) وAMC إلى NetAdapt وإعادة الضبط التكرارية (iterative fine-tuning) وEIE وtensor cores بنمط 2:4، إما أنها طريقة لاختيار عدد القيم غير الصفرية التي يحق لكل طبقة أن تحتفظ بها، أو طريقة للاستفادة من الأصفار التي ينتجها هذا الاختيار. لن يكون لأي من ذلك معنى ما لم تكن مسألة الـ pruning نفسها واضحة تمامًا في ذهنك.

هذا الجزء جسر، وليس محاضرة ثانية. الشرائح السبع الأولى من العرض تكرر المحاضرة 04-1 تقريبًا حرفيًا، لذلك الهدف هنا أن نضغط ما حسمته تلك المحاضرة في صفحة واحدة تستطيع إعادة كتابتها في ظروف الامتحان: الصياغة مع تعريف كل رمز فيها، وسبب عدم إمكان تحسين القيد مباشرة، ومعيار المقدار (magnitude) على مصفوفة 2 x 2، وسلّم درجات التفصيل (granularity) من الأوزان المنفردة إلى القنوات الكاملة. توقّع أن تُسأل عن الصياغة وعن معنى ||W_P||_0، كما أن النشر على الأجهزة الطرفية (edge deployment) في مشروعك البحثي يبدأ بتحديد ميزانية للقيم غير الصفرية لكل طبقة، وهي بالضبط الرمز N أدناه.

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

  1. Write the pruning formulation and define L, x, W, W_P, ||W_P||_0 and N.أن تكتب صياغة الـ pruning وتعرّف L و x و W و W_P و ||W_P||_0 و N.
  2. Explain why the L0 count is neither a norm nor differentiable, and why that forces heuristic criteria.أن تشرح لماذا لا يُعدّ عدد الـ L0 معيارًا (norm) ولا دالة قابلة للاشتقاق، ولماذا يجبرنا ذلك على معايير تقريبية (heuristic).
  3. Reproduce the 2x2 magnitude example and state the pruned matrix and its sparsity.أن تعيد حل مثال المقدار (magnitude) على مصفوفة 2x2 وتذكر المصفوفة بعد التقليم ونسبة الـ sparsity فيها.
  4. Place fine-grained through channel pruning on the flexibility versus hardware-friendliness axis.أن تضع مستويات التقليم من الدقيق (fine-grained) حتى تقليم القنوات (channel) على محور المرونة مقابل ملاءمة العتاد.
  5. Say which of the five questions 04-1 answered and which two this lecture answers.أن تذكر أي الأسئلة الخمسة أجابت عنها المحاضرة 04-1، وأي سؤالين تجيب عنهما هذه المحاضرة.

Take one layer with 16 weights and suppose the deployment budget allows you to keep only 8 of them. Which eight? That single question is the whole of Pruning. Every answer in lectures 04-1 and 04-2 is a different way of choosing those eight, and every hardware trick at the end of this lecture is a way of profiting from the eight zeros that remain.

خذ طبقة واحدة فيها 16 وزنًا، وافترض أن ميزانية النشر تسمح لك بالاحتفاظ بـ 8 منها فقط. أي ثمانية؟ هذا السؤال الواحد هو كل ما في الـ pruning. كل إجابة في المحاضرتين 04-1 و04-2 هي طريقة مختلفة لاختيار تلك الثمانية، وكل حيلة عتادية في نهاية هذه المحاضرة هي طريقة للاستفادة من الأصفار الثمانية المتبقية.

The general rule states the question as a constrained optimization. Among all weight tensors that have at most N nonzero entries, pick the one that makes the training loss smallest.

القاعدة العامة تصوغ السؤال على أنه مسألة تحسين مقيّدة (constrained optimization): من بين كل موترات الأوزان (weight tensors) التي فيها N قيمة غير صفرية على الأكثر، اختر الموتر الذي يجعل خسارة التدريب (training loss) أصغر ما يمكن.

arg⁡min⁡WPL(x; WP)subject to∥WP∥0≤N\arg\min_{W_P} L(x;\, W_P) \quad \text{subject to} \quad \|W_P\|_0 \le N
Pruning as loss minimization under a nonzero budgetالتقليم بوصفه تقليلًا للخسارة تحت ميزانية للقيم غير الصفرية

Every symbol in the formulationكل رمز في الصياغة

L
The training objective, the same loss the network was trained with, for example cross-entropyهدف التدريب، وهو دالة الخسارة نفسها التي دُرّبت بها الشبكة، مثل cross-entropy
x
The input data the loss is evaluated onبيانات الإدخال التي تُحسب عليها الخسارة
W
The original dense weights of the trained networkالأوزان الأصلية الكثيفة (dense) للشبكة المدرّبة
W_P
The pruned weights: the same shape as W, with some entries forced to exactly zeroالأوزان بعد التقليم: لها شكل W نفسه، مع إجبار بعض عناصرها على أن تساوي صفرًا بالضبط
||W_P||_0
The number of nonzero entries in W_P, the L0 normعدد العناصر غير الصفرية في W_P، وهو ما يُسمّى L0 norm
N
The target number of nonzeros, the budget the pruned network must respectالعدد المستهدف من القيم غير الصفرية، أي الميزانية التي يجب أن تلتزم بها الشبكة بعد التقليم

Read the formula from the inside out. L(x; W_P) asks how badly the network with weights W_P does on the data. The arg min says we want the W_P that makes that number smallest. The constraint says we may only search among tensors whose nonzero count fits the budget. The budget is what connects this formula to the Pruning ratio of the next part: with M weights in the layer and N survivors, the fraction removed is 1 - N / M, so for M = 16 and N = 8 the layer is 50% sparse. The weight count is written M rather than |W|, because |W| below means the element-wise absolute value.

اقرأ الصيغة من الداخل إلى الخارج. L(x; W_P) تسأل: ما مدى سوء أداء الشبكة ذات الأوزان W_P على البيانات؟ والـ arg min تقول إننا نريد W_P التي تجعل هذا الرقم أصغر ما يمكن. والقيد يقول إنه لا يُسمح لنا بالبحث إلا بين الموترات التي يتسع عدد قيمها غير الصفرية ضمن الميزانية. والميزانية هي ما يربط هذه الصيغة بالـ pruning ratio (نسبة التقليم) في الجزء التالي: إذا كان في الطبقة M وزنًا وبقي منها N، فالنسبة المحذوفة هي 1 - N / M، فعند M = 16 وN = 8 تكون الطبقة متناثرة (sparse) بنسبة 50%. نكتب عدد الأوزان M بدلًا من |W| لأن |W| فيما يلي تعني القيمة المطلقة عنصرًا بعنصر.

Sixteen weights, a budget of eight. Cells whose magnitude falls below the threshold fade to zero until the nonzero count meets N.ستة عشر وزنًا وميزانية ثمانية. الخلايا التي يقل مقدارها عن العتبة تتلاشى إلى الصفر حتى يصل عدد القيم غير الصفرية إلى N.

Why nobody solves this formula directlyلماذا لا يحل أحد هذه الصيغة مباشرة

The formula looks like something you could hand to gradient descent, and that is the trap. The nonzero count is a step function: nudge a weight from 0.30 to 0.31 and the count does not move, set it to exactly zero and the count drops by one. Its gradient is zero almost everywhere and undefined at zero, so no gradient flows through the constraint. Louizos, Welling and Kingma open their ICLR 2018 paper on this exact point: the L0 norm of the weights is non-differentiable, which is why it cannot simply be added to the training objective. Without a gradient, the exact problem is a combinatorial search, choosing which N of the M positions to keep, and for a layer with millions of weights that search is hopeless.

تبدو الصيغة كأنها شيء تستطيع تسليمه إلى خوارزمية الانحدار التدرجي (gradient descent)، وهذا هو الفخ. عدد القيم غير الصفرية دالة درجية (step function): حرّك وزنًا من 0.30 إلى 0.31 ولن يتغير العدد، واجعله صفرًا بالضبط فينقص العدد بواحد. تدرّجها صفر في كل مكان تقريبًا وغير معرّف عند الصفر، لذلك لا يمر أي تدرّج عبر القيد. يفتتح Louizos وWelling وKingma ورقتهم في ICLR 2018 بهذه النقطة بالذات: الـ L0 norm للأوزان غير قابل للاشتقاق، ولهذا لا يمكن ببساطة إضافته إلى هدف التدريب. ومن دون تدرّج تصبح المسألة الدقيقة بحثًا تركيبيًا (combinatorial search)، أي اختيار أي N من المواقع الـ M نحتفظ بها، وفي طبقة فيها ملايين الأوزان يكون هذا البحث ميؤوسًا منه.

The heuristics are not arbitrary. Every one of them is a proxy for the same quantity: how much would L change if this weight were removed. The constraint side of the formula only fixes the budget; the loss side is what actually decides the answer, so the best criterion is the one whose ranking best tracks the change in loss. That is why the slide on selection later in this part says that the less useful the removed neurons are, the better the pruned network performs. Useful means low loss change, nothing else.

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

ModelالنموذجBeforeقبلAfterبعدReductionنسبة التخفيض
AlexNetAlexNet61M61M6.7M6.7M9x9x
VGG-16VGG-16138M138M10.3M10.3M13x13x
Han et al. 2015 compression resultsنتائج الضغط عند Han et al. 2015

Recall

Write the pruning formulation and name every symbol.اكتب صياغة الـ pruning وسمِّ كل رمز فيها.

arg min over W_P of L(x; W_P) subject to ||W_P||_0 <= N. L is the training loss, x the input, W the original weights, W_P the pruned weights, ||W_P||_0 the number of nonzeros in W_P, and N the target number of nonzeros.
arg min over W_P of L(x; W_P) بشرط ||W_P||_0 <= N. L هي خسارة التدريب، وx المدخلات، وW الأوزان الأصلية، وW_P الأوزان بعد التقليم، و||W_P||_0 عدد القيم غير الصفرية في W_P، وN العدد المستهدف من القيم غير الصفرية.

Recall

Why can you not just run gradient descent on the constraint ||W_P||_0 <= N?لماذا لا تستطيع ببساطة تطبيق gradient descent على القيد ||W_P||_0 <= N؟

The count of nonzeros is piecewise constant, so its gradient is zero almost everywhere and undefined at zero. It is not a norm either. So we rank weights by a heuristic importance, keep the top N, and then fine-tune to recover the loss.
عدد القيم غير الصفرية ثابت على فترات (piecewise constant)، لذلك تدرّجه صفر في كل مكان تقريبًا وغير معرّف عند الصفر. وهو ليس معيارًا (norm) أيضًا. لذلك نرتّب الأوزان بدرجة أهمية تقريبية، ونحتفظ بأعلى N، ثم نُجري fine-tuning لاستعادة الخسارة.

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

In the pruning formulation, what does the term ||W_P||_0 measure?في صياغة الـ pruning، ماذا يقيس الحد ||W_P||_0؟

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

Why do all pruning criteria rank weights by an importance score instead of solving the arg min directly?لماذا ترتّب كل معايير الـ pruning الأوزان بدرجة أهمية بدلًا من حل الـ arg min مباشرة؟

The formulation says nothing about how to find good survivors. Lecture 04-1 gave two practical answers, a shape and a score, and slides 4 to 6 of this deck replay them in the space of one minute. Start with the score on the smallest example that still teaches something: a 2 x 2 weight matrix that must lose half of its entries.

الصياغة لا تقول شيئًا عن كيفية إيجاد الأوزان الجيدة التي تبقى. أعطت المحاضرة 04-1 إجابتين عمليتين: شكلًا ودرجة، والشرائح من 4 إلى 6 في هذا العرض تعيدهما في دقيقة واحدة. ابدأ بالدرجة على أصغر مثال لا يزال يعلّم شيئًا: مصفوفة أوزان 2 x 2 يجب أن تفقد نصف عناصرها.

Worked exampleمثال محلول

Magnitude pruning on a 2 x 2 matrix at 50%الـ Magnitude pruning على مصفوفة 2 x 2 بنسبة 50%

  1. Start from the weightsابدأ من الأوزان

    W = [[3, -2], [1, -5]], four weights, two of which must go.
    W = [[3, -2], [1, -5]]، أربعة أوزان يجب أن يُحذف اثنان منها.
  2. Score every weight by its absolute valueأعطِ كل وزن درجة تساوي قيمته المطلقة

    Element-wise |W| = [[3, 2], [1, 5]]. The sign is discarded; only distance from zero counts.
    القيمة المطلقة عنصرًا بعنصر |W| = [[3, 2], [1, 5]]. الإشارة تُهمل، والمهم فقط البعد عن الصفر.
  3. Keep the N = 2 highest scoresاحتفظ بأعلى N = 2 من الدرجات

    Sorted importances are 5, 3, 2, 1. The top two are 5 and 3, which belong to -5 and 3. The entries scored 2 and 1 are set to zero.
    الأهميات بعد الترتيب هي 5, 3, 2, 1. الأعلى اثنتان هما 5 و3، وهما تعودان إلى -5 و3. العنصران اللذان درجتهما 2 و1 يُجعلان صفرًا.
  4. Resultالنتيجة

    W_P = [[3, 0], [0, -5]], with ||W_P||_0 = 2 and sparsity 50%. Notice that -5 survives although it is the most negative weight in the matrix.
    W_P = [[3, 0], [0, -5]]، حيث ||W_P||_0 = 2 ونسبة الـ sparsity تساوي 50%. لاحظ أن -5 يبقى مع أنه الوزن الأكثر سالبية في المصفوفة.

This is Magnitude-based pruning, and the slide is honest about its status: it is a heuristic criterion. The assumption is that a weight far from zero contributes more to the output, and therefore to the loss, than a weight near zero. Han et al. (NeurIPS 2015) used exactly this threshold rule to produce the 9x and 13x reductions quoted in the first concept, which is strong evidence that the assumption is usually good enough. It is not the only score. Lecture 04-1, part 05, adds scaling factors such as batch-norm gammas for whole channels, and part 06 adds second-order saliency from Optimal Brain Damage, the percentage of zero activations, and regression-based selection. All of them plug into the same three steps: score, sort, keep the top N.

هذا هو الـ magnitude-based pruning، والشريحة صريحة بشأن طبيعته: إنه معيار تقريبي (heuristic). الافتراض أن الوزن البعيد عن الصفر يساهم في المخرجات، وبالتالي في الخسارة، أكثر من الوزن القريب من الصفر. استخدم Han et al. (NeurIPS 2015) قاعدة العتبة هذه بالضبط للوصول إلى التخفيضين 9x و13x المذكورين في المفهوم الأول، وهذا دليل قوي على أن الافتراض جيد بما يكفي في أغلب الأحوال. لكنه ليس الدرجة الوحيدة. تضيف المحاضرة 04-1 في جزئها 05 عوامل القياس (scaling factors) مثل قيم gamma في الـ batch-norm للقنوات الكاملة، ويضيف الجزء 06 أهمية الرتبة الثانية (second-order saliency) من Optimal Brain Damage، ونسبة التنشيطات الصفرية (zero activations)، والاختيار المعتمد على الانحدار (regression). وكلها تدخل في الخطوات الثلاث نفسها: أعطِ درجة، ثم رتّب، ثم احتفظ بأعلى N.

The shape of what is removedشكل ما يُحذف

Scoring weights one at a time and zeroing the smallest gives the pattern the slide calls fine-grained: zeros scattered wherever the small weights happened to be. The pruned network figure on that slide, again from Han et al., shows synapses vanishing at arbitrary positions and whole neurons disappearing once every synapse into them, or every synapse out of them, is gone. Fine-grained removal has the most freedom, since any index may be pruned, and that freedom is what buys it the highest compression ratios. The cost is that the survivors no longer form a dense block. Their positions must be stored as indices, and the hardware needs a sparse kernel that skips the holes. Mao et al. (2017) measured the other end of the trade: coarse-grained pruning reaches a sparsity similar to unstructured pruning without losing accuracy, needs far fewer indices, and saves about 2x the memory references compared with fine-grained sparsity.

إعطاء درجة لكل وزن على حدة وجعل الأصغر صفرًا ينتج النمط الذي تسميه الشريحة fine-grained (دقيق): أصفار متناثرة أينما صادف أن كانت الأوزان الصغيرة. شكل الشبكة بعد التقليم في تلك الشريحة، وهو أيضًا من Han et al.، يُظهر وصلات (synapses) تختفي في مواقع عشوائية، وعصبونات كاملة تختفي بمجرد أن تزول كل الوصلات الداخلة إليها أو كل الوصلات الخارجة منها. الحذف الدقيق يملك أكبر قدر من الحرية، لأن أي فهرس يمكن تقليمه، وهذه الحرية هي التي تمنحه أعلى نسب الضغط. الثمن أن الأوزان الباقية لم تعد تشكّل كتلة كثيفة (dense block). يجب تخزين مواقعها على شكل فهارس (indices)، ويحتاج العتاد إلى نواة حسابية متناثرة (sparse kernel) تتخطى الفراغات. قاس Mao et al. (2017) الطرف الآخر من هذه المقايضة: التقليم الخشن (coarse-grained) يصل إلى sparsity قريبة من التقليم غير المنتظم (unstructured) دون خسارة في الدقة، ويحتاج إلى فهارس أقل بكثير، ويوفّر نحو 2x من مرات الوصول إلى الذاكرة (memory references) مقارنة بالـ sparsity الدقيقة.

LevelالمستوىWhat is removedما الذي يُحذفFlexibilityالمرونةHardware friendlinessملاءمة العتاد
Fine-grainedدقيق (Fine-grained)Single weights at arbitrary positionsأوزان منفردة في مواقع عشوائيةHighestالأعلىNeeds stored indices and sparse kernelsيحتاج إلى تخزين الفهارس (indices) وأنوية حسابية متناثرة (sparse kernels)
Pattern-basedقائم على نمط (Pattern-based)Weights in a fixed pattern, such as M:N (for example 2:4)أوزان بنمط ثابت مثل M:N (مثلًا 2:4)HighعاليةRegular enough for special hardware supportمنتظم بما يكفي لدعم عتادي خاص
Vector-levelعلى مستوى المتجه (Vector-level)One 1-D row of a kernel, W[o, i, r, :]صف أحادي البعد واحد من النواة، W[o, i, r, :]MediumمتوسطةModerate, fewer indices per blockمتوسطة، فهارس أقل لكل كتلة
Kernel-levelعلى مستوى النواة (Kernel-level)One whole k x k kernelنواة كاملة واحدة بحجم k x kLowerأقلGood, whole blocks disappearجيدة، تختفي كتل كاملة
Channel-levelعلى مستوى القناة (Channel-level)A whole filter and its output channelمرشّح (filter) كامل مع قناته الخارجةLowestالأدنىBest, the layer simply gets narrowerالأفضل، الطبقة ببساطة تصبح أضيق
The granularity ladder, from lecture 04-1 parts 03 and 04سلّم درجات التفصيل (granularity)، من المحاضرة 04-1، الجزءين 03 و04

That ladder is the Pruning granularity axis, and the two ends pull against each other. Irregular patterns give the criterion freedom and therefore compression; regular patterns give the hardware dense blocks and therefore speed. Every design choice later in this lecture sits somewhere on this axis, and the 2:4 pattern of the tensor-core part is the industry's attempt to sit in both places at once.

هذا السلّم هو محور الـ pruning granularity (درجة تفصيل التقليم)، وطرفاه يتجاذبان في اتجاهين متعاكسين. الأنماط غير المنتظمة تعطي المعيار حرية، وبالتالي ضغطًا أكبر؛ والأنماط المنتظمة تعطي العتاد كتلًا كثيفة، وبالتالي سرعة أكبر. كل قرار تصميمي لاحق في هذه المحاضرة يقع في مكان ما على هذا المحور، ونمط 2:4 في جزء الـ tensor cores هو محاولة الصناعة للوقوف في المكانين معًا.

Recall

Weights 3, -2, 1, -5, keep half by magnitude: what survives and what is ||W_P||_0?الأوزان 3 و -2 و 1 و -5، احتفظ بنصفها حسب المقدار (magnitude): ما الذي يبقى، وما قيمة ||W_P||_0؟

Importances are 3, 2, 1, 5. The two largest are 5 and 3, so -5 and 3 survive. W_P = [[3, 0], [0, -5]], ||W_P||_0 = 2, sparsity 50%.
الأهميات هي 3, 2, 1, 5. الأكبر اثنتان هما 5 و3، لذلك يبقى -5 و3. W_P = [[3, 0], [0, -5]]، و||W_P||_0 = 2، والـ sparsity تساوي 50%.

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

Applying Importance = |W| to 3, -2, 1, -5 and keeping half, which weights survive?عند تطبيق Importance = |W| على الأوزان 3 و -2 و 1 و -5 والاحتفاظ بنصفها، أي الأوزان تبقى؟

The coarse end of the ladder deserves one concrete picture, because it explains a sentence that students often quote without understanding: Neuron pruning is coarse-grained weight pruning. Slide 6 draws both cases, the linear layer and the convolution layer, and the same picture in matrix form makes the sentence obvious.

الطرف الخشن من السلّم يستحق صورة واحدة ملموسة، لأنها تشرح جملة يقتبسها الطلاب كثيرًا دون فهم: الـ neuron pruning (تقليم العصبونات) هو تقليم أوزان خشن (coarse-grained). ترسم الشريحة 6 الحالتين، الطبقة الخطية (linear layer) وطبقة الالتفاف (convolution layer)، والصورة نفسها في شكل مصفوفة تجعل هذه الجملة بديهية.

Removing a neuron is removing a rowحذف عصبون هو حذف صف

A linear layer computes y = W x with W of shape out x in. Output neuron i is nothing more than row i of W: its incoming weights are the entries of that row, and its output is that row's dot product with x. Deleting the neuron therefore deletes the whole row at once, which is the white stripe in the slide's weight matrix, and the next layer loses the matching column because that input no longer exists. That is neuron pruning, and it is weight pruning where the removed set is a structured block of in weights chosen together rather than one weight at a time. Lecture 04-1, part 06, first drew this equivalence next to Optimal Brain Damage.

الطبقة الخطية تحسب y = W x حيث شكل W هو out x in. العصبون الخارج i ليس أكثر من الصف i في W: أوزانه الداخلة هي عناصر ذلك الصف، ومخرجه هو حاصل الضرب النقطي لذلك الصف مع x. لذلك فإن حذف العصبون يحذف الصف كله دفعة واحدة، وهو الشريط الأبيض في مصفوفة الأوزان في الشريحة، وتفقد الطبقة التالية العمود المقابل لأن ذلك المدخل لم يعد موجودًا. هذا هو تقليم العصبونات، وهو تقليم أوزان تكون فيه المجموعة المحذوفة كتلة منتظمة من in وزنًا تُختار معًا، لا وزنًا واحدًا في كل مرة. رسمت المحاضرة 04-1، الجزء 06، هذا التكافؤ أول مرة بجانب Optimal Brain Damage.

Deleting output neuron 2 removes its four incoming edges on the left and strikes out row 2 of W on the right. The other rows survive intact.حذف العصبون الخارج 2 يزيل وصلاته الداخلة الأربع على اليسار ويشطب الصف 2 من W على اليمين. أما بقية الصفوف فتبقى سليمة.

The convolution version is the same idea one dimension up. A conv layer holds weights of shape C_out x C_in x k x k. Output channel j is produced by filter j, which is the slice of all C_in kernels that feed it. Deleting a channel deletes that entire filter, the two dashed blocks in the slide's stack of six filters and the two white rows of kernels in its weight grid (two of six output channels removed). That is Channel pruning, and its reward is that nothing sparse is left behind: the layer simply has C_out minus the pruned count of channels and runs on the same dense kernels as before.

نسخة الالتفاف هي الفكرة نفسها ببُعد إضافي. طبقة الـ conv تحمل أوزانًا شكلها C_out x C_in x k x k. القناة الخارجة j ينتجها المرشّح j، وهو الشريحة المكوّنة من كل الأنوية (kernels) الـ C_in التي تغذّيها. حذف قناة يحذف ذلك المرشّح بالكامل، وهما الكتلتان المنقّطتان في رزمة المرشّحات الستة في الشريحة، والصفّان الأبيضان من الأنوية في شبكة أوزانها (حُذفت قناتان خارجتان من ست). هذا هو الـ channel pruning، ومكافأته أنه لا يترك خلفه أي شيء متناثر: الطبقة ببساطة يصبح فيها C_out ناقص عدد القنوات المقلّمة، وتعمل على الأنوية الحسابية الكثيفة (dense kernels) نفسها كما كانت من قبل.

WorkالعملModel and dataالنموذج والبياناتResultالنتيجة
Li et al., ICLR 2017Li et al., ICLR 2017VGG-16, CIFAR-10VGG-16, CIFAR-10Up to 34% fewer FLOPsعدد FLOPs أقل بنسبة تصل إلى 34%
Li et al., ICLR 2017Li et al., ICLR 2017ResNet-110, CIFAR-10ResNet-110, CIFAR-10Up to 38% fewer FLOPsعدد FLOPs أقل بنسبة تصل إلى 38%
He et al., ICCV 2017He et al., ICCV 2017VGG-16VGG-165x speed-up, +0.3% errorتسريع 5x، مع زيادة في الخطأ +0.3%
Channel pruning results on dense kernelsنتائج الـ channel pruning على أنوية حسابية كثيفة (dense kernels)

Five questions, three answeredخمسة أسئلة، أُجيب عن ثلاثة منها

The outline that opens this deck on slide 2, and returns on slide 7 to close this part, lists five questions, and the same outline appeared three times in lecture 04-1. It is the map of both lectures, so it is worth knowing where each question was answered. The formulation above answers the first. Granularity, the pattern of removal, was answered in 04-1. Criterion, the score used to rank weights, was also answered in 04-1. What remains open is how many weights each layer should lose, and how to recover the accuracy once they are gone.

المخطط الذي يفتتح هذا العرض في الشريحة 2، ويعود في الشريحة 7 ليختم هذا الجزء، يسرد خمسة أسئلة، وقد ظهر المخطط نفسه ثلاث مرات في المحاضرة 04-1. إنه خريطة المحاضرتين، لذلك يستحق أن تعرف أين أُجيب عن كل سؤال. الصياغة أعلاه تجيب عن السؤال الأول. ودرجة التفصيل (granularity)، أي نمط الحذف، أُجيب عنها في 04-1. والمعيار (criterion)، أي الدرجة المستخدمة لترتيب الأوزان، أُجيب عنه أيضًا في 04-1. ما بقي مفتوحًا هو كم وزنًا يجب أن تفقد كل طبقة، وكيف نستعيد الدقة بعد حذفها.

QuestionالسؤالAsksماذا يسألAnswered inأين أُجيب عنه
Introductionالمقدمة (Introduction)What is pruning and how do we formulate it?ما الـ pruning وكيف نصوغه رياضيًا؟Lecture 04-1, part 01, and this partالمحاضرة 04-1، الجزء 01، وهذا الجزء
Granularityدرجة التفصيل (Granularity)In what pattern should weights be removed?بأي نمط يجب أن تُحذف الأوزان؟Lecture 04-1, parts 03 and 04المحاضرة 04-1، الجزءان 03 و04
Criterionالمعيار (Criterion)Which synapses or neurons should go?أي الوصلات (synapses) أو العصبونات يجب أن تُحذف؟Lecture 04-1, parts 05 and 06المحاضرة 04-1، الجزءان 05 و06
Ratioالنسبة (Ratio)What target sparsity should each layer get?ما نسبة الـ sparsity المستهدفة لكل طبقة؟This lecture, parts 02 to 05هذه المحاضرة، الأجزاء من 02 إلى 05
Fine-tune or trainإعادة الضبط أو التدريب (Fine-tune or train)How do we recover the accuracy we lost?كيف نستعيد الدقة التي فقدناها؟This lecture, part 06هذه المحاضرة، الجزء 06
The five pruning questions and where they are answeredأسئلة الـ pruning الخمسة وأين أُجيب عنها
The three questions settled in 04-1 are ticked. Ratio is lit and marked in focus because the outline highlights it next, and fine-tuning waits behind it.الأسئلة الثلاثة التي حُسمت في 04-1 عليها علامة صح. النسبة (ratio) مضاءة ومعلّمة بأنها محل التركيز لأن المخطط يبرزها تاليًا، وإعادة الضبط (fine-tuning) تنتظر خلفها.

On slide 2 both open questions, ratio and fine-tuning, are highlighted in yellow. On slide 7, which closes this part, ratio turns green while fine-tuning stays yellow: ratio is being opened now, fine-tuning is still queued. The outline also under-sells the deck. After the five questions, parts 07 onward add a story the list never mentions, how EIE, 2:4 sparse tensor cores and sparse convolution engines turn the zeros produced by pruning into real speed and energy savings on hardware.

في الشريحة 2 يظهر السؤالان المفتوحان، النسبة (ratio) وإعادة الضبط (fine-tuning)، مظللين بالأصفر. وفي الشريحة 7، التي تختم هذا الجزء، تتحول النسبة إلى الأخضر بينما يبقى الـ fine-tuning أصفر: النسبة تُفتح الآن، والـ fine-tuning لا يزال في الانتظار. والمخطط أيضًا لا يعطي العرض حقه. فبعد الأسئلة الخمسة، تضيف الأجزاء من 07 فصاعدًا قصة لا تذكرها القائمة أبدًا: كيف تحوّل EIE وtensor cores المتناثرة بنمط 2:4 ومحركات الالتفاف المتناثر (sparse convolution engines) الأصفار الناتجة عن التقليم إلى سرعة حقيقية وتوفير فعلي في الطاقة على العتاد.

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

Removing one neuron from a linear layer deletes what from its weight matrix?حذف عصبون واحد من طبقة خطية يحذف ماذا من مصفوفة أوزانها؟

Recall

What does removing one neuron of a linear layer do to W, and one channel of a conv layer?ماذا يفعل حذف عصبون واحد من طبقة خطية بالمصفوفة W، وماذا يفعل حذف قناة واحدة من طبقة conv؟

It deletes one whole row of W. Removing a conv channel deletes one whole filter, all C_in of its kernels. Both remove a structured block of many weights at once, so both are coarse-grained weight pruning.
يحذف صفًّا كاملًا من W. وحذف قناة من طبقة conv يحذف مرشّحًا كاملًا، أي كل الأنوية الـ C_in التابعة له. كلاهما يزيل كتلة منتظمة من أوزان كثيرة دفعة واحدة، لذلك كلاهما تقليم أوزان خشن (coarse-grained).

Recall

Which of the five questions did 04-1 answer, and which does 04-2 answer?أي الأسئلة الخمسة أجابت عنها 04-1، وأيها تجيب عنها 04-2؟

04-1 answered formulation, granularity and criterion. 04-2 answers the pruning ratio per layer and fine-tuning, then goes beyond the outline to sparse hardware.
أجابت 04-1 عن الصياغة ودرجة التفصيل (granularity) والمعيار (criterion). وتجيب 04-2 عن نسبة التقليم لكل طبقة (pruning ratio) وعن الـ fine-tuning، ثم تتجاوز المخطط إلى العتاد المخصص للمصفوفات المتناثرة (sparse hardware).

Recapالخلاصة

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

  • Pruning: minimize L(x; W_P) subject to ||W_P||_0 <= N, where N is a budget on nonzeros.الـ Pruning: نقلّل L(x; W_P) بشرط ||W_P||_0 <= N، حيث N ميزانية لعدد القيم غير الصفرية.
  • ||.||_0 counts nonzeros. It is not a norm and has no gradient, so every criterion is a heuristic proxy for the change in L.الرمز ||.||_0 يعدّ القيم غير الصفرية. ليس معيارًا (norm) وليس له تدرّج (gradient)، لذلك كل معيار للتقليم هو تقريب heuristic لمقدار التغيّر في L.
  • Slide 3 mixes < N with <= N and W_p with W_P. Read <= N and one matrix.الشريحة 3 تخلط بين < N و <= N، وبين W_p و W_P. اقرأها على أنها <= N ومصفوفة واحدة.
  • Magnitude criterion: Importance = |W|. Weights 3, -2, 1, -5 at 50% keep 3 and -5.معيار المقدار: Importance = |W|. من الأوزان 3 و -2 و 1 و -5 عند نسبة 50% نُبقي 3 و -5.
  • Granularity runs from fine-grained (flexible, index heavy) to channel (regular, dense-friendly).درجة التفصيل (granularity) تمتد من الدقيق fine-grained (مرن لكنه يحتاج فهارس كثيرة) إلى مستوى القناة channel (منتظم ومناسب للحساب الكثيف dense).
  • Neuron pruning removes a row of W. Channel pruning removes a filter. Both are coarse-grained weight pruning.تقليم العصبون (neuron pruning) يحذف صفًّا من W. وتقليم القناة (channel pruning) يحذف مرشّحًا (filter) كاملًا. كلاهما تقليم أوزان خشن (coarse-grained).
  • 04-1 settled formulation, granularity and criterion. 04-2 answers ratio and fine-tuning, then adds sparse hardware.حسمت المحاضرة 04-1 الصياغة ودرجة التفصيل والمعيار. وتجيب 04-2 عن النسبة (ratio) وإعادة الضبط (fine-tuning)، ثم تضيف العتاد المخصص للمصفوفات المتناثرة (sparse hardware).

Sourcesالمصادر