COE 592Lecture 4.2المحاضرة 4.2Full guideالشرح الكامل
Pruning ratios, fine-tuning and sparse hardwareنسب التقليم والضبط الدقيق والعتاد المتناثر
The whole lecture on one page, taught concept by concept. Work through the parts in order, mark each concept once you understand it, and open the slide chips when you want the original slides.المحاضرة كاملة في صفحة واحدة، مشروحة مفهومًا مفهومًا. امشِ على الأجزاء بالترتيب، وعلّم كل مفهوم بعد أن تفهمه، وافتح أزرار الشرائح عندما تريد الرجوع إلى الشرائح الأصلية.
- Partsالأجزاء
- 13
- Conceptsالمفاهيم
- 44
- Slidesالشرائح
- 115
- Readingمدة القراءة
- 264 min264 دقيقة
Part 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)، والمقدار بوصفه المعيار الافتراضي، وتقليم العصبونات أو القنوات بوصفه تقليمًا خشنًا للأوزان، تمهيدًا للسؤالين المفتوحين اللذين تجيب عنهما هذه المحاضرة.
3 concepts3 مفاهيم, ، slides 1-7الشرائح 1-7
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في نهاية هذا الجزء ستستطيع
- 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.
- Explain why the L0 count is neither a norm nor differentiable, and why that forces heuristic criteria.أن تشرح لماذا لا يُعدّ عدد الـ L0 معيارًا (norm) ولا دالة قابلة للاشتقاق، ولماذا يجبرنا ذلك على معايير تقريبية (heuristic).
- Reproduce the 2x2 magnitude example and state the pruned matrix and its sparsity.أن تعيد حل مثال المقدار (magnitude) على مصفوفة 2x2 وتذكر المصفوفة بعد التقليم ونسبة الـ sparsity فيها.
- Place fine-grained through channel pruning on the flexibility versus hardware-friendliness axis.أن تضع مستويات التقليم من الدقيق (fine-grained) حتى تقليم القنوات (channel) على محور المرونة مقابل ملاءمة العتاد.
- 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) أصغر ما يمكن.
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| فيما يلي تعني القيمة المطلقة عنصرًا بعنصر.
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نسبة التخفيض |
|---|---|---|---|
| AlexNetAlexNet | 61M61M | 6.7M6.7M | 9x9x |
| VGG-16VGG-16 | 138M138M | 10.3M10.3M | 13x13x |
Recall
Write the pruning formulation and name every symbol.اكتب صياغة الـ pruning وسمِّ كل رمز فيها.
Recall
Why can you not just run gradient descent on the constraint ||W_P||_0 <= N?لماذا لا تستطيع ببساطة تطبيق gradient descent على القيد ||W_P||_0 <= N؟
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%
Start from the weightsابدأ من الأوزان
W = [[3, -2], [1, -5]], four weights, two of which must go.W = [[3, -2], [1, -5]]، أربعة أوزان يجب أن يُحذف اثنان منها.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]]. الإشارة تُهمل، والمهم فقط البعد عن الصفر.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 يُجعلان صفرًا.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 k | Lowerأقل | Good, whole blocks disappearجيدة، تختفي كتل كاملة |
| Channel-levelعلى مستوى القناة (Channel-level) | A whole filter and its output channelمرشّح (filter) كامل مع قناته الخارجة | Lowestالأدنى | Best, the layer simply gets narrowerالأفضل، الطبقة ببساطة تصبح أضيق |
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؟
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.
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 2017 | VGG-16, CIFAR-10VGG-16, CIFAR-10 | Up to 34% fewer FLOPsعدد FLOPs أقل بنسبة تصل إلى 34% |
| Li et al., ICLR 2017Li et al., ICLR 2017 | ResNet-110, CIFAR-10ResNet-110, CIFAR-10 | Up to 38% fewer FLOPsعدد FLOPs أقل بنسبة تصل إلى 38% |
| He et al., ICCV 2017He et al., ICCV 2017 | VGG-16VGG-16 | 5x speed-up, +0.3% errorتسريع 5x، مع زيادة في الخطأ +0.3% |
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 |
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؟
Recall
Which of the five questions did 04-1 answer, and which does 04-2 answer?أي الأسئلة الخمسة أجابت عنها 04-1، وأيها تجيب عنها 04-2؟
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المصادر
- Learning both Weights and Connections for Efficient Neural NetworkPaperNeurIPS 2015, Han, Pool, Tran and DallyMagnitude threshold pruning with the train, prune, retrain loop; AlexNet 61M to 6.7M (9x), VGG-16 138M to 10.3M (13x).تقليم بعتبة المقدار (magnitude threshold) مع حلقة التدريب ثم التقليم ثم إعادة التدريب (train, prune, retrain)؛ AlexNet من 61M إلى 6.7M (9x)، وVGG-16 من 138M إلى 10.3M (13x).(opens in a new tab)(يفتح في تبويب جديد)
- Deep Learning, chapter 2: Linear Algebra, section 2.5 NormsBookMIT Press, Goodfellow, Bengio and CourvilleThe so-called L0 norm is incorrect terminology: the nonzero count does not scale with its argument, so it is not a norm.تسمية L0 norm مصطلح غير صحيح: عدد القيم غير الصفرية لا يتناسب مع مدخله عند ضربه في ثابت، لذلك ليس معيارًا (norm).(opens in a new tab)(يفتح في تبويب جديد)
- Learning Sparse Neural Networks through L0 RegularizationPaperICLR 2018, Louizos, Welling and KingmaStates that the L0 norm of the weights is non-differentiable, the reason it cannot be optimized by gradient descent.تنص على أن الـ L0 norm للأوزان غير قابل للاشتقاق، وهذا سبب عدم إمكان تحسينه بالـ gradient descent.(opens in a new tab)(يفتح في تبويب جديد)
- Optimal Brain DamagePaperNIPS 1989, LeCun, Denker and SollaSecond-derivative saliency as a criterion for removing weights.الأهمية المبنية على المشتقة الثانية (second-derivative saliency) معيارًا لحذف الأوزان.(opens in a new tab)(يفتح في تبويب جديد)
- Exploring the Regularity of Sparse Structure in Convolutional Neural NetworksPaperarXiv 2017, Mao et al.Granularity spectrum, index saving, and about 2x fewer memory references for coarse-grained sparsity.طيف درجات التفصيل (granularity)، والتوفير في الفهارس (indices)، وعدد أقل بنحو 2x من مرات الوصول إلى الذاكرة (memory references) في الـ sparsity الخشنة (coarse-grained).(opens in a new tab)(يفتح في تبويب جديد)
- Pruning Filters for Efficient ConvNetsPaperICLR 2017, Li, Kadav, Durdanovic, Samet and GrafWhole filters removed with their feature maps; FLOP reductions of up to 34% on VGG-16 and 38% on ResNet-110 for CIFAR-10 with dense BLAS.حذف مرشّحات (filters) كاملة مع خرائط السمات (feature maps) التابعة لها؛ تخفيض في الـ FLOPs يصل إلى 34% على VGG-16 و38% على ResNet-110 على CIFAR-10 باستخدام dense BLAS.(opens in a new tab)(يفتح في تبويب جديد)
- Channel Pruning for Accelerating Very Deep Neural NetworksPaperICCV 2017, He, Zhang and SunLASSO-based channel selection; 5x speed-up on VGG-16 with a 0.3% increase in error.اختيار القنوات بالاعتماد على LASSO؛ تسريع 5x على VGG-16 مع زيادة في الخطأ قدرها 0.3%.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2024DocsMIT HAN Lab, Song HanLectures 3 and 4, Pruning and Sparsity parts I and II, the deck these COE 592 slides follow.المحاضرتان 3 و4، Pruning and Sparsity الجزءان I و II، وهو العرض الذي تتبعه شرائح COE 592 هذه.(opens in a new tab)(يفتح في تبويب جديد)
Part 02: Why every layer needs its own pruning ratioلماذا تحتاج كل طبقة نسبة تقليم خاصة بها
Uniform shrinking loses to non-uniform pruning, so each layer needs its own ratio. Sensitivity analysis measures how much accuracy each layer loses as it is pruned harder.التصغير المنتظم يخسر أمام التقليم غير المنتظم، لذا تحتاج كل طبقة نسبتها الخاصة. تحليل الحساسية (sensitivity analysis) يقيس مقدار الدقة التي تفقدها كل طبقة كلما قُلّمت بقوة أكبر.
3 concepts3 مفاهيم, ، slides 8-17الشرائح 8-17
Why this part mattersلماذا يهمّ هذا الجزء
Every embedded deployment you will ship in this course, and every exam question on this lecture, starts from one decision: how much to prune each layer. Get it wrong by treating all layers alike and you pay accuracy at the same latency, about 2.1 points on MobileNet at roughly 70 ms. Get it right per layer and you have the foundation that AMC, NetAdapt and the threshold method in the next part all build on.
Part 01 left two questions open, and this part answers the first: what pruning ratio should each layer get? The answer comes in three moves. First the evidence that one ratio for all layers is a bad idea. Then the reason, which is that layers differ in sensitivity. Then the measurement, a sweep that prunes one layer at a time and records how much accuracy it costs, producing the family of curves that the next part reads ratios from.
كل نشر على الأنظمة المدمجة ستنفذه في هذا المقرر، وكل سؤال امتحان عن هذه المحاضرة، يبدأ من قرار واحد: كم نقلّم من كل طبقة؟ إذا أخطأت فيه وعاملت كل الطبقات بالطريقة نفسها، دفعت ثمنه دقةً عند زمن الاستجابة نفسه، أي نحو 2.1 points في MobileNet عند حوالي 70 ms. وإذا أصبت فيه لكل طبقة على حدة، صار عندك الأساس الذي تبني عليه AMC وNetAdapt وطريقة العتبة في الجزء التالي.
ترك الجزء 01 سؤالين مفتوحين، وهذا الجزء يجيب عن الأول: ما نسبة التقليم (pruning ratio) التي تستحقها كل طبقة؟ تأتي الإجابة في ثلاث خطوات. أولًا الدليل على أن نسبة واحدة لكل الطبقات فكرة سيئة. ثم السبب، وهو أن الطبقات تختلف في حساسيتها. ثم القياس، وهو مسح يقلّم طبقة واحدة في كل مرة ويسجّل كم يكلّف ذلك من الدقة، فينتج عائلة المنحنيات التي يقرأ منها الجزء التالي النسب.
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain, with the MobileNet numbers, why non-uniform pruning dominates uniform shrinking on accuracy versus latency.اشرح، بأرقام MobileNet، لماذا يتفوق التقليم غير المنتظم على التصغير المنتظم في الموازنة بين الدقة وزمن الاستجابة.
- Define layer sensitivity and Delta Acc, and give three reasons the first layer is usually the most sensitive.عرّف حساسية الطبقة (layer sensitivity) و Delta Acc، واذكر ثلاثة أسباب تجعل الطبقة الأولى عادةً هي الأكثر حساسية.
- Carry out the four-step sensitivity sweep and read a sensitivity chart for VGG-11 on CIFAR-10.نفّذ خطوات مسح الحساسية الأربع، واقرأ مخطط الحساسية لـ VGG-11 على CIFAR-10.
- Compute the evaluation cost of a sweep as layers times ratios, and explain why it is evaluation only, not training.احسب تكلفة التقييم في المسح بوصفها عدد الطبقات مضروبًا في عدد النسب، واشرح لماذا هو تقييم فقط وليس تدريبًا.
- State what the sweep cannot tell you (interactions between layers), preparing for the threshold and automated methods that follow.اذكر ما لا يستطيع المسح أن يخبرك به (التفاعلات بين الطبقات)، تمهيدًا لطريقة العتبة والطرق المؤتمتة التي تأتي بعده.
Start with a measurement, not a principle. Take MobileNet on ImageNet and run it on a Google Pixel 1 CPU with TensorFlow Lite. The dense network scores 70.6% top-1 at 123.3 ms per image. Now shrink it two different ways to roughly half the work. The first way multiplies every layer's width by 0.75, the built-in MobileNet knob. The second way, AMC, lets every layer keep a different fraction of its channels (He et al., ECCV 2018, Table 4). MMACs counts millions of multiply-accumulate operations per image, a hardware-neutral measure of compute; a FLOPs target asks AMC to halve that compute, while a latency target asks it to halve measured time on the phone.
ابدأ بقياس لا بمبدأ. خذ MobileNet على ImageNet وشغّله على معالج Google Pixel 1 CPU باستخدام TensorFlow Lite. الشبكة الكثيفة (dense) تحقق 70.6% في top-1 بزمن 123.3 ms لكل صورة. الآن صغّرها بطريقتين مختلفتين إلى نحو نصف العمل تقريبًا. الطريقة الأولى تضرب عرض كل طبقة في 0.75، وهو المقبض المدمج في MobileNet. الطريقة الثانية، AMC، تسمح لكل طبقة أن تحتفظ بنسبة مختلفة من قنواتها (He et al., ECCV 2018, Table 4). يعدّ MMACs ملايين عمليات الضرب والتجميع (multiply-accumulate) لكل صورة، وهو مقياس للحوسبة لا يرتبط بعتاد معين. هدف FLOPs يطلب من AMC أن يخفض هذه الحوسبة إلى النصف، بينما هدف زمن الاستجابة (latency) يطلب منه أن يخفض الزمن المقاس على الهاتف إلى النصف.
| Modelالنموذج | Top-1Top-1 | MMACsMMACs | Pixel 1 latencyزمن الاستجابة على Pixel 1 |
|---|---|---|---|
| 1.0 MobileNet (dense)1.0 MobileNet (كثيف) | 70.6%70.6% | 569569 | 123.3 ms123.3 ms |
| 0.75 MobileNet (uniform width multiplier)0.75 MobileNet (مضاعف عرض منتظم) | 68.4%68.4% | 325325 | 72.3 ms72.3 ms |
| AMC, 50% FLOPs targetAMC، هدف 50% من FLOPs | 70.5%70.5% | 285285 | 68.3 ms68.3 ms |
| AMC, 50% latency targetAMC، هدف 50% من زمن الاستجابة | 70.2%70.2% | 272272 | 63.3 ms63.3 ms |
Read the middle two rows against each other. At nearly the same latency, 72.3 ms versus 68.3 ms, the per-layer version keeps 2.1 points more accuracy. Read the first and third rows together and the gap is even more striking: AMC's 68.3 ms model loses only 0.1 points against the full network at 123.3 ms. Slide 9 plots the same story as a chart (AMC Figure 5b), and the values read off it land in one table.
قارن الصفين الأوسطين أحدهما بالآخر. عند زمن استجابة متقارب جدًا، 72.3 ms مقابل 68.3 ms، تحتفظ النسخة ذات النسب الخاصة بكل طبقة بدقة أعلى بمقدار 2.1 points. واقرأ الصفين الأول والثالث معًا تجد الفجوة أوضح: نموذج AMC ذو 68.3 ms يخسر 0.1 points فقط مقارنة بالشبكة الكاملة عند 123.3 ms. الشريحة 9 ترسم القصة نفسها في مخطط (AMC Figure 5b)، والقيم المقروءة منه مجموعة في جدول واحد.
| Seriesالسلسلة | Latencyزمن الاستجابة | Top-1Top-1 |
|---|---|---|
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 52 ms52 ms | 67.4%67.4% |
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 72 ms72 ms | 68.4%68.4% |
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 91 ms91 ms | 69.1%69.1% |
| Uniform (width or resolution multiplier)منتظم (مضاعف العرض أو مضاعف الدقة) | 123 ms123 ms | 70.6%70.6% |
| AMC (per-layer pruning)AMC (تقليم خاص بكل طبقة) | 52 ms52 ms | 69.2%69.2% |
| AMC (per-layer pruning)AMC (تقليم خاص بكل طبقة) | 63 ms63 ms | 70.2%70.2% |
| AMC (per-layer pruning)AMC (تقليم خاص بكل طبقة) | 68 ms68 ms | 70.5%70.5% |
Every AMC point sits above every uniform point. The uniform line on that chart mixes MobileNet's width multiplier with its input-resolution multiplier, which is why it has four points while Table 4 lists two; either knob shrinks every layer by the same factor.
كل نقطة لـ AMC تقع فوق كل نقطة منتظمة. الخط المنتظم في ذلك المخطط يخلط بين مضاعف العرض (width multiplier) في MobileNet ومضاعف دقة الصورة المدخلة (resolution multiplier)، ولهذا فيه أربع نقاط بينما يذكر Table 4 نقطتين فقط. وأيّ المقبضين استخدمت فإنه يصغّر كل طبقة بالمعامل نفسه.
The two stacks of bars on the slide are the whole idea in one picture. Uniform shrinking keeps every layer the same shape, just thinner: MobileNet's width multiplier alpha "thins a network uniformly at each layer" (Howard et al. 2017, section 3.3). Per-layer channel pruning ends with a ragged stack, some layers barely touched and others cut hard, because each layer got its own pruning ratio.
مكدسا الأعمدة في الشريحة يلخصان الفكرة كلها في صورة واحدة. Uniform shrinking (التصغير المنتظم) يُبقي كل طبقة على شكلها نفسه لكن أنحف: مضاعف العرض alpha في MobileNet "يُنحّف الشبكة بانتظام عند كل طبقة" (Howard et al. 2017, section 3.3). أما channel pruning (تقليم القنوات) لكل طبقة فينتهي بمكدس غير متساوٍ، بعض الطبقات بالكاد مُسّت وأخرى قُصّت بشدة، لأن كل طبقة حصلت على pruning ratio (نسبة تقليم) خاصة بها.
Why the ragged stack winsلماذا يفوز المكدس غير المتساوي
Uniform shrinking rests on a hidden assumption: that every layer has the same slack. It does not. Han et al. (NeurIPS 2015, section 5) found that "the first convolutional layer, which interacts with the input image directly, is most sensitive to pruning", and suspected this sensitivity is "due to the input layer having only 3 channels and thus less redundancy than the other convolutional layers". The AMC paper records the standard hand-crafted rule of thumb that grew from such findings, one it then argues is non-optimal because layers are not independent: "prune less parameters in the first layer which extracts low level features and have the least amount of parameters". To see how little the first layer has to give, count the weights of the first six convolution layers of VGG-11 configuration A (Simonyan and Zisserman 2015, Table 1), each a 3 x 3 kernel over its input channels.
يقوم التصغير المنتظم على افتراض خفي: أن لكل طبقة الهامش نفسه من الفائض. وهذا غير صحيح. وجد Han et al. (NeurIPS 2015, section 5) أن "طبقة الالتفاف الأولى، التي تتعامل مع صورة الدخل مباشرة، هي الأكثر حساسية للتقليم"، ورجّحوا أن هذه الحساسية "سببها أن طبقة الدخل فيها 3 قنوات فقط، وبالتالي فائض أقل من طبقات الالتفاف الأخرى". وتسجّل ورقة AMC قاعدة الإبهام اليدوية المعتادة التي نشأت من مثل هذه النتائج، ثم تجادل بأنها غير مثلى لأن الطبقات ليست مستقلة: "قلّم معاملات أقل في الطبقة الأولى التي تستخرج الميزات منخفضة المستوى وفيها أقل عدد من المعاملات". ولترى كم هو قليل ما تستطيع الطبقة الأولى أن تتخلى عنه، عُدّ أوزان أول ست طبقات التفاف في VGG-11 بالتكوين A (Simonyan and Zisserman 2015, Table 1)، وكل منها نواة 3 x 3 على قنوات دخلها.
| Layerالطبقة | Shapeالأبعاد | Weightsالأوزان | Left at r = 0.9المتبقي عند r = 0.9 |
|---|---|---|---|
| L0L0 | 3 x 3 x 3 x 643 x 3 x 3 x 64 | 1,7281,728 | 173173 |
| L1L1 | 3 x 3 x 64 x 1283 x 3 x 64 x 128 | 73,72873,728 | 7,3737,373 |
| L2L2 | 3 x 3 x 128 x 2563 x 3 x 128 x 256 | 294,912294,912 | 29,49129,491 |
| L3L3 | 3 x 3 x 256 x 2563 x 3 x 256 x 256 | 589,824589,824 | 58,98258,982 |
| L4L4 | 3 x 3 x 256 x 5123 x 3 x 256 x 512 | 1,179,6481,179,648 | 117,965117,965 |
| L5L5 | 3 x 3 x 512 x 5123 x 3 x 512 x 512 | 2,359,2962,359,296 | 235,930235,930 |
Prune 90% of L0 and 173 weights are left to describe every edge and colour detector that the rest of the network depends on. Prune 90% of L5 and 235,930 weights remain. A uniform rule takes the same 90% from a 1,728-weight layer and a 2.36-million-weight layer as if both had the same room to spare. This difference in slack is what the lecture calls sensitivity, and the next concept defines it precisely.
قلّم 90% من L0 فيبقى 173 وزنًا فقط لتصف كل كاشفات الحواف والألوان التي تعتمد عليها بقية الشبكة. وقلّم 90% من L5 فيبقى 235,930 وزنًا. القاعدة المنتظمة تأخذ 90% نفسها من طبقة فيها 1,728 وزنًا ومن طبقة فيها 2.36 مليون وزن، كأن لكلتيهما المساحة نفسها للاستغناء. هذا الفرق في الفائض هو ما تسميه المحاضرة sensitivity (الحساسية)، والمفهوم التالي يعرّفه بدقة.
Quick checkاختبار سريع
On slide 9, what does uniform shrinking do to a network?في الشريحة 9، ماذا يفعل التصغير المنتظم (uniform shrinking) بالشبكة؟
Recall
Give the MobileNet numbers that show non-uniform pruning beating uniform shrinking at about the same latency.اذكر أرقام MobileNet التي تُظهر تفوق التقليم غير المنتظم على التصغير المنتظم عند زمن استجابة متقارب.
Here is the same experiment on a network you can count by hand. Train VGG-11 on CIFAR-10 until it reaches about 93% test accuracy. Prune 90% of the weights in L0, the first convolution, and touch nothing else: accuracy falls to about 32%, a drop of about 61 points. RestoreL0, prune 90% of L1 instead: accuracy falls only to about 85%, a drop of about 8. Same ratio, roughly eight times the damage.
إليك التجربة نفسها على شبكة تستطيع أن تعدّ أوزانها بيدك. درّب VGG-11 على CIFAR-10 حتى تصل إلى دقة اختبار تقارب 93%. قلّم 90% من الأوزان في L0، أي طبقة الالتفاف الأولى، ولا تلمس شيئًا آخر: تهبط الدقة إلى نحو 32%، أي انخفاض بنحو 61 points. أعد L0 كما كانت، وقلّم 90% من L1 بدلًا منها: تهبط الدقة إلى نحو 85% فقط، أي انخفاض بنحو 8. النسبة نفسها، وضرر أكبر بنحو ثماني مرات.
That difference is what layer sensitivity measures: how much accuracy the network loses when one layer alone is pruned at a given ratio, with every other layer left dense. Write the dense accuracy as Acc_dense and the accuracy after pruning only layer L_i at ratio r as Acc_r^i. The degradation is their difference.
هذا الفرق هو ما تقيسه layer sensitivity (حساسية الطبقة): مقدار الدقة التي تخسرها الشبكة عندما تُقلَّم طبقة واحدة وحدها بنسبة معينة، وتبقى كل الطبقات الأخرى كثيفة. اكتب الدقة الكثيفة على أنها Acc_dense، والدقة بعد تقليم الطبقة L_i وحدها بالنسبة r على أنها Acc_r^i. التدهور هو الفرق بينهما.
Plot Acc_r^i against r and a sensitive layer gives a steep curve while a redundant layer gives a flat one. Slide 10 states the two ends of the spectrum: some layers are more sensitive, the first layer being the usual example, and some are more redundant. The word "usual" matters, because sensitivity is measured, not assumed, and the reasons the first layer tends to top the list are worth spelling out rather than memorizing.
ارسم Acc_r^i مقابل r، فتعطيك الطبقة الحساسة منحنى حادًا، والطبقة ذات الفائض منحنى مسطحًا. تذكر الشريحة 10 طرفي الطيف: بعض الطبقات أكثر حساسية، والطبقة الأولى هي المثال المعتاد، وبعضها أكثر فائضًا (redundant). وكلمة "المعتاد" مهمة، لأن الحساسية تُقاس ولا تُفترض، والأسباب التي تجعل الطبقة الأولى تتصدر القائمة عادةً تستحق أن تُشرح لا أن تُحفظ.
Three reasons the first layer is usually most sensitiveثلاثة أسباب تجعل الطبقة الأولى عادةً هي الأكثر حساسية
- Fewest parameters. VGG-11's L0 has 1,728 weights against 73,728 in L1 and millions further in (VGG Table 1 arithmetic). Every weight removed from L0 is a larger share of what the layer knows.أقل عدد من المعاملات. في VGG-11 تحتوي L0 على 1,728 وزنًا مقابل 73,728 في L1 وملايين في الطبقات الأعمق (حساب من VGG Table 1). كل وزن يُزال من L0 يمثل حصة أكبر مما تعرفه الطبقة.
- Only three input channels. The layer sees raw RGB, so there is little redundancy to absorb a loss. This is the explanation Han et al. (2015) give for AlexNet, where the first convolution was the most sensitive layer in their per-layer sweep (Figure 6).ثلاث قنوات دخل فقط. الطبقة ترى RGB الخام، فلا يوجد فائض يُذكر يمتص الخسارة. وهذا هو التفسير الذي يقدمه Han et al. (2015) لشبكة AlexNet، حيث كانت طبقة الالتفاف الأولى هي الأكثر حساسية في مسحهم لكل طبقة (Figure 6).
- Everything downstream depends on it. Every feature in L1 through the classifier is a function of L0's output, so an error introduced there is inherited by every later layer rather than corrected.كل ما بعدها يعتمد عليها. كل ميزة من L1 حتى المصنّف هي دالة في مخرج L0، لذا فإن أي خطأ يدخل هناك ترثه كل طبقة لاحقة بدلًا من أن يُصحَّح.
Recall
Why is the first layer usually the most sensitive to pruning?لماذا تكون الطبقة الأولى عادةً هي الأكثر حساسية للتقليم؟
Recall
Write the definition of Delta Acc_r^i in words and as a formula.اكتب تعريف Delta Acc_r^i بالكلمات وبالصيغة.
If sensitivity is a curve per layer, the procedure to obtain it is fixed by the definition: isolate one layer, vary its ratio, measure, repeat. Slides 12 to 17 build that chart one curve at a time for VGG-11 on CIFAR-10. Here is the procedure as a whole, carried out on L0, then generalized.
إذا كانت الحساسية منحنى لكل طبقة، فإن طريقة الحصول عليه يحددها التعريف نفسه: اعزل طبقة واحدة، وغيّر نسبتها، وقِس، ثم كرّر. الشرائح من 12 إلى 17 تبني ذلك المخطط منحنى بعد منحنى لـ VGG-11 على CIFAR-10. وإليك الإجراء كاملًا، مطبقًا على L0، ثم معمّمًا.
Worked exampleمثال محلول
Sensitivity analysis of VGG-11 on CIFAR-10تحليل الحساسية لـ VGG-11 على CIFAR-10
Pick a layer L_i in the modelاختر طبقة L_i في النموذج
Start with L0, the first convolution, 3 x 3 x 3 x 64 with 1,728 weights. Every other layer stays exactly as trained.ابدأ بـ L0، طبقة الالتفاف الأولى، بأبعاد 3 x 3 x 3 x 64 وفيها 1,728 وزنًا. كل طبقة أخرى تبقى تمامًا كما دُرّبت.Prune only L_i with ratio r in {0, 0.1, 0.2, ..., 0.9}قلّم L_i وحدها بالنسبة r ضمن {0, 0.1, 0.2, ..., 0.9}
For each r, apply magnitude-based fine-grained pruning to that one tensor: zero the smallest r fraction of its weights by absolute value. The slide allows "other strides", for example steps of 0.05, at proportionally more cost.لكل قيمة r، طبّق تقليمًا دقيقًا (fine-grained) magnitude-based (قائمًا على المقدار) على ذلك المُوتّر (tensor) وحده: صفّر أصغر جزء r من أوزانه بحسب القيمة المطلقة. تسمح الشريحة بـ "خطوات أخرى" (other strides)، مثل خطوات بمقدار 0.05، مقابل تكلفة أكبر بالتناسب.Observe the accuracy degradation Delta Acc_r^i for each ratioلاحظ تدهور الدقة Delta Acc_r^i لكل نسبة
Evaluate the pruned model on the CIFAR-10 test set, 10,000 images, 1,000 per class (Krizhevsky). For L0 the readings are about 2 points lost at r = 0.5, 10 at 0.7, 22 at 0.8 and 61 at 0.9.قيّم النموذج المقلَّم على مجموعة اختبار CIFAR-10، وهي 10,000 صورة، 1,000 لكل فئة (Krizhevsky). بالنسبة لـ L0 تكون القراءات نحو 2 points مفقودة عند r = 0.5، و10 عند 0.7، و22 عند 0.8، و61 عند 0.9.Restore L_i and repeat the process for all layersأعد L_i كما كانت وكرّر العملية لكل الطبقات
Copy the saved dense tensor back so the next sweep starts from the same model, then move to L1, L2 and onward. Plot every layer's curve on the same axes.انسخ المُوتّر الكثيف المحفوظ وأعده مكانه حتى يبدأ المسح التالي من النموذج نفسه، ثم انتقل إلى L1 وL2 وما بعدها. ارسم منحنى كل طبقة على المحاور نفسها.A family of curves, one per layerعائلة من المنحنيات، منحنى لكل طبقة
All curves share an x axis (pruning rate) and a y axis (accuracy). Slide 21, in the next part, reads per-layer ratios from this chart by drawing a horizontal threshold across it.تشترك كل المنحنيات في محور x (نسبة التقليم) ومحور y (الدقة). الشريحة 21، في الجزء التالي، تقرأ النسب لكل طبقة من هذا المخطط برسم threshold (عتبة) أفقية عبره.
The completed chart on slide 17 is the payoff. Every layer stays close to 93% until about 50% pruning, which tells you that any one layer can lose half its weights while the rest stay dense; whether every layer can lose half at once is a different question, taken up below. Past that point the layers separate. Values below are read off the slide to the nearest point.
المخطط المكتمل في الشريحة 17 هو الحصيلة. تبقى كل طبقة قريبة من 93% حتى تقليم يقارب 50%، وهذا يخبرك أن أي طبقة واحدة يمكنها أن تخسر نصف أوزانها بينما تبقى البقية كثيفة. أما هل تستطيع كل الطبقات أن تخسر النصف في الوقت نفسه فهذا سؤال مختلف نتناوله أدناه. بعد تلك النقطة تتباعد الطبقات. القيم أدناه مقروءة من الشريحة لأقرب نقطة.
| Layerالطبقة | r = 0.5r = 0.5 | r = 0.6r = 0.6 | r = 0.7r = 0.7 | r = 0.8r = 0.8 | r = 0.9r = 0.9 |
|---|---|---|---|---|---|
| L0 (first conv, blue)L0 (الالتفاف الأول، أزرق) | 9292 | 8888 | 8383 | 7171 | 3232 |
| L1 (green)L1 (أخضر) | 9393 | 9393 | 9393 | 9292 | 8585 |
| L2 (red, added on slide 15)L2 (أحمر، أُضيف في الشريحة 15) | 9393 | 9393 | 9292 | 9090 | 7979 |
| L3 (orange)L3 (برتقالي) | 9393 | 9393 | 9191 | 8686 | 5151 |
| L4 (red, added on slide 17)L4 (أحمر، أُضيف في الشريحة 17) | 9393 | 9393 | 9090 | 7777 | 3939 |
Try the sweep yourself. The simulator holds the chart values, lets you pick the layer being pruned and slide its ratio, and reports the accuracy, the drop and how many of that layer's weights are gone. Leave the ratio at 0.9 and switch between L0 and L1 to feel the difference in one click.
جرّب المسح بنفسك. يحتوي المحاكي على قيم المخطط، ويتيح لك اختيار الطبقة التي تُقلَّم وتحريك نسبتها، ويعرض الدقة، والانخفاض، وكم من أوزان تلك الطبقة قد أُزيل. اترك النسبة عند 0.9 وبدّل بين L0 وL1 لتشعر بالفرق بنقرة واحدة.
Leave the slider at r = 0.9 and switch between L0 and L1: the first layer loses about 61 points, the second about 8. Every point on every curve comes from one evaluation with only that layer pruned and nothing retrained. Values are read from the slide chart to the nearest point, so treat them as approximate.اترك المنزلق عند r = 0.9 وبدّل بين L0 وL1: تخسر الطبقة الأولى نحو 61 نقطة، والثانية نحو 8. كل نقطة على كل منحنى تأتي من تقييم واحد قُلّمت فيه تلك الطبقة وحدها دون أي إعادة تدريب. القيم مقروءة من مخطط الشريحة إلى أقرب نقطة، فتعامل معها على أنها تقريبية.
Why each layer is swept aloneلماذا تُمسح كل طبقة وحدها
Sweeping one layer while the rest stay dense is what makes the curve interpretable. If two layers were pruned together and accuracy fell, the drop could not be attributed to either one. Isolation buys attribution. It also has a price, which the next part turns into a whole discussion: it assumes the damage from pruning several layers adds up. AMC's authors put it bluntly, the single-layer approach "assumes that errors of different pruned layers can be summed up linearly, which does not stand according to our experiments" (He et al. 2018, section 4). Keep that interaction in mind: the sweep tells you which layers are fragile, not what happens when you prune them all at once.
مسح طبقة واحدة بينما تبقى البقية كثيفة هو ما يجعل المنحنى قابلًا للتفسير. لو قُلّمت طبقتان معًا وهبطت الدقة، لما أمكن نسبة الانخفاض إلى أيٍّ منهما. العزل يشتري لك القدرة على نسبة السبب. لكن له ثمن أيضًا، يحوّله الجزء التالي إلى نقاش كامل: فهو يفترض أن الضرر الناتج عن تقليم عدة طبقات يُجمع جمعًا. ويقولها مؤلفو AMC صراحة، فالنهج أحادي الطبقة "يفترض أن أخطاء الطبقات المقلّمة المختلفة يمكن جمعها خطيًا، وهذا لا يصح بحسب تجاربنا" (He et al. 2018, section 4). أبقِ هذا interaction (التفاعل) في ذهنك: المسح يخبرك أي الطبقات هشة، لا ما يحدث حين تقلّمها كلها دفعة واحدة.
What the sweep costsكم يكلّف المسح
No gradient step runs during a sweep, but every point on every curve is one full pass over the evaluation set. The number of evaluations is the number of layers times the number of ratios, and each evaluation is a forward pass over every test image.
لا تُنفَّذ أي خطوة تدرّج (gradient step) أثناء المسح، لكن كل نقطة على كل منحنى هي مرور كامل على مجموعة التقييم. عدد التقييمات هو عدد الطبقات مضروبًا في عدد النسب، وكل تقييم هو مرور أمامي (forward pass) على كل صورة اختبار.
| Networkالشبكة | Layersالطبقات | Ratiosالنسب | Evaluationsالتقييمات | Images per evaluationالصور في كل تقييم | Forward passesالمرورات الأمامية |
|---|---|---|---|---|---|
| VGG-11 on CIFAR-10VGG-11 على CIFAR-10 | 99 | 1010 | 9090 | 10,00010,000 | 900,000900,000 |
| 50-layer network on ImageNetشبكة من 50 طبقة على ImageNet | 5050 | 1010 | 500500 | 50,00050,000 | 25 million25 مليون |
The CIFAR-10 VGG-11 behind this chart has 9 weight layers (8 convolutions plus a 1-layer classifier), so ten ratios mean 90 evaluations over the 10,000-image CIFAR-10 test set, about 900,000 forward passes. One small saving: r = 0 is the same dense model for every layer, so it only needs to be evaluated once. A 50-layer ImageNet network evaluated on the 50,000 ILSVRC validation images (Russakovsky et al. 2015) needs 25 million. The cost is linear in depth, which is tolerable for VGG-11 and painful for deep networks, and it is one of the reasons the automated methods later in this lecture, AMC and NetAdapt, search the ratios instead of sweeping them.
شبكة VGG-11 الخاصة بـ CIFAR-10 وراء هذا المخطط فيها 9 طبقات أوزان (8 طبقات التفاف ومصنّف من 1 طبقة)، لذا فإن عشر نسب تعني 90 تقييمًا على مجموعة اختبار CIFAR-10 ذات 10,000 صورة، أي نحو 900,000 مرور أمامي. وهناك توفير صغير: r = 0 هو النموذج الكثيف نفسه لكل طبقة، فيكفي تقييمه مرة واحدة. أما شبكة ImageNet من 50 طبقة تُقيَّم على صور التحقق ILSVRC البالغة 50,000 (Russakovsky et al. 2015) فتحتاج 25 million. التكلفة خطية في العمق، وهذا مقبول لـ VGG-11 ومؤلم للشبكات العميقة، وهو أحد أسباب أن الطرق المؤتمتة لاحقًا في هذه المحاضرة، AMC وNetAdapt، تبحث عن النسب بدلًا من مسحها.
The sweep in four linesالمسح في أربعة أسطر
- Inputالمدخل
- A trained dense model and a held-out evaluation setنموذج كثيف مدرَّب ومجموعة تقييم محجوزة جانبًا
- Loopالحلقة
- for each layer L_i, for each r: prune only L_i, evaluate, restoreلكل طبقة L_i، ولكل r: قلّم L_i وحدها، ثم قيّم، ثم أعدها كما كانت
- Outputالمخرج
- one curve per layer, Delta Acc_r^i against rمنحنى واحد لكل طبقة، Delta Acc_r^i مقابل r
- Costالتكلفة
- layers x ratios evaluations, no trainingعدد الطبقات x عدد النسب من التقييمات، بلا تدريب
Quick checkاختبار سريع
In the sensitivity sweep, which layers are pruned while layer L_i is being measured?في مسح الحساسية، ما الطبقات التي تُقلَّم أثناء قياس الطبقة L_i؟
Quick checkاختبار سريع
What happens to weights during a sensitivity sweep?ماذا يحدث للأوزان أثناء مسح الحساسية؟
Quick checkاختبار سريع
VGG-11 on CIFAR-10: pruning L0 to 90 percent gives about what accuracy?VGG-11 على CIFAR-10: تقليم L0 بنسبة 90% يعطي دقة تقارب كم؟
Recall
State the four steps of sensitivity analysis.اذكر الخطوات الأربع لتحليل الحساسية.
Recall
During the sweep, what state are the other layers in, and why?أثناء المسح، في أي حالة تكون الطبقات الأخرى، ولماذا؟
Recall
How many evaluations does a sweep cost, and what is it for VGG-11 with ten ratios? Does any training happen?كم تقييمًا يكلّف المسح، وكم يبلغ لـ VGG-11 بعشر نسب؟ هل يحدث أي تدريب؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Uniform shrinking gives every layer the same factor. AMC's per-layer ratios reach 70.5% at 68.3 ms, while 0.75 MobileNet reaches 68.4% at 72.3 ms.التصغير المنتظم يعطي كل طبقة المعامل نفسه. نسب AMC الخاصة بكل طبقة تصل إلى 70.5% عند 68.3 ms، بينما يصل 0.75 MobileNet إلى 68.4% عند 72.3 ms.
- Layers differ in sensitivity. The first layer of VGG-11 has only 1,728 weights and 3 input channels, and every later feature depends on its output.الطبقات تختلف في حساسيتها. الطبقة الأولى في VGG-11 فيها 1,728 وزنًا فقط و 3 قنوات دخل، وكل ميزة لاحقة تعتمد على مخرجها.
- Sensitivity analysis: pick L_i, prune only L_i at r in {0, 0.1, ..., 0.9}, record Delta Acc for each r, restore the layer, repeat for all layers.تحليل الحساسية: اختر L_i، وقلّم L_i وحدها عند r ضمن {0, 0.1, ..., 0.9}، وسجّل Delta Acc لكل r، ثم أعد الطبقة كما كانت، وكرّر ذلك لكل الطبقات.
- On VGG-11 CIFAR-10 every layer stays near 93% up to about 50% pruning. At 90%, L0 falls to about 32, L4 to 39 and L3 to 51, while L1, L2 and L5 stay near or above 80.في VGG-11 على CIFAR-10 تبقى كل طبقة قرب 93% حتى تقليم يقارب 50%. عند 90% تهبط L0 إلى نحو 32، و L4 إلى 39، و L3 إلى 51، بينما تبقى L1 و L2 و L5 قرب 80 أو فوقها.
- The sweep is evaluation only, with no fine-tuning, and costs layers times ratios evaluations: 90 for the CIFAR-10 VGG-11 with ten ratios.المسح تقييم فقط بلا ضبط دقيق (fine-tuning)، وتكلفته عدد الطبقات مضروبًا في عدد النسب من التقييمات: 90 تقييمًا لـ VGG-11 على CIFAR-10 بعشر نسب.
- Sweeping one layer at a time isolates causes but ignores interactions between layers, which is the limitation the next parts address.مسح طبقة واحدة في كل مرة يعزل الأسباب لكنه يتجاهل التفاعلات بين الطبقات، وهذا هو القصور الذي تعالجه الأجزاء التالية.
Sourcesالمصادر
- AMC: AutoML for Model Compression and Acceleration on Mobile DevicesPaperECCV 2018, He, Lin, Liu, Wang, Li and HanTable 4 MobileNet numbers on Pixel 1, Figure 5b accuracy versus latency, section 1 first-layer heuristic, section 4 critique of single-layer sensitivity.أرقام MobileNet في الجدول 4 على Pixel 1، والشكل 5b للدقة مقابل زمن الاستجابة، والقاعدة التجريبية عن الطبقة الأولى في القسم 1، ونقد الحساسية أحادية الطبقة في القسم 4.(opens in a new tab)(يفتح في تبويب جديد)
- Learning both Weights and Connections for Efficient Neural NetworksPaperNeurIPS 2015, Han, Pool, Tran and DallyFigure 6 per-layer sensitivity of AlexNet; first conv layer most sensitive, attributed to its 3 input channels.الشكل 6 لحساسية كل طبقة في AlexNet، وطبقة الالتفاف الأولى هي الأكثر حساسية، ويُعزى ذلك إلى قنوات دخلها الثلاث.(opens in a new tab)(يفتح في تبويب جديد)
- Pruning Filters for Efficient ConvNetsPaperICLR 2017, Li, Kadav, Durdanovic, Samet and GrafSection 3.2 prune each layer independently and evaluate; section 4.1 first layer robust under filter pruning on CIFAR-10.القسم 3.2 تقليم كل طبقة باستقلال ثم التقييم، والقسم 4.1 الطبقة الأولى متينة تحت تقليم المرشحات (filter pruning) على CIFAR-10.(opens in a new tab)(يفتح في تبويب جديد)
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision ApplicationsPaperHoward et al., 2017Section 3.3 width multiplier thins a network uniformly at each layer; Table 6: 0.75 MobileNet 68.4 percent, 325 MMACs.القسم 3.3 مضاعف العرض يُنحّف الشبكة بانتظام عند كل طبقة، والجدول 6: 0.75 MobileNet بدقة 68.4% و 325 MMACs.(opens in a new tab)(يفتح في تبويب جديد)
- Very Deep Convolutional Networks for Large-Scale Image RecognitionPaperICLR 2015, Simonyan and ZissermanTable 1 configuration A: 11 weight layers and the channel widths used for the weight counts.الجدول 1 التكوين A: 11 طبقة أوزان وعروض القنوات المستخدمة في عدّ الأوزان.(opens in a new tab)(يفتح في تبويب جديد)
- The CIFAR-10 datasetDocsAlex Krizhevsky, University of Toronto60,000 32x32 images in 10 classes; 10,000 test images with 1,000 per class.60,000 صورة بحجم 32x32 في 10 فئات، منها 10,000 صورة اختبار بواقع 1,000 لكل فئة.(opens in a new tab)(يفتح في تبويب جديد)
- ImageNet Large Scale Visual Recognition ChallengePaperIJCV 2015, Russakovsky et al.50 thousand validation images across 1,000 classes, used for the sweep-cost example.50 ألف صورة تحقق موزعة على 1,000 فئة، استُخدمت في مثال تكلفة المسح.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2023DocsMIT HAN LabLecture 4, Pruning and Sparsity Part II: the sensitivity analysis slides and VGG-11 on CIFAR-10 chart this part is built on. The linked Lab 1 notebook implements the sweep as prune one tensor, evaluate, copy the saved clone back, with no training step.المحاضرة 4، Pruning and Sparsity Part II: شرائح تحليل الحساسية ومخطط VGG-11 على CIFAR-10 اللذان يقوم عليهما هذا الجزء. ودفتر Lab 1 المرتبط ينفّذ المسح بتقليم مُوتّر واحد، ثم التقييم، ثم إعادة النسخة المحفوظة مكانه، بلا أي خطوة تدريب.(opens in a new tab)(يفتح في تبويب جديد)
Part 03: From sensitivity curves to per-layer ratiosمن منحنيات الحساسية إلى نسب لكل طبقة
Pick an accuracy threshold, read off each layer's pruning rate where its curve crosses it, and see why this heuristic ignores the interaction between layers.اختر عتبة للدقة، واقرأ نسبة التقليم لكل طبقة عند النقطة التي يتقاطع فيها منحناها مع العتبة، وافهم لماذا يتجاهل هذا الأسلوب الاستدلالي (heuristic) التفاعل بين الطبقات.
3 concepts3 مفاهيم, ، slides 18-23الشرائح 18-23
Why this part mattersلماذا يهمّ هذا الجزء
Part 02 ended with a wall of six curves and no numbers. This part is the step that converts that chart into the six per-layer ratios you actually type into a pruning script, and it is the exact place where an exam will hand you a small accuracy table, a threshold and a parameter count per layer, and ask for the per-layer rates and the overall rate.
It is also the baseline that every automated method in the rest of the lecture is judged against. AMC and NetAdapt exist because the threshold read-off has a specific, nameable flaw, so for the research project you need to be able to run this heuristic, defend it as a cheap starting point, and say precisely why it falls short. One horizontal line, six crossings, one weighted sum, one honest caveat. That is the whole part.
انتهى الجزء 02 بجدار من ستة منحنيات بلا أي أرقام. هذا الجزء هو الخطوة التي تحوّل ذلك المخطط إلى النسب الست الخاصة بكل طبقة، وهي النسب التي تكتبها فعلًا في سكربت التقليم (pruning script). وهو بالضبط الموضع الذي سيعطيك فيه الامتحان جدول دقة صغيرًا، وعتبة، وعدد المعاملات لكل طبقة، ثم يطلب منك نسبة كل طبقة والنسبة الكلية.
وهو أيضًا خط الأساس (baseline) الذي تُقارن به كل طريقة آلية في بقية المحاضرة. فـ AMC و NetAdapt موجودتان لأن قراءة العتبة فيها عيب محدد يمكن تسميته، لذلك تحتاج في مشروعك البحثي إلى أن تكون قادرًا على تشغيل هذه الطريقة التقريبية، والدفاع عنها كنقطة بداية رخيصة، وأن تقول بدقة لماذا تقصر. خط أفقي واحد، ست نقاط عبور، مجموع موزون واحد، وتحفّظ صادق واحد. هذا هو الجزء كله.
By the end you canفي نهاية هذا الجزء ستستطيع
- Read a sensitivity chart and classify layers as sensitive or redundant from the slope of their curves.قراءة مخطط الحساسية وتصنيف الطبقات إلى حساسة (sensitive) أو فائضة (redundant) من ميل منحنياتها.
- Apply the threshold rule to read off a pruning rate for every layer, including layers that never cross T.تطبيق قاعدة العتبة لاستخراج نسبة تقليم لكل طبقة، بما في ذلك الطبقات التي لا تعبر T أبدًا.
- Compute the overall pruning rate as a parameter-weighted average and adjust T until it meets a target.حساب نسبة التقليم الكلية كمتوسط موزون بعدد المعاملات، وتعديل T حتى تحقق الهدف المطلوب.
- Explain in one sentence why the result is sub-optimal, using the words single-layer sweep and interaction.شرح سبب كون النتيجة دون المثلى (sub-optimal) في جملة واحدة، باستخدام عبارتي single-layer sweep و interaction.
- Connect the limits of the heuristic to the motivation for automated pruning in the next two parts.ربط حدود هذه الطريقة التقريبية (heuristic) بالدافع وراء التقليم الآلي في الجزأين التاليين.
Put your finger on the 80% column of the VGG-11 chart and read straight down. The green L1 curve is still at about 92% accuracy. The blue L0 curve has already dropped to about 71%. Same network, same dataset, same pruning ratio, and the two layers are twenty points apart. That gap is the entire reason per-layer pruning ratios exist, and it is what the six curves are there to expose.
ضع إصبعك على عمود 80% في مخطط VGG-11 واقرأ نزولًا. المنحنى الأخضر L1 ما زال عند دقة تقارب 92%، أما المنحنى الأزرق L0 فقد هبط بالفعل إلى نحو 71%. الشبكة نفسها، ومجموعة البيانات نفسها، ونسبة التقليم نفسها، ومع ذلك تفصل بين الطبقتين عشرون نقطة. هذه الفجوة هي السبب الكامل لوجود نسب تقليم خاصة بكل طبقة، وهي ما وُضعت المنحنيات الست لكشفه.
Recall what each curve is. Sensitivity analysis prunes one layer L_i alone at ratios r in {0, 0.1, ..., 0.9}, measures the accuracy at each ratio with every other layer left dense, then moves on to the next layer and repeats. The result is one accuracy versus ratio line per layer. Every line starts at the same place, the dense accuracy of about 93% on CIFAR-10, so the starting point carries no information at all. What differs is the slope: how soon and how steeply each line bends down as r grows. That slope is the layer's sensitivity.
تذكّر ما يمثله كل منحنى. يقوم sensitivity analysis بتقليم طبقة واحدة L_i وحدها عند النسب r ضمن {0, 0.1, ..., 0.9}، ويقيس الدقة عند كل نسبة مع ترك كل الطبقات الأخرى كثيفة (dense)، ثم ينتقل إلى الطبقة التالية ويكرر. النتيجة خط واحد للدقة مقابل النسبة لكل طبقة. كل الخطوط تبدأ من المكان نفسه، أي الدقة الكثيفة التي تقارب 93% على CIFAR-10، لذلك فنقطة البداية لا تحمل أي معلومة على الإطلاق. ما يختلف هو الميل: متى وبأي حدة ينحني كل خط إلى الأسفل كلما كبرت r. هذا الميل هو sensitivity الطبقة، أي حساسيتها.
| Layerالطبقة | At 70% prunedعند تقليم 70% | At 80% prunedعند تقليم 80% | At 90% prunedعند تقليم 90% | Verdictالحكم |
|---|---|---|---|---|
| L0L0 | 83.5%83.5% | 71%71% | 32%32% | Most sensitive: bends first, falls off a cliffالأكثر حساسية: تنحني أولًا ثم تسقط كأنها من فوق جرف |
| L1L1 | 93%93% | 92%92% | 85%85% | Most redundant: flat almost to the endالأكثر فائضًا: مسطحة تقريبًا حتى النهاية |
| L2L2 | 91.5%91.5% | 89.5%89.5% | 79%79% | Redundant: still about 79% at 90%فائضة: ما زالت عند نحو 79% عند 90% |
| L3L3 | 91.5%91.5% | 85.5%85.5% | 51%51% | Moderate: bends late, drops hard at 90%متوسطة: تنحني متأخرة، ثم تهبط بشدة عند 90% |
| L4L4 | 90.5%90.5% | 77%77% | 39%39% | Sensitive past 70%حساسة بعد 70% |
| L5L5 | 92%92% | 90%90% | 82%82% | Redundant: about 82% at 90%فائضة: نحو 82% عند 90% |
The rule that falls out of the table is simple. A curve that stays flat as r grows belongs to a redundant layer: most of its weights can go with no visible cost, so it should be pruned hard. A curve that bends early belongs to a sensitive layer: its weights are doing work that nothing else in the network can absorb, so it should be pruned gently. The slide summarizes it as "some layers are less sensitive to pruning" (L1, the flattest) and "some layers are more sensitive to pruning" (L0, the steepest), and the whole point of drawing all six on one axis is that you can rank them by eye.
القاعدة التي تخرج من الجدول بسيطة. المنحنى الذي يبقى مسطحًا كلما كبرت r يعود إلى طبقة فائضة (redundant): يمكن حذف معظم أوزانها دون كلفة ظاهرة، لذلك ينبغي تقليمها بقوة. أما المنحنى الذي ينحني مبكرًا فيعود إلى طبقة حساسة (sensitive): أوزانها تؤدي عملًا لا يستطيع أي جزء آخر من الشبكة أن يعوّضه، لذلك ينبغي تقليمها بلطف. تلخّص الشريحة ذلك بعبارة "some layers are less sensitive to pruning" (أي L1، الأكثر تسطحًا) وعبارة "some layers are more sensitive to pruning" (أي L0، الأكثر انحدارًا)، والهدف كله من رسم المنحنيات الست على محور واحد هو أن تستطيع ترتيبها بالعين.
Why the first layer is the fragile oneلماذا الطبقة الأولى هي الطبقة الهشّة
L0 being the most sensitive is not a quirk of this run. Han et al. (2015), the paper the chart's method comes from, report the same pattern on AlexNet: "The first convolutional layer, which interacts with the input image directly, is most sensitive to pruning. We suspect this sensitivity is due to the input layer having only 3 channels and thus less redundancy than the other convolutional layers" (section 5, Figure 6). Their Figure 6 also shows convolutional layers as a group being more sensitive than fully connected layers, which is the same story at coarser resolution: the layers with the fewest weights per unit of work have the least slack. A 3 x 3 kernel over three input channels has 27 weights per filter; removing 80% of them leaves five, and five numbers cannot describe an edge detector.
كون L0 الأكثر حساسية ليس مصادفة في هذه التجربة. فـ Han et al. (2015)، وهي الورقة التي جاءت منها طريقة المخطط، تذكر النمط نفسه على AlexNet: "The first convolutional layer, which interacts with the input image directly, is most sensitive to pruning. We suspect this sensitivity is due to the input layer having only 3 channels and thus less redundancy than the other convolutional layers" (القسم 5، الشكل 6)، أي أن أول طبقة التفافية، التي تتعامل مع صورة الإدخال مباشرة، هي الأكثر حساسية للتقليم، ويرجّحون أن السبب أن طبقة الإدخال لها 3 قنوات فقط وبالتالي فائض أقل من بقية الطبقات الالتفافية. ويُظهر الشكل 6 لديهم أيضًا أن الطبقات الالتفافية كمجموعة أكثر حساسية من الطبقات المتصلة بالكامل (fully connected)، وهي القصة نفسها بدقة أقل: الطبقات التي تملك أقل عدد من الأوزان لكل وحدة عمل لديها أقل هامش. نواة 3 x 3 على ثلاث قنوات إدخال فيها 27 وزنًا لكل مرشّح (filter)، وحذف 80% منها يُبقي خمسة فقط، وخمسة أرقام لا تكفي لوصف كاشف حواف (edge detector).
Recall
Which VGG-11 layer in the chart is most sensitive, and what physical reason does Han et al. give?أي طبقة من VGG-11 في المخطط هي الأكثر حساسية، وما السبب الفيزيائي الذي يذكره Han et al.؟
Quick checkاختبار سريع
On the VGG-11 chart, which layer tolerates 90 percent pruning best, and what does that say about it?في مخطط VGG-11، أي طبقة تتحمل تقليم 90 بالمئة بأفضل شكل، وماذا يقول ذلك عنها؟
Now draw one dashed horizontal line across the chart just under 80% accuracy, where the slide puts it (measured against the gridlines it sits at about 79%). Walk along the blue L0 curve from the left. It sits above the line through 60%, is still above it at 70% (about 83.5%), and has dropped to 71% by 80%. Somewhere between those two grid points it crossed the line, at roughly 73% pruning. That crossing is L0's pruning rate. Do the same for the orange L3 (about 82%) and the steep red L4, whose 80% point sits just under the line: strict interpolation puts the crossing at about 78.5%, and the slide rounds its drawn guide up to 80%. L1, the flat red L2 and L5 never reach the line inside the sweep, so they get the largest tested rate, 90%, which is where the slide draws its last vertical guide.
الآن ارسم خطًا أفقيًا متقطعًا واحدًا عبر المخطط تحت دقة 80% بقليل، حيث تضعه الشريحة (بالقياس على خطوط الشبكة يقع عند نحو 79%). امشِ على المنحنى الأزرق L0 من اليسار. يبقى فوق الخط حتى 60%، وما زال فوقه عند 70% (نحو 83.5%)، ثم يهبط إلى 71% عند 80%. في مكان ما بين نقطتي الشبكة هاتين عبر الخط، عند تقليم يقارب 73%. نقطة العبور هذه هي نسبة تقليم L0. افعل الشيء نفسه مع المنحنى البرتقالي L3 (نحو 82%) ومع المنحنى الأحمر الحاد L4، الذي تقع نقطته عند 80% تحت الخط بقليل: الاستكمال الدقيق (interpolation) يضع العبور عند نحو 78.5%، والشريحة تقرّب خطها الإرشادي المرسوم إلى 80%. أما L1 والأحمر المسطح L2 و L5 فلا تصل إلى الخط أبدًا داخل نطاق المسح، لذلك تأخذ أكبر نسبة مُختبرة، 90%، وهي المكان الذي ترسم فيه الشريحة آخر خط إرشادي رأسي.
Pruning rates read off at T of about 79 to 80 percent (from the dashed guides on the slide)نسب التقليم المقروءة عند T تقارب 79 إلى 80 بالمئة (من الخطوط الإرشادية المتقطعة في الشريحة)
- L0
- about 73%: crosses T between the 70% and 80% pointsنحو 73%: تعبر T بين النقطتين 70% و 80%
- L1
- 90% or beyond: still about 85% accuracy at the last swept ratio90% أو أكثر: ما زالت دقتها نحو 85% عند آخر نسبة مُختبرة
- L2
- 90% or beyond: about 79% accuracy at 90%, on the line90% أو أكثر: دقتها نحو 79% عند 90%، أي على الخط تمامًا
- L3
- about 82%: crosses just past the 80% pointنحو 82%: تعبر بعد نقطة 80% بقليل
- L4
- about 78% by interpolation; the slide rounds its drawn guide up to 80%نحو 78% بالاستكمال (interpolation)، والشريحة تقرّب خطها الإرشادي المرسوم إلى 80%
- L5
- 90% or beyond: about 82% accuracy at 90%90% أو أكثر: دقتها نحو 82% عند 90%
That is the whole mechanism, and it deserves to be stated as an algorithm rather than a picture, because the exam version comes as a table, not a chart. Choose an accuracy threshold T. For each layer, the pruning ratio is the largest swept ratio whose accuracy is still at or above T. Layers whose curves never dip below T inside the sweep get the maximum swept ratio.
هذه هي الآلية كلها، وتستحق أن تُصاغ كخوارزمية لا كصورة، لأن نسخة الامتحان تأتي كجدول لا كمخطط. اختر accuracy threshold T، أي عتبة الدقة. لكل طبقة، تكون pruning ratio هي أكبر نسبة مُختبرة ما زالت دقتها عند T أو أعلى منها. والطبقات التي لا تنزل منحنياتها أبدًا تحت T داخل نطاق المسح تأخذ أكبر نسبة مُختبرة.
The read-off table above and the worked example below follow the slide's drawn guides, which use the chart form and interpolate between grid points. By the strict table form L0 and L4 would snap to 70% and L3 to 80%, and exact interpolation puts L4 at about 78.5%, so the slide's 80% guide for L4 is a rounding of its own chart. The formula is the exam rule; the guides are how the slide applies it by eye.
جدول القراءة أعلاه والمثال المحلول أدناه يتبعان الخطوط الإرشادية المرسومة في الشريحة، وهي تستخدم صيغة المخطط وتستكمل بين نقاط الشبكة. وفق صيغة الجدول الصارمة كانت L0 و L4 ستُقرَّبان إلى 70% و L3 إلى 80%، والاستكمال الدقيق يضع L4 عند نحو 78.5%، لذلك فإن خط 80% الإرشادي لـ L4 في الشريحة هو تقريب لمخططها نفسه. المعادلة هي قاعدة الامتحان، والخطوط الإرشادية هي طريقة تطبيق الشريحة لها بالعين.
From six rates to one overall rateمن ست نسب إلى نسبة كلية واحدة
The slide bullet reads "pick a degradation threshold T such that the overall pruning rate is desired", and the word overall hides a calculation students routinely get wrong. The overall rate is not the average of the six numbers. It is the fraction of all weights removed, so each layer's rate is weighted by how many weights that layer has. A 90% rate on a layer with 2.36 million weights removes far more than a 73% rate on a layer with 1,728.
يقول بند الشريحة "pick a degradation threshold T such that the overall pruning rate is desired"، أي اختر عتبة تدهور T بحيث تكون نسبة التقليم الكلية هي المطلوبة، وكلمة overall (الكلية) تخفي حسابًا يخطئ فيه الطلاب كثيرًا. فـ overall rate ليست متوسط الأرقام الستة، بل هي نسبة كل الأوزان المحذوفة، لذلك تُوزن نسبة كل طبقة بعدد أوزانها. نسبة 90% على طبقة فيها 2.36 مليون وزن تحذف أكثر بكثير من نسبة 73% على طبقة فيها 1,728 وزنًا.
T is the one knob. If R comes out below the target, lower T: every curve now runs further right before it crosses, so every r_i grows or stays pinned at the maximum swept ratio, and R never falls. If the pruned network turns out too inaccurate, raise T and no rate can grow. The loop is: pick T, read off six rates, compute R, compare with the target, move T, repeat. It converges in a handful of iterations because R is monotone in T.
T هي المقبض الوحيد. إذا خرجت R أقل من الهدف فاخفض T: كل منحنى يمتد الآن أبعد نحو اليمين قبل أن يعبر، فكل r_i تكبر أو تبقى مثبتة عند أكبر نسبة مُختبرة، و R لا تنخفض أبدًا. وإذا تبيّن أن الشبكة المقلّمة دقتها ضعيفة جدًا فارفع T، وعندها لا يمكن لأي نسبة أن تكبر. الحلقة هي: اختر T، اقرأ ست نسب، احسب R، قارنها بالهدف، حرّك T، كرّر. وهي تتقارب خلال بضع تكرارات لأن R رتيبة (monotone) بالنسبة إلى T.
Worked exampleمثال محلول
What the slide's T buys on VGG-11ماذا تحقق T الموجودة في الشريحة على VGG-11
Assign illustrative weight countsعيّن أعدادًا توضيحية للأوزان
The slide does not say which six layers L0 to L5 are, so take the first six 3 x 3 conv layers of VGG configuration A (Simonyan and Zisserman, Table 1) with biases ignored: 3 x 64 x 9 = 1,728, 64 x 128 x 9 = 73,728, 128 x 256 x 9 = 294,912, 256 x 256 x 9 = 589,824, 256 x 512 x 9 = 1,179,648, 512 x 512 x 9 = 2,359,296. Total 4,499,136. These counts are illustrative; the read-off rule does not depend on them, but R does.لا تذكر الشريحة ما هي الطبقات الست من L0 إلى L5، لذلك خذ أول ست طبقات conv بحجم 3 x 3 من إعداد VGG رقم A (Simonyan and Zisserman، الجدول 1) مع تجاهل الانحيازات (biases): 3 x 64 x 9 = 1,728، 64 x 128 x 9 = 73,728، 128 x 256 x 9 = 294,912، 256 x 256 x 9 = 589,824، 256 x 512 x 9 = 1,179,648، 512 x 512 x 9 = 2,359,296. المجموع 4,499,136. هذه الأعداد توضيحية، وقاعدة القراءة لا تعتمد عليها، لكن R تعتمد عليها.Multiply each rate by its countاضرب كل نسبة في عددها
Rates in layer order are 0.73, 0.90, 0.90, 0.82, 0.80, 0.90, taken from the slide's drawn guides rather than the strict grid rule: exact interpolation puts L4 at 0.785, and the 0.80 here is the slide's rounding of that guide. So 1,728 x 0.73 + 73,728 x 0.90 + 294,912 x 0.90 + 589,824 x 0.82 + 1,179,648 x 0.80 + 2,359,296 x 0.90 is about 3,883,778 weights pruned.النسب بترتيب الطبقات هي 0.73, 0.90, 0.90, 0.82, 0.80, 0.90، مأخوذة من الخطوط الإرشادية المرسومة في الشريحة لا من قاعدة الشبكة الصارمة: الاستكمال الدقيق يضع L4 عند 0.785، والقيمة 0.80 هنا هي تقريب الشريحة لذلك الخط. إذن 1,728 x 0.73 + 73,728 x 0.90 + 294,912 x 0.90 + 589,824 x 0.82 + 1,179,648 x 0.80 + 2,359,296 x 0.90 تساوي نحو 3,883,778 وزنًا مقلّمًا.Divide by the totalاقسم على المجموع
R = 3,883,778 / 4,499,136 = 86.3%. About 615,358 weights remain.R = 3,883,778 / 4,499,136 = 86.3%. يتبقى نحو 615,358 وزنًا.Weighted versus unweightedالموزون مقابل غير الموزون
Quantityالكمية Valueالقيمة Why it differsسبب الاختلاف Unweighted mean of the six ratesالمتوسط غير الموزون للنسب الست 84.2%84.2% Treats the 1,728-weight L0 like the 2.36M-weight L5يعامل L0 ذات 1,728 وزنًا مثل L5 ذات 2.36M وزن Parameter-weighted rate Rالنسبة الموزونة بعدد المعاملات R 86.3%86.3% The big late layers are pruned at 80 to 90%, so R is higherالطبقات الكبيرة المتأخرة تُقلَّم بين 80 و 90%، لذلك تكون R أعلى Weights remainingالأوزان المتبقية 615,358 of 4,499,136615,358 من 4,499,136 About one in seven survivesينجو نحو وزن واحد من كل سبعة Compression factorمعامل الضغط 7.3x7.3x 1 / (1 - 0.863)1 / (1 - 0.863)
The simulator below runs this loop on curves digitized from the slide, so at its default T of 79% the interpolated crossings land within about a point and a half of the slide's guides (L4 reads 78.5% against the drawn 80%) and R reads 86.0% against the worked example's 86.3%. Drag T and watch all six vertical guides move at once; switch between snapping to the 10% grid and interpolating between grid points; and read R, the unweighted mean and the compression factor as they update. Try T at 90 first, then 70, and note which direction R moves.
المحاكي أدناه يشغّل هذه الحلقة على منحنيات مُرقمنة من الشريحة، لذلك عند قيمته الافتراضية T = 79% تقع نقاط العبور المستكملة ضمن نحو نقطة ونصف من خطوط الشريحة الإرشادية (L4 تقرأ 78.5% مقابل 80% المرسومة) وتقرأ R القيمة 86.0% مقابل 86.3% في المثال المحلول. اسحب T وراقب الخطوط الإرشادية الرأسية الستة تتحرك معًا؛ وبدّل بين التقريب إلى شبكة 10% والاستكمال بين نقاط الشبكة؛ واقرأ R والمتوسط غير الموزون ومعامل الضغط (compression factor) وهي تتحدث. جرّب T عند 90 أولًا، ثم عند 70، ولاحظ في أي اتجاه تتحرك R.
| Layerالطبقة | Shape (illustrative)الشكل (توضيحي) | Rateالنسبة | Accuracy thereالدقة عندها | Weightsالأوزان | Prunedالمقلَّم |
|---|---|---|---|---|---|
| L0 | 3 x 64 x 3 x 3 | 73.6% | 79.0% | 1,728 | 1,272 |
| L1 | 64 x 128 x 3 x 3 | 90.0% | 85.0% | 73,728 | 66,355 |
| L2 | 128 x 256 x 3 x 3 | 90.0% | 79.0% | 294,912 | 265,421 |
| L3 | 256 x 256 x 3 x 3 | 81.9% | 79.0% | 589,824 | 482,972 |
| L4 | 256 x 512 x 3 x 3 | 78.5% | 79.0% | 1,179,648 | 926,242 |
| L5 | 512 x 512 x 3 x 3 | 90.0% | 82.0% | 2,359,296 | 2,123,366 |
Drag T down and every vertical guide slides right at once: one knob moves all six rates. Drag it up and the guides retreat, so a higher T prunes less. The six curves are digitized from the slide chart, and the default T of 79% is where the slide draws its dashed line, a hair under the 80 mark. The weight counts are illustrative: the first six 3 x 3 conv layers of VGG configuration A with biases ignored, since the slide does not say which layers L0 to L5 are. Snap mode returns the last grid point still at or above T; interpolate mode places the crossing between grid points, which is what the dashed guides on the slide do.اسحب T إلى الأسفل فتنزلق كل الخطوط الرأسية إلى اليمين معًا: مقبض واحد يحرك النسب الست كلها. واسحبه إلى الأعلى فتتراجع الخطوط، أي أن T الأعلى يقلّم أقل. المنحنيات الست مرقمنة من مخطط الشريحة، والقيمة الافتراضية T = 79% هي حيث ترسم الشريحة خطها المتقطع، تحت علامة 80 بقليل. أعداد الأوزان توضيحية: هي أول ست طبقات التفاف 3 x 3 في إعداد VGG من النوع A مع تجاهل الانحيازات(biases)، لأن الشريحة لا تحدد أي الطبقات هي L0 إلى L5. وضع الالتقاط(snap) يعيد آخر نقطة في الشبكة لا تزال عند T أو فوقه، ووضع الاستيفاء(interpolate) يضع نقطة التقاطع بين نقاط الشبكة، وهذا ما تفعله الخطوط المتقطعة في الشريحة.
The exam version: a table instead of a chartنسخة الامتحان: جدول بدلًا من مخطط
On paper you will get an accuracy table for two or three layers, a threshold and a weight count per layer. The procedure is identical. Read each row until the accuracy falls below T, take the last ratio that was still at or above T, weight by the counts, and add.
على الورق ستحصل على جدول دقة لطبقتين أو ثلاث، وعتبة، وعدد أوزان لكل طبقة. الإجراء مطابق: اقرأ كل صف حتى تنزل الدقة تحت T، وخذ آخر نسبة كانت ما تزال عند T أو أعلى، ثم زِن بالأعداد واجمع.
| Layerالطبقة | r = 50%r = 50% | r = 60%r = 60% | r = 70%r = 70% | r = 80%r = 80% | r = 90%r = 90% |
|---|---|---|---|---|---|
| A (100,000 weights)A (100,000 وزن) | 90%90% | 84%84% | 70%70% | 52%52% | 30%30% |
| B (400,000 weights)B (400,000 وزن) | 95%95% | 93%93% | 91%91% | 86%86% | 75%75% |
| C (500,000 weights)C (500,000 وزن) | 95%95% | 95%95% | 94%94% | 93%93% | 90%90% |
Worked exampleمثال محلول
Three layers, T = 90 percentثلاث طبقات، T = 90 بالمئة
Read each rowاقرأ كل صف
A is at 90% at r = 50 and 84% at 60, so r_A = 50%. B is at 91% at 70 and 86% at 80, so r_B = 70%. C is still at 90% at the last ratio, so r_C = 90%.الطبقة A عند 90% في r = 50 وعند 84% في 60، إذن r_A = 50%. الطبقة B عند 91% في 70 وعند 86% في 80، إذن r_B = 70%. الطبقة C ما زالت عند 90% في آخر نسبة، إذن r_C = 90%.Weight by the countsزِن بالأعداد
100,000 x 0.5 + 400,000 x 0.7 + 500,000 x 0.9 = 50,000 + 280,000 + 450,000 = 780,000.100,000 x 0.5 + 400,000 x 0.7 + 500,000 x 0.9 = 50,000 + 280,000 + 450,000 = 780,000.Divide by the totalاقسم على المجموع
R = 780,000 / 1,000,000 = 78%. 220,000 weights remain, a compression of about 4.5x. The unweighted mean would have been 70%, which is wrong.R = 780,000 / 1,000,000 = 78%. يتبقى 220,000 وزن، أي ضغط بنحو 4.5x. المتوسط غير الموزون كان سيعطي 70%، وهذا خطأ.One sentence on optimalityجملة واحدة عن الأمثلية
The rates come from single-layer sweeps, so the accuracy of pruning A, B and C together is never measured and is usually below T. The next concept explains why.النسب مأخوذة من مسوحات على طبقة واحدة (single-layer sweeps)، لذلك فإن دقة تقليم A و B و C معًا لا تُقاس أبدًا وتكون عادة تحت T. المفهوم التالي يشرح السبب.
Recall
State the rule that turns one layer's sensitivity curve into a pruning rate.اذكر القاعدة التي تحوّل منحنى حساسية طبقة واحدة إلى نسبة تقليم.
Recall
Your overall pruning rate comes out below target. Do you raise or lower T, and why?خرجت نسبة التقليم الكلية أقل من الهدف. هل ترفع T أم تخفضها، ولماذا؟
Recall
Three layers with 100k, 400k and 500k weights read off at 50, 70 and 90 percent. What is the overall rate?ثلاث طبقات فيها 100k و 400k و 500k وزن، قُرئت نسبها عند 50 و 70 و 90 بالمئة. ما النسبة الكلية؟
Quick checkاختبار سريع
You raise the accuracy threshold T from 80 percent to 88 percent on the sensitivity chart. What happens to the per-layer pruning rates read off the curves?رفعت عتبة الدقة T من 80 بالمئة إلى 88 بالمئة على مخطط الحساسية. ماذا يحدث لنسب التقليم الخاصة بكل طبقة المقروءة من المنحنيات؟
Quick checkاختبار سريع
Layer A has 200,000 weights and crosses T at 60 percent, B has 300,000 and crosses at 80 percent, C has 500,000 and crosses at 90 percent. Overall pruning rate?الطبقة A فيها 200,000 وزن وتعبر T عند 60 بالمئة، و B فيها 300,000 وتعبر عند 80 بالمئة، و C فيها 500,000 وتعبر عند 90 بالمئة. ما نسبة التقليم الكلية؟
Take two of the rates you just read off. L0 pruned to 73% on its own costs about 14 points (93 down to the line at 79). L4 pruned to 80% on its own costs about 16 points. Now prune both at once. L4 was trained on features that flow through a dense L0. Its tolerance to losing 80% of its weights was measured with those features intact, and that condition no longer holds. The network now sees both perturbations at the same time, and the combined drop is usually larger than either single-layer drop, and the chart contains no measurement of it.
خذ نسبتين من النسب التي قرأتها للتو. تقليم L0 إلى 73% وحدها يكلّف نحو 14 نقطة (من 93 نزولًا إلى الخط عند 79). وتقليم L4 إلى 80% وحدها يكلّف نحو 16 نقطة. الآن قلّم الاثنتين معًا. لقد دُرّبت L4 على ميزات (features) تمر عبر L0 كثيفة. وقد قيس تحمّلها لفقدان 80% من أوزانها وتلك الميزات سليمة، وهذا الشرط لم يعد قائمًا. الشبكة الآن ترى الاضطرابين في الوقت نفسه، والهبوط المشترك يكون عادة أكبر من أي من الهبوطين المنفردين، والمخطط لا يحتوي أي قياس له.
| Experimentالتجربة | Accuracyالدقة | Dropالهبوط |
|---|---|---|
| L0 pruned to 73%, nothing else touchedتقليم L0 إلى 73% دون المساس بأي طبقة أخرى | 93 to about 79من 93 إلى نحو 79 | about 14 points, measured on the chartنحو 14 نقطة، مقيسة على المخطط |
| L4 pruned to 80%, nothing else touchedتقليم L4 إلى 80% دون المساس بأي طبقة أخرى | 93 to about 77من 93 إلى نحو 77 | about 16 points, measured on the chartنحو 16 نقطة، مقيسة على المخطط |
| Both pruned at onceتقليم الاثنتين معًا | not on any curveغير موجودة على أي منحنى | usually more than either single drop, never measured by the sweepعادة أكبر من أي من الهبوطين المنفردين، ولم يقسها المسح أبدًا |
The slide asks "is this optimal?" and answers itself: "maybe not. We do not consider the interaction between layers." The next slide of the source deck puts it even more directly, "sensitivity analysis ignores the interaction between layers, sub-optimal". The reason is built into the procedure. Each curve is a one-dimensional slice of accuracy along one layer's axis, taken with every other layer frozen dense. The read-off then treats those axes as independent, as if you could add up six separate tolerances and get the tolerance of the whole. Layers are not independent. That is the Layer interaction the heuristic leaves out, and it is why T is only a proxy for the accuracy you will actually get, not a guarantee.
تسأل الشريحة "is this optimal?" (هل هذا أمثل؟) وتجيب نفسها: "maybe not. We do not consider the interaction between layers."، أي ربما لا، فنحن لا نأخذ التفاعل بين الطبقات في الحسبان. والشريحة التالية في العرض الأصلي تقولها بشكل أوضح: "sensitivity analysis ignores the interaction between layers, sub-optimal". السبب مبني في الإجراء نفسه. كل منحنى شريحة أحادية البعد من الدقة على محور طبقة واحدة، مأخوذة وكل الطبقات الأخرى مجمّدة كثيفة. ثم تعامل القراءة تلك المحاور كأنها مستقلة، كأنك تستطيع جمع ست قدرات تحمّل منفصلة لتحصل على تحمّل الكل. لكن الطبقات ليست مستقلة. هذا هو layer interaction (التفاعل بين الطبقات) الذي تُغفله هذه الطريقة التقريبية، ولهذا فإن T مجرد مؤشر تقريبي للدقة التي ستحصل عليها فعلًا، وليست ضمانًا.
Every other layer stays dense while one layer is pruned.
تبقى كل الطبقات الأخرى كثيفة بينما تُقلَّم طبقة واحدة.
Each rate assumes the other five layers are still dense.
كل نسبة تفترض أن الطبقات الخمس الأخرى ما زالت كثيفة.
Losses compound. Fine-tuning recovers some of the gap.
تتراكم الخسائر. ويستعيد الضبط الدقيق (fine-tuning) جزءًا من الفجوة.
Why the heuristic ignores interactions on purposeلماذا تتجاهل الطريقة التقريبية التفاعلات عن قصد
The omission is a cost decision, not an oversight. The sweep needs (layers) x (ratios) evaluations, 6 x 9 = 54 here, each a forward pass over the validation set. Measuring every joint setting would need 9^6 = 531,441 evaluations for six layers, and real networks have dozens of layers. The AMC paper says exactly this about hand-crafted rules: "as the layers in deep neural networks are not independent, these rule-based pruning policies are non-optimal, and doesn't transfer from one model to another model", and "the design space has exponential complexity, which is infeasible to be solved by greedy, rule-based methods" (He et al., 2018, section 1). The heuristic trades optimality for a search that finishes in an afternoon.
هذا الإغفال قرار كلفة، لا سهو. يحتاج المسح إلى (عدد الطبقات) x (عدد النسب) من التقييمات، أي 6 x 9 = 54 هنا، وكل تقييم تمرير أمامي (forward pass) على مجموعة التحقق (validation set). أما قياس كل إعداد مشترك فيحتاج إلى 9^6 = 531,441 تقييمًا لست طبقات، والشبكات الحقيقية فيها عشرات الطبقات. وورقة AMC تقول هذا بالضبط عن القواعد المصممة يدويًا: "as the layers in deep neural networks are not independent, these rule-based pruning policies are non-optimal, and doesn't transfer from one model to another model"، أي أن طبقات الشبكات العميقة ليست مستقلة فهذه السياسات القائمة على القواعد ليست مثلى ولا تنتقل من نموذج إلى آخر، و "the design space has exponential complexity, which is infeasible to be solved by greedy, rule-based methods"، أي أن فضاء التصميم أُسّي التعقيد ولا يمكن حله بطرق جشعة (greedy) قائمة على القواعد (He et al., 2018، القسم 1). تقايض هذه الطريقة الأمثلية ببحث ينتهي في فترة ما بعد الظهر.
Two things keep it usable in practice. First, Fine-tuning after pruning (part 06) recovers a large share of the compounded loss, so the read-off does not have to be exact, only in the right region. Second, it is the starting point that the automated methods improve on rather than throw away. NetAdapt removes filters from one layer per iteration, re-measures accuracy after a short fine-tune, and keeps the best proposal, so interactions get folded in one step at a time (Yang et al., 2018). AMC goes further and learns the whole per-layer assignment as one policy, rewarded on the accuracy of the jointly pruned network (He et al., 2018). Both are Automated pruning, and both exist because the single-layer sweep leaves accuracy on the table.
أمران يُبقيانها صالحة للاستخدام عمليًا. الأول أن fine-tuning بعد التقليم (الجزء 06) يستعيد جزءًا كبيرًا من الخسارة المتراكمة، لذلك لا يلزم أن تكون القراءة دقيقة، بل يكفي أن تكون في المنطقة الصحيحة. والثاني أنها نقطة البداية التي تحسّنها الطرق الآلية بدلًا من أن ترميها. فـ NetAdapt تحذف مرشّحات من طبقة واحدة في كل تكرار، وتعيد قياس الدقة بعد ضبط دقيق قصير، وتحتفظ بأفضل اقتراح، فتُدمج التفاعلات خطوة بخطوة (Yang et al., 2018). و AMC تذهب أبعد فتتعلم التوزيع الكامل لكل الطبقات كسياسة (policy) واحدة، مكافأتها دقة الشبكة المقلّمة بشكل مشترك (He et al., 2018). كلتاهما من automated pruning (التقليم الآلي)، وكلتاهما موجودتان لأن المسح على طبقة واحدة يترك دقة ممكنة دون استغلال.
Recall
In one sentence, why is the threshold read-off sub-optimal?في جملة واحدة، لماذا تكون قراءة العتبة دون المثلى؟
Recall
How many evaluations does the sweep cost for six layers and nine ratios, and how many would a full joint search cost?كم تقييمًا يكلّف المسح لست طبقات وتسع نسب، وكم سيكلّف بحث مشترك كامل؟
Quick checkاختبار سريع
Why does pruning every layer at its threshold-read rate usually lose more accuracy than T predicts?لماذا يخسر تقليم كل طبقة عند نسبتها المقروءة من العتبة عادةً دقة أكبر مما تتنبأ به T؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Sensitivity is the slope of a layer's accuracy versus ratio curve. L0 (first conv, 3-channel input) is the most sensitive, L1 the most redundant.الحساسية هي ميل منحنى الدقة مقابل النسبة لكل طبقة. الطبقة L0 (أول طبقة conv، ومدخلها 3 قنوات) هي الأكثر حساسية، و L1 هي الأكثر فائضًا.
- The threshold rule: r_i is where the curve crosses T. In table form it is the largest swept ratio at or above T; in chart form it is the interpolated crossing between grid points. Layers that never cross T get the maximum swept ratio.قاعدة العتبة: r_i هي النقطة التي يعبر فيها المنحنى T. في صيغة الجدول هي أكبر نسبة مُختبرة دقتها عند T أو أعلى منها، وفي صيغة المخطط هي نقطة العبور المستكملة (interpolated) بين نقاط الشبكة. الطبقات التي لا تعبر T أبدًا تأخذ أكبر نسبة مُختبرة.
- With T at about 79 to 80 percent (the slide's dashed line) the guides read off roughly 73, 90+, 90+, 82, 80 and 90+ percent for L0 to L5.عندما تكون T نحو 79 إلى 80 بالمئة (الخط المتقطع في الشريحة) تعطي الخطوط الإرشادية تقريبًا 73 و 90+ و 90+ و 82 و 80 و 90+ بالمئة للطبقات من L0 إلى L5.
- The overall rate is parameter-weighted, not the mean of the six rates. With illustrative VGG-11 counts it is about 86 percent (7.3x) against an unweighted 84 percent.النسبة الكلية موزونة بعدد المعاملات، وليست متوسط النسب الست. باستخدام أعداد توضيحية لـ VGG-11 تبلغ نحو 86 بالمئة (7.3x) مقابل 84 بالمئة للمتوسط غير الموزون.
- Higher T keeps more weights, lower T prunes more. Tune T until the overall rate hits the target.رفع T يُبقي أوزانًا أكثر، وخفض T يقلّم أكثر. عدّل T حتى تصل النسبة الكلية إلى الهدف.
- Every curve is a single-layer experiment, so simultaneous pruning compounds losses the chart never measured. T is a proxy and the assignment is sub-optimal.كل منحنى تجربة على طبقة واحدة فقط، لذلك فإن التقليم المتزامن يُراكم خسائر لم يقسها المخطط أبدًا. T مجرد مؤشر تقريبي (proxy) والتوزيع الناتج دون الأمثل.
- Han et al. used this heuristic successfully (9x on AlexNet, 13x on VGG-16 with iterative retraining). AMC and NetAdapt exist because a better joint assignment exists.استخدم Han et al. هذه الطريقة بنجاح (9x على AlexNet و 13x على VGG-16 مع إعادة تدريب تكرارية). وتوجد AMC و NetAdapt لأن هناك توزيعًا مشتركًا أفضل.
Sourcesالمصادر
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2024DocsMIT HAN LabCourse page for Lecture 4, Pruning and Sparsity Part II, the source of this deckصفحة المقرر للمحاضرة 4، Pruning and Sparsity Part II، وهي مصدر هذه الشرائح(opens in a new tab)(يفتح في تبويب جديد)
- Lecture 4 slides: Pruning and Sparsity Part IIDocsMIT HAN LabVGG-11 on CIFAR-10 sensitivity chart, the threshold bullet, and the interaction between layers slideمخطط الحساسية لـ VGG-11 على CIFAR-10، وبند العتبة، وشريحة التفاعل بين الطبقات(opens in a new tab)(يفتح في تبويب جديد)
- Lecture 4 video: Pruning and Sparsity Part IIVideoMIT HAN LabSpoken walkthrough of the sensitivity analysis and threshold read-offشرح صوتي لتحليل الحساسية (sensitivity analysis) وقراءة العتبة(opens in a new tab)(يفتح في تبويب جديد)
- Learning both Weights and Connections for Efficient Neural NetworksPaperHan, Pool, Tran and Dally, NIPS 2015Section 5: first conv layer most sensitive, thresholds set from sensitivity, 9x AlexNet and 13x VGG-16القسم 5: أول طبقة conv هي الأكثر حساسية، والعتبات تُحدَّد من الحساسية، و 9x على AlexNet و 13x على VGG-16(opens in a new tab)(يفتح في تبويب جديد)
- AMC: AutoML for Model Compression and Acceleration on Mobile DevicesPaperHe, Lin, Liu, Wang, Li and Han, ECCV 2018Layers are not independent, rule-based policies are non-optimal, exponential design spaceالطبقات ليست مستقلة، والسياسات القائمة على القواعد ليست مثلى، وفضاء التصميم أُسّي(opens in a new tab)(يفتح في تبويب جديد)
- NetAdapt: Platform-Aware Neural Network Adaptation for Mobile ApplicationsPaperYang et al., ECCV 2018One layer simplified per iteration, the highest short-term accuracy proposal keptتبسيط طبقة واحدة في كل تكرار، والاحتفاظ بالاقتراح صاحب أعلى دقة قصيرة المدى(opens in a new tab)(يفتح في تبويب جديد)
- Very Deep Convolutional Networks for Large-Scale Image RecognitionPaperSimonyan and Zisserman, ICLR 2015Table 1, configuration A (VGG-11) channel widths used for the illustrative per-layer weight countsالجدول 1، عروض القنوات في الإعداد A (VGG-11) المستخدمة في الأعداد التوضيحية للأوزان لكل طبقة(opens in a new tab)(يفتح في تبويب جديد)
- What is the State of Neural Network Pruning?PaperBlalock, Ortiz, Frankle and Guttag, MLSys 2020Global versus layerwise budget allocation changes accuracy at a fixed model sizeتوزيع الميزانية بشكل عام (global) مقابل طبقة بطبقة (layerwise) يغيّر الدقة عند حجم نموذج ثابت(opens in a new tab)(يفتح في تبويب جديد)
- Distiller documentation: pruning algorithms, sensitivity prunerDocsIntel LabsSensitivity analysis as an empirical starting guess for per-layer thresholds in a production toolkitتحليل الحساسية كتخمين تجريبي أولي لعتبات كل طبقة في أداة إنتاجية(opens in a new tab)(يفتح في تبويب جديد)
Part 04: AMC: pruning ratios as a reinforcement learning problemAMC: نسب التقليم بوصفها مسألة تعلم معزز
Given an overall compression target, AMC lets a DDPG agent choose each layer's sparsity, rewarded by accuracy under a FLOPs or latency constraint, and beats hand-tuned and uniformly scaled MobileNets on a real phone.بإعطاء هدف ضغط إجمالي، يترك AMC وكيلًا من نوع DDPG يختار تناثر كل طبقة، ويكافئه بالدقة تحت قيد على FLOPs أو زمن الاستجابة، ويتفوق على نماذج MobileNet المضبوطة يدويًا والمصغّرة بانتظام على هاتف حقيقي.
4 concepts4 مفاهيم, ، slides 24-32الشرائح 24-32
Why this part mattersلماذا يهمّ هذا الجزء
Your research models will have to meet a latency or FLOPs budget on one specific device, and someone has to decide how much of that budget each layer gives up. Part 03 showed the hand method. This part shows the first method that learns the answer, and it is the one the exam will ask you to formulate.
AMC (He et al., ECCV 2018) is the canonical example of turning a hand-tuned hyperparameter search into a learned policy. You will see why the search is hard, how the four ingredients of reinforcement learning map onto pruning, what the agent discovered on ResNet-50 that no expert had written down, and a table of phone measurements that settles the argument between counting FLOPs and measuring time.
ستحتاج نماذجك البحثية إلى الالتزام بميزانية زمن استجابة (latency) أو FLOPs على جهاز محدد، ولا بد أن يقرر أحدٌ ما مقدار ما تتنازل عنه كل طبقة من هذه الميزانية. عرض الجزء 03 الطريقة اليدوية. أما هذا الجزء فيعرض أول طريقة تتعلّم الإجابة بنفسها، وهي الطريقة التي سيطلب منك الامتحان صياغتها.
يُعد AMC (He et al., ECCV 2018) المثال المرجعي على تحويل بحث يدوي عن معامل فائق (hyperparameter) إلى سياسة متعلَّمة (learned policy). سترى لماذا البحث صعب، وكيف تنطبق المكونات الأربعة للتعلم المعزز (reinforcement learning) على التقليم، وما الذي اكتشفه الوكيل في ResNet-50 ولم يكتبه أي خبير من قبل، وجدولًا من قياسات على هاتف يحسم الجدل بين عدّ FLOPs وقياس الزمن فعليًا.
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain why per-layer ratio selection is a combinatorial search and why sensitivity analysis is sub-optimal.أن تشرح لماذا يُعد اختيار النسبة لكل طبقة بحثًا تركيبيًا، ولماذا يعطي تحليل الحساسية نتيجة دون المثلى.
- Name AMC's state, action, agent and reward, and say why the action is continuous and the reward is minus error under a constraint.أن تسمّي الحالة والفعل والوكيل والمكافأة في AMC، وأن توضح لماذا الفعل متصل ولماذا المكافأة هي سالب الخطأ تحت قيد.
- Describe what DDPG's actor and critic each do in one AMC episode.أن تصف ما يفعله كل من الممثل (actor) والناقد (critic) في DDPG خلال حلقة واحدة من AMC.
- Read the ResNet-50 density plot: peaks at 1x1, crests at 3x3, 5x versus 3.4x at equal accuracy.أن تقرأ مخطط الكثافة لـ ResNet-50: قمم عند طبقات 1x1، وقيعان عند طبقات 3x3، و5x مقابل 3.4x عند الدقة نفسها.
- Interpret the MobileNet table: measured time versus FLOPs targets, and why both beat uniform 0.75 shrinking.أن تفسّر جدول MobileNet: هدف الزمن المقاس مقابل هدف FLOPs، ولماذا يتفوق كلاهما على التصغير المنتظم 0.75.
Take a ResNet-50 and allow each of its roughly fifty prunable layers to keep one of ten possible fractions of its weights. That is 10^50 ways to spend one overall budget. The Sensitivity analysis of part 03 escapes the explosion by never looking at combinations at all: it prunes one layer at a time, runs 50 x 10 = 500 single-layer experiments, and reads each layer's Pruning ratio off its own curve where it crosses the accuracy threshold.
خذ شبكة ResNet-50 واسمح لكل طبقة من طبقاتها القابلة للتقليم، وعددها نحو خمسين، بأن تحتفظ بواحد من عشرة كسور ممكنة من أوزانها. هذا يعطي 10^50 طريقة لإنفاق ميزانية إجمالية واحدة. أما sensitivity analysis (تحليل الحساسية) في الجزء 03 فيتجنب هذا الانفجار بألا ينظر إلى التركيبات أبدًا: فهو يقلّم طبقة واحدة في كل مرة، ويجري 50 x 10 = 500 تجربة على طبقة منفردة، ويقرأ pruning ratio (نسبة التقليم) لكل طبقة من منحناها الخاص عند النقطة التي يقطع فيها حدّ الدقة.
The saving comes from a hidden assumption: that the accuracy lost by pruning several layers at once is the sum of what each loses alone. The AMC authors tested exactly this and report that the sensitivity approach "assumes that errors of different pruned layers can be summed up linearly, which does not stand according to our experiments" (He et al., 2018). That is the Layer interaction that slide 24 says the analysis ignores. Pruning layer 3 changes what layer 4 receives, so the curve you measured for layer 4 on a dense network is the wrong curve once layer 3 is thin. The ratios are usable, but they are sub-optimal, and they belong to the network they were measured on. Change the architecture and every curve must be measured again.
يأتي هذا التوفير من افتراض خفي: أن الدقة المفقودة عند تقليم عدة طبقات معًا تساوي مجموع ما تفقده كل طبقة وحدها. اختبر مؤلفو AMC هذا الافتراض تحديدًا، وذكروا أن نهج الحساسية "يفترض أن أخطاء الطبقات المقلّمة المختلفة يمكن جمعها خطيًا، وهذا لا يصمد وفق تجاربنا" (He et al., 2018). هذا هو layer interaction (تفاعل الطبقات) الذي تقول الشريحة 24 إن التحليل يتجاهله. تقليم الطبقة 3 يغيّر ما تستقبله الطبقة 4، لذا فإن المنحنى الذي قسته للطبقة 4 على شبكة كثيفة يصبح المنحنى الخطأ بمجرد أن تصبح الطبقة 3 رفيعة. النسب صالحة للاستخدام، لكنها دون المثلى، وهي تخص الشبكة التي قيست عليها. غيّر المعمارية، وسيلزم قياس كل منحنى من جديد.
Worked exampleمثال محلول
Counting the search spaceعدّ فضاء البحث
Combinationsالتركيبات
Fifty layers, ten candidate ratios each: 10^50 full configurations. No amount of GPU time enumerates that.خمسون طبقة، ولكل منها عشر نسب مرشحة: 10^50 إعدادًا كاملًا. لا يكفي أي قدر من وقت GPU لتعدادها كلها.What sensitivity analysis actually triesما يجرّبه تحليل الحساسية فعليًا
One layer at a time: 50 x 10 = 500 pruned networks, each with only one layer changed. It then picks the ratios by a threshold, never trying the chosen combination until the very end.طبقة واحدة في كل مرة: 50 x 10 = 500 شبكة مقلّمة، في كل منها طبقة واحدة فقط متغيرة. ثم يختار النسب بحدّ عتبة، دون أن يجرّب التركيبة المختارة إلا في النهاية تمامًا.What is never measuredما لا يُقاس أبدًا
Any configuration in which two or more layers are pruned together. The compounding of part 03 (both layers at once losing more than either alone) lives entirely in the unmeasured region.أي إعداد تُقلَّم فيه طبقتان أو أكثر معًا. فالتراكم الذي رأيناه في الجزء 03 (أن تقليم الطبقتين معًا يُفقد أكثر مما تُفقده أي منهما وحدها) يقع بالكامل في المنطقة غير المقاسة.A first-order estimate, not an optimumتقدير من الرتبة الأولى، لا حلّ أمثل
Sensitivity analysis is a valid linear approximation. The per-layer rates it produces are a starting point, not the best allocation of the budget.تحليل الحساسية تقريب خطي صالح. المعدلات التي ينتجها لكل طبقة نقطة بداية، وليست أفضل توزيع للميزانية.
The bottleneck is peopleعنق الزجاجة هو البشر
Slide 25 shows the practical consequence. Conventionally the allocation relies on human expertise and trial and error. Three customers with three engineers is a workable shop. Many customers overwhelm even a team of engineers (the red cross and the alarmed manager in the middle column), and every new model, new target device or new budget restarts the trial and error from scratch, because rules such as prune the first layer less and the fully connected layers more are, in the paper's words, "non-optimal, and doesn't transfer from one model to another" (He et al., 2018). The right column serves the same crowd with one engineer and an engine that takes the model and the constraint and returns the compressed network.
تعرض الشريحة 25 النتيجة العملية. تقليديًا، يعتمد توزيع النسب على خبرة البشر وعلى التجربة والخطأ. ثلاثة عملاء مع ثلاثة مهندسين ورشة قابلة للعمل. لكن كثرة العملاء تُغرق حتى فريقًا من المهندسين (العلامة الحمراء والمدير القلق في العمود الأوسط)، وكل نموذج جديد أو جهاز مستهدف جديد أو ميزانية جديدة يعيد التجربة والخطأ من الصفر، لأن قواعد مثل قلّم الطبقة الأولى أقل والطبقات المتصلة بالكامل (fully connected) أكثر هي، بكلمات الورقة، "غير مثلى، ولا تنتقل من نموذج إلى آخر" (He et al., 2018). أما العمود الأيمن فيخدم الحشد نفسه بمهندس واحد ومحرك يأخذ النموذج والقيد ويعيد الشبكة المضغوطة.
Slide 26 names the ambition: a push-the-button solution. Today an efficient network needs someone who is both a machine learning expert and a hardware expert. The goal is that a non-expert plus a hardware-centric AutoML tool reaches the same efficient network. This is the definition of Automated pruning in this lecture: an algorithm, not a person, chooses the per-layer ratios for an overall target, and it does so with the target hardware in the loop.
تسمّي الشريحة 26 الطموح: حلّ بضغطة زر (push-the-button). اليوم تحتاج الشبكة الفعالة إلى شخص خبير في تعلم الآلة وخبير في العتاد معًا. والهدف أن يصل غير الخبير، مع أداة AutoML متمحورة حول العتاد، إلى الشبكة الفعالة نفسها. هذا هو تعريف automated pruning (التقليم المؤتمت) في هذه المحاضرة: خوارزمية، لا شخص، تختار النسب لكل طبقة لتحقيق هدف إجمالي، وتفعل ذلك والعتاد المستهدف داخل الحلقة.
| Methodالطريقة | Who chooses the ratiosمن يختار النسب | Costالتكلفة | Interaction modelledهل يُنمذَج التفاعل | Transfers to a new modelهل تنتقل إلى نموذج جديد |
|---|---|---|---|---|
| Human expert rulesقواعد الخبير البشري | An engineer, by trial and errorمهندس، بالتجربة والخطأ | Days of experiments per modelأيام من التجارب لكل نموذج | Only in the engineer's headفقط في ذهن المهندس | No, rules are written per modelلا، القواعد تُكتب لكل نموذج على حدة |
| Sensitivity analysisتحليل الحساسية | A curve per layer plus one thresholdمنحنى لكل طبقة مع عتبة واحدة | Layers x ratios single-layer runsتجارب على طبقة منفردة بعدد الطبقات x النسب | No, one layer at a timeلا، طبقة واحدة في كل مرة | No, curves belong to one networkلا، المنحنيات تخص شبكة واحدة |
| Learned policy (AMC)سياسة متعلَّمة (AMC) | A DDPG agent, layer by layerوكيل DDPG، طبقة بعد طبقة | Hundreds of pruned networks, no retrainingمئات الشبكات المقلّمة، دون إعادة تدريب | Yes, the reward sees the whole networkنعم، المكافأة ترى الشبكة كاملة | Same method, new search per model and budgetالطريقة نفسها، مع بحث جديد لكل نموذج وميزانية |
Recall
An overall compression target is given. Why is choosing the per-layer ratios still a hard problem, and what does sensitivity analysis do about it?لديك هدف ضغط إجمالي. لماذا يبقى اختيار النسب لكل طبقة مسألة صعبة، وماذا يفعل تحليل الحساسية حيالها؟
Quick checkاختبار سريع
Why do the ratios from sensitivity analysis end up sub-optimal?لماذا تكون النسب الناتجة عن تحليل الحساسية دون المثلى في النهاية؟
Follow one pass of AMC over MobileNet. Layer t-1 has just been pruned at 30%. The agent now looks at layer t: it receives a short vector describing that layer, its index, its channel counts, its kernel size, its FLOPs, how many FLOPs earlier layers already gave up and how many remain in later layers. It answers with one number, say 50%. The environment removes half of that layer's channels by magnitude and presents layer t+1. When the last layer is done, the whole pruned network is evaluated on a held-out set, and a single number comes back: minus the error. That number is the only feedback the agent ever gets, and it arrives once per pass.
تتبّع مرورًا واحدًا لـ AMC على MobileNet. الطبقة t-1 قُلّمت للتو بنسبة 30%. ينظر الوكيل الآن إلى الطبقة t: يستقبل متجهًا قصيرًا يصف تلك الطبقة، فيه رقمها، وعدد قنواتها، وحجم نواتها (kernel)، وFLOPs الخاصة بها، وكم من FLOPs تخلّت عنه الطبقات السابقة، وكم بقي في الطبقات اللاحقة. ويجيب برقم واحد، لنقل 50%. تزيل البيئة نصف قنوات تلك الطبقة بحسب المقدار (magnitude) وتعرض الطبقة t+1. وعند الانتهاء من الطبقة الأخيرة، تُقيَّم الشبكة المقلّمة كاملة على مجموعة محجوزة، ويعود رقم واحد: سالب الخطأ. هذا الرقم هو التغذية الراجعة الوحيدة التي يحصل عليها الوكيل، ويصل مرة واحدة في كل مرور.
That story contains every ingredient of a reinforcement learning problem, which is what slide 27 means by "pruning as a reinforcement learning problem". The paper's own description: the agent "processes the network in a layer-wise manner", "receives a layer embedding s_t", "outputs a precise compression ratio a_t", and after every layer is compressed the "validation accuracy of the pruned model with all layers compressed is evaluated without fine-tuning, which is an efficient delegate of the fine-tuned accuracy" (He et al., 2018). Only the best network found after the search is fine-tuned.
تحتوي هذه القصة على كل مكونات مسألة تعلم معزز، وهذا ما تعنيه الشريحة 27 بعبارة "التقليم بوصفه مسألة تعلم معزز". وصف الورقة نفسها: الوكيل "يعالج الشبكة طبقة بعد طبقة"، و"يستقبل تضمين الطبقة s_t"، و"يُخرج نسبة ضغط دقيقة a_t"، وبعد ضغط كل الطبقات "تُقيَّم دقة التحقق (validation accuracy) للنموذج المقلّم بكل طبقاته المضغوطة دون ضبط دقيق، وهي بديل فعّال عن الدقة بعد الضبط الدقيق" (He et al., 2018). لا يُضبط ضبطًا دقيقًا إلا أفضل شبكة وُجدت بعد البحث.
The four RL ingredients in AMC, plus two words the exam expects around themمكونات التعلم المعزز الأربعة في AMC، مع مصطلحين إضافيين يتوقعهما الامتحان حولها
- Stateالحالة (State)
- The Layer embedding of layer t: eleven features (t, n, c, h, w, stride, k, FLOPs[t], reduced, rest, a[t-1]), each scaled to [0, 1]. The slide's [N, C, H, W, i, ...] abbreviates this list.layer embedding (تضمين الطبقة) للطبقة t: إحدى عشرة خاصية (t, n, c, h, w, stride, k, FLOPs[t], reduced, rest, a[t-1])، كل منها مُقيّسة إلى [0, 1]. والصيغة [N, C, H, W, i, ...] في الشريحة اختصار لهذه القائمة.
- Actionالفعل (Action)
- One continuous number, the sparsity ratio a_t in (0, 1], for the current layer only.رقم متصل واحد، هو نسبة التفرّق a_t ضمن (0, 1]، للطبقة الحالية فقط.
- Agentالوكيل (Agent)
- DDPG, an actor-critic method: the actor proposes a_t from s_t, the critic estimates the value Q(s_t, a_t) of that choice.DDPG، طريقة من نوع ممثل وناقد (actor-critic): يقترح الممثل a_t انطلاقًا من s_t، ويقدّر الناقد القيمة Q(s_t, a_t) لهذا الاختيار.
- Environmentالبيئة (Environment)
- Channel pruning of the pretrained network, one layer per step, using magnitude selection inside the layer.channel pruning (تقليم القنوات) للشبكة المدرّبة مسبقًا، طبقة واحدة في كل خطوة، باستخدام الاختيار بالمقدار (magnitude) داخل الطبقة.
- Rewardالمكافأة (Reward)
- R = -Error when the FLOPs or latency budget holds, effectively minus infinity otherwise (slide 29). For accuracy-guaranteed search, R = -Error x log(FLOPs) (slide 28).R = -Error عندما تتحقق ميزانية FLOPs أو زمن الاستجابة، وسالب ما لا نهاية فعليًا في غير ذلك (الشريحة 29). وللبحث المضمون الدقة (accuracy-guaranteed) تكون R = -Error x log(FLOPs) (الشريحة 28).
- Episodeالحلقة (Episode)
- One full pass over all layers, producing one pruned network and one reward. The signal is validation accuracy before fine-tuning, on a few thousand training images.مرور كامل واحد على كل الطبقات، ينتج شبكة مقلّمة واحدة ومكافأة واحدة. والإشارة هي دقة التحقق (validation accuracy) قبل الضبط الدقيق، على بضعة آلاف من صور التدريب.
Why the action must be continuous, and why an actor and a criticلماذا يجب أن يكون الفعل متصلًا، ولماذا ممثل وناقد
A pruning ratio is a real number, and the compressed model's accuracy is very sensitive to it. A discrete agent would need a grid fine enough to tell 48% from 52%, which explodes the number of actions, and a grid also throws away the order between neighbouring ratios (He et al., 2018), so the agent could not exploit the fact that neighbouring ratios behave alike. DDPG (Lillicrap et al., 2015) is the standard actor-critic method for continuous control: it concurrently learns a Q-function and a policy and can only be used with continuous action spaces (OpenAI Spinning Up). Sutton and Barto give the naming: when a value function is used "to assess, or criticize, the policy's action selections, then the value function is called a critic and the policy is called an actor". In AMC the critic learns, from replayed transitions, how much reward a state and ratio pair leads to; the actor is then nudged by gradient ascent on that estimate to propose ratios the critic scores higher. The critic judges, the actor proposes, and neither ever sees a gradient of the pruned network itself.
نسبة التقليم عدد حقيقي، ودقة النموذج المضغوط حساسة جدًا لها. سيحتاج وكيل متقطع (discrete) إلى شبكة قيم دقيقة بما يكفي للتمييز بين 48% و52%، وهذا يُفجّر عدد الأفعال، كما أن الشبكة المتقطعة تُضيّع الترتيب بين النسب المتجاورة (He et al., 2018)، فلا يستطيع الوكيل الاستفادة من أن النسب المتجاورة تتصرف بشكل متشابه. DDPG (Lillicrap et al., 2015) هي الطريقة القياسية من نوع ممثل وناقد (actor-critic) للتحكم المتصل: تتعلم دالة Q وسياسة في آنٍ واحد، ولا يمكن استخدامها إلا مع فضاءات أفعال متصلة (OpenAI Spinning Up). ويعطي Sutton وBarto أصل التسمية: عندما تُستخدم دالة قيمة "لتقييم اختيارات السياسة للأفعال، أو نقدها، تُسمّى دالة القيمة ناقدًا وتُسمّى السياسة ممثلًا". في AMC يتعلم الناقد، من انتقالات مُعاد تشغيلها (replayed transitions)، مقدار المكافأة التي يؤدي إليها زوج من الحالة والنسبة؛ ثم يُدفع الممثل بالصعود التدرجي (gradient ascent) على هذا التقدير ليقترح نسبًا يمنحها الناقد درجة أعلى. الناقد يحكم، والممثل يقترح، ولا يرى أي منهما تدرجًا (gradient) للشبكة المقلّمة نفسها أبدًا.
Why the reward is minus error under a constraintلماذا المكافأة هي سالب الخطأ تحت قيد
Reinforcement learning maximizes reward, so maximizing -Error is minimizing error. The budget appears as a constraint rather than a bonus on purpose: if the agent were paid for shrinking, it would keep shrinking past the target and lose accuracy for nothing. With a hard constraint there is no reward for finishing under budget, so the agent "can precisely arrive at the target compression ratio" (He et al., 2018). The minus infinity branch is the slide's compact way of saying an infeasible network earns nothing useful.
التعلم المعزز يعظّم المكافأة، لذا فإن تعظيم -Error يعني تقليل الخطأ. تظهر الميزانية كقيد لا كمكافأة إضافية عن قصد: لو كوفئ الوكيل على التصغير، لاستمر في التصغير متجاوزًا الهدف وخسر الدقة بلا مقابل. ومع قيد صارم لا توجد مكافأة على الانتهاء تحت الميزانية، فيستطيع الوكيل "الوصول بدقة إلى نسبة الضغط المستهدفة" (He et al., 2018). وفرع سالب ما لا نهاية هو طريقة الشريحة المختصرة للقول إن الشبكة غير الممكنة (التي تخرق القيد) لا تكسب شيئًا مفيدًا.
A wasted episode teaches the critic nothing, so the paper never lets one happen. Before each action it computes the duty: the share of the removal target alpha W_all that this layer must carry, given what earlier layers already removed (W_reduced) and the most the remaining layers could remove at the cap a_max (0.8 for convolutions and 0.98 for fully connected layers in fine-grained pruning; 0.8 for every layer in channel pruning). If the actor's proposal is too timid, it is raised to the duty. The budget is therefore met by construction, and the minus infinity case is a formal backstop, not a common outcome.
الحلقة المهدرة لا تعلّم الناقد شيئًا، لذا لا تسمح الورقة بحدوثها أبدًا. قبل كل فعل تحسب الحصة الواجبة (duty): نصيب هدف الإزالة alpha W_all الذي يجب أن تتحمله هذه الطبقة، بالنظر إلى ما أزالته الطبقات السابقة (W_reduced) وأقصى ما يمكن أن تزيله الطبقات المتبقية عند السقف a_max (0.8 للالتفافات و0.98 للطبقات المتصلة بالكامل في التقليم الدقيق الحبيبات (fine-grained)؛ و0.8 لكل الطبقات في تقليم القنوات). إذا كان اقتراح الممثل متحفظًا أكثر من اللازم، يُرفع إلى الحصة الواجبة. وهكذا تتحقق الميزانية بحكم البناء، وتكون حالة سالب ما لا نهاية صمام أمان شكليًا، لا نتيجة شائعة.
Slide 28 shows the other protocol. When the goal is the smallest model with no accuracy loss, the budget is unknown in advance, so the reward itself must push on size. The bubble chart on the slide (Canziani et al., 2016) shows that top-1 accuracy rises roughly with the logarithm of the operation count, so multiplying -Error by log(FLOPs) gives, in the paper's words, "a small incentive for reducing FLOPs" while staying "sensitive to Error". The ResNet-50 and MobileNet results in the next two concepts use the constrained reward, not this one.
تعرض الشريحة 28 البروتوكول الآخر. عندما يكون الهدف أصغر نموذج دون أي خسارة في الدقة، تكون الميزانية مجهولة مسبقًا، لذا يجب أن تضغط المكافأة نفسها باتجاه الحجم. مخطط الفقاعات في الشريحة (Canziani et al., 2016) يبيّن أن دقة top-1 ترتفع تقريبًا مع لوغاريتم عدد العمليات، لذا فإن ضرب -Error في log(FLOPs) يعطي، بكلمات الورقة، "حافزًا صغيرًا لتقليل FLOPs" مع البقاء "حساسًا للخطأ". نتائج ResNet-50 وMobileNet في المفهومين التاليين تستخدم المكافأة المقيّدة، لا هذه.
The constraint need not be FLOPs. The paper notes that the resource can be "FLOPs or the actual inference time on mobile device", and slide 29 adds the mechanism: a pre-built Latency lookup table of measured per-layer times on the target phone, the same device-in-the-loop idea NetAdapt uses in part 05. Substituting measured time for FLOPs turns a FLOPs-constrained search into a latency-constrained one, and the MobileNet table at the end of this part shows why that matters.
لا يلزم أن يكون القيد FLOPs. تذكر الورقة أن المورد يمكن أن يكون "FLOPs أو زمن الاستدلال الفعلي على الجهاز المحمول"، وتضيف الشريحة 29 الآلية: جدول بحث مُعدّ مسبقًا latency lookup table فيه أزمنة مقاسة لكل طبقة على الهاتف المستهدف، وهي فكرة الجهاز داخل الحلقة نفسها التي يستخدمها NetAdapt في الجزء 05. استبدال FLOPs بالزمن المقاس يحوّل بحثًا مقيدًا بـFLOPs إلى بحث مقيد بزمن الاستجابة، وجدول MobileNet في نهاية هذا الجزء يبيّن لماذا يهم ذلك.
- L1a=0.5020M, 3x3
- L2?60M, 3x3
- L3?100M, 3x3
- L4?80M, 1x1
- L5?40M, 3x3
| Featureالسمة | Rawالقيمة الخام | Scaled to [0, 1]بعد التحجيم إلى [0, 1] |
|---|---|---|
| t | 1 | 0.00 |
| n | 32 | 0.13 |
| c | 3 | 0.02 |
| k | 3x3 | 1.00 |
| FLOPs[t] | 20M | 0.20 |
| reduced | 0M | 0.00 |
| rest | 280M | 0.93 |
| a[t-1] | none | 0.00 |
Toy numbers. Error is 30 + 100 x sum of s_j a_j^2 with sensitivities 0.20, 0.06, 0.04, 0.05, 0.10, so the first and last layers are expensive to prune. The budget bar projects the unpruned layers at full cost until you act on them.أرقام تجريبية. الخطأ يساوي 30 + 100 x sum of s_j a_j^2 بحساسيات 0.20, 0.06, 0.04, 0.05, 0.10، لذا فتقليم الطبقتين الأولى والأخيرة مكلف. يحسب شريط الميزانية الطبقات غير المقلّمة بكامل تكلفتها إلى أن تتخذ فيها فعلًا.
Recall
Name the four RL ingredients of AMC and what each is concretely.سمِّ مكونات التعلم المعزز الأربعة في AMC، وما هو كل منها تحديدًا.
Recall
Why is the reward minus error rather than accuracy, and why is it given only at the end of the episode?لماذا المكافأة هي سالب الخطأ لا الدقة، ولماذا تُعطى فقط في نهاية الحلقة؟
Recall
Why must the action space be continuous?لماذا يجب أن يكون فضاء الأفعال متصلًا؟
Recall
What does AMC not learn?ما الذي لا يتعلمه AMC؟
Quick checkاختبار سريع
Which fact makes AMC choose DDPG rather than a discrete-action agent?ما الحقيقة التي تجعل AMC يختار DDPG بدلًا من وكيل بأفعال متقطعة؟
Quick checkاختبار سريع
Under a FLOPs budget, what reward does the agent get when the pruned model breaks the budget?تحت ميزانية FLOPs، ما المكافأة التي يحصل عليها الوكيل عندما يخرق النموذج المقلّم الميزانية؟
Slide 30 puts the agent up against Song Han's own hand-pruned ResNet-50 from his PhD thesis. The human expert kept 29% of the weights, a 3.4x reduction. The agent kept 20%, a 5x reduction, at the same accuracy: 76.13% top-1 for the original and 76.11% for AMC (He et al., 2018). This experiment uses fine-grained weight pruning, not channel pruning, and it is run as Iterative pruning in four rounds at 50%, 35%, 25% and 20% overall density with 30 fine-tuning epochs after each round, which is the schedule part 06 explains.
تضع الشريحة 30 الوكيل في مواجهة شبكة ResNet-50 التي قلّمها Song Han بيده في أطروحة الدكتوراه. احتفظ الخبير البشري بـ29% من الأوزان، أي تقليل بمقدار 3.4x. واحتفظ الوكيل بـ20%، أي تقليل بمقدار 5x، عند الدقة نفسها: 76.13% في top-1 للأصلية و76.11% لـ AMC (He et al., 2018). تستخدم هذه التجربة تقليم الأوزان الدقيق الحبيبات (fine-grained)، لا تقليم القنوات، وتُنفَّذ بوصفها iterative pruning (تقليمًا تكراريًا) على أربع جولات عند كثافة إجمالية 50% و35% و25% و20%، مع 30 حقبة من fine-tuning (الضبط الدقيق) بعد كل جولة، وهو الجدول الذي يشرحه الجزء 06.
| Regionالمنطقة | Human expertالخبير البشري | AMCAMC |
|---|---|---|
| Conv1Conv1 | 50%50% | 43%43% |
| ResBlock1ResBlock1 | 31%31% | 28%28% |
| ResBlock2ResBlock2 | 31%31% | 28%28% |
| ResBlock3ResBlock3 | 30%30% | 23%23% |
| ResBlock4ResBlock4 | 30%30% | 19%19% |
| FCFC | 20%20% | 10%10% |
| Totalالإجمالي | 29%29% | 20%20% |
Worked exampleمثال محلول
From density to compression ratioمن الكثافة إلى نسبة الضغط
Human expertالخبير البشري
Density 29%, so compression 1 / 0.29 = 3.4x. The thesis records the rules behind it: first layer 50%, residual blocks about 30%, fully connected layer 20% (Han, 2017).الكثافة 29%، إذن الضغط 1 / 0.29 = 3.4x. وتسجّل الأطروحة القواعد وراء ذلك: الطبقة الأولى 50%، والكتل المتبقية (residual blocks) نحو 30%، والطبقة المتصلة بالكامل 20% (Han, 2017).AMCAMC
Density 20%, so compression 1 / 0.20 = 5.0x, with the biggest gains in the late blocks (30% to 19% in ResBlock4) and the classifier (20% to 10%).الكثافة 20%، إذن الضغط 1 / 0.20 = 5.0x، وأكبر المكاسب في الكتل المتأخرة (من 30% إلى 19% في ResBlock4) وفي المصنّف (من 20% إلى 10%).Same accuracy, 1.5x fewer weightsالدقة نفسها، وأوزان أقل بمقدار 1.5x
76.13% versus 76.11% top-1, a difference well inside run-to-run noise, for 5x instead of 3.4x.76.13% مقابل 76.11% في top-1، وهو فرق يقع ضمن ضجيج التكرار من تشغيل لآخر، مقابل 5x بدلًا من 3.4x.
What the agent noticed inside a residual blockما الذي لاحظه الوكيل داخل الكتلة المتبقية
The per-region bars hide the interesting pattern, which slide 31 shows layer by layer. ResNet-50 is built from bottleneck blocks: a 1x1 convolution that reduces the channel count, a 3x3 convolution, and a 1x1 convolution that restores it (He et al., 2016). Walk along the layer index and the kept density forms a sawtooth. The peaks, where the agent kept more, are the 1x1 layers. The crests, where it cut deep, are the 3x3 layers. The paper draws the conclusion directly: the agent "automatically learns that 3x3 convolution has more redundancy than 1x1 convolution and can be pruned more" (He et al., 2018). Nobody told it about kernel shapes; the kernel size k is just one of the eleven features in the state.
الأعمدة حسب المنطقة تخفي النمط المثير، وتعرضه الشريحة 31 طبقة بطبقة. تتكون ResNet-50 من كتل عنق الزجاجة (bottleneck): التفاف 1x1 يقلّل عدد القنوات، ثم التفاف 3x3، ثم التفاف 1x1 يعيده (He et al., 2016). امشِ على رقم الطبقة وستجد أن الكثافة المحتفظ بها ترسم شكل أسنان المنشار. القمم، حيث احتفظ الوكيل بأكثر، هي طبقات 1x1. والقيعان، حيث قطع بعمق، هي طبقات 3x3. وتستخلص الورقة النتيجة مباشرة: الوكيل "يتعلم تلقائيًا أن التفاف 3x3 فيه تكرار (redundancy) أكثر من التفاف 1x1 ويمكن تقليمه أكثر" (He et al., 2018). لم يخبره أحد عن أشكال الأنوية؛ فحجم النواة k مجرد واحدة من الخصائص الإحدى عشرة في الحالة.
The finding makes sense once you think about where redundancy lives. A 1x1 kernel mixes channels and has no spatial extent, so every weight is a distinct channel-to-channel connection with nothing next to it to stand in for it. A 3x3 kernel has nine spatial taps per channel pair, many of which are near zero after training, and it also holds most of a block's weights: in a stage-3 bottleneck the 3x3 layer carries about 590K of the block's 1.1M parameters against 262K for each 1x1 layer (Han, 2017). Cutting the 3x3 layers hard is where the compression is, and it is also where accuracy is cheapest to spend, which is exactly the trade the reward rewards.
تصبح النتيجة منطقية حين تفكر في مكان وجود التكرار. نواة 1x1 تمزج القنوات وليس لها امتداد مكاني، فكل وزن فيها اتصال مميز بين قناة وقناة، ولا يوجد بجواره ما ينوب عنه. أما نواة 3x3 ففيها تسع نقاط مكانية لكل زوج من القنوات، وكثير منها قريب من الصفر بعد التدريب، كما أنها تحمل معظم أوزان الكتلة: في كتلة عنق زجاجة من المرحلة 3 تحمل طبقة 3x3 نحو 590K من أصل 1.1M معامل في الكتلة، مقابل 262K لكل طبقة 1x1 (Han, 2017). قطع طبقات 3x3 بقوة هو حيث يوجد الضغط، وهو أيضًا حيث تكون الدقة أرخص ما يمكن إنفاقه، وهذه بالضبط المقايضة التي تكافئها المكافأة.
Recall
What did AMC learn about 3x3 versus 1x1 convolutions in ResNet-50, and what did that buy?ماذا تعلّم AMC عن التفافات 3x3 مقابل 1x1 في ResNet-50، وماذا كسب من ذلك؟
Quick checkاختبار سريع
Inside the residual blocks of ResNet-50, which layers did the agent keep densest?داخل الكتل المتبقية في ResNet-50، أي الطبقات أبقاها الوكيل الأكثف؟
The final slide moves from weights to milliseconds. MobileNet is run with TF-Lite on a Samsung Galaxy S7 Edge with a Qualcomm Snapdragon SoC, single core, batch size 1, which is the latency-oriented setting of a phone serving one image at a time. Four models are measured: the full 1.0 MobileNet, two AMC results and the 0.75 MobileNet baseline, which is the same architecture with every layer's width scaled by 75%.
تنتقل الشريحة الأخيرة من الأوزان إلى الميلي ثواني. تُشغَّل MobileNet باستخدام TF-Lite على هاتف Samsung Galaxy S7 Edge بشريحة Qualcomm Snapdragon SoC، على نواة واحدة، وبحجم دفعة 1، وهو الإعداد الموجّه لزمن الاستجابة لهاتف يخدم صورة واحدة في كل مرة. تُقاس أربعة نماذج: 1.0 MobileNet الكاملة، ونتيجتان من AMC، وخط الأساس 0.75 MobileNet، وهي المعمارية نفسها مع تحجيم عرض كل طبقة إلى 75%.
| Modelالنموذج | MACMAC | Top-1Top-1 | Latencyزمن الاستجابة | Speedupالتسريع | Memoryالذاكرة |
|---|---|---|---|---|---|
| 1.0 MobileNet | 569M | 70.6% | 119.0 ms | 1x | 20.1 MB |
| AMC (50% FLOPs) | 285M | 70.5% | 64.4 ms | 1.8x | 14.3 MB |
| AMC (50% Time) | 272M | 70.2% | 59.7 ms | 2.0x | 13.2 MB |
| 0.75 MobileNet | 325M | 68.4% | 69.5 ms | 1.7x | 14.8 MB |
Worked exampleمثال محلول
Checking the tableالتحقق من الجدول
Speedupsمعاملات التسريع
119.0 / 64.4 = 1.85 (shown as 1.8x), 119.0 / 59.7 = 1.99 (2.0x), 119.0 / 69.5 = 1.71 (1.7x).119.0 / 64.4 = 1.85 (معروضة 1.8x)، و119.0 / 59.7 = 1.99 (2.0x)، و119.0 / 69.5 = 1.71 (1.7x).MAC fractionsنسب MAC
285 / 569 = 0.50, 272 / 569 = 0.48, 325 / 569 = 0.57. The width multiplier scales cost by roughly alpha^2 = 0.5625 (Howard et al., 2017), which matches the 0.57.285 / 569 = 0.50، و272 / 569 = 0.48، و325 / 569 = 0.57. مضاعِف العرض (width multiplier) يحجّم التكلفة بنحو alpha^2 = 0.5625 (Howard et al., 2017)، وهذا يطابق 0.57.Accuracy deltas from 70.6%فروق الدقة عن 70.6%
-0.1, -0.4 and -2.2 points.-0.1 و-0.4 و-2.2 نقطة.Both AMC rows dominate the uniform baselineكلا صفّي AMC يتفوقان على خط الأساس المنتظم
Each AMC model has fewer MACs, lower latency, less memory and higher accuracy than 0.75 MobileNet. Halving FLOPs gave 1.85x, not 2x; targeting time came closest, at 1.99x.كل نموذج من AMC فيه MACs أقل، وزمن استجابة أقل، وذاكرة أقل، ودقة أعلى من 0.75 MobileNet. تنصيف FLOPs أعطى 1.85x، لا 2x؛ واستهداف الزمن كان الأقرب، عند 1.99x.
Reading the two AMC rows against each otherقراءة صفّي AMC أحدهما مقابل الآخر
- Latencyزمن الاستجابة
- 50% Time is 4.7 ms faster (59.7 versus 64.4 ms)50% Time أسرع بـ4.7 ms (59.7 مقابل 64.4 ms)
- Accuracyالدقة
- 50% Time loses 0.3 points (70.2% versus 70.5%)50% Time يخسر 0.3 نقطة (70.2% مقابل 70.5%)
- MACs
- 272M versus 285M: the time target also ends up slightly smaller272M مقابل 285M: هدف الزمن ينتهي أيضًا بنموذج أصغر قليلًا
- Against 0.75 MobileNetمقابل 0.75 MobileNet
- Both are at least 1.8 points more accurate, at least 5 ms faster, with fewer MACsكلاهما أدق بـ1.8 نقطة على الأقل، وأسرع بـ5 ms على الأقل، مع MACs أقل
Two lessons in one tableدرسان في جدول واحد
First, FLOPs are a proxy. Halving the multiply-accumulates bought 1.85x, not 2x, because a phone does not spend time in proportion to arithmetic. MobileNet's depthwise layers have a low ratio of computation to memory traffic, so trimming them saves fewer milliseconds than the MAC count suggests; the paper reports about 2x speedup on the 1x1 convolutions but less on the depthwise ones (He et al., 2018). When the agent is instead constrained by measured time from the lookup table, it removes work where the phone is actually slow, and the search lands at 59.7 ms, a 1.99x speedup that all but hits the 2x target. That allocation is less accuracy-friendly, which is the 0.3 point cost. You choose the target you care about, and you pay in the other currency.
أولًا، FLOPs مجرد بديل تقريبي. تنصيف عمليات الضرب والجمع (multiply-accumulates) أعطى 1.85x، لا 2x، لأن الهاتف لا يقضي وقته بالتناسب مع الحساب. طبقات depthwise في MobileNet نسبة الحساب فيها إلى حركة الذاكرة منخفضة، لذا فتقليصها يوفّر ميلي ثواني أقل مما يوحي به عدد MAC؛ وتذكر الورقة تسريعًا بنحو 2x على التفافات 1x1 وأقل من ذلك على طبقات depthwise (He et al., 2018). وعندما يُقيَّد الوكيل بدلًا من ذلك بالزمن المقاس من جدول البحث، فإنه يزيل العمل حيث يكون الهاتف بطيئًا فعلًا، فيصل البحث إلى 59.7 ms، أي تسريع 1.99x يكاد يصيب هدف 2x. هذا التوزيع أقل رفقًا بالدقة، وهذه هي تكلفة الـ0.3 نقطة. أنت تختار الهدف الذي يهمك، وتدفع بالعملة الأخرى.
Second, non-uniform beats uniform. Uniform shrinking with the width multiplier is a single knob turned on every layer, and the thinner model must be trained from scratch (Howard et al., 2017). AMC prunes a pretrained network with a different ratio per layer, keeps 2.1 (50% FLOPs) or 1.8 (50% Time) more points of accuracy with fewer MACs than 0.75 MobileNet, and does it after a short fine-tune. In the accuracy versus latency plane the AMC points sit above and to the left, which is the definition of a better Pareto frontier.
ثانيًا، غير المنتظم يتفوق على المنتظم. uniform shrinking (التصغير المنتظم) باستخدام مضاعِف العرض مقبض واحد يُدار على كل طبقة، ويجب تدريب النموذج الأرفع من الصفر (Howard et al., 2017). أما AMC فيقلّم شبكة مدرّبة مسبقًا بنسبة مختلفة لكل طبقة، ويحتفظ بـ2.1 (50% FLOPs) أو 1.8 (50% Time) نقطة دقة إضافية مع MACs أقل من 0.75 MobileNet، ويفعل ذلك بعد ضبط دقيق قصير. في مستوى الدقة مقابل زمن الاستجابة تقع نقاط AMC في الأعلى وإلى اليسار، وهذا هو تعريف جبهة Pareto أفضل.
Recall
In the MobileNet table, why does 50% Time beat 50% FLOPs on latency but lose 0.3 points?في جدول MobileNet، لماذا يتفوق 50% Time على 50% FLOPs في زمن الاستجابة لكنه يخسر 0.3 نقطة؟
Quick checkاختبار سريع
Why does AMC (50% Time) run faster than AMC (50% FLOPs) on the Galaxy S7 Edge?لماذا يعمل AMC (50% Time) أسرع من AMC (50% FLOPs) على Galaxy S7 Edge؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- An overall compression ratio fixes the sum; allocating it across layers is a search whose objective is only observable by trying it.نسبة الضغط الإجمالية تحدد المجموع فقط؛ أما توزيعها على الطبقات فهو بحث لا يمكن رؤية دالة هدفه إلا بتجربته.
- Sensitivity analysis assumes per-layer losses add. Layers interact, so its ratios are sub-optimal and do not transfer between models.يفترض تحليل الحساسية أن خسائر الطبقات تُجمع جمعًا. لكن الطبقات تتفاعل، لذا تكون نسبه دون المثلى ولا تنتقل من نموذج إلى آخر.
- AMC: state = layer embedding of 11 scaled features, action = continuous sparsity ratio, agent = DDPG, reward = minus error once all layers are pruned, budget enforced as a constraint.في AMC: الحالة = تضمين الطبقة من 11 خاصية مُقيّسة، والفعل = نسبة تفرّق (sparsity) متصلة، والوكيل = DDPG، والمكافأة = سالب الخطأ بعد تقليم كل الطبقات، مع فرض الميزانية كقيد.
- Continuous actions because ratios are real numbers and grids lose ordering; the critic scores Q(s, a), the actor proposes a.الأفعال متصلة لأن النسب أعداد حقيقية والشبكات المتقطعة تُضيّع الترتيب؛ الناقد يقيّم Q(s, a) والممثل يقترح a.
- AMC learns only the ratios. Magnitude selection inside each layer and one final fine-tune are unchanged.يتعلم AMC النسب فقط. اختيار الأوزان بالمقدار (magnitude) داخل كل طبقة وضبط دقيق (fine-tune) نهائي واحد يبقيان كما هما.
- ResNet-50: 20% density (5x) versus the expert's 29% (3.4x) at 76.1% top-1; 3x3 layers are pruned harder than 1x1 layers.في ResNet-50: كثافة 20% (5x) مقابل 29% للخبير (3.4x) عند دقة top-1 تساوي 76.1%؛ وتُقلَّم طبقات 3x3 بقوة أكبر من طبقات 1x1.
- MobileNet on a Galaxy S7 Edge: 50% FLOPs gives 64.4 ms at 70.5%, 50% time gives 59.7 ms at 70.2%, both beating 0.75 MobileNet at 69.5 ms and 68.4%.MobileNet على Galaxy S7 Edge: هدف 50% FLOPs يعطي 64.4 ms عند 70.5%، وهدف 50% Time يعطي 59.7 ms عند 70.2%، وكلاهما يتفوق على 0.75 MobileNet عند 69.5 ms و68.4%.
- Targeting measured time lands within a whisker of the speed goal; targeting FLOPs is only a proxy.استهداف الزمن المقاس يصل إلى هدف السرعة تقريبًا تمامًا؛ أما استهداف FLOPs فهو مجرد بديل تقريبي (proxy).
Sourcesالمصادر
- AMC: AutoML for Model Compression and Acceleration on Mobile DevicesPaperECCV 2018, He, Lin, Liu, Wang, Li and HanEleven-feature state, continuous action, rewards, Algorithm 1, ResNet-50 density, Pixel 1 MobileNet table. DOI 10.1007/978-3-030-01234-2_48.حالة من إحدى عشرة خاصية، وفعل متصل، والمكافآت، وAlgorithm 1، وكثافة ResNet-50، وجدول MobileNet على Pixel 1. DOI 10.1007/978-3-030-01234-2_48.(opens in a new tab)(يفتح في تبويب جديد)
- 6.5940 TinyML and Efficient Deep Learning Computing, Lecture 4: Pruning and Sparsity Part IIDocsMIT HAN Lab, Fall 2023Source of slides 27 to 32 and of the Galaxy S7 Edge measurements.مصدر الشرائح من 27 إلى 32 وقياسات Galaxy S7 Edge.(opens in a new tab)(يفتح في تبويب جديد)
- Continuous control with deep reinforcement learningPaperLillicrap et al., 2015DDPG: an actor-critic, model-free algorithm for continuous action spaces.DDPG: خوارزمية من نوع ممثل وناقد (actor-critic) لا تعتمد على نموذج (model-free)، لفضاءات الأفعال المتصلة.(opens in a new tab)(يفتح في تبويب جديد)
- Deep Deterministic Policy GradientDocsOpenAI Spinning UpLearns a Q-function and a policy concurrently; only for continuous actions; off-policy; actor trained by ascent on Q.تتعلم دالة Q وسياسة في آنٍ واحد؛ للأفعال المتصلة فقط؛ خارج السياسة (off-policy)؛ ويُدرَّب الممثل بالصعود على Q.(opens in a new tab)(يفتح في تبويب جديد)
- Reinforcement Learning: An Introduction, 2nd editionBookMIT Press 2018, Sutton and BartoChapter 13: the critic assesses the policy's action selections, the policy is the actor.الفصل 13: الناقد يقيّم اختيارات السياسة للأفعال، والسياسة هي الممثل.(opens in a new tab)(يفتح في تبويب جديد)
- Efficient Methods and Hardware for Deep LearningPaperStanford PhD thesis 2017, Song HanTable 3.8: human-expert ResNet-50 densities, 3.4x; per-layer parameter counts of a bottleneck block.Table 3.8: كثافات ResNet-50 لدى الخبير البشري، 3.4x؛ وعدد المعاملات لكل طبقة في كتلة عنق الزجاجة (bottleneck).(opens in a new tab)(يفتح في تبويب جديد)
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision ApplicationsPaperHoward et al., 2017Table 6: 1.0 MobileNet 569M and 70.6%, 0.75 MobileNet 325M and 68.4%; the width multiplier thins every layer uniformly and needs retraining.Table 6: 1.0 MobileNet بـ569M و70.6%، و0.75 MobileNet بـ325M و68.4%؛ مضاعِف العرض يرقّق كل طبقة بشكل منتظم ويحتاج إلى إعادة تدريب.(opens in a new tab)(يفتح في تبويب جديد)
- Deep Residual Learning for Image RecognitionPaperHe, Zhang, Ren and Sun, CVPR 2016The bottleneck block: 1x1 reduce, 3x3, 1x1 restore.كتلة عنق الزجاجة (bottleneck): 1x1 للتقليل، ثم 3x3، ثم 1x1 للاستعادة.(opens in a new tab)(يفتح في تبويب جديد)
- An Analysis of Deep Neural Network Models for Practical ApplicationsPaperCanziani, Paszke and Culurciello, 2016The accuracy versus operations bubble chart on slide 28; accuracy rises roughly with log operations.مخطط الفقاعات للدقة مقابل عدد العمليات في الشريحة 28؛ ترتفع الدقة تقريبًا مع لوغاريتم عدد العمليات.(opens in a new tab)(يفتح في تبويب جديد)
- mit-han-lab/amcDocsGitHubReference implementation of AMC.التنفيذ المرجعي لـAMC.(opens in a new tab)(يفتح في تبويب جديد)
Part 05: NetAdapt: platform-aware pruning to a latency budgetNetAdapt: تقليم واعٍ بالمنصة حتى ميزانية زمن استجابة
A rule-based automatic method that removes latency in fixed steps, tries pruning each layer with a measured latency lookup table, keeps the layer whose short fine-tune loses the least accuracy, and produces a whole series of models.طريقة آلية قائمة على القواعد تزيل زمن الاستجابة بخطوات ثابتة، وتجرب تقليم كل طبقة باستخدام جدول بحث لزمن الاستجابة المقاس، وتحتفظ بالطبقة التي يفقد ضبطها الدقيق القصير أقل دقة، وتنتج سلسلة كاملة من النماذج.
2 conceptsمفهومان, ، slides 33-40الشرائح 33-40
Why this part mattersلماذا يهمّ هذا الجزء
Your edge deployments do not start from a FLOPs target. They start from a latency spec on a specific board: the camera pipeline must answer in 7 ms on this phone, or the classifier must fit one frame period on that microcontroller. NetAdapt is the pruning method built for that situation. It takes a pretrained network, a measured latency budget and the device itself, and hands back a network that meets the budget.
It is also the rule-based counterpart to AMC from part 04, so exam questions like to contrast the two, and it is the finishing step inside MobileNetV3. This part walks the loop once in words, once as a worked example you can redo by hand, and once in a simulator, then shows why a single run leaves you with a whole family of models rather than one.
مشاريعك على أجهزة الحافة (edge) لا تبدأ من هدف بعدد الـ FLOPs. إنها تبدأ من مواصفة latency على لوحة محددة: يجب أن يستجيب مسار الكاميرا خلال 7 ms على هذا الهاتف، أو يجب أن يتسع المصنِّف لفترة إطار واحد على ذلك المتحكم الدقيق (microcontroller). NetAdapt هي طريقة الـ pruning المصممة لهذا الموقف بالذات. تأخذ شبكة مدرَّبة مسبقًا، وميزانية latency مقيسة، والجهاز نفسه، وتعيد لك شبكة تحقق الميزانية.
وهي أيضًا النظير القائم على القواعد (rule-based) لـ AMC من الجزء 04، لذلك تحب أسئلة الاختبار المقارنة بينهما، وهي كذلك الخطوة الأخيرة داخل MobileNetV3. يمر هذا الجزء على الحلقة مرة بالكلمات، ومرة كمثال محلول تستطيع إعادته يدويًا، ومرة في محاكٍ، ثم يبيّن لماذا يترك لك تشغيل واحد عائلة كاملة من النماذج بدل نموذج واحد.
By the end you canفي نهاية هذا الجزء ستستطيع
- Write the NetAdapt loop from memory: Delta R, one proposal per layer, lookup table, short-term fine-tune, pick the highest accuracy, repeat, long-term fine-tune.اكتب حلقة NetAdapt من الذاكرة: Delta R، ومقترح (proposal) واحد لكل طبقة، وجدول البحث (lookup table)، ثم short-term fine-tune، ثم اختيار المقترح الأعلى دقة، ثم التكرار، وأخيرًا long-term fine-tune.
- Explain why a measured per-layer latency lookup table beats counting FLOPs, using the 19 percent fewer MACs but 29 percent slower example.اشرح لماذا يتفوق جدول بحث يقيس الـ latency لكل طبقة على عدّ الـ FLOPs، مستخدمًا مثال الشبكة التي فيها MACs أقل بنسبة 19 بالمئة لكنها أبطأ بنسبة 29 بالمئة.
- Run three iterations by hand on a four-layer network and bring it from 10.0 ms under a 7.0 ms budget.نفّذ ثلاثة تكرارات يدويًا على شبكة من أربع طبقات، وأنزلها من 10.0 ms إلى ما دون ميزانية 7.0 ms.
- Contrast NetAdapt with AMC on who decides the ratios, the cost model, the fine-tuning and what comes out.قارن NetAdapt مع AMC من حيث: من يقرر النسب، ونموذج الكلفة، والـ fine-tuning، وما الذي يخرج في النهاية.
- Explain why one run yields a whole accuracy versus latency frontier and read the slide 40 chart.اشرح لماذا يعطي تشغيل واحد منحنى (frontier) كاملًا للمفاضلة بين الدقة والـ latency، واقرأ الرسم في الشريحة 40.
Suppose a pretrained MobileNet runs in 10.0 ms on one core of a Pixel 1 and the product needs 7.0 ms. The Sensitivity analysis of part 03 cannot help directly, because its curves are in accuracy versus Pruning ratio, not milliseconds, and it ignores Layer interaction. AMC (AutoML for Model Compression) from part 04 could be pointed at latency, but it needs a reinforcement learning agent and a training loop of its own. NetAdapt asks a much simpler question, and asks it many times: which single layer can I thin right now so that latency falls by a fixed step while accuracy falls the least?
لنفترض أن شبكة MobileNet مدرَّبة مسبقًا تعمل في 10.0 ms على نواة واحدة من هاتف Pixel 1، والمنتج يحتاج إلى 7.0 ms. لا يستطيع sensitivity analysis من الجزء 03 أن يساعد مباشرة، لأن منحنياته تعبّر عن الدقة مقابل pruning ratio، لا بالملّي ثانية، كما أنه يتجاهل layer interaction. ويمكن توجيه AMC من الجزء 04 نحو الـ latency، لكنه يحتاج إلى وكيل تعلّم معزَّز (reinforcement learning agent) وحلقة تدريب خاصة به. أما NetAdapt فيطرح سؤالًا أبسط بكثير، ويطرحه مرات كثيرة: ما الطبقة الواحدة التي أستطيع ترقيقها الآن بحيث تنخفض الـ latency بخطوة ثابتة بينما تنخفض الدقة بأقل قدر ممكن؟
The slides call it a rule-based iterative, or progressive, method, and every word matters. Rule-based means no learned policy: the decision each round is a comparison of measured numbers. Iterative means the budget is reached in many small steps rather than one cut. Progressive means each step starts from the winner of the previous one. It is Automated pruning in the sense of part 04, because nobody hand-picks per-layer ratios, but the automation is a loop you could run with a spreadsheet.
تسميها الشرائح طريقة تكرارية، أو تدريجية (progressive)، قائمة على القواعد (rule-based)، وكل كلمة هنا مهمة. القائمة على القواعد تعني عدم وجود سياسة متعلَّمة (learned policy): القرار في كل جولة هو مقارنة بين أرقام مقيسة. التكرارية تعني أن الميزانية تُبلغ عبر خطوات صغيرة كثيرة بدل قطع واحد. والتدريجية تعني أن كل خطوة تبدأ من الفائز في الخطوة السابقة. إنها automated pruning بمعنى الجزء 04، لأن أحدًا لا يختار نسب كل طبقة يدويًا، لكن الأتمتة هنا حلقة تستطيع تشغيلها بجدول بيانات (spreadsheet).
The problem, and the trick of tightening it slowlyالمسألة، وحيلة تضييقها ببطء
Yang et al. state the goal as a constrained optimization. Accuracy should be as high as possible while every resource of interest (latency, energy, model size) stays under its budget.
يصوغ Yang et al. الهدف كمسألة تحسين مقيَّدة (constrained optimization). يجب أن تكون الدقة أعلى ما يمكن بينما يبقى كل مورد مهم (الـ latency، والطاقة، وحجم النموذج) تحت ميزانيته.
Solving that in one shot is hopeless, so the paper breaks it into a chain of easier problems. At iteration i the constraint is not the final budget but the previous network's resource use minus a step ΔR.
حل هذه المسألة دفعة واحدة ميؤوس منه، لذلك تقسمها الورقة إلى سلسلة من المسائل الأسهل. عند التكرار i لا يكون القيد هو الميزانية النهائية، بل استهلاك الشبكة السابقة للمورد ناقص خطوة ΔR.
The paper calls ΔR the resource reduction schedule and compares it to a learning-rate schedule. In the small MobileNetV1 experiments it starts at 0.5 ms and decays by 0.96 every iteration; for larger networks the initial step is scaled with the network's latency. The slides simplify this to a manually defined constant, and the worked example below does the same. Think of it as a progressive barrier: each round the wall moves in a little, and the network only has to squeeze past the new wall, never the final one.
تسمي الورقة ΔR بـ resource reduction schedule (جدول تقليص المورد) وتشبّهه بجدول معدل التعلّم (learning-rate schedule). في تجارب MobileNetV1 الصغيرة يبدأ عند 0.5 ms ويتناقص بمعامل 0.96 في كل تكرار؛ أما في الشبكات الأكبر فتُقاس الخطوة الابتدائية بحسب latency الشبكة. تبسّط الشرائح ذلك إلى ثابت يُحدَّد يدويًا، والمثال المحلول أدناه يفعل الشيء نفسه. تخيّله كحاجز تدريجي: في كل جولة يتقدم الجدار قليلًا إلى الداخل، ولا يُطلب من الشبكة إلا أن تعبر من الجدار الجديد، لا من الجدار النهائي أبدًا.
One iteration, step by stepتكرار واحد، خطوة بخطوة
Read slides 34 to 39 as a single loop body. The paper's Algorithm 1 has the same shape, with K equal to the number of convolutional and fully connected layers, so a network with K such layers produces K proposals per iteration.
اقرأ الشرائح من 34 إلى 39 كجسم حلقة واحد. للخوارزمية Algorithm 1 في الورقة الشكل نفسه، حيث K يساوي عدد طبقات الـ convolution والطبقات الكاملة الاتصال (fully connected)، لذلك تنتج شبكة فيها K من هذه الطبقات K مقترحات في كل تكرار.
Time the pretrained network on the target once. Everything after this reads tables.
قِس زمن الشبكة المدرَّبة مسبقًا على الجهاز المستهدف مرة واحدة. كل ما بعد ذلك يقرأ من الجداول.
The target for this round is only ΔR below the current latency.
الهدف في هذه الجولة أقل من زمن الاستجابة الحالي بمقدار ΔR فقط.
Pick the largest filter count whose summed table latency meets Con, keep the largest-l2 filters, short-term fine-tune, measure.
اختر أكبر عدد مرشحات يحقق مجموع زمنه في الجدول القيد Con، واحتفظ بالمرشحات ذات أكبر معيار l2، ثم اضبط ضبطًا دقيقًا قصير المدى وقِس.
Net_(i+1) is the proposal with the best accuracy. Its latency becomes Res_(i+1).
Net_(i+1) هو المقترح صاحب أفضل دقة، ويصبح زمن استجابته Res_(i+1).
Every iteration starts from the previous winner and moves the wall in by ΔR again.
يبدأ كل تكرار من الفائز السابق ويقرّب الجدار مرة أخرى بمقدار ΔR.
Recover accuracy on the final architecture. This is the number you report.
استعد الدقة على البنية النهائية. هذا هو الرقم الذي تعلنه.
- Set the constraint for this round: Con = Res_i minus ΔR_i.حدّد قيد هذه الجولة: Con = Res_i minus ΔR_i.
- For each layer L_k, choose the number of filters to keep, from the lookup table, so the whole network meets Con; then choose which filters to keep by l2 magnitude.لكل طبقة L_k، اختر من جدول البحث عدد الـ filters التي تُبقيها بحيث تحقق الشبكة كلها Con؛ ثم اختر أي الـ filters تُبقي بحسب l2 magnitude.
- Short-term fine-tune that proposal (the slides say about 10k iterations) and measure its accuracy on a holdout set.نفّذ short-term fine-tune لذلك المقترح (تقول الشرائح نحو 10k تكرار) وقِس دقته على مجموعة holdout.
- Keep the proposal with the highest accuracy; it becomes the starting point of the next iteration.احتفظ بالمقترح الأعلى دقة؛ فهو يصبح نقطة البداية للتكرار التالي.
- Repeat while the latency is still above the budget.كرّر ما دامت الـ latency فوق الميزانية.
- Long-term fine-tune the final network until convergence.نفّذ long-term fine-tune على الشبكة النهائية حتى التقارب (convergence).
Why a lookup table and not FLOPsلماذا جدول بحث وليس FLOPs
The constraint in Eq. 2 is a latency, so the loop needs to know the latency of every proposal, and there are K of them per iteration. Timing each one on the phone is slow and hard to parallelize. NetAdapt instead builds a Latency lookup table per layer before the loop starts: for every shape a layer might take (input channels, output channels, resolution), measure it once on the device and store the number. Layers that share a shape share an entry. The latency of a whole proposal is then the sum of its layers' entries. The paper's own illustration is a two-layer network where layer 1 with 4 filters on a 3-channel input costs 6 ms, and layer 2 with 6 filters on the 4 channels that layer 1 now produces costs 4 ms, so the network is estimated at 6 + 4 = 10 ms. Notice that the second entry is indexed by the first layer's filter count, which is how the table accounts for the removed input channels. A table indexed by whole networks would grow exponentially with depth; a table per layer grows linearly.
القيد في Eq. 2 هو latency، لذلك تحتاج الحلقة إلى معرفة latency كل مقترح، وعددها K في كل تكرار. قياس كل واحد منها على الهاتف بطيء ويصعب تنفيذه بالتوازي. بدلًا من ذلك يبني NetAdapt جدول latency lookup table لكل طبقة قبل أن تبدأ الحلقة: لكل شكل قد تأخذه الطبقة (قنوات الإدخال، وقنوات الإخراج، والدقة المكانية resolution)، يُقاس مرة واحدة على الجهاز ويُخزَّن الرقم. الطبقات التي تتشارك الشكل نفسه تتشارك المدخل نفسه. عندئذ تكون latency المقترح كله مجموع مدخلات طبقاته. المثال التوضيحي في الورقة شبكة من طبقتين: الطبقة 1 فيها 4 filters على إدخال من 3 قنوات وكلفتها 6 ms، والطبقة 2 فيها 6 filters على القنوات الـ 4 التي تنتجها الطبقة 1 الآن وكلفتها 4 ms، فتُقدَّر الشبكة بـ 6 + 4 = 10 ms. لاحظ أن المدخل الثاني مفهرس بعدد filters الطبقة الأولى، وبهذه الطريقة يحتسب الجدول قنوات الإدخال المحذوفة. الجدول المفهرس بشبكات كاملة سيكبر أُسّيًا مع العمق؛ أما جدول لكل طبقة فيكبر خطيًا.
Why not skip the measurement and count multiply-accumulates? Because MACs are an indirect metric, and their relation to latency is neither linear nor the same across devices. The paper makes the point with a striking table: a network guided by MACs ended up with 19% fewer MACs than the baseline and 29% longer latency on a Pixel 1 CPU.
لماذا لا نتجاوز القياس ونعدّ عمليات الضرب والجمع (multiply-accumulates)؟ لأن الـ MACs مقياس غير مباشر، وعلاقتها بالـ latency ليست خطية وليست واحدة عبر الأجهزة. توضح الورقة ذلك بجدول لافت: شبكة موجَّهة بالـ MACs انتهت بعدد MACs أقل من الأساس (baseline) بنسبة 19% وبـ latency أطول بنسبة 29% على معالج Pixel 1.
| Networkالشبكة | Top-1Top-1 | MACsMACs | Latencyالـ Latency |
|---|---|---|---|
| 25% MobileNetV1 (128)25% MobileNetV1 (128) | 45.1%45.1% | 13.6 M (100%)13.6 M (100%) | 4.65 ms (100%)4.65 ms (100%) |
| MorphNetMorphNet | 46.0%46.0% | 15.0 M (110%)15.0 M (110%) | 6.52 ms (140%)6.52 ms (140%) |
| NetAdapt guided by MACsNetAdapt موجَّهًا بالـ MACs | 46.3%46.3% | 11.0 M (81%)11.0 M (81%) | 6.01 ms (129%)6.01 ms (129%) |
The lesson carries over to your own boards. Memory traffic, kernel launch overheads, cache behaviour and how well a library tiles a particular layer shape all change latency without changing the MAC count. The honest number is the one the device reports, and the lookup table is a cheap way to have that number on hand for every candidate. The paper checks the approximation on a Pixel 1 and finds the summed estimate highly correlated with the real measurement. Part 04 noted that AMC can also use a pre-built lookup table to optimize latency; NetAdapt makes it the default rather than an option.
هذا الدرس ينطبق على لوحاتك أنت أيضًا. حركة الذاكرة، وكلفة إطلاق الـ kernel، وسلوك الذاكرة المخبئية (cache)، ومدى جودة تقسيم المكتبة لشكل طبقة معيّن إلى بلاطات (tiling)، كلها تغيّر الـ latency دون أن تغيّر عدد الـ MACs. الرقم الصادق هو الذي يُبلغ عنه الجهاز، وجدول البحث طريقة رخيصة لجعل هذا الرقم متاحًا لكل مرشح. تتحقق الورقة من هذا التقريب على Pixel 1 وتجد أن التقدير بالجمع مرتبط بقوة بالقياس الحقيقي. ذكر الجزء 04 أن AMC يمكنه أيضًا استخدام جدول بحث مبني مسبقًا لتحسين الـ latency؛ أما NetAdapt فيجعله الوضع الافتراضي لا مجرد خيار.
Why fine-tune twiceلماذا نُجري الـ fine-tune مرتين
There are two kinds of Fine-tuning in the loop and they serve different purposes. The short-term fine-tune happens once per proposal, so K times per iteration. Its only job is to make the K accuracies comparable. The paper reports that without it, the accuracy of a small network after pruning rapidly drops to nearly zero, and the algorithm then picks the best proposal solely based on noise. With 10k iterations the accuracy stays above 20% and the ranking becomes meaningful.
في الحلقة نوعان من fine-tuning ولكل منهما غرض مختلف. الـ short-term fine-tune يحدث مرة لكل مقترح، أي K مرة في كل تكرار. وظيفته الوحيدة أن يجعل دقّات المقترحات الـ K قابلة للمقارنة. تذكر الورقة أنه بدونه تنهار دقة الشبكة الصغيرة بعد الـ pruning بسرعة إلى ما يقارب الصفر، فتختار الخوارزمية أفضل مقترح بناءً على الضجيج وحده. ومع 10k تكرار تبقى الدقة فوق 20% ويصبح الترتيب ذا معنى.
The long-term fine-tune happens once, after the loop has stopped, and runs until convergence. This is the step that repairs the damage of all the cuts on the final architecture. In the paper it adds between 1.8 and 4.5 points, 3.4 on average, on top of the last short-term number.
أما الـ long-term fine-tune فيحدث مرة واحدة، بعد توقف الحلقة، ويستمر حتى التقارب. هذه هي الخطوة التي تصلح ضرر كل القطوع على البنية النهائية. في الورقة يضيف ما بين 1.8 و4.5 نقطة، 3.4 في المتوسط، فوق آخر رقم من الـ short-term.
A run you can redo by handتشغيل تستطيع إعادته يدويًا
Take a four-layer network with 32, 64, 64 and 128 filters (layers A to D), a measured latency of 10.0 ms and a budget of 7.0 ms. Fix ΔR = 1.0 ms, ten percent of the starting latency. The lookup tables below are illustrative, the accuracies are synthetic, and the effect of one layer's cut on the next layer's input channels is ignored so the sums stay readable. The paper decays ΔR and accounts for the next layer.
خذ شبكة من أربع طبقات فيها 32 و64 و64 و128 filters (الطبقات من A إلى D)، وlatency مقيسة قدرها 10.0 ms، وميزانية قدرها 7.0 ms. ثبّت ΔR = 1.0 ms، أي عشرة بالمئة من الـ latency الابتدائية. جداول البحث أدناه توضيحية، والدقّات اصطناعية، وتأثير قطع طبقة على قنوات الإدخال في الطبقة التالية مُهمَل كي تبقى المجاميع سهلة القراءة. أما الورقة فتُنقص ΔR تدريجيًا وتحتسب أثر الطبقة التالية.
Illustrative latency lookup tables, filters kept: msجداول بحث توضيحية للـ latency، عدد الـ filters المُبقاة: ms
- Layer A (32 filters)الطبقة A (32 filter)
- 32: 3.0, 24: 2.4, 16: 1.8, 8: 1.232: 3.0, 24: 2.4, 16: 1.8, 8: 1.2
- Layer B (64 filters)الطبقة B (64 filter)
- 64: 3.0, 48: 2.3, 32: 1.6, 16: 1.0, 8: 0.564: 3.0, 48: 2.3, 32: 1.6, 16: 1.0, 8: 0.5
- Layer C (64 filters)الطبقة C (64 filter)
- 64: 2.5, 48: 2.0, 32: 1.5, 16: 1.0, 8: 0.564: 2.5, 48: 2.0, 32: 1.5, 16: 1.0, 8: 0.5
- Layer D (128 filters)الطبقة D (128 filter)
- 128: 1.5, 96: 1.2, 64: 0.9, 32: 0.6, 16: 0.4128: 1.5, 96: 1.2, 64: 0.9, 32: 0.6, 16: 0.4
Worked exampleمثال محلول
Three iterations from 10.0 ms to a 7.0 ms budgetثلاثة تكرارات من 10.0 ms إلى ميزانية 7.0 ms
Check the starting pointتحقّق من نقطة البداية
3.0 + 3.0 + 2.5 + 1.5 = 10.0 ms at 71.0%. Above budget, so the loop runs.3.0 + 3.0 + 2.5 + 1.5 = 10.0 ms بدقة 71.0%. هذا فوق الميزانية، لذلك تعمل الحلقة.Iteration 1, Con = 10.0 minus 1.0 = 9.0 msالتكرار 1، Con = 10.0 minus 1.0 = 9.0 ms
For each layer, read the largest filter count whose sum meets 9.0 ms, short-term fine-tune the proposal and measure it.
Layerالطبقة Filters keptالـ filters المُبقاة Layer msms الطبقة Total msms الإجمالي Short-term accدقة الـ short-term AA 16 of 3216 من 32 1.81.8 8.88.8 61.0%61.0% BB 32 of 6432 من 64 1.61.6 8.68.6 68.2%68.2% C (kept)C (المُختارة) 32 of 6432 من 64 1.51.5 9.09.0 69.3%69.3% DD 16 of 12816 من 128 0.40.4 8.98.9 67.3%67.3% All four proposals meet the constraint, and NetAdapt does not reward going further below it (the 8.6 ms proposal earns nothing for its extra margin), so accuracy alone decides: layer C loses the least. Net_1 = A32 B64 C32 D128, 9.0 ms, 69.3%.
لكل طبقة، اقرأ أكبر عدد filters يحقق مجموعه 9.0 ms، ونفّذ short-term fine-tune للمقترح وقِسه.
Layerالطبقة Filters keptالـ filters المُبقاة Layer msms الطبقة Total msms الإجمالي Short-term accدقة الـ short-term AA 16 of 3216 من 32 1.81.8 8.88.8 61.0%61.0% BB 32 of 6432 من 64 1.61.6 8.68.6 68.2%68.2% C (kept)C (المُختارة) 32 of 6432 من 64 1.51.5 9.09.0 69.3%69.3% DD 16 of 12816 من 128 0.40.4 8.98.9 67.3%67.3% المقترحات الأربعة كلها تحقق القيد، وNetAdapt لا يكافئ النزول أكثر تحته (المقترح ذو 8.6 ms لا يكسب شيئًا من هامشه الإضافي)، لذلك تحسم الدقة وحدها: الطبقة C هي الأقل خسارة. Net_1 = A32 B64 C32 D128، 9.0 ms، 69.3%.
Iteration 2, Con = 9.0 minus 1.0 = 8.0 msالتكرار 2، Con = 9.0 minus 1.0 = 8.0 ms
Start from Net_1. Layer C already sits at 32, so its next table entry that saves a full millisecond is 8 filters, a much deeper cut.
Layerالطبقة Filters keptالـ filters المُبقاة Layer msms الطبقة Total msms الإجمالي Short-term accدقة الـ short-term AA 16 of 3216 من 32 1.81.8 7.87.8 59.2%59.2% B (kept)B (المُختارة) 32 of 6432 من 64 1.61.6 7.67.6 66.4%66.4% CC 8 of 648 من 64 0.50.5 8.08.0 65.0%65.0% DD 16 of 12816 من 128 0.40.4 7.97.9 65.5%65.5% Thinning C again would now cost more than thinning B for the first time, so the greedy rule switches layers. Net_2 = A32 B32 C32 D128, 7.6 ms, 66.4%.
ابدأ من Net_1. الطبقة C أصبحت عند 32، لذلك فإن مدخلها التالي في الجدول الذي يوفر ملّي ثانية كاملة هو 8 filters، وهو قطع أعمق بكثير.
Layerالطبقة Filters keptالـ filters المُبقاة Layer msms الطبقة Total msms الإجمالي Short-term accدقة الـ short-term AA 16 of 3216 من 32 1.81.8 7.87.8 59.2%59.2% B (kept)B (المُختارة) 32 of 6432 من 64 1.61.6 7.67.6 66.4%66.4% CC 8 of 648 من 64 0.50.5 8.08.0 65.0%65.0% DD 16 of 12816 من 128 0.40.4 7.97.9 65.5%65.5% ترقيق C مرة أخرى سيكلف الآن أكثر من ترقيق B لأول مرة، لذلك تنتقل القاعدة الـ greedy إلى طبقة أخرى. Net_2 = A32 B32 C32 D128، 7.6 ms، 66.4%.
Iteration 3, Con = 7.6 minus 1.0 = 6.6 msالتكرار 3، Con = 7.6 minus 1.0 = 6.6 ms
7.6 ms is still above 7.0 ms, so one more round. Note that the constraint is set from the current latency, not from the budget.
Layerالطبقة Filters keptالـ filters المُبقاة Layer msms الطبقة Total msms الإجمالي Short-term accدقة الـ short-term AA 16 of 3216 من 32 1.81.8 6.46.4 56.4%56.4% BB 8 of 648 من 64 0.50.5 6.56.5 59.6%59.6% CC 8 of 648 من 64 0.50.5 6.66.6 62.2%62.2% D (kept)D (المُختارة) 16 of 12816 من 128 0.40.4 6.56.5 62.7%62.7% Layer D, the widest and least sensitive, wins. Net_3 = A32 B32 C32 D16, 6.5 ms, which is at or below 7.0 ms. The loop stops.
7.6 ms ما زالت فوق 7.0 ms، لذلك نحتاج جولة أخرى. لاحظ أن القيد يُحدَّد من الـ latency الحالية، لا من الميزانية.
Layerالطبقة Filters keptالـ filters المُبقاة Layer msms الطبقة Total msms الإجمالي Short-term accدقة الـ short-term AA 16 of 3216 من 32 1.81.8 6.46.4 56.4%56.4% BB 8 of 648 من 64 0.50.5 6.56.5 59.6%59.6% CC 8 of 648 من 64 0.50.5 6.66.6 62.2%62.2% D (kept)D (المُختارة) 16 of 12816 من 128 0.40.4 6.56.5 62.7%62.7% تفوز الطبقة D، الأعرض والأقل حساسية. Net_3 = A32 B32 C32 D16، 6.5 ms، وهي عند 7.0 ms أو دونها. تتوقف الحلقة.
Long-term fine-tuneالـ long-term fine-tune
Train Net_3 to convergence. Short-term 62.7% becomes 65.2%, a gain of 2.5 points, inside the paper's 1.8 to 4.5 range.درّب Net_3 حتى التقارب. دقة الـ short-term البالغة 62.7% تصبح 65.2%، أي مكسب قدره 2.5 نقطة، داخل نطاق الورقة من 1.8 إلى 4.5.Resultالنتيجة
Three iterations, three valid networks along the way (9.0, 7.6 and 6.5 ms), a final model at 6.5 ms and 65.2%. Layer A, the first layer, was never chosen, because the synthetic model gives it the highest Layer sensitivity by construction, mirroring the part 03 intuition that early layers are expensive to prune.ثلاثة تكرارات، وثلاث شبكات صالحة على طول الطريق (9.0 و7.6 و6.5 ms)، ونموذج نهائي عند 6.5 ms و65.2%. الطبقة A، وهي الطبقة الأولى، لم تُختر أبدًا، لأن النموذج الاصطناعي يعطيها أعلى layer sensitivity عن قصد، بما يعكس حدس الجزء 03 بأن الطبقات المبكرة مكلفة عند تقليمها.
Now run it yourself. The simulator uses the same tables and the same synthetic accuracy model, so its default run reproduces the example above. Then change the budget or the step and watch which layer gets picked: a smaller ΔR takes more iterations, produces more intermediate models, and tends to end slightly higher in accuracy, which is what the paper's schedule study found.
الآن شغّلها بنفسك. يستخدم المحاكي الجداول نفسها ونموذج الدقة الاصطناعي نفسه، لذلك يعيد تشغيله الافتراضي إنتاج المثال أعلاه. ثم غيّر الميزانية أو الخطوة وراقب أي طبقة تُختار: ΔR الأصغر يحتاج تكرارات أكثر، وينتج نماذج وسيطة أكثر، ويميل إلى الانتهاء بدقة أعلى قليلًا، وهذا ما وجدته دراسة الـ schedule في الورقة.
- A32/32
- B64/64
- C64/64
- D128/128
The network starts dense at 10.0 ms and 71.0%. Each press builds one proposal per layer from the lookup table and keeps the one with the highest short-term accuracy.تبدأ الشبكة كثيفة عند 10.0 ms و71.0%. كل ضغطة تبني مقترحًا واحدًا لكل طبقة من جدول البحث، وتحتفظ بالمقترح صاحب أعلى دقة في المدى القصير.
Lookup tables and accuracies are synthetic. Accuracy is 71.0 minus a per-layer penalty that grows with the fraction of filters removed, so early layer A is expensive to cut and layer C is cheap. The latency effect on the next layer's input channels is ignored for readability.جداول البحث والدقة هنا مصطنعة. الدقة تساوي 71.0 ناقص عقوبة لكل طبقة تكبر مع نسبة المرشحات المحذوفة، لذا فقص الطبقة المبكرة A مكلف وقص الطبقة C رخيص. أُهمل أثر زمن الاستجابة على قنوات الإدخال للطبقة التالية تسهيلًا للقراءة.
NetAdapt against AMCNetAdapt مقابل AMC
Both methods answer the question of part 02, which Pruning ratio for which layer, without a human in the loop, and both were published at the same conference. They differ in almost every mechanism, and the NetAdapt paper even uses AMC (under its earlier name, ADC) as a baseline, beating it by 1.2x in latency on the large MobileNetV1.
كلتا الطريقتين تجيبان عن سؤال الجزء 02، أي pruning ratio لأي طبقة، دون إنسان في الحلقة، وكلتاهما نُشرتا في المؤتمر نفسه. وتختلفان في كل آلية تقريبًا، بل إن ورقة NetAdapt تستخدم AMC (باسمه الأقدم ADC) كخط أساس (baseline) وتتفوق عليه بـ 1.2x في الـ latency على MobileNetV1 الكبيرة.
| Aspectالجانب | AMC (part 04)AMC (الجزء 04) | NetAdaptNetAdapt |
|---|---|---|
| Who decides the ratiosمن يقرر النسب | A DDPG agent learns a policy from rewardsوكيل DDPG يتعلم سياسة (policy) من المكافآت | A greedy rule: the proposal with the highest accuracy winsقاعدة greedy: يفوز المقترح الأعلى دقة |
| Search unitوحدة البحث | The agent visits every layer once per episodeيزور الوكيل كل طبقة مرة واحدة في كل حلقة (episode) | One layer changed per iteration, all layers triedتتغير طبقة واحدة في كل تكرار، مع تجربة كل الطبقات |
| Cost modelنموذج الكلفة | FLOPs or latency in the reward, optionally a lookup tableالـ FLOPs أو الـ latency داخل المكافأة، مع جدول بحث اختياري | Per-layer latency lookup table measured on the device and summedجدول بحث لـ latency كل طبقة، مقيس على الجهاز ومجموع |
| Fine-tuningFine-tuning | One fine-tune of the final networkfine-tune واحد للشبكة النهائية | Short-term per proposal, long-term once at the endshort-term لكل مقترح، وlong-term مرة واحدة في النهاية |
| Outputالمُخرَج | One model per targetنموذج واحد لكل هدف | A model at every iteration, the whole frontierنموذج عند كل تكرار، أي المنحنى (frontier) كاملًا |
| Interpretabilityقابلية التفسير | A learned policyسياسة متعلَّمة | Every pick is explainable from measurementsكل اختيار قابل للتفسير من القياسات |
| Paperالورقة | He et al., ECCV 2018He et al., ECCV 2018 | Yang et al., ECCV 2018Yang et al., ECCV 2018 |
Recall
List the NetAdapt steps of one iteration in order.اذكر خطوات تكرار واحد في NetAdapt بالترتيب.
Recall
Why does NetAdapt use a measured per-layer lookup table instead of counting FLOPs or MACs?لماذا يستخدم NetAdapt جدول بحث مقيسًا لكل طبقة بدل عدّ الـ FLOPs أو الـ MACs؟
Recall
What is the short-term fine-tune for, and which accuracy is reported for the final model?ما فائدة الـ short-term fine-tune، وأي دقة تُنشر للنموذج النهائي؟
Quick checkاختبار سريع
In one NetAdapt iteration, what decides which layer's pruned proposal is carried to the next iteration?في تكرار واحد من NetAdapt، ما الذي يحدد أي مقترح (طبقة مقلَّمة) يُنقل إلى التكرار التالي؟
Quick checkاختبار سريع
Why does NetAdapt read a pre-measured lookup table instead of counting FLOPs?لماذا يقرأ NetAdapt جدول بحث مقيسًا مسبقًا بدل عدّ الـ FLOPs؟
Quick checkاختبار سريع
Which accuracy number describes the final NetAdapt model reported in the paper?أي رقم دقة يصف نموذج NetAdapt النهائي المنشور في الورقة؟
Look back at the worked example. The run was aiming for one network at 7.0 ms, but on the way it produced Net_1 at 9.0 ms and Net_2 at 7.6 ms, and neither took any extra work. Each was the best of its round and each already satisfied its own, slightly looser, constraint. Slide 40 is that observation at full scale: the number of models equals the number of iterations.
عُد إلى المثال المحلول. كان التشغيل يهدف إلى شبكة واحدة عند 7.0 ms، لكنه أنتج في الطريق Net_1 عند 9.0 ms وNet_2 عند 7.6 ms، ولم تتطلب أي منهما عملًا إضافيًا. كل منهما كانت الأفضل في جولتها وكانت تحقق بالفعل قيدها الخاص الأوسع قليلًا. الشريحة 40 هي هذه الملاحظة على نطاق كامل: عدد النماذج يساوي عدد التكرارات.
The paper states it directly. Besides the final network, NetAdapt can generate a sequence of simplified networks, the highest-accuracy network from each iteration Net_1 to Net_i, which together provide the efficient frontier of accuracy and resource consumption trade-offs. The authors call it a family of simplified networks that allows dynamic network selection. With the 0.5 ms initial step and 0.96 decay, the small MobileNetV1 run in Table 2 took 28 iterations, so it delivered 28 networks. The red dots on slide 40 are a series of the same kind plotted the same way, one dot per iteration winner, from about 3.5 ms to 11 ms.
تقول الورقة ذلك صراحة. إلى جانب الشبكة النهائية، يستطيع NetAdapt توليد سلسلة من الشبكات المبسَّطة، أي الشبكة الأعلى دقة من كل تكرار من Net_1 إلى Net_i، وهي معًا تشكّل المنحنى الكفء (efficient frontier) للمفاضلة بين الدقة واستهلاك المورد. ويسميها المؤلفون عائلة من الشبكات المبسَّطة تتيح اختيار الشبكة ديناميكيًا. مع خطوة ابتدائية قدرها 0.5 ms وتناقص بمعامل 0.96، استغرق تشغيل MobileNetV1 الصغيرة في Table 2 عدد 28 تكرارًا، فأعطى 28 شبكة. النقاط الحمراء في الشريحة 40 سلسلة من النوع نفسه مرسومة بالطريقة نفسها، نقطة لكل فائز في تكرار، من نحو 3.5 ms إلى 11 ms.
Reading the chartقراءة الرسم
The horizontal axis is latency on a single large core of a Pixel 1 CPU, measured with TensorFlow Lite as the median of eleven runs. The vertical axis is ImageNet top-1 accuracy. The red dots are the NetAdapt model series for the small MobileNetV1; the green triangles are MobileNetV1 shrunk with the width and resolution multipliers, which is Uniform shrinking from part 02; the blue diamond is MorphNet. The two arrows pick a multiplier point and the MorphNet point and slide left along a horizontal line to the NetAdapt curve, which is where the speedups on the slide come from.
المحور الأفقي هو الـ latency على نواة كبيرة واحدة من معالج Pixel 1، مقيسة باستخدام TensorFlow Lite كوسيط (median) لإحدى عشرة مرة تشغيل. المحور الرأسي هو دقة top-1 على ImageNet. النقاط الحمراء هي model series الخاصة بـ NetAdapt لشبكة MobileNetV1 الصغيرة؛ والمثلثات الخضراء هي MobileNetV1 مصغَّرة بمضاعِفَي العرض والدقة المكانية (width and resolution multipliers)، وهذا هو uniform shrinking من الجزء 02؛ والمعيّن الأزرق هو MorphNet. يختار السهمان نقطة من الـ multiplier ونقطة MorphNet وينزلقان يسارًا على خط أفقي حتى منحنى NetAdapt، ومن هنا تأتي أرقام التسريع في الشريحة.
| Methodالطريقة | Latencyالـ Latency | Top-1Top-1 |
|---|---|---|
| NetAdapt, smallest pointNetAdapt، أصغر نقطة | about 3.5 msنحو 3.5 ms | about 43.0%نحو 43.0% |
| NetAdapt, matched to MorphNetNetAdapt، المقابلة لـ MorphNet | about 4.4 msنحو 4.4 ms | about 46.3%نحو 46.3% |
| MorphNetMorphNet | about 7.0 ms (6.52 ms in Table 1)نحو 7.0 ms (6.52 ms في Table 1) | 46.0%46.0% |
| NetAdapt, matched to the multiplierNetAdapt، المقابلة للـ multiplier | about 7.3 msنحو 7.3 ms | about 53.1%نحو 53.1% |
| Width multiplier baselineخط أساس الـ width multiplier | about 12.1 msنحو 12.1 ms | about 52.7%نحو 52.7% |
| NetAdapt, largest pointNetAdapt، أكبر نقطة | about 11.1 msنحو 11.1 ms | about 56.8%نحو 56.8% |
From about 12.1 ms to about 7.3 ms is 1.7x faster with 0.3% higher accuracy than the multiplier baseline. From about 7.0 ms to about 4.4 ms is 1.6x faster with 0.3% higher accuracy than MorphNet. Across the whole curve the paper summarises it as up to 1.7x faster with the same or higher accuracy. On a mobile GPU (Samsung Galaxy S8 through SNPE) the gain drops to about 1.2x, because about 6.2 ms of that pipeline's latency is overhead that no amount of pruning can remove.
الانتقال من نحو 12.1 ms إلى نحو 7.3 ms يعني تسريعًا بـ 1.7x مع دقة أعلى بـ 0.3% من خط أساس الـ multiplier. والانتقال من نحو 7.0 ms إلى نحو 4.4 ms يعني تسريعًا بـ 1.6x مع دقة أعلى بـ 0.3% من MorphNet. وعلى امتداد المنحنى كله تلخّص الورقة النتيجة بأنها أسرع حتى 1.7x بدقة مساوية أو أعلى. على معالج رسوميات محمول (Samsung Galaxy S8 عبر SNPE) ينخفض المكسب إلى نحو 1.2x، لأن نحو 6.2 ms من latency ذلك المسار كلفة ثابتة (overhead) لا يستطيع أي قدر من الـ pruning إزالتها.
Why does the frontier beat the multipliers at all? A width multiplier thins every layer by the same factor, so it cannot express that some layers matter more. NetAdapt's greedy picks build a non-uniform architecture: the paper's Fig. 10 shows it keeping more filters in layer 6, where the feature map resolution drops, and in the last convolution that feeds the 1000-class classifier, while cutting layers 7 to 10 harder. That is the same lesson as part 02, now discovered by measurement rather than by a sensitivity sweep.
لماذا يتفوق المنحنى على الـ multipliers أصلًا؟ الـ width multiplier يرقّق كل طبقة بالمعامل نفسه، فلا يستطيع التعبير عن أن بعض الطبقات أهم من غيرها. أما اختيارات NetAdapt الـ greedy فتبني بنية غير منتظمة (non-uniform): يُظهر Fig. 10 في الورقة أنها تُبقي filters أكثر في الطبقة 6، حيث تنخفض الدقة المكانية لخريطة الخصائص (feature map)، وفي آخر convolution تغذي المصنِّف ذا الـ 1000 فئة، بينما تقطع الطبقات من 7 إلى 10 بقوة أكبر. هذا هو درس الجزء 02 نفسه، لكنه مكتشف الآن بالقياس لا بمسح الحساسية (sensitivity sweep).
What the schedule does to the seriesماذا يفعل الـ schedule بالسلسلة
Because the series is a by-product of the loop, the step size shapes it. The paper compares three schedules for the same target latency.
بما أن السلسلة ناتج جانبي للحلقة، فإن حجم الخطوة يشكّلها. تقارن الورقة ثلاثة schedules للـ latency المستهدفة نفسها.
| Initial ΔRΔR الابتدائية | Decayمعامل التناقص | Iterationsالتكرارات | Top-1Top-1 | Latencyالـ Latency |
|---|---|---|---|---|
| 0.5 ms0.5 ms | 0.960.96 | 2828 | 47.7%47.7% | 4.63 ms4.63 ms |
| 0.5 ms0.5 ms | 1.01.0 | 2020 | 47.4%47.4% | 4.71 ms4.71 ms |
| 0.8 ms0.8 ms | 0.950.95 | 2020 | 46.7%46.7% | 4.65 ms4.65 ms |
Recall
Why does one NetAdapt run give a series of models, and how many?لماذا يعطي تشغيل واحد لـ NetAdapt سلسلة من النماذج، وكم عددها؟
Quick checkاختبار سريع
A NetAdapt run needs 28 iterations to reach its latency budget. How many trade-off models does it produce along the way?يحتاج تشغيل NetAdapt إلى 28 تكرارًا للوصول إلى ميزانية الـ latency. كم نموذجًا للمفاضلة ينتج في الطريق؟
Quick checkاختبار سريع
Compared with the width-multiplier baseline on slide 40, what does the NetAdapt model series achieve?مقارنة بخط أساس الـ width multiplier في الشريحة 40، ماذا تحقق سلسلة نماذج NetAdapt؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- NetAdapt solves maximize Acc(Net) subject to Res(Net) <= Bud by tightening the constraint by Delta R every iteration, a progressive barrier rather than one big cut.يحل NetAdapt مسألة تعظيم Acc(Net) بشرط Res(Net) <= Bud عن طريق تضييق القيد بمقدار Delta R في كل تكرار، أي حاجز تدريجي بدل قطع واحد كبير.
- Each iteration thins exactly one layer: for every layer, read the filter count that meets Res minus Delta R from the lookup table, keep the largest-l2 filters, short-term fine-tune, measure holdout accuracy; keep the best proposal.كل تكرار يرقّق طبقة واحدة فقط: لكل طبقة، اقرأ من جدول البحث عدد الـ filters الذي يحقق Res ناقص Delta R، واحتفظ بالـ filters ذات أكبر l2، ثم نفّذ short-term fine-tune، وقِس الدقة على مجموعة holdout؛ ثم احتفظ بأفضل مقترح.
- Latency comes from summed per-layer lookup tables measured on the target device. MACs are an indirect metric: the paper shows 19 percent fewer MACs running 29 percent slower.تأتي الـ latency من جمع جداول بحث لكل طبقة مقيسة على الجهاز المستهدف. الـ MACs مقياس غير مباشر: تُظهر الورقة شبكة فيها MACs أقل بنسبة 19 بالمئة لكنها أبطأ بنسبة 29 بالمئة.
- The short-term fine-tune only ranks candidates; one long-term fine-tune at the end recovers 1.8 to 4.5 points and is the accuracy that gets reported.الـ short-term fine-tune يرتب المرشحين فقط؛ أما long-term fine-tune واحد في النهاية فيستعيد من 1.8 إلى 4.5 نقطة، وهو الدقة التي تُنشر في النتائج.
- Delta R is a schedule: 0.5 ms decaying by 0.96 per iteration gave 28 iterations and 47.7 percent for the small MobileNetV1; larger steps finish sooner at a cost in accuracy, and for the same iteration count a smaller initial step with slower decay is preferable.Delta R جدول زمني (schedule): البدء بـ 0.5 ms مع تناقص بمعامل 0.96 في كل تكرار أعطى 28 تكرارًا ودقة 47.7 بالمئة لشبكة MobileNetV1 الصغيرة؛ الخطوات الأكبر تنتهي أسرع لكن على حساب الدقة، ولنفس عدد التكرارات يُفضَّل خطوة ابتدائية أصغر مع تناقص أبطأ.
- Number of models equals number of iterations, so one run traces the accuracy versus latency frontier: 1.7x faster than width multipliers and 1.6x faster than MorphNet at equal or 0.3 percent higher accuracy on a Pixel 1 CPU.عدد النماذج يساوي عدد التكرارات، لذلك يرسم تشغيل واحد منحنى المفاضلة بين الدقة والـ latency: أسرع بـ 1.7x من الـ width multipliers وأسرع بـ 1.6x من MorphNet بدقة مساوية أو أعلى بـ 0.3 بالمئة على معالج Pixel 1.
- Versus AMC: a greedy rule instead of an RL agent, one layer per iteration, a measured lookup table, and a model at every iteration.مقارنة بـ AMC: قاعدة greedy بدل وكيل RL، وطبقة واحدة في كل تكرار، وجدول بحث مقيس، ونموذج عند كل تكرار.
Sourcesالمصادر
- NetAdapt: Platform-Aware Neural Network Adaptation for Mobile ApplicationsPaperECCV 2018, Yang, Howard, Chen, Zhang, Go, Sandler, Sze and Adam (arXiv)Eq. 1 and 2, Algorithm 1, lookup tables, Table 1 (MACs versus latency), Table 2 (schedules), Fig. 5 (slide 40), fine-tuning ablations.المعادلتان 1 و2، وAlgorithm 1، وجداول البحث، والجدول 1 (الـ MACs مقابل الـ latency)، والجدول 2 (الـ schedules)، والشكل 5 (الشريحة 40)، وتجارب الحذف (ablations) الخاصة بالـ fine-tuning.(opens in a new tab)(يفتح في تبويب جديد)
- NetAdapt, ECCV 2018 open-access PDFPaperEuropean Computer Vision AssociationCamera-ready version with the figures reproduced on slides 33 to 40.النسخة النهائية (camera-ready) التي تحتوي الأشكال المعاد عرضها في الشرائح من 33 إلى 40.(opens in a new tab)(يفتح في تبويب جديد)
- 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2023, Lecture 4: Pruning and Sparsity Part IIDocsMIT HAN LabThe source deck for slides 33 to 40 of this lecture.مجموعة الشرائح الأصلية للشرائح من 33 إلى 40 في هذه المحاضرة.(opens in a new tab)(يفتح في تبويب جديد)
- AMC: AutoML for Model Compression and Acceleration on Mobile DevicesPaperECCV 2018, He, Lin, Liu, Wang, Li and Han (arXiv)The reinforcement learning counterpart, used as the ADC baseline in the NetAdapt paper.النظير القائم على التعلّم المعزَّز (reinforcement learning)، والمستخدم كخط أساس ADC في ورقة NetAdapt.(opens in a new tab)(يفتح في تبويب جديد)
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision ApplicationsPaperHoward et al., 2017 (arXiv)Width and resolution multipliers, the uniform-shrinking baseline on slide 40.مضاعِفا العرض والدقة المكانية (width and resolution multipliers)، أي خط أساس الـ uniform shrinking في الشريحة 40.(opens in a new tab)(يفتح في تبويب جديد)
- MorphNet: Fast and Simple Resource-Constrained Structure Learning of Deep NetworksPaperCVPR 2018, Gordon et al. (arXiv)The MorphNet baseline point on slide 40.نقطة خط أساس MorphNet في الشريحة 40.(opens in a new tab)(يفتح في تبويب جديد)
- Searching for MobileNetV3PaperICCV 2019, Howard et al. (arXiv)NetAdapt as the finishing step after hardware-aware architecture search.NetAdapt كخطوة أخيرة بعد البحث المعماري الواعي بالعتاد (hardware-aware architecture search).(opens in a new tab)(يفتح في تبويب جديد)
Part 06: Fine-tuning, iterative pruning and regularizationالضبط الدقيق والتقليم التكراري والتنظيم
Pruning costs accuracy, fine-tuning at a much smaller learning rate recovers it, repeating prune and fine-tune pushes AlexNet from 5x to 9x compression, and L1 or L2 regularization during training makes weights easier to prune.التقليم يكلّف دقة، والضبط الدقيق بمعدل تعلم أصغر بكثير يستعيدها، وتكرار التقليم والضبط الدقيق يرفع ضغط AlexNet من 5x إلى 9x، والتنظيم L1 أو L2 أثناء التدريب يجعل الأوزان أسهل تقليمًا.
4 concepts4 مفاهيم, ، slides 41-52الشرائح 41-52
Why this part mattersلماذا يهمّ هذا الجزء
Every pruning method in this course, magnitude pruning, AMC, NetAdapt and the 2:4 sparsity of part 10, only reaches its quoted ratio because a fine-tuning step follows the cut. The EIE numbers in the next part assume the roughly 89% weight sparsity that this part explains how to obtain.
This is the fifth of the five questions the lecture opened with, and for embedded research it is the recipe you will actually run: cut, retrain the survivors gently, cut again. Two hyperparameters decide whether the loop works, the learning rate during fine-tuning and the regularizer used during training, and both are favorite exam questions because each has a single number or a single formula attached.
كل طريقة تقليم في هذا المقرر، الـ magnitude pruning والـ AMC والـ NetAdapt والـ2:4 sparsity في الجزء 10، لا تصل إلى النسبة المذكورة لها إلا لأن خطوة fine-tuningتأتي بعد القطع. وأرقام EIE في الجزء التالي تفترض weight sparsity تقارب 89%، وهذا الجزء يشرح كيف نحصل عليها.
هذا هو السؤال الخامس من الأسئلة الخمسة التي افتُتحت بها المحاضرة، وفي بحوث الأنظمة المدمجة هو الوصفة التي ستنفّذها فعلًا: اقطع، ثم أعِد تدريب الأوزان الباقية بلطف، ثم اقطع مرة أخرى. هناك معاملان فائقان (hyperparameters) يحددان هل تنجح الحلقة أم لا: معدل التعلّم أثناء الـ fine-tuning، والـregularizer المستخدم أثناء التدريب. وكلاهما من أسئلة الامتحان المفضّلة لأن لكل منهما رقمًا واحدًا أو معادلة واحدة مرتبطة به.
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain why accuracy drops after pruning and why fine-tuning at 1/10 to 1/100 of the original learning rate recovers it.أن تشرح لماذا تنخفض الدقة بعد التقليم (pruning)، ولماذا يستعيدها الـ fine-tuning بمعدل تعلّم يساوي 1/10 إلى 1/100 من معدل التعلّم الأصلي.
- Draw the Train Connectivity, Prune Connections, Train Weights pipeline with its loop arrow, and define one iteration.أن ترسم خط المعالجة Train Connectivity ثم Prune Connections ثم Train Weights مع سهم الحلقة، وأن تعرّف التكرار الواحد (iteration).
- Read the three accuracy-loss curves and quote the 5x to 9x AlexNet result with its parameter counts.أن تقرأ منحنيات فقدان الدقة الثلاثة، وأن تذكر نتيجة AlexNet من 5x إلى 9x مع أعداد المعاملات.
- Write the L1 and L2 regularized losses, say which yields exact zeros, and explain why L2 still won for magnitude pruning.أن تكتب دالتَي الخسارة مع الـ L1 والـ L2 regularization، وأن تقول أيّهما يعطي أصفارًا تامة، وأن تشرح لماذا فاز الـ L2 مع ذلك في الـ magnitude pruning.
- Connect Network Slimming's penalty on batch norm scaling factors to scaling-based channel pruning from lecture 04-1.أن تربط عقوبة Network Slimming على معاملات التحجيم (scaling factors) في الـ batch norm بتقليم القنوات المبني على التحجيم من المحاضرة 04-1.
Take the AlexNet that Han, Pool, Tran and Dally started from in 2015: 61 million parameters, five convolution layers and three fully connected ones, 57.2% top-1 accuracy. They kept roughly one weight in nine and ended with a network that was not measurably worse. That is the headline of this part, and the whole trick behind it is what happens after the cut.
خذ شبكة AlexNet التي بدأ منها Han وPool وTran وDally عام 2015: 61 million معامل، وخمس طبقات convolution وثلاث طبقات fully connected، ودقة top-1 قدرها 57.2%. أبقوا تقريبًا وزنًا واحدًا من كل تسعة، وانتهوا بشبكة ليست أسوأ بشكل يمكن قياسه. هذا هو العنوان الرئيسي لهذا الجزء، والحيلة كلها وراءه هي ما يحدث بعد القطع.
AlexNet before and after prune plus retrain (Han et al. 2015, Table 1 and section 4.2)AlexNet قبل التقليم مع إعادة التدريب وبعده (Han et al. 2015، الجدول 1 والقسم 4.2)
- Parametersعدد المعاملات
- 61M to 6.7M (9x)من 61M إلى 6.7M (9x)
- Top-1 errorخطأ top-1
- 42.78% to 42.77%من 42.78% إلى 42.77%
- Top-5 errorخطأ top-5
- 19.73% to 19.67%من 19.73% إلى 19.67%
- Original training timeزمن التدريب الأصلي
- 75 hours on a Titan X75 ساعة على Titan X
- Retraining time after pruningزمن إعادة التدريب بعد التقليم
- 173 hours at 1/100 of the initial learning rate173 ساعة بمعدل تعلّم يساوي 1/100 من معدل التعلّم الابتدائي
Now look at what those hours say. Retraining took more than twice as long as training. The authors did not treat it as optional polish; section 3 of the paper calls the final retraining step critical and states that if the pruned network is used without retraining, accuracy is significantly impacted. So the answer to the outline's fifth question, how to fine-tune a pruned network, is a method, not a footnote: the Pruning mask decides which weights exist, and Fine-tuning decides whether the survivors can still do the job.
انظر الآن إلى ما تقوله تلك الساعات. استغرقت إعادة التدريب أكثر من ضعف مدة التدريب. لم يعامل المؤلفون هذه الخطوة كتلميع اختياري؛ فالقسم 3 من الورقة يصف خطوة إعادة التدريب الأخيرة بأنها حاسمة، ويقرر أنه إذا استُخدمت الشبكة المقلَّمة دون إعادة تدريب فإن الدقة تتأثر بشكل كبير. لذلك فإن جواب السؤال الخامس في المخطط، أي كيف نعمل fine-tune لشبكة مقلَّمة، هو طريقة قائمة بذاتها لا حاشية: الـ mask الخاص بالـ pruning يقرر أي الأوزان موجودة، والـ fine-tuning يقرر هل تستطيع الأوزان الباقية أن تؤدي المهمة.
Why the survivors are wounded, and why the wound healsلماذا تتضرر الأوزان الباقية، ولماذا يلتئم الجرح
A trained layer is a set of weights that were optimized together. Zeroing the smallest of them, the magnitude criterion from lecture 04-1, is a small perturbation to any one output, but a large Pruning ratio removes so many small contributions that the outputs shift and the accuracy drops, more steeply the higher the ratio (this is what the chart on the slide shows for the dashed curve). The survivors are still near a good solution, though. Nothing about them was wrong; the function they were tuned to complete simply lost some of its terms. Fine-tuning continues gradient descent on exactly those survivors, with the removed weights held at zero, so they can absorb the work of the missing ones.
الطبقة المدرَّبة هي مجموعة أوزان جرى تحسينها معًا. تصفير أصغرها، أي magnitude criterion من المحاضرة 04-1، هو اضطراب صغير لأي مخرج منفرد، لكن pruning ratio كبيرة تزيل مساهمات صغيرة كثيرة جدًا، فتنزاح المخرجات وتنخفض الدقة، ويكون الانخفاض أشد كلما ارتفعت النسبة (وهذا ما يُظهره الرسم في الشريحة للمنحنى المتقطع). ومع ذلك تبقى الأوزان الباقية قريبة من حل جيد. لم يكن فيها أي خطأ؛ كل ما في الأمر أن الدالة التي ضُبطت لتكملها فقدت بعض حدودها. الـ fine-tuning يواصل الـ gradient descent على تلك الأوزان الباقية تحديدًا، مع إبقاء الأوزان المحذوفة عند الصفر، فتستطيع أن تتحمّل عمل الأوزان المفقودة.
This is why the learning rate matters so much. The slide states the rule: the fine-tuning learning rate is usually 1/100 or 1/10 of the original learning rate. In the paper, LeNet was retrained at 1/10 of the original rate (section 4.1) and AlexNet at 1/100 of the initial rate (section 4.2). A large step would throw the weights out of the basin in which the magnitude ranking was measured, undoing the very judgement the pruning made. Small steps walk the network back down the loss surface from where the cut left it.
ولهذا يهمّ معدل التعلّم كثيرًا. تذكر الشريحة القاعدة: معدل التعلّم في الـ fine-tuning يكون عادةً 1/100 أو 1/10 من معدل التعلّم الأصلي. في الورقة، أُعيد تدريب LeNet بمعدل 1/10 من المعدل الأصلي (القسم 4.1)، وأُعيد تدريب AlexNet بمعدل 1/100 من المعدل الابتدائي (القسم 4.2). الخطوة الكبيرة سترمي الأوزان خارج الحوض (basin) الذي قيس فيه ترتيب المقادير، فتُلغي الحكم نفسه الذي بنى عليه التقليم قراره. أما الخطوات الصغيرة فتعيد الشبكة نزولًا على سطح الخسارة من المكان الذي تركها فيه القطع.
Slide 41 makes the same point as an optimization statement. Pruning poses the problem as minimizing the loss over the pruned weights W_P subject to a budget N on the L0 norm, the count of nonzero weights. The mask chooses which entries of W_P may be nonzero at all (the constraint), and fine-tuning is the argmin over the survivors with that mask fixed: the best values the kept weights can take.
الشريحة 41 تقول الفكرة نفسها في صيغة مسألة تحسين. التقليم يصوغ المسألة على أنها تقليل الخسارة على الأوزان المقلَّمة W_P بشرط ميزانية N على الـ L0 norm، أي عدد الأوزان غير الصفرية. الـ mask يختار أي عناصر W_P يُسمح لها أصلًا بأن تكون غير صفرية (القيد)، والـ fine-tuning هو الـ argmin على الأوزان الباقية مع تثبيت ذلك الـ mask: أفضل قيم يمكن أن تأخذها الأوزان المحتفَظ بها.
The paper adds a second reason to keep the survivors instead of re-initializing them. Section 3.3 observes that networks contain fragile co-adapted features: gradient descent finds a good solution when the network is first trained, but not after re-initializing some layers and retraining them. Fine-tuning starts from the co-adapted weights and preserves that structure. The paper also notes that during retraining it can help to fix the convolution parameters while the fully connected ones retrain, and vice versa, to avoid vanishing gradients through the sparse layers.
تضيف الورقة سببًا ثانيًا للاحتفاظ بالأوزان الباقية بدل إعادة تهيئتها. يلاحظ القسم 3.3 أن الشبكات تحتوي على سمات هشّة متكيّفة معًا (co-adapted features): الـ gradient descent يجد حلًا جيدًا عند تدريب الشبكة أول مرة، لكنه لا يجده بعد إعادة تهيئة بعض الطبقات وإعادة تدريبها. الـ fine-tuning يبدأ من الأوزان المتكيّفة معًا ويحافظ على تلك البنية. وتذكر الورقة أيضًا أنه قد يفيد أثناء إعادة التدريب تثبيت معاملات الـ convolution بينما يُعاد تدريب طبقات الـ fully connected، والعكس، لتجنّب تلاشي المشتقات (vanishing gradients) عبر الطبقات المتفرّقة.
The three-box pipelineخط المعالجة ذو الصناديق الثلاثة
The figure on the slide is Figure 2 of the paper. The first box, Train Connectivity, is ordinary training, but its purpose is reframed: it learns which connections are important, not their final values. The second box, Prune Connections, applies the magnitude threshold. The third box, Train Weights, retrains the sparse network. In Han et al.'s implementation the threshold was a quality parameter multiplied by the standard deviation of each layer's weights, and Caffe was modified to add a mask that disregards pruned parameters during network operation for each weight tensor.
الشكل في الشريحة هو Figure 2 من الورقة. الصندوق الأول، Train Connectivity، تدريب عادي، لكن غرضه أُعيدت صياغته: هو يتعلّم أي الاتصالات مهمة، لا قيمها النهائية. الصندوق الثاني، Prune Connections، يطبّق عتبة المقدار. والصندوق الثالث، Train Weights، يعيد تدريب الشبكة المتفرّقة. في تطبيق Han et al. كانت العتبة معامل جودة مضروبًا في الانحراف المعياري لأوزان كل طبقة، وعُدّل Caffe بإضافة mask لكل tensor أوزان يتجاهل المعاملات المقلَّمة أثناء تشغيل الشبكة.
Learn which connections matter, not just their values.
تعلّم أي الوصلات مهمة، لا قيمها فقط.
Zero weights below the threshold and fix the mask.
صفّر الأوزان التي تحت الحد وثبّت القناع.
Retrain the sparse network to recover accuracy.
أعد تدريب الشبكة المتناثرة لاستعادة الدقة.
Reading the chart on slide 43قراءة الرسم في الشريحة 43
The chart plots accuracy loss against the fraction of parameters pruned away for AlexNet. The dashed purple curve is pruning with no retraining; the green curve adds fine-tuning. Reading the points off the figure gives the following.
يرسم المخطط فقدان الدقة مقابل نسبة المعاملات المقلَّمة في AlexNet. المنحنى البنفسجي المتقطع هو التقليم دون إعادة تدريب؛ والمنحنى الأخضر يضيف الـ fine-tuning. قراءة النقاط من الشكل تعطي ما يلي.
| Pruned awayالنسبة المقلَّمة | Pruning onlyالتقليم فقط | Pruning + fine-tuningالتقليم مع fine-tuning |
|---|---|---|
| 50%50% | about -0.1نحو -0.1 | about 0.0نحو 0.0 |
| 67%67% | about -0.9نحو -0.9 | about +0.2نحو +0.2 |
| 75%75% | about -2.1نحو -2.1 | about +0.2نحو +0.2 |
| 80%80% | about -4.0نحو -4.0 | about 0.0نحو 0.0 |
| 85.5%85.5% | off the chartخارج الرسم | about -0.5نحو -0.5 |
| 90%90% | off the chartخارج الرسم | about -1.7نحو -1.7 |
| 93%93% | off the chartخارج الرسم | about -3.8نحو -3.8 |
The paper summarizes the same curves in section 5: without retraining, accuracy begins dropping much sooner, at one third of the original connections rather than one tenth. It describes a free lunch of removing half the connections with no loss even without retraining, while with retraining the connections can be reduced by 9x. Read that 9x carefully: it is reached with the iterative scheme of the next two concepts. A single prune and retrain, the green curve, is already at about -1.7% by 90% pruned. Two green points (at about 67% and 75% pruned) sit slightly above zero, which the authors attribute to pruning finding the right capacity of the network and thereby reducing overfitting. Because sparsity and compression ratio are two ways of saying the same thing, keep the conversion at hand: ratio = 1 / (1 - s).
تلخّص الورقة المنحنيات نفسها في القسم 5: دون إعادة تدريب تبدأ الدقة بالانخفاض أبكر بكثير، عند بقاء ثلث الاتصالات الأصلية بدل العُشر. وتصف "وجبة مجانية" (free lunch) هي إزالة نصف الاتصالات دون أي فقدان حتى بلا إعادة تدريب، بينما مع إعادة التدريب يمكن تقليل الاتصالات بمقدار 9x. اقرأ هذا الـ 9x بعناية: فهو يتحقق بالمخطط التكراري في المفهومين التاليين. أما تقليم واحد مع إعادة تدريب واحدة، أي المنحنى الأخضر، فيكون عند نحو -1.7% بالفعل عند 90% مقلَّمة. وتقع نقطتان خضراوان (عند نحو 67% و75% مقلَّمة) فوق الصفر بقليل، ويعزو المؤلفون ذلك إلى أن التقليم يجد السعة المناسبة للشبكة فيقلّل الـ overfitting. ولأن الـ sparsity ونسبة الضغط طريقتان لقول الشيء نفسه، أبقِ التحويل في متناول يدك: النسبة = 1 / (1 - s).
| Ratioالنسبة | Pruned awayالنسبة المقلَّمة |
|---|---|
| 2x2x | 50%50% |
| 3x3x | 66.7%66.7% |
| 5x5x | 80%80% |
| 9x9x | 88.9%88.9% |
| 10x10x | 90%90% |
| 13x13x | 92.3%92.3% |
Quick checkاختبار سريع
Fine-tuning a pruned network usually uses which learning rate, relative to the original?ما معدل التعلّم المستخدم عادةً في الـ fine-tuning لشبكة مقلَّمة، مقارنةً بالمعدل الأصلي؟
Recall
What learning rate does fine-tuning a pruned network usually use, and why?ما معدل التعلّم المستخدم عادةً في الـ fine-tuning لشبكة مقلَّمة، ولماذا؟
Once retraining is part of the recipe, a natural question follows: why cut to the final sparsity in one go? The slides tell the story as a sequence. Prune to 30%, retrain the weights. Prune to 50%, retrain. Prune to 70%, retrain. The only change to the pipeline figure is a single arrow from Train Weights back up to Prune Connections, and that arrow is the whole idea of Iterative pruning.
ما دامت إعادة التدريب جزءًا من الوصفة، فإن سؤالًا طبيعيًا يتبع: لماذا نقطع إلى الـ sparsity النهائية دفعة واحدة؟ الشرائح تروي القصة كسلسلة. قلّم إلى 30%، وأعِد تدريب الأوزان. قلّم إلى 50%، وأعِد التدريب. قلّم إلى 70%، وأعِد التدريب. التغيير الوحيد في شكل خط المعالجة هو سهم واحد من Train Weights عائدًا إلى Prune Connections، وهذا السهم هو الفكرة كلها في الـ iterative pruning.
Define the unit first: one iteration is a prune followed by a fine-tune. Iterative pruning repeats that unit while gradually increasing the target sparsity in each iteration, instead of jumping to the final sparsity in one step. Han et al. put it plainly in section 3.4: learning the right connections is an iterative process, pruning followed by retraining is one iteration, and after many such iterations the minimum number of connections can be found. Each iteration is a greedy search for the best connections. They also tried pruning parameters probabilistically by absolute value and found it gave worse results.
عرّف الوحدة أولًا: التكرار الواحد هو prune يتبعه fine-tune. الـ iterative pruning يكرر هذه الوحدة مع رفع الـ sparsity المستهدفة تدريجيًا في كل تكرار، بدل القفز إلى الـ sparsity النهائية في خطوة واحدة. يقولها Han et al. بوضوح في القسم 3.4: تعلّم الاتصالات الصحيحة عملية تكرارية، والتقليم متبوعًا بإعادة التدريب تكرار واحد، وبعد تكرارات كثيرة كهذه يمكن الوصول إلى أقل عدد من الاتصالات. كل تكرار هو بحث جشع (greedy search) عن أفضل الاتصالات. وجرّبوا أيضًا تقليم المعاملات احتماليًا بحسب قيمتها المطلقة فوجدوا أنه يعطي نتائج أسوأ.
Why gradual beats one-shotلماذا يتفوّق التدريج على القطع دفعة واحدة
The magnitude criterion ranks weights on the network as it is right now. After a 30% cut and a fine-tune, the survivors have re-settled: some grew to cover the removed terms, some shrank because their job was taken over. The ranking for the next cut is therefore measured on a network that has adapted, and the weights it marks as small really are the least needed. A one-shot cut to 90% ranks all 90% on a network that has never adapted to any loss, so it discards weights that would have become important once their neighbors were gone. Zhu and Gupta describe the same principle in the general form of a sparsity schedule: the binary mask is updated every few hundred steps to gradually increase the sparsity of the network while allowing the training steps to recover from any pruning-induced loss in accuracy. Their cubic schedule prunes quickly at first, when redundant connections are abundant, and slowly near the end.
معيار المقدار يرتّب الأوزان على الشبكة كما هي الآن. بعد قطع 30% وعمل fine-tune، تكون الأوزان الباقية قد استقرّت من جديد: بعضها كبر ليغطي الحدود المحذوفة، وبعضها صغر لأن غيره تولّى عمله. لذلك فإن الترتيب للقطع التالي يُقاس على شبكة تكيّفت، والأوزان التي يعلّمها بأنها صغيرة هي فعلًا الأقل حاجة. أما القطع دفعة واحدة إلى 90% فيرتّب الـ 90% كلها على شبكة لم تتكيّف مع أي فقدان، فيتخلّص من أوزان كانت ستصبح مهمة بعد ذهاب جيرانها. يصف Zhu وGupta المبدأ نفسه في صورته العامة كجدول sparsity: يُحدَّث الـ binary mask كل بضع مئات من الخطوات لرفع sparsity الشبكة تدريجيًا، مع السماح لخطوات التدريب بأن تتعافى من أي فقدان في الدقة سبّبه التقليم. وجدولهم التكعيبي (cubic) يقلّم بسرعة في البداية، حين تكون الاتصالات الزائدة وفيرة، وببطء قرب النهاية.
The schedule in this part uses five hand-picked targets rather than a closed form, but the shape is the same: larger cuts early, smaller ones late. On a 6 x 6 matrix of 36 weights, rounding 36 s gives the following zero counts, which are also what the simulator below shows.
الجدول في هذا الجزء يستخدم خمسة أهداف مختارة يدويًا بدل صيغة مغلقة، لكن الشكل واحد: قطعات أكبر في البداية، وأصغر في النهاية. على مصفوفة 6 x 6 من 36 وزنًا، تقريب 36 s يعطي أعداد الأصفار التالية، وهي أيضًا ما يعرضه المحاكي أدناه.
| Targetالهدف | Zerosالأصفار | Nonzeros leftغير الصفرية الباقية | Actual sparsityالـ sparsity الفعلية | Ratioالنسبة |
|---|---|---|---|---|
| 30%30% | 1111 | 2525 | 30.6%30.6% | 1.4x1.4x |
| 50%50% | 1818 | 1818 | 50.0%50.0% | 2.0x2.0x |
| 70%70% | 2525 | 1111 | 69.4%69.4% | 3.3x3.3x |
| 80%80% | 2929 | 77 | 80.6%80.6% | 5.1x5.1x |
| 90%90% | 3232 | 44 | 88.9%88.9% | 9.0x9.0x |
Illustrative only. Fine-tuning is stood in for by letting each surviving weight in a row absorb 0.5 of the magnitude its row just lost, an echo of the surviving weights spreading outward in Han et al. Figure 7. The two loss curves are shape fits to the green and red curves of slide 51, not measured data. Cells with a teal border were zeroed in the latest step; survivors with a bright border moved up the magnitude ranking.للتوضيح فقط. يُحاكى الضبط الدقيق بأن يمتص كل وزن باقٍ في الصف 0.5 من المقدار الذي خسره صفه للتو، صدى لانتشار الأوزان الباقية نحو الخارج في الشكل 7 من Han et al.. منحنيا الخسارة مطابقة شكلية للمنحنيين الأخضر والأحمر في الشريحة 51، وليسا بيانات مقيسة. الخلايا ذات الحد الأزرق المخضر صُفّرت في الخطوة الأخيرة، والأوزان الباقية ذات الحد الساطع ارتفعت في ترتيب المقدار.
The loop also connects backwards to part 05. NetAdapt runs a short-term fine-tune after every layer it thins and a long-term fine-tune at the end, which is the same prune-then-fine-tune loop driven by a latency budget instead of a sparsity schedule. Whatever criterion or granularity you choose, the outer loop looks like this figure.
الحلقة ترتبط أيضًا بالجزء 05 السابق. الـ NetAdapt يشغّل short-term fine-tune بعد كل طبقة يرقّقها، وlong-term fine-tune في النهاية، وهذه هي حلقة التقليم ثم الـ fine-tune نفسها لكن تقودها ميزانية زمن استجابة (latency) بدل جدول sparsity. أيًا كان المعيار أو الدقة (granularity) التي تختارها، فإن الحلقة الخارجية تبدو مثل هذا الشكل.
Quick checkاختبار سريع
In iterative pruning, what exactly counts as one iteration?في الـ iterative pruning، ما الذي يُعدّ بالضبط تكرارًا واحدًا؟
Recall
Define one iteration of iterative pruning and say what changes between iterations.عرّف التكرار الواحد في الـ iterative pruning، وقل ما الذي يتغيّر بين التكرارات.
Slide 51 adds one bullet and one curve, and together they carry the number you will be asked for: Iterative pruning boosts the Pruning ratio from 5x to 9x on AlexNet compared to single-step aggressive pruning. The red curve is what that sentence looks like.
تضيف الشريحة 51 نقطة واحدة ومنحنى واحدًا، ومعًا يحملان الرقم الذي ستُسأل عنه: الـ iterative pruning يرفع الـ pruning ratio من 5x إلى 9x على AlexNet مقارنةً بالتقليم العنيف بخطوة واحدة (single-step aggressive pruning). المنحنى الأحمر هو الصورة البيانية لهذه الجملة.
| Curveالمنحنى | Within 0.5% loss up toضمن فقدان 0.5% حتى | Reaches about -4% atيصل إلى نحو -4% عند |
|---|---|---|
| Pruning onlyالتقليم فقط | about 60%نحو 60% | about 80% (5x)نحو 80% (5x) |
| Pruning + fine-tuningالتقليم مع fine-tuning | about 85%نحو 85% | about 93% (14x)نحو 93% (14x) |
| Iterative pruning + fine-tuningالتقليم التكراري مع fine-tuning | about 92% (12.5x)نحو 92% (12.5x) | about 95.5% (22x)نحو 95.5% (22x) |
| Pruned awayالنسبة المقلَّمة | Accuracy lossفقدان الدقة |
|---|---|
| 87.5%87.5% | +0.1+0.1 |
| 89%89% | +0.05+0.05 |
| 90%90% | 0.00.0 |
| 91.5%91.5% | -0.3-0.3 |
| 92.5%92.5% | -0.6-0.6 |
| 93.5%93.5% | -1.0-1.0 |
| 94.5%94.5% | -2.0-2.0 |
| 95.5%95.5% | -4.1-4.1 |
Notice where the curve begins. It does not start at 40% like the others. The paper explains why in section 5: the biggest gain comes from iterative pruning, where the pruned and retrained network of the green curve is pruned and retrained again. The leftmost red dot corresponds to the point on the green line at 80% (5x) pruned further to 8x. There is no accuracy loss at 9x, and not until 10x does the accuracy begin to drop sharply.
لاحظ أين يبدأ المنحنى. فهو لا يبدأ من 40% مثل المنحنيات الأخرى. تشرح الورقة السبب في القسم 5: أكبر مكسب يأتي من الـ iterative pruning، حيث تُقلَّم الشبكة التي قُلّمت وأُعيد تدريبها في المنحنى الأخضر ثم يُعاد تدريبها مرة أخرى. أقصى نقطة حمراء على اليسار تقابل النقطة على الخط الأخضر عند 80% (5x) بعد تقليمها أكثر إلى 8x. لا يوجد فقدان في الدقة عند 9x، ولا تبدأ الدقة بالانخفاض الحاد إلا عند 10x.
Worked exampleمثال محلول
The 5x to 9x claim in parametersادعاء 5x إلى 9x بلغة عدد المعاملات
Single-step toleranceتحمّل الخطوة الواحدة
5x of 61M leaves 12.2M weights, which is 80% pruned away.5x من 61M يُبقي 12.2M وزن، أي أن 80% قد قُلّمت.Iterative resultالنتيجة التكرارية
9x leaves about 6.8M; the paper's measured count is 6.7M (61 / 6.7 = 9.1x, quoted as 9x), at about 89% pruned away.9x يُبقي نحو 6.8M؛ والعدد المقيس في الورقة هو 6.7M (61 / 6.7 = 9.1x، ويُذكر على أنه 9x)، أي نحو 89% مقلَّمة.What the extra iterations removedما أزالته التكرارات الإضافية
12.2M - 6.8M = 5.4M further weights, 44% of what single-step pruning had kept, at no accuracy cost.12.2M - 6.8M = 5.4M وزن إضافي، أي 44% مما كان التقليم بخطوة واحدة قد أبقاه، دون أي كلفة في الدقة.Where it stopsأين يتوقف
10x would be 6.1M weights, and there the paper reports the accuracy beginning to drop sharply.10x يعني 6.1M وزن، وهناك تذكر الورقة أن الدقة تبدأ بالانخفاض الحاد.
The same paper reaches 13x on VGG-16 with five iterations of pruning and retraining, shrinking it to 7.5% of its original size with fc6 and fc7 each pruned to less than 4% of their original size. These pruned networks are the starting point of Deep Compression, which quantizes the surviving weights to 8 bits in convolution layers and 5 bits in fully connected layers and Huffman codes the result to reach 35x on AlexNet (240 MB to 6.9 MB) and 49x on VGG-16. The roughly 90% Weight sparsity that EIE assumes in the next part is this number.
الورقة نفسها تصل إلى 13x على VGG-16 بخمسة تكرارات من التقليم وإعادة التدريب، فتصغّرها إلى 7.5% من حجمها الأصلي، مع تقليم كل من fc6 وfc7 إلى أقل من 4% من حجمها الأصلي. هذه الشبكات المقلَّمة هي نقطة انطلاق Deep Compression، الذي يحوّل الأوزان الباقية بالـ quantization إلى 8 بت في طبقات الـ convolution و5 بت في طبقات الـ fully connected، ثم يرمّز النتيجة بـ Huffman coding ليصل إلى 35x على AlexNet (من 240 MB إلى 6.9 MB) و49x على VGG-16. والـ weight sparsity البالغة نحو 90% التي يفترضها EIE في الجزء التالي هي هذا الرقم.
Quick checkاختبار سريع
On AlexNet, iterative pruning raised the achievable pruning ratio from what to what?على AlexNet، رفع الـ iterative pruning نسبة التقليم الممكنة من كم إلى كم؟
Recall
Quote the AlexNet number for iterative versus single-step pruning and convert both to percent pruned.اذكر رقم AlexNet للتقليم التكراري مقابل التقليم بخطوة واحدة، وحوّل كليهما إلى نسبة مئوية مقلَّمة.
Fine-tuning repairs the network after the cut. Regularization (for pruning) prepares it before the cut. Follow one weight w = 0.05 through training with a penalty coefficient lambda = 0.01 and a learning rate eta = 0.1, ignoring the data loss for the moment so only the penalty acts.
الـ Fine-tuning يصلح الشبكة بعد القطع. والـ regularization يجهّزها قبل القطع. تتبّع وزنًا واحدًا w = 0.05 عبر التدريب مع معامل عقوبة lambda = 0.01 ومعدل تعلّم eta = 0.1، متجاهلًا خسارة البيانات مؤقتًا حتى تعمل العقوبة وحدها.
Worked exampleمثال محلول
One weight under an L1 and an L2 penaltyوزن واحد تحت عقوبة L1 وعقوبة L2
L1 pullسحب الـ L1
The gradient of lambda |w| is lambda sign(w), so each step subtracts eta lambda = 0.001 regardless of how small w is. From 0.05 the weight reaches exactly zero in 50 steps and stays there.مشتقة lambda |w| هي lambda sign(w)، لذلك كل خطوة تطرح eta lambda = 0.001 مهما كان w صغيرًا. من 0.05 يصل الوزن إلى الصفر تمامًا في 50 خطوة ويبقى هناك.L2 pullسحب الـ L2
The gradient of lambda w^2 is 2 lambda w, so each step subtracts eta 2 lambda w = 0.002 w. The weight is multiplied by 0.998 every step: after 50 steps 0.05 x 0.998^50 = 0.0452, after 1000 steps 0.0068, never zero.مشتقة lambda w^2 هي 2 lambda w، لذلك كل خطوة تطرح eta 2 lambda w = 0.002 w. يُضرب الوزن في 0.998 في كل خطوة: بعد 50 خطوة 0.05 x 0.998^50 = 0.0452، وبعد 1000 خطوة 0.0068، ولا يصل إلى الصفر أبدًا.Two different destinationsوجهتان مختلفتان
L1 subtracts a constant and lands on zero. L2 multiplies by a constant and only approaches it.الـ L1 يطرح مقدارًا ثابتًا فيستقر عند الصفر. والـ L2 يضرب في معامل ثابت فيقترب من الصفر فقط.
| Stepsالخطوات | L1L1 | L2L2 |
|---|---|---|
| 00 | 0.05000.0500 | 0.05000.0500 |
| 5050 | 0.00000.0000 | 0.04520.0452 |
| 200200 | 0.00000.0000 | 0.03350.0335 |
| 10001000 | 0.00000.0000 | 0.00680.0068 |
The two regularized lossesدالتا الخسارة مع الـ regularization
The slide states the general rule. During training, or during the fine-tuning of a pruned network, a penalty is added to the loss to penalize nonzero parameters and to encourage smaller ones. The two common choices are the L1 and L2 penalties on the weights W, with lambda setting how strongly the penalty competes with the data loss L(x; W).
تذكر الشريحة القاعدة العامة. أثناء التدريب، أو أثناء الـ fine-tuning لشبكة مقلَّمة، تُضاف عقوبة إلى الخسارة لمعاقبة المعاملات غير الصفرية وتشجيع المعاملات الأصغر. الخياران الشائعان هما عقوبتا L1 وL2 على الأوزان W، حيث يحدد lambda مدى قوة منافسة العقوبة لخسارة البيانات L(x; W).
Goodfellow, Bengio and Courville make both halves precise. L2 regularization, commonly known as weight decay, drives the weights closer to the origin; its update multiplicatively shrinks the weight vector by a constant factor on each step (their equation 7.5). L1 regularization, in comparison, results in a solution that is more sparse, where sparsity means that some parameters have an optimal value of exactly zero, and this property is why L1 has been used extensively for feature selection (LASSO). The gradient forms above are the reason. Near zero the L1 gradient lambda sign(w) keeps its full size, so the weight is pushed onto zero and pinned there. The L2 gradient 2 lambda w shrinks with the weight, so the push fades before it arrives.
يجعل Goodfellow وBengio وCourville الجانبين دقيقين. الـ L2 regularization، المعروف عادةً باسم weight decay، يقرّب الأوزان من نقطة الأصل؛ وتحديثه يقلّص متجه الأوزان بشكل ضربي بمعامل ثابت في كل خطوة (معادلتهم 7.5). أما الـ L1 regularization فيؤدي بالمقارنة إلى حل أكثر تفرّقًا (sparse)، حيث يعني التفرّق أن بعض المعاملات قيمتها المثلى صفر تمامًا، وهذه الخاصية هي سبب استخدام الـ L1 على نطاق واسع لاختيار السمات (LASSO). وصيغ المشتقات أعلاه هي السبب. قرب الصفر تحافظ مشتقة الـ L1، lambda sign(w)، على حجمها الكامل، فيُدفع الوزن إلى الصفر ويُثبَّت هناك. أما مشتقة الـ L2، 2 lambda w، فتصغر مع الوزن، فيخفت الدفع قبل أن يصل.
| L1L1 | L2L2 | |
|---|---|---|
| Gradient of the penaltyمشتقة العقوبة | lambda sign(w), constantlambda sign(w)، ثابتة | 2 lambda w, shrinks with w2 lambda w، تصغر مع w |
| Effect per stepالأثر في كل خطوة | Subtract a fixed amountطرح مقدار ثابت | Multiply by a factor below oneالضرب في معامل أقل من واحد |
| Where weights endأين تنتهي الأوزان | Exactly zero, then stayعند الصفر تمامًا، وتبقى هناك | Small but never zeroصغيرة لكنها لا تصبح صفرًا أبدًا |
| Accuracy before retraining (Han et al.)الدقة قبل إعادة التدريب (Han et al.) | Betterأفضل | Worseأسوأ |
| Accuracy after retraining (Han et al.)الدقة بعد إعادة التدريب (Han et al.) | Worseأسوأ | Better, best overallأفضل، والأفضل إجمالًا |
Why both help pruning, and why L2 won anywayلماذا يساعد كلاهما التقليم، ولماذا فاز الـ L2 مع ذلك
Either penalty shrinks the weights the data loss does not defend. That does two things for magnitude pruning. The ranking becomes a cleaner signal, because a weight that stayed large did so against a constant pull, and the mass of the distribution near zero grows, so more weights fall under the threshold at a given accuracy. L1 goes further and parks weights on exactly zero, so removing them changes nothing at all.
أي من العقوبتين يقلّص الأوزان التي لا تدافع عنها خسارة البيانات. وهذا يفيد الـ magnitude pruning بأمرين. يصبح الترتيب إشارة أنظف، لأن الوزن الذي بقي كبيرًا فعل ذلك رغم سحب ثابت، وتزداد كتلة التوزيع قرب الصفر، فيقع عدد أكبر من الأوزان تحت العتبة عند دقة معيّنة. والـ L1 يذهب أبعد فيثبّت الأوزان عند الصفر تمامًا، فلا تغيّر إزالتها شيئًا على الإطلاق.
It is tempting to conclude that L1 must be the better choice for pruning, and this is the classic trap. Han et al. (section 3.1) report that L1 regularization does give better accuracy after pruning but before retraining, since more parameters sit near zero. However, the remaining connections are not as good as with L2, resulting in lower accuracy after retraining, and overall L2 regularization gives the best pruning results. They also tried L1 for the pruning phase followed by L2 for retraining and found it did not beat using L2 for both, because parameters from one mode do not adapt well to the other. That is why the slide says magnitude-based fine-grained pruning applies L2 regularization on weights.
من المغري أن تستنتج أن الـ L1 لا بد أن يكون الخيار الأفضل للتقليم، وهذا هو الفخ الكلاسيكي. يذكر Han et al. (القسم 3.1) أن الـ L1 regularization يعطي فعلًا دقة أفضل بعد التقليم وقبل إعادة التدريب، لأن عددًا أكبر من المعاملات يكون قرب الصفر. لكن الاتصالات الباقية ليست بجودة ما يتركه الـ L2، فتكون الدقة بعد إعادة التدريب أقل، وإجمالًا يعطي الـ L2 regularization أفضل نتائج تقليم. وجرّبوا أيضًا الـ L1 لمرحلة التقليم ثم الـ L2 لإعادة التدريب، فوجدوا أنه لا يتفوّق على استخدام الـ L2 في المرحلتين، لأن المعاملات القادمة من نمط لا تتكيّف جيدًا مع النمط الآخر. ولهذا تقول الشريحة إن الـ magnitude-based fine-grained pruning يطبّق الـ L2 regularization على الأوزان.
Network Slimming: the same penalty on channel scaling factorsNetwork Slimming: العقوبة نفسها على معاملات تحجيم القنوات
The second example on the slide moves the penalty from weights to channels, which connects back to the scaling-based criterion of lecture 04-1. Network Slimming (Liu et al., ICCV 2017) notes that every batch normalization layer already computes z_out = gamma z_hat + beta per channel, so gamma is a free scaling factor for that channel. Their training objective adds a sparsity penalty on those factors.
المثال الثاني في الشريحة ينقل العقوبة من الأوزان إلى القنوات، وهذا يعيدنا إلى المعيار المبني على التحجيم (scaling-based) في المحاضرة 04-1. يلاحظ Network Slimming (Liu et al.، ICCV 2017) أن كل طبقة batch normalization تحسب أصلًا z_out = gamma z_hat + beta لكل قناة، لذلك فإن gamma معامل تحجيم مجاني لتلك القناة. ودالة الهدف في تدريبهم تضيف عقوبة sparsity على تلك المعاملات.
Channels whose gamma has been pushed toward zero contribute almost nothing and are removed with a global percentile threshold (pruning 70% of channels means choosing the 70th percentile of all gamma values), followed by fine-tuning. Because a whole channel goes, this is Channel pruning, the coarse end of Pruning granularity, and the resulting network stays dense. On VGGNet the method reports a 20x smaller model and 5x fewer computing operations. The paper also describes a multi-pass scheme that repeats train, prune and fine-tune, the same loop as the previous concepts, now driven by gamma instead of |w|.
القنوات التي دُفع gamma الخاص بها نحو الصفر لا تساهم بشيء تقريبًا، وتُزال بعتبة مئينية عامة (global percentile threshold)؛ فتقليم 70% من القنوات يعني اختيار المئين 70th من كل قيم gamma، ثم يتبع ذلك fine-tuning. ولأن القناة تُحذف كاملة، فهذا channel pruning، أي الطرف الخشن من pruning granularity، والشبكة الناتجة تبقى كثيفة (dense). على VGGNet تذكر الطريقة نموذجًا أصغر بـ 20x وعمليات حسابية أقل بـ 5x. وتصف الورقة أيضًا مخططًا متعدد المرور يكرر التدريب ثم التقليم ثم الـ fine-tune، وهي الحلقة نفسها في المفاهيم السابقة، لكن يقودها الآن gamma بدل |w|.
Quick checkاختبار سريع
Why does an L1 penalty drive weights exactly to zero while L2 only shrinks them?لماذا تدفع عقوبة L1 الأوزان إلى الصفر تمامًا بينما تكتفي L2 بتقليصها؟
Quick checkاختبار سريع
Network Slimming applies its sparsity penalty to which quantity?على أي كمية يطبّق Network Slimming عقوبة الـ sparsity؟
Recall
Write the L1 and L2 regularized losses and say which one produces exact zeros.اكتب دالتَي الخسارة مع الـ L1 والـ L2 regularization، وقل أيّهما يُنتج أصفارًا تامة.
Recall
Which regularizer did Han et al. find best overall for pruning, and what does Network Slimming penalize?أي regularizer وجده Han et al. الأفضل إجمالًا للتقليم، وما الذي يعاقبه Network Slimming؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Pruning without retraining starts losing accuracy once only one third of the original connections remain (about 67 percent pruned). One prune plus fine-tune holds to about 80 percent, and the full retraining scheme reaches one tenth remaining (Han et al.).التقليم دون إعادة تدريب يبدأ بفقدان الدقة عندما يبقى ثلث الاتصالات الأصلية فقط (أي نحو 67 بالمئة مقلَّمة). أما تقليم واحد مع fine-tune فيصمد حتى نحو 80 بالمئة، ومخطط إعادة التدريب الكامل يصل إلى بقاء العُشر فقط (Han et al.).
- Fine-tuning retrains only the survivors, with the mask fixed, at 1/10 to 1/100 of the original learning rate. AlexNet took 173 hours to retrain versus 75 hours to train.الـ fine-tuning يعيد تدريب الأوزان الباقية فقط، مع تثبيت الـ mask، بمعدل تعلّم يساوي 1/10 إلى 1/100 من المعدل الأصلي. استغرقت إعادة تدريب AlexNet 173 ساعة مقابل 75 ساعة للتدريب الأصلي.
- One iteration is prune then fine-tune. Iterative pruning raises the target sparsity each round and lifted AlexNet from 5x to 9x (61M to 6.7M parameters, top-5 error 19.73 to 19.67 percent).التكرار الواحد هو تقليم ثم fine-tune. الـ iterative pruning يرفع الـ sparsity المستهدفة في كل جولة، وقد رفع AlexNet من 5x إلى 9x (من 61M إلى 6.7M معامل، وخطأ top-5 من 19.73 إلى 19.67 بالمئة).
- On the curve, iterative pruning stays within 0.5 percent loss to about 92 percent pruned and reaches -4 percent only near 95.5 percent; single prune plus fine-tune holds zero loss only to 80 percent (5x).على المنحنى، يبقى الـ iterative pruning ضمن فقدان 0.5 بالمئة حتى نحو 92 بالمئة مقلَّمة، ولا يصل إلى -4 بالمئة إلا قرب 95.5 بالمئة؛ أما تقليم واحد مع fine-tune فيحافظ على فقدان صفري حتى 80 بالمئة فقط (5x).
- L1 (lambda |W|) parks weights at exact zero; L2 (lambda ||W||^2) shrinks every weight multiplicatively. Both make small weights cheaper to remove.الـ L1 (lambda |W|) يثبّت الأوزان عند الصفر تمامًا؛ والـ L2 (lambda ||W||^2) يقلّص كل وزن بشكل ضربي. كلاهما يجعل إزالة الأوزان الصغيرة أقل كلفة.
- Han et al. found L2 best overall for magnitude pruning; Network Slimming puts an L1 penalty on batch norm scaling factors to select channels, and its multi-pass scheme is the same loop.وجد Han et al. أن الـ L2 هو الأفضل إجمالًا للـ magnitude pruning؛ أما Network Slimming فيضع عقوبة L1 على معاملات التحجيم في الـ batch norm لاختيار القنوات، ومخططه متعدد المرور هو الحلقة نفسها.
- Deep Compression and EIE (next part) start from exactly this 9x to 13x pruned network.الـ Deep Compression والـ EIE (الجزء التالي) يبدآن من هذه الشبكة المقلَّمة بنسبة 9x إلى 13x تحديدًا.
Sourcesالمصادر
- Learning both Weights and Connections for Efficient Neural NetworksPaperNeurIPS 2015, Han, Pool, Tran and DallyThree-step pipeline, 1/10 and 1/100 learning rates, 5x to 9x iterative result, L1 versus L2 (3.1), dropout adjustment (3.2), Figures 5 and 7, Table 1خط المعالجة ذو الخطوات الثلاث، ومعدلا التعلّم 1/10 و1/100، ونتيجة التقليم التكراري من 5x إلى 9x، والـ L1 مقابل الـ L2 (3.1)، وتعديل الـ dropout (3.2)، والشكلان 5 و7، والجدول 1(opens in a new tab)(يفتح في تبويب جديد)
- Learning Efficient Convolutional Networks through Network SlimmingPaperICCV 2017, Liu, Li, Shen, Huang, Yan and ZhangEquation 1 with g(s) = |s|, batch norm gamma as scaling factor, smooth-L1 as an alternative, percentile threshold, 20x size and 5x compute on VGGNet, multi-pass schemeالمعادلة 1 مع g(s) = |s|، وgamma في الـ batch norm كمعامل تحجيم، والـ smooth-L1 كبديل، والعتبة المئينية، وتصغير الحجم 20x والحساب 5x على VGGNet، والمخطط متعدد المرور(opens in a new tab)(يفتح في تبويب جديد)
- Deep Learning, chapter 7: Regularization for Deep LearningBookMIT Press, Goodfellow, Bengio and Courville7.1.1 weight decay shrinks multiplicatively (equation 7.5); 7.1.2 L1 yields sparse solutions (equation 7.18) and LASSO feature selection7.1.1 الـ weight decay يقلّص بشكل ضربي (المعادلة 7.5)؛ 7.1.2 الـ L1 يعطي حلولًا متفرّقة (المعادلة 7.18) واختيار السمات بـ LASSO(opens in a new tab)(يفتح في تبويب جديد)
- To prune, or not to prune: exploring the efficacy of pruning for model compressionPaperarXiv 2017, Zhu and GuptaGradual sparsity schedule (equation 1), masks updated every delta t steps so training recovers between cutsجدول sparsity تدريجي (المعادلة 1)، مع تحديث الـ masks كل delta t خطوة حتى يتعافى التدريب بين القطعات(opens in a new tab)(يفتح في تبويب جديد)
- The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural NetworksPaperICLR 2019, Frankle and CarbinIterative magnitude pruning over n rounds; winning tickets at 10 to 20 percent of size; related reading only, not in the deckالـ iterative magnitude pruning على n جولة؛ والتذاكر الرابحة (winning tickets) بحجم 10 إلى 20 بالمئة؛ قراءة ذات صلة فقط، وليست في العرض(opens in a new tab)(يفتح في تبويب جديد)
- Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman CodingPaperICLR 2016, Han, Mao and DallyPruning at 9x to 13x feeds 35x on AlexNet and 49x on VGG-16التقليم بنسبة 9x إلى 13x هو أساس الوصول إلى 35x على AlexNet و49x على VGG-16(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2024, Lecture 4: Pruning and Sparsity Part IIDocsMIT HAN Lab, Song HanSource of slides 43 to 52 (MIT slides 44 to 53), including the inherited wording errataمصدر الشرائح 43 إلى 52 (شرائح MIT من 44 إلى 53)، بما في ذلك أخطاء الصياغة الموروثة(opens in a new tab)(يفتح في تبويب جديد)
Part 07: EIE: the first accelerator for sparse, compressed networksEIE: أول مسرّع للشبكات المتناثرة والمضغوطة
Why sparsity needs hardware support, Han's co-design paradigm, and how EIE exploits weight sparsity, activation sparsity and weight sharing by splitting a sparse matrix-vector product across processing elements.لماذا يحتاج التناثر إلى دعم من العتاد، ونموذج التصميم المشترك (co-design) لـHan، وكيف يستغل EIE تناثر الأوزان وتناثر التنشيطات ومشاركة الأوزان بتقسيم ضرب مصفوفة متناثرة في متجه على عناصر المعالجة (PE).
3 concepts3 مفاهيم, ، slides 53-60الشرائح 53-60
Why this part mattersلماذا يهمّ هذا الجزء
Parts 02 to 06 chose pruning ratios and recovered accuracy. They never asked the uncomfortable question: after you remove 90 percent of the weights, is the network actually faster? On a GPU the honest answer is often no, and sometimes it is slower. This part explains why, and shows what hardware must do for pruning to become speed and energy.
The vehicle is EIE, the Efficient Inference Engine from Han et al. at ISCA 2016, the first accelerator built to run directly on a pruned, quantized model. You will learn its three sources of savings with the exact numbers on the slide, why one of them is dynamic and the other two static, and how a sparse matrix-vector product is split across processing elements so that zero weights are never stored and zero activations are never multiplied. This is the bridge to the M:N tensor cores and point-cloud engines later in the lecture, to the exam question "explain EIE's three savings and its PE dataflow", and to any research project that deploys a pruned model on an embedded accelerator.
اختارت الأجزاء من 02 إلى 06 نسب الـ pruning واستعادت الدقة. لكنها لم تطرح السؤال المحرج: بعد أن تحذف 90 percent من الأوزان، هل تصبح الشبكة أسرع فعلًا؟ على الـ GPU الجواب الصادق غالبًا لا، وأحيانًا تصبح أبطأ. يشرح هذا الجزء السبب، ويبيّن ما الذي يجب أن يفعله العتاد حتى يتحول الـ pruning إلى سرعة وتوفير في الطاقة.
الأداة هنا هي EIE، أي Efficient Inference Engine من Han وزملائه في ISCA 2016، وهو أول مسرّع (accelerator) بُني ليعمل مباشرة على نموذج مُقلَّم ومُكمَّم (pruned, quantized). ستتعلم مصادر توفيره الثلاثة بالأرقام الدقيقة الموجودة على الشريحة، ولماذا أحدها ديناميكي (dynamic) والآخران ثابتان (static)، وكيف يُقسَّم ضرب مصفوفة متناثرة في متجه (sparse matrix-vector product) على وحدات المعالجة (processing elements) بحيث لا تُخزَّن الأوزان الصفرية أبدًا ولا تُضرب التفعيلات الصفرية أبدًا. هذا هو الجسر إلى M:N tensor cores ومحركات السحب النقطية (point-cloud engines) لاحقًا في المحاضرة، وإلى سؤال الامتحان "explain EIE's three savings and its PE dataflow" (اشرح مصادر التوفير الثلاثة في EIE وتدفق البيانات بين وحدات المعالجة)، وإلى أي مشروع بحثي ينشر نموذجًا مُقلَّمًا على مسرّع مدمج (embedded accelerator).
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain, with the EIE paper's Table IV numbers, why fine-grained sparsity gives little or even negative speedup on CPUs and GPUs.اشرح، بأرقام Table IV من ورقة EIE، لماذا يعطي التناثر الدقيق (fine-grained sparsity) تسريعًا ضئيلًا أو حتى سالبًا على الـ CPU والـ GPU.
- Name the three systems on slide 54 and the kind of sparsity each one exploits.سمِّ الأنظمة الثلاثة على الشريحة 54 ونوع التناثر الذي يستغله كل منها.
- State EIE's three sources of savings with their sparsity or bit width and their computation and memory factors, and explain the 5x versus 10x gap.اذكر مصادر التوفير الثلاثة في EIE مع نسبة التناثر أو عرض البتات (bit width) لكل منها ومعاملَي التوفير في الحساب والذاكرة، واشرح الفرق بين 5x و10x.
- Distinguish static from dynamic sparsity and say why ReLU makes activation sparsity dynamic.ميّز بين التناثر الثابت (static) والتناثر الديناميكي (dynamic)، وبيّن لماذا يجعل ReLU تناثر التفعيلات ديناميكيًا.
- Draw the 8 x 4 example: assign rows to PEs round-robin, broadcast the nonzero activations, and count the multiplications that actually happen.ارسم مثال 8 x 4: وزّع الصفوف على وحدات المعالجة (PEs) بالتناوب (round-robin)، وابثّ التفعيلات غير الصفرية، وعُدّ عمليات الضرب التي تحدث فعلًا.
Take AlexNet's FC6 layer, a 9216 x 4096 matrix that Han's Pruning left 91 percent zeros. Feed it one input vector. The EIE paper timed exactly this layer on a desktop CPU and a Titan X GPU, once with the dense matrix and once with the sparse one stored in a compressed format and run through the vendor's sparse kernels (MKL and cuSPARSE). The results are the whole motivation for this part.
خذ طبقة FC6 في AlexNet، وهي مصفوفة 9216 x 4096 جعل الـ pruning الذي طبّقه Han نسبة 91 percent منها أصفارًا. مرّر إليها متجه إدخال واحدًا. قاست ورقة EIE زمن هذه الطبقة بالذات على CPU مكتبي وعلى Titan X GPU، مرة بالمصفوفة الكثيفة (dense) ومرة بالمصفوفة المتناثرة مخزّنة بصيغة مضغوطة ومنفّذة عبر نوى التناثر التي توفرها الشركات المصنّعة (MKL وcuSPARSE). هذه النتائج هي الدافع الكامل لهذا الجزء.
| Platformالمنصة | Batchحجم الدفعة (Batch) | Dense matrixالمصفوفة الكثيفة | Sparse matrixالمصفوفة المتناثرة | Sparse versus denseالمتناثرة مقارنة بالكثيفة |
|---|---|---|---|---|
| Core i7-5930k CPUCore i7-5930k CPU | 11 | 7516.2 μs7516.2 μs | 3066.5 μs3066.5 μs | 2.5x fasterأسرع بـ 2.5x |
| GeForce Titan X GPUGeForce Titan X GPU | 11 | 541.5 μs541.5 μs | 134.8 μs134.8 μs | 4.0x fasterأسرع بـ 4.0x |
| GeForce Titan X GPUGeForce Titan X GPU | 6464 | 19.8 μs19.8 μs | 94.6 μs94.6 μs | 4.8x slowerأبطأ بـ 4.8x |
| EIE, 64 PEsEIE، 64 PEs | 11 | runs only the sparse formيشغّل الصيغة المتناثرة فقط | 30.3 μs30.3 μs | 248x vs dense CPU248x مقارنة بالـ CPU الكثيف |
Removing 91 percent of the multiplications bought only 2.5x on the CPU and 4x on the GPU, not the 11x the arithmetic promises. Worse, once the GPU batches 64 inputs so that the dense kernel can use its full width, the sparse kernel falls 4.8x behind. The paper's summary is blunt: "the irregular pattern caused by compression hinders the effective acceleration on CPUs and GPUs". A general-purpose core cannot skip a zero for free. It has to read an index, compute an address, gather a scattered activation and suffer the cache miss, and that bookkeeping costs more than the multiply it avoided. Custom accelerators before EIE did no better: sparse matrix-vector (SpMV) engines from scientific computing handle the static zeros in the weights but not the run-time zeros in the activations, and DNN accelerators of the day "must expand the network to dense form" before they can run it.
حذف 91 percent من عمليات الضرب لم يكسب سوى 2.5x على الـ CPU و4x على الـ GPU، لا الـ 11x التي يعد بها الحساب. والأسوأ أنه حين يجمع الـ GPU دفعة من 64 inputs حتى تستغل النواة الكثيفة كامل عرضها، تتأخر النواة المتناثرة بمقدار 4.8x. خلاصة الورقة صريحة: "the irregular pattern caused by compression hinders the effective acceleration on CPUs and GPUs"، أي أن النمط غير المنتظم الناتج عن الضغط يعيق التسريع الفعلي على الـ CPUs والـ GPUs. النواة عامة الغرض (general-purpose core) لا تستطيع تخطي الصفر مجانًا. عليها أن تقرأ فهرسًا، وتحسب عنوانًا، وتجمع (gather) تفعيلًا مبعثرًا، وتتحمل إخفاق الذاكرة المخبئية (cache miss)، وكلفة هذه المحاسبة أكبر من كلفة عملية الضرب التي تجنبتها. ولم تكن المسرّعات المخصصة قبل EIE أفضل حالًا: محركات ضرب المصفوفة المتناثرة في متجه (SpMV) القادمة من الحوسبة العلمية تتعامل مع الأصفار الثابتة في الأوزان لكنها لا تتعامل مع الأصفار التي تظهر وقت التشغيل في التفعيلات، ومسرّعات الشبكات العصبية (DNN accelerators) في ذلك الوقت "must expand the network to dense form"، أي يجب أن تعيد توسيع الشبكة إلى الصيغة الكثيفة قبل أن تشغّلها.
Why memory is the real enemyلماذا الذاكرة هي العدو الحقيقي
| Operation (45 nm)العملية (45 nm) | Energyالطاقة | Relative to SRAM readنسبةً إلى قراءة SRAM |
|---|---|---|
| 32-bit SRAM readقراءة SRAM بعرض 32-bit | 5 pJ5 pJ | 1x1x |
| 32-bit DRAM readقراءة DRAM بعرض 32-bit | 640 pJ640 pJ | 128x128x |
| 32-bit float multiplyضرب أعداد عائمة (float) بعرض 32-bit | 3.7 pJ3.7 pJ | about 0.7xنحو 0.7x |
The table is the second half of the argument, the one that decides whether a model can run on a phone at all: the 128x gap between an on-chip and an off-chip read dwarfs the multiply itself. A network with one billion connections evaluated at 20 Hz spends 20 x 10^9 x 640 pJ = 12.8 W on DRAM traffic alone, far past any mobile power budget. The lesson that Deep Compression drew from this is that the goal is not fewer FLOPs but a model small enough to live entirely in SRAM: AlexNet shrinks from 240 MB to 6.9 MB and VGG-16 from 552 MB to 11.3 MB, both with no loss of accuracy. Once the whole model fits on chip, every weight read is the cheap kind.
الجدول هو النصف الثاني من الحجة، وهو الذي يقرر هل يمكن تشغيل النموذج على هاتف أصلًا: الفجوة البالغة 128x بين القراءة من داخل الشريحة (on-chip) والقراءة من خارجها (off-chip) تتضاءل أمامها كلفة الضرب نفسه. شبكة فيها مليار وصلة تُقيَّم بتردد 20 Hz تستهلك 20 x 10^9 x 640 pJ = 12.8 W على حركة DRAM وحدها، وهذا أبعد بكثير من أي ميزانية طاقة لجهاز محمول. الدرس الذي استخلصه Deep Compression من هذا هو أن الهدف ليس تقليل عدد الـ FLOPs بل الوصول إلى نموذج صغير بما يكفي ليعيش بالكامل في الـ SRAM: ينكمش AlexNet من 240 MB إلى 6.9 MB، وVGG-16 من 552 MB إلى 11.3 MB، وكلاهما دون أي خسارة في الدقة. وما إن يتسع النموذج كله داخل الشريحة حتى تصبح كل قراءة للأوزان من النوع الرخيص.
This is the point at which the five questions of the outline slide (what pruning is and how to formulate it, which granularity, which criterion, what ratio per layer, and how to fine-tune) hand over to a sixth that the outline never lists: on what hardware. All five are now answered, in lecture 04-1 and in parts 02 to 06 here, and the constraint ||W_P||_0 <= N has produced a model with few nonzeros. The rest of the lecture is about turning that small N into small time and small energy.
عند هذه النقطة تسلّم الأسئلة الخمسة في شريحة المخطط (ما هو الـ pruning وكيف نصوغه، وأي granularity، وأي معيار (criterion)، وأي نسبة لكل طبقة، وكيف نجري الـ fine-tuning) الراية إلى سؤال سادس لا يذكره المخطط أبدًا: على أي عتاد؟ الأسئلة الخمسة أُجيب عنها كلها الآن، في المحاضرة 04-1 وفي الأجزاء من 02 إلى 06 هنا، والقيد ||W_P||_0 <= N أنتج نموذجًا فيه عدد قليل من القيم غير الصفرية. بقية المحاضرة تدور حول تحويل هذا الـ N الصغير إلى زمن قصير وطاقة قليلة.
Han's paradigm: co-design the compression and the engineنموذج Han: تصميم الضغط والمحرك معًا (co-design)
Slide 56 draws the conventional flow as training on a server, then a big network shipped to a phone for slow, power-hungry inference. The proposed flow inserts a model compression stage between them and replaces the phone's generic processor with accelerated inference. The labels under each stage are five papers by the same group, and reading them as a set is the fastest way to see that compression and the engine were designed together. Neither is useful alone: a compressed model on a GPU gives the Table IV numbers above, and an engine for sparse models with nothing sparse to run is idle silicon. Together they deliver what the slide calls fast and power efficient: EIE with 64 PEs at 800 MHz draws about 600 mW and beats both baselines on the same nine FC and LSTM benchmarks by the margins below.
ترسم الشريحة 56 المسار التقليدي هكذا: تدريب على خادم، ثم شبكة كبيرة تُشحن إلى الهاتف لاستدلال (inference) بطيء ومستهلك للطاقة. أما المسار المقترح فيُدخل مرحلة ضغط النموذج (model compression) بينهما، ويستبدل المعالج العام في الهاتف باستدلال مُسرَّع (accelerated inference). العناوين تحت كل مرحلة هي خمس أوراق من المجموعة البحثية نفسها، وقراءتها كمجموعة واحدة هي أسرع طريقة لترى أن الضغط والمحرك صُمّما معًا. لا فائدة لأيّ منهما وحده: النموذج المضغوط على GPU يعطي أرقام Table IV أعلاه، والمحرك المخصص للنماذج المتناثرة دون شيء متناثر يشغّله ليس إلا سيليكونًا عاطلًا. معًا يحققان ما تسميه الشريحة سريعًا وموفرًا للطاقة (fast and power efficient): يستهلك EIE بـ 64 PEs عند 800 MHz نحو 600 mW، ويتفوق على كلا خطّي الأساس (baselines) في معايير الاختبار التسعة نفسها لطبقات FC وLSTM بالفوارق المبيّنة أدناه.
| EIE versusEIE مقارنة بـ | Speedupالتسريع | Energy efficiencyكفاءة الطاقة |
|---|---|---|
| Core i7-5930k CPUCore i7-5930k CPU | 189x189x | 24,000x24,000x |
| Titan X GPUTitan X GPU | 13x13x | 3,400x3,400x |
The five paper labels on slide 56عناوين الأوراق الخمس على الشريحة 56
- ICLR 2017, under TrainingICLR 2017، تحت Training
- DSD: dense-sparse-dense training, a regularizer that prunes and regrows during training to reach a better dense modelDSD: تدريب dense-sparse-dense، وهو أسلوب تنظيم (regularizer) يقلّم الأوزان ثم يعيد إنباتها أثناء التدريب للوصول إلى نموذج كثيف أفضل
- NeurIPS 2015, under Model CompressionNeurIPS 2015، تحت Model Compression
- Learning both Weights and Connections: train, prune, retrain, giving 9x fewer AlexNet and 13x fewer VGG-16 parameters without accuracy lossLearning both Weights and Connections: درّب، ثم قلّم، ثم أعد التدريب، فتقل معاملات AlexNet بـ 9x ومعاملات VGG-16 بـ 13x دون خسارة في الدقة
- ICLR 2016 best paper, under Model Compressionأفضل ورقة في ICLR 2016، تحت Model Compression
- Deep Compression: pruning, trained quantization with a k-means codebook, then Huffman coding; AlexNet 240 MB to 6.9 MB (35x), VGG-16 552 MB to 11.3 MB (49x)Deep Compression: الـ pruning، ثم quantization مُدرَّب بقاموس k-means، ثم ترميز Huffman؛ AlexNet من 240 MB إلى 6.9 MB (35x)، وVGG-16 من 552 MB إلى 11.3 MB (49x)
- ISCA 2016, under Accelerated InferenceISCA 2016، تحت Accelerated Inference
- EIE: the ASIC that runs directly on the pruned, codebook-quantized weightsEIE: الـ ASIC الذي يعمل مباشرة على الأوزان المُقلَّمة والمُكمَّمة بالقاموس (codebook-quantized)
- FPGA 2017 best paper, under Accelerated Inferenceأفضل ورقة في FPGA 2017، تحت Accelerated Inference
- ESE: the same idea for sparse LSTMs on a Xilinx XCKU060 FPGA, 20x compression and 282 GOPS with load-balance-aware pruningESE: الفكرة نفسها لشبكات LSTM المتناثرة على Xilinx XCKU060 FPGA، بضغط 20x و282 GOPS مع pruning يراعي توازن الحمل (load-balance-aware pruning)
Three systems, three kinds of sparsityثلاثة أنظمة وثلاثة أنواع من التناثر
Slide 54 lists the hardware this section covers, and each entry targets a different sparsity. EIE exploits Weight sparsity and Activation sparsity at the same time, which is what made it the first of its kind. The NVIDIA sparse tensor core accepts only structured M:N sparsity, trading flexibility for a dense-friendly pattern. TorchSparse and PointAcc exploit activation sparsity of a very different origin: point clouds are mostly empty space, so the zeros are in the input, not in the weights.
تعرض الشريحة 54 العتاد الذي يغطيه هذا القسم، وكل عنصر فيها يستهدف نوعًا مختلفًا من التناثر. يستغل EIE الـ weight sparsity (تناثر الأوزان) والـ activation sparsity (تناثر التفعيلات) في الوقت نفسه، وهذا ما جعله الأول من نوعه. أما الـ tensor core المتناثر من NVIDIA فلا يقبل إلا الـ M:N sparsity المنتظم (structured)، مقايضًا المرونة بنمط يلائم العتاد الكثيف. ويستغل TorchSparse وPointAcc تناثر تفعيلات ذا أصل مختلف تمامًا: السحب النقطية (point clouds) في معظمها فضاء فارغ، لذلك تكون الأصفار في المُدخل لا في الأوزان.
Roadmap for the rest of the lecture, from slide 54خريطة بقية المحاضرة، من الشريحة 54
- EIE (Han et al., ISCA 2016)
- Weight sparsity plus activation sparsity in fully connected layers, on a custom ASIC. This part and parts 08 and 09.تناثر الأوزان مع تناثر التفعيلات في الطبقات المتصلة بالكامل (fully connected)، على ASIC مخصص. هذا الجزء والجزءان 08 و09.
- NVIDIA Tensor Core (Ampere)
- M:N weight sparsity, specifically 2:4: two of every four consecutive weights must be zero, and the hardware skips the matching activations. Part 10.تناثر أوزان من نوع M:N، وتحديدًا 2:4: يجب أن يكون وزنان من كل أربعة أوزان متتالية صفرًا، ويتخطى العتاد التفعيلات المقابلة لهما. الجزء 10.
- TorchSparse and PointAccTorchSparse و PointAcc
- Activation sparsity of point clouds, where most voxels are empty, handled by sparse convolution on GPUs and on a custom accelerator. Parts 11 to 13.تناثر التفعيلات في السحب النقطية (point clouds)، حيث معظم الـ voxels فارغة، ويُعالَج بالـ sparse convolution على الـ GPUs وعلى مسرّع مخصص. الأجزاء من 11 إلى 13.
Recall
Why does a 91 percent sparse FC6 layer run only 2.5x faster on a CPU, and slower than dense on a GPU at batch 64?لماذا تعمل طبقة FC6 المتناثرة بنسبة 91 percent أسرع بـ 2.5x فقط على الـ CPU، وأبطأ من النسخة الكثيفة على الـ GPU عند batch 64؟
Recall
Name the three systems on slide 54 and the sparsity each exploits.سمِّ الأنظمة الثلاثة على الشريحة 54 ونوع التناثر الذي يستغله كل منها.
Look at one fully connected layer of AlexNet, FC7, a 4096 x 4096 matrix of 16.8 M weights that occupies 64 MB in 32-bit floating point. A dense engine stores all 16.8 M values and performs 16.8 M multiply-accumulate operations (MACs) for every input. After Deep Compression, the EIE paper reports that only 9% of the weights survive, about 35% of the input activations are nonzero, and 3% of the original FLOPs remain. EIE reaches that 3 percent by combining three savings that the slide states in round numbers.
انظر إلى طبقة واحدة متصلة بالكامل (fully connected) في AlexNet، هي FC7، مصفوفة 4096 x 4096 فيها 16.8 M وزن تشغل 64 MB بصيغة الفاصلة العائمة 32-bit. المحرك الكثيف يخزّن كل القيم الـ 16.8 M وينفّذ 16.8 M عملية ضرب وتجميع (multiply-accumulate، أي MACs) لكل مُدخل. بعد Deep Compression تذكر ورقة EIE أن 9% فقط من الأوزان تبقى، وأن نحو 35% من تفعيلات الإدخال غير صفرية، وأن 3% فقط من الـ FLOPs الأصلية تبقى. يصل EIE إلى هذه الـ 3 percent بالجمع بين ثلاثة مصادر للتوفير تذكرها الشريحة بأرقام مقرّبة.
| Sourceالمصدر | Sparsity or bitsالتناثر أو عدد البتات | Computation savingالتوفير في الحساب | Memory savingالتوفير في الذاكرة | Rule of thumbالقاعدة التقريبية |
|---|---|---|---|---|
| Sparse weightالأوزان المتناثرة | 90% static sparsityتناثر ثابت بنسبة 90% | 10x less computationحساب أقل بـ 10x | 5x less memory footprintذاكرة أقل بـ 5x | 0 x A = 00 x A = 0 |
| Sparse activationالتفعيلات المتناثرة | 70% dynamic sparsityتناثر ديناميكي بنسبة 70% | 3x less computationحساب أقل بـ 3x | none claimed on the slideلا تذكر الشريحة أي توفير | W x 0 = 0W x 0 = 0 |
| Weight sharingمشاركة الأوزان | 4-bit weightsأوزان 4-bit | none claimed on the slideلا تذكر الشريحة أي توفير | 8x less memory footprintذاكرة أقل بـ 8x | 2.09, 1.92 => 22.09, 1.92 => 2 |
The first column is Weight sparsity. Pruning zeroed about 90 percent of the matrix, so a product 0 x A is known to be zero without looking at A. An engine that never stores those weights skips their multiplications for free, hence 10x less computation. The second column is Activation sparsity. About 70 percent of the input vector is zero because it came out of a ReLU, so W x 0 is also known without looking at W. Skipping those columns removes another factor of roughly 1 / 0.3 = 3.3, which the slide rounds to 3x, and the paper measures that skipping them saves about 65 percent of the computation cycles. The third column is Weight sharing: the surviving weights are not stored as32-bit floats but as 4-bit indices into a per-layer codebook of 2^4 = 16 shared values, which is where the crossed-out 2.09, 1.92 => 2 comes from. Both weights snap to the same centroid and are stored as the same index, and 32 / 4 is the 8x memory saving.
العمود الأول هو الـ weight sparsity (تناثر الأوزان). جعل الـ pruning نحو 90 percent من المصفوفة أصفارًا، لذا فحاصل الضرب 0 x A معروف أنه صفر دون النظر إلى A. والمحرك الذي لا يخزّن تلك الأوزان أبدًا يتخطى عمليات ضربها مجانًا، ومن هنا جاء الحساب الأقل بـ 10x. العمود الثاني هو الـ activation sparsity (تناثر التفعيلات). نحو 70 percent من متجه الإدخال أصفار لأنه خرج من ReLU، لذا فـ W x 0 معروف أيضًا دون النظر إلى W. تخطي تلك الأعمدة يزيل معاملًا آخر قدره تقريبًا 1 / 0.3 = 3.3، تقرّبه الشريحة إلى 3x، وتقيس الورقة أن تخطيها يوفّر نحو 65 percent من دورات الحساب. العمود الثالث هو الـ weight sharing (مشاركة الأوزان): الأوزان الباقية لا تُخزَّن كأعداد عائمة 32-bit بل كفهارس 4-bit تشير إلى قاموس (codebook) خاص بكل طبقة يضم 2^4 = 16 قيمة مشتركة، ومن هنا جاءت العبارة المشطوبة 2.09, 1.92 => 2. كلا الوزنين ينجذبان إلى المركز (centroid) نفسه ويُخزَّنان بالفهرس نفسه، و32 / 4 هو توفير الذاكرة البالغ 8x.
The formula packs all three savings into one line. The sum runs only over X_i ∩ Y, the columns that are nonzero in both the weight row and the activation vector, which is the 10x and the 3x. Each weight appears as S[I_ij], a codebook lookup, which is the 8x. The two computation factors multiply to 10 x 3 = 30x, which is why the paper can describe 102 GOPS (giga operations per second) of work on the compressed network as about 3 TOPS (tera operations per second) on the uncompressed one. The 8x from the codebook is a memory factor and does not reduce the operation count.
تجمع المعادلة مصادر التوفير الثلاثة في سطر واحد. المجموع يمر فقط على X_i ∩ Y، أي الأعمدة غير الصفرية في صف الأوزان وفي متجه التفعيلات معًا، وهذا هو الـ 10x والـ 3x. ويظهر كل وزن على شكل S[I_ij]، أي بحث في القاموس، وهذا هو الـ 8x. معاملا الحساب يتضاعفان إلى 10 x 3 = 30x، ولهذا تستطيع الورقة أن تصف 102 GOPS (مليار عملية في الثانية) من العمل على الشبكة المضغوطة بأنها تعادل نحو 3 TOPS (تريليون عملية في الثانية) على الشبكة غير المضغوطة. أما الـ 8x القادمة من القاموس فهي معامل ذاكرة ولا تقلل عدد العمليات.
Why memory shrinks 5x and not 10xلماذا تنكمش الذاكرة 5x لا 10x
The one number that trips students is the 5x. Ten percent of the weights survive, so why not 10x less memory? Because a nonzero that is stored without its neighbors must carry its position. EIE stores each surviving weight together with a 4-bit relative index (the number of zeros since the previous nonzero in the column), a scheme explained fully in part 08 under Compressed sparse column (CSC). The retrospective on the paper states it directly: "the weight and index are both 4bit giving a 50% storage overhead". Half of every stored entry is bookkeeping, so the 10x from sparsity is halved to 5x. Computation keeps its full 10x, since the index is read but never multiplied.
الرقم الذي يُربك الطلاب هو الـ 5x. تبقى عشرة بالمئة من الأوزان، فلماذا لا تقل الذاكرة 10x؟ لأن القيمة غير الصفرية التي تُخزَّن دون جيرانها يجب أن تحمل موقعها معها. يخزّن EIE كل وزن باقٍ مع فهرس نسبي (relative index) بعرض 4-bit (عدد الأصفار منذ القيمة غير الصفرية السابقة في العمود)، وهي طريقة تُشرح بالكامل في الجزء 08 تحت compressed sparse column. والمراجعة اللاحقة للورقة (retrospective) تقولها مباشرة: "the weight and index are both 4bit giving a 50% storage overhead"، أي أن الوزن والفهرس كلاهما 4bit مما يعطي كلفة تخزين إضافية قدرها 50%. نصف كل مُدخل مخزَّن هو محاسبة، لذا فالـ 10x القادمة من التناثر تُنصَّف إلى 5x. أما الحساب فيحتفظ بالـ 10x كاملة، لأن الفهرس يُقرأ لكنه لا يُضرب أبدًا.
Worked exampleمثال محلول
From 3200 bits to 80 bitsمن 3200 بت إلى 80 بت
Dense storageالتخزين الكثيف
100 weights in 32-bit floating point occupy 100 x 32 = 3200 bits.100 وزن بصيغة الفاصلة العائمة 32-bit تشغل 100 x 32 = 3200 bits.Prune to 10 percent, keep full precisionقلّم إلى 10 percent مع الحفاظ على الدقة الكاملة
10 survivors, each with a 32-bit value plus a 32-bit position: 10 x 64 = 640 bits. That is 3200 / 640 = 5x, which is the slide's sparsity row: the index costs as much as the value.10 أوزان باقية، لكل منها قيمة 32-bit وموقع 32-bit: 10 x 64 = 640 bits. وهذا يعني 3200 / 640 = 5x، وهو صف التناثر على الشريحة: الفهرس يكلّف بقدر ما تكلّف القيمة.Add weight sharingأضف مشاركة الأوزان
Weight sharing drops the value to a 4-bit codebook index (32 / 4 = 8x). EIE also keeps the position the same width as the value, a 4-bit relative index, so the index overhead stays at 2x and the 5x from step 2 holds: 10 x (4 + 4) = 80 bits. Relative to the 640-bit step this is 8x, the slide's weight-sharing row.مشاركة الأوزان تُنزل القيمة إلى فهرس قاموس بعرض 4-bit (32 / 4 = 8x). ويُبقي EIE الموقع أيضًا بعرض القيمة نفسه، أي فهرسًا نسبيًا بعرض 4-bit، فتبقى كلفة الفهرس الإضافية 2x ويبقى الـ 5x من الخطوة 2 صحيحًا: 10 x (4 + 4) = 80 bits. ومقارنة بخطوة الـ 640-bit هذا يساوي 8x، وهو صف مشاركة الأوزان على الشريحة.40x overall40x إجمالًا
3200 / 80 = 40x, which is exactly 5 x 8. The decomposition assumes the index is as wide as the value, which is how EIE stores it: the slide assigns the index overhead to the sparsity factor and the bit-width gain to the sharing factor, and the two multiply.3200 / 80 = 40x، وهو بالضبط 5 x 8. هذا التفكيك يفترض أن الفهرس بعرض القيمة نفسه، وهذه هي طريقة تخزين EIE له: تنسب الشريحة كلفة الفهرس الإضافية إلى معامل التناثر، والمكسب من عرض البتات إلى معامل المشاركة، والمعاملان يتضاعفان.
Static versus dynamicالثابت (static) مقابل الديناميكي (dynamic)
The italic words on the slide, static and dynamic, are the conceptual core of this part and the key to Static versus dynamic sparsity. The paper defines X_i as the set of columns where row i of W is nonzero and Y as the set of indices where a is nonzero, then says: "The set X_i is fixed for a given model. The set Y varies from input to input." Weight zeros are decided once, when pruning and Fine-tuning finish, so the storage format can be laid out offline with every zero already gone. Activation zeros are made fresh by ReLU for every input, since a different image produces a different set of negative pre-activations. No format can remove them in advance; the engine must find them at run time, which is the job of the Leading non-zero detection unit in part 08.
الكلمتان المائلتان على الشريحة، static وdynamic، هما اللب المفاهيمي لهذا الجزء ومفتاح فهم static versus dynamic sparsity. تعرّف الورقة X_i بأنها مجموعة الأعمدة التي يكون فيها الصف i من W غير صفري، وY بأنها مجموعة الفهارس التي يكون فيها a غير صفري، ثم تقول: "The set X_i is fixed for a given model. The set Y varies from input to input."، أي أن المجموعة X_i ثابتة لنموذج معيّن بينما تتغير Y من مُدخل لآخر. أصفار الأوزان تتحدد مرة واحدة، عند انتهاء الـ pruning والـ fine-tuning، لذا يمكن ترتيب صيغة التخزين مسبقًا (offline) وقد أُزيل منها كل صفر. أما أصفار التفعيلات فيصنعها ReLU من جديد لكل مُدخل، لأن صورة مختلفة تنتج مجموعة مختلفة من القيم السالبة قبل التفعيل (pre-activations). لا توجد صيغة تستطيع إزالتها مسبقًا؛ على المحرك أن يجدها وقت التشغيل، وهذه مهمة وحدة الـ leading non-zero detection في الجزء 08.
What the two words on the slide meanمعنى الكلمتين على الشريحة
- Static sparsity (weights)التناثر الثابت (الأوزان)
- The set X_i of columns where row i has a nonzero is fixed once pruning and fine-tuning finish. It can be encoded offline into the storage format and never changes from input to input.المجموعة X_i من الأعمدة التي يحمل فيها الصف i قيمة غير صفرية تثبت بمجرد انتهاء الـ pruning والـ fine-tuning. يمكن ترميزها مسبقًا (offline) في صيغة التخزين، ولا تتغير أبدًا من مُدخل لآخر.
- Dynamic sparsity (activations)التناثر الديناميكي (التفعيلات)
- The set Y of indices where a_j is nonzero depends on this input: ReLU zeroed whatever came out negative. It must be detected at run time by scanning the vector.المجموعة Y من الفهارس التي يكون فيها a_j غير صفري تعتمد على هذا المُدخل بالذات: صفّر ReLU كل ما خرج سالبًا. يجب اكتشافها وقت التشغيل بمسح المتجه.
The four factors behind the paper's 28,800x energy figureالمعاملات الأربعة وراء رقم الطاقة 28,800x في الورقة
- SRAM instead of DRAMSRAM بدلًا من DRAM
- 120x120x
- Weight sparsityتناثر الأوزان
- 10x10x
- Weight sharingمشاركة الأوزان
- 8x8x
- Skipped activationsالتفعيلات المتخطّاة
- 3x3x
- Productحاصل الضرب
- 120 x 10 x 8 x 3 = 28,800x120 x 10 x 8 x 3 = 28,800x
Quick checkاختبار سريع
Which of EIE's savings is dynamic, meaning it depends on the input at run time?أيّ مصادر التوفير في EIE ديناميكي، أي يعتمد على المُدخل وقت التشغيل؟
Quick checkاختبار سريع
Why does 90 percent weight sparsity cut EIE's memory only 5x while cutting computation 10x?لماذا يقلل تناثر الأوزان بنسبة 90 percent ذاكرة EIE بـ 5x فقط بينما يقلل الحساب بـ 10x؟
Recall
State EIE's three sources of savings with the numbers on slide 57.اذكر مصادر التوفير الثلاثة في EIE بالأرقام الموجودة على الشريحة 57.
Recall
Why is activation sparsity called dynamic while weight sparsity is static?لماذا يُسمّى تناثر التفعيلات ديناميكيًا بينما تناثر الأوزان ثابت؟
Slides 58 to 60 show the same small figure three times, and it is worth working it with real numbers before reading the rule. The input is a = (0, a1, 0, a3), the weight matrix is 8 x 4 with eleven nonzeros, and there are four processing elements. Give the symbols values: a = (0, 2, 0, 1), and in the matrix w00 = 1, w01 = 3, w03 = -2, w12 = 5, w21 = -1, w23 = 1, row 3 empty, w42 = 2, w43 = -3, w50 = 6, w63 = 2, w71 = -4. The colors on the slide say who owns what: row 0 is PE0, row 1 is PE1, row 2 is PE2, row 3 is PE3, and row 4 wraps around to PE0 again.
تعرض الشرائح من 58 إلى 60 الشكل الصغير نفسه ثلاث مرات، ويستحق أن تحلّه بأرقام حقيقية قبل قراءة القاعدة. المُدخل هو a = (0, a1, 0, a3)، ومصفوفة الأوزان بحجم 8 x 4 فيها إحدى عشرة قيمة غير صفرية، وهناك أربع processing elements (وحدات معالجة). أعطِ الرموز قيمًا: a = (0, 2, 0, 1)، وفي المصفوفة w00 = 1، w01 = 3، w03 = -2، w12 = 5، w21 = -1، w23 = 1، والصف 3 فارغ، w42 = 2، w43 = -3، w50 = 6، w63 = 2، w71 = -4. الألوان على الشريحة تبيّن من يملك ماذا: الصف 0 لـ PE0، والصف 1 لـ PE1، والصف 2 لـ PE2، والصف 3 لـ PE3، ثم يلتف الصف 4 عائدًا إلى PE0 من جديد.
Worked exampleمثال محلول
Two broadcasts, seven multiplicationsبثّان وسبع عمليات ضرب
Scan a for its first nonzeroامسح a بحثًا عن أول قيمة غير صفرية
a0 = 0, so column 0 is skipped for every PE at once. The first nonzero is a1 = 2, and the controller broadcasts the pair (2, j = 1) to all four PEs.a0 = 0، لذا يُتخطّى العمود 0 لكل الـ PEs دفعة واحدة. أول قيمة غير صفرية هي a1 = 2، فيبثّ المتحكم (controller) الزوج (2, j = 1) إلى الـ PEs الأربع.Each PE works column 1 of its own rowsكل PE يعالج العمود 1 من صفوفه
PE0 holds w01 = 3: b0 += 3 x 2 = 6. PE2 holds w21 = -1: b2 += -2. PE3 holds w71 = -4: b7 += -8. PE1 has no nonzero in column 1 and does nothing.PE0 يحمل w01 = 3: b0 += 3 x 2 = 6. PE2 يحمل w21 = -1: b2 += -2. PE3 يحمل w71 = -4: b7 += -8. ليس لدى PE1 أي قيمة غير صفرية في العمود 1 فلا يفعل شيئًا.Scan on and broadcast a3تابع المسح وابثّ a3
a2 = 0, so column 2 is skipped, and with it w12 and w42, which are never read. The next nonzero is a3 = 1, broadcast as (1, j = 3).a2 = 0، لذا يُتخطّى العمود 2، ومعه w12 وw42 اللذان لا يُقرآن أبدًا. القيمة غير الصفرية التالية هي a3 = 1، وتُبثّ على شكل (1, j = 3).Each PE works column 3كل PE يعالج العمود 3
PE0: b0 += -2 x 1, giving 4; and b4 += -3 x 1 = -3. PE2: b2 += 1 x 1, giving -1; and b6 += 2 x 1 = 2. PE1 and PE3 have nothing in column 3.PE0: b0 += -2 x 1، فيصبح 4؛ وb4 += -3 x 1 = -3. PE2: b2 += 1 x 1، فيصبح -1؛ وb6 += 2 x 1 = 2. ليس لدى PE1 وPE3 شيء في العمود 3.ReLU inside each PEReLU داخل كل PE
b = (4, 0, -1, 0, -3, 0, 2, -8) becomes (4, 0, 0, 0, 0, 0, 2, 0). The negative rows 2, 4 and 7 are the ones the slide draws as -b2, -b4, -b7 and zeroes after ReLU.b = (4, 0, -1, 0, -3, 0, 2, -8) يصبح (4, 0, 0, 0, 0, 0, 2, 0). الصفوف السالبة 2 و4 و7 هي التي ترسمها الشريحة على شكل -b2 و-b4 و-b7 ثم أصفارًا بعد ReLU.7 multiplications instead of 327 عمليات ضرب بدلًا من 32
The dense product needs 8 x 4 = 32 MACs. EIE performs 7, a 4.6x reduction, stores 11 weights instead of 32, and never touches columns 0 and 2.الضرب الكثيف يحتاج 8 x 4 = 32 عملية MAC. أما EIE فينفّذ 7 فقط، أي تقليل بمقدار 4.6x، ويخزّن 11 وزنًا بدلًا من 32، ولا يلمس العمودين 0 و2 أبدًا.
| PEPE | Rows ownedالصفوف التي يملكها | Nonzero weights storedالأوزان غير الصفرية المخزّنة | MACs performedعمليات MAC المنفّذة | Outputs before ReLUالمُخرجات قبل ReLU |
|---|---|---|---|---|
| PE0PE0 | 0, 40, 4 | 55 | 3 (w01, w03, w43)3 (w01, w03, w43) | b0 = 4, b4 = -3b0 = 4, b4 = -3 |
| PE1PE1 | 1, 51, 5 | 22 | 0 (columns 0 and 2 skipped)0 (العمودان 0 و2 متخطّيان) | b1 = 0, b5 = 0b1 = 0, b5 = 0 |
| PE2PE2 | 2, 62, 6 | 33 | 3 (w21, w23, w63)3 (w21, w23, w63) | b2 = -1, b6 = 2b2 = -1, b6 = 2 |
| PE3PE3 | 3, 73, 7 | 11 | 1 (w71)1 (w71) | b3 = 0, b7 = -8b3 = 0, b7 = -8 |
| Totalالمجموع | 8 rows8 صفوف | 11 of 3211 من 32 | 7 of 32 dense MACs7 من 32 عملية MAC كثيفة | ReLU keeps b0 = 4 and b6 = 2يُبقي ReLU على b0 = 4 وb6 = 2 |
The rule: interleave rows, broadcast activationsالقاعدة: وزّع الصفوف بالتناوب، وابثّ التفعيلات
The paper states the partition in one sentence: with N PEs, "PE_k holds all rows W_i, output activationsb_i, and input activations a_i for which i (mod N) = k". Rows are dealt out round-robin like cards, so PE0 gets rows 0, 4, 8 and so on. Each PE keeps only the nonzeros of its rows, in its own CSC arrays and its own SRAM, so no PE ever sees the full matrix and no zero weight is stored anywhere. That is the rule of thumb 0 x A = 0 made physical. On the left of slide 58 the same idea appears as hardware: a grid of identical PEs wired to one central control unit that does the scanning and broadcasting (the slide draws 16; the EIE configuration evaluated in the paper uses 64).
تذكر الورقة التقسيم في جملة واحدة: مع N من الـ PEs، "PE_k holds all rows W_i, output activations b_i, and input activations a_i for which i (mod N) = k"، أي أن PE_k يحمل كل الصفوف W_i وتفعيلات الإخراج b_i وتفعيلات الإدخال a_i التي تحقق i (mod N) = k. تُوزَّع الصفوف بالتناوب (round-robin) كما تُوزَّع أوراق اللعب، فيحصل PE0 على الصفوف 0 و4 و8 وهكذا. يحتفظ كل PE بالقيم غير الصفرية من صفوفه فقط، في مصفوفات CSC الخاصة به وفي ذاكرة SRAM الخاصة به، لذا لا يرى أي PE المصفوفة كاملة أبدًا ولا يُخزَّن أي وزن صفري في أي مكان. هذه هي القاعدة التقريبية 0 x A = 0 وقد تجسّدت في العتاد. وعلى يسار الشريحة 58 تظهر الفكرة نفسها كعتاد: شبكة من PEs متطابقة موصولة بوحدة تحكم مركزية واحدة تتولى المسح والبث (ترسم الشريحة 16؛ أما إعداد EIE الذي قيّمته الورقة فيستخدم 64).
The dataflow follows from the ownership. The paper describes it as "scanning vector a to find its next non-zero value a_j and broadcasting a_j along with its index j to all PEs. Each PE then multiplies a_j by the non-zero elements in its portion of column W_j, accumulating the partial sums in accumulators for each element of the output activation vector b." The broadcast is necessary because a_j lives in a column, and a column cuts across every PE's rows: any of the four might hold a nonzero in column j, and only the PE that owns row i is allowed to update b_i. The reward is that every output belongs to exactly one PE, so there is no reduction step between PEs at the end. The paper weighs this explicitly among three ways to partition the matrix and concludes that distributing rows gives "full locality for vector b. The drawback is that vector a needs to be broadcast". The broadcast is cheap: a is about 4 K long and about 30 percent dense, so around 1.2 K broadcasts per layer, each followed by many cycles of local work, and FIFOs decouple the controller from the PEs so the broadcast is not on the critical path.
تدفق البيانات (dataflow) ينتج مباشرة عن هذه الملكية. تصفه الورقة هكذا: "scanning vector a to find its next non-zero value a_j and broadcasting a_j along with its index j to all PEs. Each PE then multiplies a_j by the non-zero elements in its portion of column W_j, accumulating the partial sums in accumulators for each element of the output activation vector b."، أي مسح المتجه a لإيجاد قيمته غير الصفرية التالية a_j وبثّ a_j مع فهرسه j إلى كل الـ PEs، ثم يضرب كل PE القيمة a_j في العناصر غير الصفرية في حصته من العمود W_j، ويجمّع المجاميع الجزئية في مُجمِّعات (accumulators) لكل عنصر من متجه تفعيلات الإخراج b. الـ broadcast (البث) ضروري لأن a_j يقابل عمودًا، والعمود يقطع صفوف كل الـ PEs: أيٌّ من الأربعة قد يحمل قيمة غير صفرية في العمود j، ووحده الـ PE الذي يملك الصف i مسموح له بتحديث b_i. والمكافأة أن كل مُخرَج ينتمي إلى PE واحد بالضبط، فلا حاجة إلى خطوة اختزال (reduction) بين الـ PEs في النهاية. توازن الورقة هذا صراحةً بين ثلاث طرق لتقسيم المصفوفة وتخلص إلى أن توزيع الصفوف يعطي "full locality for vector b. The drawback is that vector a needs to be broadcast"، أي محلية كاملة للمتجه b، وعيبها أن المتجه a يجب أن يُبثّ. والبث رخيص: طول a نحو 4 K وكثافته نحو 30 percent، أي قرابة 1.2 K عملية بث لكل طبقة، تتبع كلًّا منها دورات كثيرة من العمل المحلي، وطوابير FIFO تفصل المتحكم عن الـ PEs حتى لا يقع البث على المسار الحرج (critical path).
Zero activations, the Activation sparsity of the previous concept, are handled by the scan itself. A zero is never broadcast, so its whole column is skipped for all N PEs in one decision, which is W x 0 = 0 made physical and what slide 60 highlights by boxing a0 = 0. In part 08 that scan is the Leading non-zero detection unit, and the word "logically" on slide 59 is a reminder that the tidy 8 x 4 grid is the logical view only. Physically PE0 holds a compressed slice with five entries and never sees the zeros that the figure draws.
التفعيلات الصفرية، أي الـ activation sparsity من المفهوم السابق، يعالجها المسح نفسه. الصفر لا يُبثّ أبدًا، لذا يُتخطّى عموده كاملًا لكل الـ N من الـ PEs بقرار واحد، وهذه هي W x 0 = 0 وقد تجسّدت في العتاد، وهي ما تبرزه الشريحة 60 بوضع إطار حول a0 = 0. في الجزء 08 يكون هذا المسح هو وحدة الـ leading non-zero detection، وكلمة "logically" (منطقيًا) على الشريحة 59 تذكير بأن شبكة 8 x 4 المرتبة هي العرض المنطقي فقط. فعليًا يحمل PE0 شريحة مضغوطة فيها خمسة مُدخلات، ولا يرى أبدًا الأصفار التي يرسمها الشكل.
- PE0rows 0, 4الصفوف 0, 4idle this broadcastخاملة في هذا البث5 stored5 مخزّنة0 MACs so far0 MACs حتى الآن
- PE1rows 1, 5الصفوف 1, 5idle this broadcastخاملة في هذا البث2 stored2 مخزّنة0 MACs so far0 MACs حتى الآن
- PE2rows 2, 6الصفوف 2, 6idle this broadcastخاملة في هذا البث3 stored3 مخزّنة0 MACs so far0 MACs حتى الآن
- PE3rows 3, 7الصفوف 3, 7idle this broadcastخاملة في هذا البث1 stored1 مخزّنة0 MACs so far0 MACs حتى الآن
Row i belongs to PE (i mod 4), so each output b_i is accumulated inside exactly one PE and no result ever crosses between PEs. The controller scans a for its next nonzero, broadcasts that value with its column index, and every PE multiplies it by the nonzero weights it holds in that column. A zero activation means the whole column is skipped for all four PEs at once, and a zero weight was never stored, so neither rule of thumb costs a cycle. The imbalance readout shows the price: whichever PE holds the most nonzeros in the broadcast column sets the pace.الصف i ينتمي إلى PE (i mod 4)، لذا يُجمَّع كل خرج b_i داخل PE واحدة بالضبط ولا تنتقل أي نتيجة بين وحدات PE. يفحص المتحكم المتجه a بحثًا عن القيمة غير الصفرية التالية، ويبثها مع فهرس عمودها، فتضربها كل PE في الأوزان غير الصفرية التي تحملها في ذلك العمود. التنشيط الصفري يعني تخطي العمود كله في الوحدات الأربع معًا، والوزن الصفري لم يُخزَّن أصلًا، فلا تكلف أي من القاعدتين دورة واحدة. ويُظهر مؤشر عدم التوازن الثمن: الوحدة التي تحمل أكثر القيم غير الصفرية في عمود البث هي التي تحدد الإيقاع.
Why interleave rather than blockلماذا التوزيع بالتناوب لا بالكتل
The paper weighs three partitions (Section VII-A). Splitting by columns gives each a_j to one PE but needs a reduction across PEs and becomes unbalanced because a is 70 percent zero. 2D blocks need both a broadcast and a reduction. Splitting by rows keeps each b_i local and costs only one broadcast per column. Dealing rows out round-robin (rather than in contiguous blocks, a choice the paper does not justify explicitly) spreads each column's nonzeros across PEs. The small example already shows the residual problem: column 3 gives PE0 and PE2 two multiplications each while PE1 and PE3 get none, and over the whole product PE1 does nothing at all. The busiest PE sets the pace of every broadcast. This is the Load balance issue that the activation queue in part 08 softens by letting PEs run ahead, and that ESE later attacked at pruning time.
توازن الورقة بين ثلاثة تقسيمات (Section VII-A). التقسيم حسب الأعمدة يعطي كل a_j لـ PE واحد، لكنه يحتاج إلى اختزال (reduction) عبر الـ PEs ويصبح غير متوازن لأن 70 percent من a أصفار. والكتل ثنائية الأبعاد (2D blocks) تحتاج إلى بث واختزال معًا. أما التقسيم حسب الصفوف فيُبقي كل b_i محليًا ولا يكلّف إلا بثًا واحدًا لكل عمود. وتوزيع الصفوف بالتناوب (round-robin) بدلًا من كتل متجاورة، وهو اختيار لا تبرره الورقة صراحةً، ينشر القيم غير الصفرية في كل عمود على الـ PEs. والمثال الصغير يُظهر بالفعل المشكلة المتبقية: العمود 3 يعطي PE0 وPE2 عمليتي ضرب لكل منهما بينما لا يحصل PE1 وPE3 على شيء، وعلى امتداد الضرب كله لا يفعل PE1 شيئًا على الإطلاق. الـ PE الأكثر انشغالًا يحدد إيقاع كل عملية بث. هذه هي مشكلة الـ load balance (توازن الحمل) التي يخففها طابور التفعيلات (activation queue) في الجزء 08 بالسماح للـ PEs بأن تسبق غيرها، والتي عالجها ESE لاحقًا وقت الـ pruning.
Quick checkاختبار سريع
In EIE, how are the rows of the weight matrix assigned to processing elements?في EIE، كيف تُوزَّع صفوف مصفوفة الأوزان على وحدات المعالجة (processing elements)؟
Quick checkاختبار سريع
The central control unit finds a nonzero activation a_j. What does EIE do with it?تجد وحدة التحكم المركزية قيمة تفعيل غير صفرية a_j. ماذا يفعل EIE بها؟
Recall
In EIE with N PEs, which PE holds row i, and what happens when the controller finds a nonzero a_j?في EIE مع N من الـ PEs، أي PE يحمل الصف i، وماذا يحدث حين يجد المتحكم قيمة غير صفرية a_j؟
Recall
Which layers did EIE accelerate, and which did it not?أي الطبقات سرّعها EIE، وأيها لم يسرّعها؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Pruning alone leaves gains on paper: a 91 percent sparse AlexNet FC6 runs only 2.5x faster on a CPU and 4x on a Titan X at batch 1, and slower than dense at batch 64.الـ pruning وحده يترك المكاسب على الورق: طبقة FC6 في AlexNet المتناثرة بنسبة 91 percent تعمل أسرع بـ 2.5x فقط على الـ CPU وبـ 4x على Titan X عند batch 1، وأبطأ من النسخة الكثيفة (dense) عند batch 64.
- Han's paradigm: train, compress (prune, quantize, Huffman), then run on an engine that computes directly on the compressed form (NeurIPS 2015, ICLR 2016, ISCA 2016, FPGA 2017).نموذج Han: درّب، ثم اضغط (pruning ثم quantization ثم Huffman)، ثم شغّل على محرك يحسب مباشرة على الصيغة المضغوطة (NeurIPS 2015، ICLR 2016، ISCA 2016، FPGA 2017).
- EIE was the first accelerator for sparse, compressed networks: 189x faster and 24,000x more energy efficient than a CPU, 13x and 3,400x versus a GPU, 102 GOPS on compressed work equal to 3 TOPS dense, 64 PEs at 800 MHz, 600 mW.كان EIE أول مسرّع للشبكات المتناثرة المضغوطة: أسرع بـ 189x وأكفأ في الطاقة بـ 24,000x من الـ CPU، و13x و3,400x مقارنة بالـ GPU، و102 GOPS على العمل المضغوط تعادل 3 TOPS على الشبكة الكثيفة، بـ 64 PEs عند 800 MHz واستهلاك 600 mW.
- Three savings: sparse weights (90 percent static) 10x compute and 5x memory; sparse activations (70 percent dynamic) 3x compute; weight sharing (4-bit) 8x memory. Rules of thumb 0 x A = 0 and W x 0 = 0.ثلاثة مصادر للتوفير: الأوزان المتناثرة (90 percent ثابت) توفر 10x في الحساب و5x في الذاكرة؛ التفعيلات المتناثرة (70 percent ديناميكي) توفر 3x في الحساب؛ مشاركة الأوزان (4-bit) توفر 8x في الذاكرة. القاعدتان التقريبيتان: 0 x A = 0 و W x 0 = 0.
- Static sparsity is fixed after training; dynamic sparsity is created by ReLU per input and must be detected at run time.التناثر الثابت يتحدد نهائيًا بعد التدريب؛ أما التناثر الديناميكي فيصنعه ReLU لكل مُدخل على حدة ويجب اكتشافه وقت التشغيل.
- Rows are interleaved, PE_k holds rows i with i mod N = k, so every output stays local; nonzero activations are broadcast with their index and zero activations skip whole columns.الصفوف موزعة بالتناوب، فالـ PE_k يحمل الصفوف i التي تحقق i mod N = k، لذا يبقى كل مُخرَج محليًا؛ وتُبثّ التفعيلات غير الصفرية مع فهرسها، والتفعيلات الصفرية تجعل أعمدة كاملة تُتخطّى.
- EIE targets matrix-vector products in FC and LSTM layers at batch size 1, not convolutions.يستهدف EIE ضرب المصفوفة في المتجه في طبقات FC و LSTM عند batch size 1، وليس الـ convolutions.
Sourcesالمصادر
- EIE: Efficient Inference Engine on Compressed Deep Neural NetworkPaperISCA 2016, Han, Liu, Mao, Pu, Pedram, Horowitz, DallySavings factors, Table I energy, Table III densities, Table IV timings, Section III-C interleaving and broadcast, Section VII partitioningمعاملات التوفير، وطاقة Table I، وكثافات Table III، وأزمنة Table IV، والتوزيع بالتناوب والبث في Section III-C، والتقسيم في Section VII(opens in a new tab)(يفتح في تبويب جديد)
- Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman CodingPaperICLR 2016 best paper, Han, Mao, Dally35x and 49x, k-means codebook, fitting the model in SRAMنسبتا 35x و49x، وقاموس k-means، واتساع النموذج داخل الـ SRAM(opens in a new tab)(يفتح في تبويب جديد)
- Learning both Weights and Connections for Efficient Neural NetworksPaperNeurIPS 2015, Han, Pool, Tran, Dally9x AlexNet and 13x VGG-16 parameter reductionتقليل معاملات AlexNet بـ 9x ومعاملات VGG-16 بـ 13x(opens in a new tab)(يفتح في تبويب جديد)
- ESE: Efficient Speech Recognition Engine with Sparse LSTM on FPGAPaperFPGA 2017 best paper, Han et al.The FPGA'17 box on slide 56; load-balance-aware pruningمربع FPGA'17 على الشريحة 56؛ والـ pruning الذي يراعي توازن الحمل(opens in a new tab)(يفتح في تبويب جديد)
- DSD: Dense-Sparse-Dense Training for Deep Neural NetworksPaperICLR 2017, Han et al.The ICLR'17 label under Training on slide 56عنوان ICLR'17 تحت Training على الشريحة 56(opens in a new tab)(يفتح في تبويب جديد)
- Retrospective: EIE, Efficient Inference Engine on Sparse and Compressed Neural NetworkPaperHan et al., 2023FC-only limitation, 50 percent index overhead, structured successorsالاقتصار على طبقات FC، وكلفة الفهارس الإضافية البالغة 50 percent، والأعمال اللاحقة ذات التناثر المنتظم (structured)(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 Fall 2024, Lecture 4: Pruning and Sparsity Part IIDocsSong Han, MIT HAN LabThe source deck these slides copy, including the 8 x 4 figureمجموعة الشرائح الأصلية التي نُسخت منها هذه الشرائح، بما فيها شكل 8 x 4(opens in a new tab)(يفتح في تبويب جديد)
- Lecture 4 video: Pruning and Sparsity Part IIVideoMIT 6.5940, Song HanWalk-through of the EIE slidesشرح متسلسل لشرائح EIE(opens in a new tab)(يفتح في تبويب جديد)
- Accelerating Inference with Sparsity Using the NVIDIA Ampere Architecture and NVIDIA TensorRTDocsNVIDIA Developer Blog2:4 definition for the roadmap rowتعريف 2:4 لصف الخريطة(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse: Efficient Point Cloud Inference EnginePaperMLSys 2022, Tang et al.Roadmap rowصف الخريطة(opens in a new tab)(يفتح في تبويب جديد)
- PointAcc: Efficient Point Cloud AcceleratorPaperMICRO 2021, Lin et al.Roadmap rowصف الخريطة(opens in a new tab)(يفتح في تبويب جديد)
- Song HanDocsMIT HAN LabStanford PhD advised by Bill Dally, for the affiliation note on slide 56دكتوراه من Stanford بإشراف Bill Dally، لملاحظة الانتماء على الشريحة 56(opens in a new tab)(يفتح في تبويب جديد)
Part 08: Inside EIE: dataflow, the PE and its storage formatsداخل EIE: تدفق البيانات وعنصر المعالجة وصيغ التخزين
How a nonzero activation walks through the PE array, what one processing element contains, how load is balanced, and how activation sparsity, CSC weight storage and 4-bit codebooks are realised in hardware.كيف يمر تنشيط غير صفري عبر مصفوفة عناصر المعالجة (PE)، وما يحتويه عنصر معالجة واحد، وكيف يُوازَن الحمل، وكيف يُنفَّذ تناثر التنشيطات وتخزين الأوزان بصيغة CSC ودفاتر الترميز (codebooks) ذات 4 بت في العتاد.
3 concepts3 مفاهيم, ، slides 61-70الشرائح 61-70
Why this part mattersلماذا يهمّ هذا الجزء
Part 07 argued that a pruned, quantized network is only fast if the hardware never looks at a zero. This part is where that argument turns into wires and SRAM words. It follows one nonzero activation from the moment the controller finds it to the moment its products land in output registers, opens a single processing element to see the five stages inside, and then reads the storage format bit by bit.
Exam questions on EIE ask for exactly these three things: the dataflow, the PE stages in order, and the storage format with bit widths. Your research project on embedded inference needs the same reasoning whenever you choose a sparse format or an accelerator, because the questions never change: how much metadata does each nonzero cost, how do you keep parallel units equally busy, and how much of the model fits on chip. The running example is the same 8 x 4 matrix on four PEs that part 07 introduced.
بيّن الجزء 07 أن الشبكة المقلَّمة (pruned) والمكمَّاة (quantized) لا تكون سريعة إلا إذا لم ينظر العتاد إلى أي صفر على الإطلاق. وفي هذا الجزء تتحول تلك الحجة إلى أسلاك وكلمات SRAM. نتتبع تفعيلًا واحدًا غير صفري من لحظة عثور وحدة التحكم عليه إلى لحظة وصول نواتج ضربه إلى سجلات المخرجات، ثم نفتح عنصر معالجة (PE) واحدًا لنرى المراحل الخمس بداخله، وبعدها نقرأ صيغة التخزين بتًّا بتًّا.
أسئلة الامتحان عن EIE تطلب هذه الأمور الثلاثة تحديدًا: مسار البيانات (dataflow)، ومراحل الـ PE بالترتيب، وصيغة التخزين مع عرض كل حقل بالبتات. ومشروعك البحثي في الاستدلال على الأنظمة المدمجة (embedded inference) يحتاج المنطق نفسه كلما اخترت صيغة متناثرة أو مسرّعًا، لأن الأسئلة لا تتغير: كم من البيانات الوصفية (metadata) تكلّف كل قيمة غير صفرية، وكيف تُبقي الوحدات المتوازية مشغولة بالتساوي، وكم من النموذج يتسع على الشريحة. المثال المستمر هو المصفوفة نفسها 8 x 4 على أربعة PEs التي قدّمها الجزء 07.
By the end you canفي نهاية هذا الجزء ستستطيع
- Trace a sparse matrix-vector product through EIE's broadcast-and-accumulate dataflow for a given input vector, listing which PEs work on each broadcast.تتبّع ضرب مصفوفة متناثرة في متجه عبر مسار البيانات في EIE القائم على البث ثم التجميع (broadcast-and-accumulate) لمتجه دخل معطى، مع تحديد أي الـ PEs تعمل في كل عملية بث.
- Name the five PE stages in order and state what data crosses each boundary.تسمية مراحل الـ PE الخمس بالترتيب، وتحديد البيانات التي تعبر كل حدّ بين مرحلتين.
- Encode a column in EIE's relative-index CSC with 4-bit indices, including padding, and derive the pointer array.ترميز عمود بصيغة CSC ذات الفهرس النسبي في EIE بفهارس من 4 بتات، بما في ذلك الحشو (padding)، واستنتاج مصفوفة المؤشرات.
- Explain how the activation FIFO, leading nonzero detection, even and odd pointer banks and the bypass path each remove a stall.شرح كيف يزيل كلٌّ من طابور التفعيلات (FIFO)، وكشف أول قيمة غير صفرية (leading nonzero detection)، وبنكي المؤشرات الزوجي والفردي، ومسار التجاوز (bypass) توقفًا معينًا.
- Quote the key EIE numbers: 4-bit weights and indices, a 16-entry codebook, 16-bit fixed point, FIFO depth 8, 64 PEs and 162 KB of SRAM per PE.ذكر أرقام EIE الأساسية: أوزان وفهارس من 4 بتات، وجدول ترميز (codebook) من 16 مدخلًا، وتمثيل ثابت الفاصلة (fixed point) بـ 16 بت، وعمق FIFO يساوي 8، و64 PE، و162 KB من SRAM لكل PE.
Start with the picture from part 07. An 8 x 4 weight matrix is split across four processing elements by interleaving rows: PE0 owns rows 0 and 4, PE1 rows 1 and 5, PE2 rows 2 and 6, PE3 rows 3 and 7. In general, with N PEs, PE k holds every row i with i mod N = k, together with the output b_i it will produce and the input a_i of the same index (Han et al., 2016). The input vector for the layer is a = (0, a1, 0, a3): two of its four entries are zero, which is typical of what ReLU leaves behind.
ابدأ بالصورة من الجزء 07. مصفوفة أوزان 8 x 4 مقسّمة على أربعة عناصر معالجة (processing elements) بتوزيع الصفوف بالتناوب: PE0 يملك الصفين 0 و4، وPE1 الصفين 1 و5، وPE2 الصفين 2 و6، وPE3 الصفين 3 و7. وبشكل عام، مع N من الـ PEs، يحمل الـ PE رقم k كل صف i يحقق i mod N = k، ومعه المخرج b_i الذي سينتجه والمدخل a_i ذو الفهرس نفسه (Han et al., 2016). متجه الدخل لهذه الطبقة هو a = (0, a1, 0, a3): اثنان من مدخلاته الأربعة أصفار، وهذا معتاد فيما يتركه ReLU خلفه.
The whole computation is a sequence of broadcasts. A central control unit scans a for its next nonzero, finds a1 at index 1, and sends the pair (a1, 1) to every PE at once. Each PE then does something entirely local: it looks up column 1 of its own rows in compressed form, multiplies each nonzero weight it finds there by a1, and adds the product into the output entry for that row. When every PE has finished (or, as the next concept shows, has at least queued the work), the controller finds the next nonzero, a3, and the same thing happens for column 3. Columns 0 and 2 are never visited, because the activations that would multiply them are zero, and W x 0 = 0. Inside each visited column, the zero weights are never visited either, because 0 x A = 0 and the compressed format simply does not store them.
الحساب كله سلسلة من عمليات البث (broadcasts). وحدة تحكم مركزية تمسح a بحثًا عن القيمة غير الصفرية التالية، فتجد a1 عند الفهرس 1، وترسل الزوج (a1, 1) إلى كل الـ PEs دفعة واحدة. ثم يقوم كل PE بعمل محلي بالكامل: يبحث عن العمود 1 من صفوفه الخاصة في صيغته المضغوطة، ويضرب كل وزن غير صفري يجده هناك في a1، ويضيف الناتج إلى مدخل المخرجات الخاص بذلك الصف. وعندما ينتهي كل PE (أو، كما تبيّن الفكرة التالية، يكون على الأقل قد وضع العمل في طابوره)، تجد وحدة التحكم القيمة غير الصفرية التالية a3، ويتكرر الشيء نفسه مع العمود 3. العمودان 0 و2 لا يُزاران أبدًا، لأن التفعيلات التي كانت ستُضرب فيهما أصفار، وW x 0 = 0. وداخل كل عمود يُزار، لا تُزار الأوزان الصفرية أيضًا، لأن 0 x A = 0 والصيغة المضغوطة ببساطة لا تخزنها.
Worked exampleمثال محلول
Two broadcasts finish the layerعمليتا بث تُنهيان الطبقة
Skip a0تخطَّ a0
The leading nonzero detector reports that the first nonzero of a is a1, not a0. Column 0 holds w00 (PE0) and w50 (PE1), and neither weight is ever read.يُبلغ كاشف أول قيمة غير صفرية (leading nonzero detector) أن أول قيمة غير صفرية في a هي a1 وليست a0. العمود 0 يحمل w00 (في PE0) وw50 (في PE1)، ولا يُقرأ أيٌّ من الوزنين أبدًا.Broadcast (a1, 1)بث (a1, 1)
PE0 walks its column-1 slice and finds w01, so b0 += w01 a1. PE1 finds nothing in column 1. PE2 finds w21, so b2 += w21 a1. PE3 finds w71, so b7 += w71 a1. Multiplies this round: 1, 0, 1, 1.يمرّ PE0 على شريحته من العمود 1 فيجد w01، إذن b0 += w01 a1. لا يجد PE1 شيئًا في العمود 1. يجد PE2 الوزن w21، إذن b2 += w21 a1. يجد PE3 الوزن w71، إذن b7 += w71 a1. عدد عمليات الضرب في هذه الجولة: 1, 0, 1, 1.Skip a2تخطَّ a2
Column 2 holds w12 (PE1) and w42 (PE0). Both stay untouched.العمود 2 يحمل w12 (في PE1) وw42 (في PE0). يبقى كلاهما دون أن يُمس.Broadcast (a3, 3)بث (a3, 3)
PE0 finds w03 then w43: b0 += w03 a3 and b4 += w43 a3. PE2 finds w23 then w63: b2 += w23 a3 and b6 += w63 a3. PE1 and PE3 have nothing in column 3. Multiplies this round: 2, 0, 2, 0.يجد PE0 الوزن w03 ثم w43: b0 += w03 a3 وb4 += w43 a3. ويجد PE2 الوزن w23 ثم w63: b2 += w23 a3 وb6 += w63 a3. أما PE1 وPE3 فليس لديهما شيء في العمود 3. عدد عمليات الضرب في هذه الجولة: 2, 0, 2, 0.Seven multiplies instead of thirty-twoسبع عمليات ضرب بدلًا من اثنتين وثلاثين
A dense multiply would have done 8 x 4 = 32 multiply-adds. EIE did 3 + 4 = 7, about 22%, and touched only the weights whose activation and value were both nonzero. ReLU then runs over b: the slide draws b2, b4 and b7 as negative, so they become zero, and the next layer's detector will skip them in turn.Outputالمخرج Contributionsالمساهمات Ownerالمالك Whenمتى b0b0 w01 a1 + w03 a3w01 a1 + w03 a3 PE0PE0 Both broadcastsعمليتا البث كلتاهما b2b2 w21 a1 + w23 a3w21 a1 + w23 a3 PE2PE2 Both broadcastsعمليتا البث كلتاهما b4b4 w43 a3w43 a3 PE0PE0 Second broadcast onlyالبث الثاني فقط b6b6 w63 a3w63 a3 PE2PE2 Second broadcast onlyالبث الثاني فقط b7b7 w71 a1w71 a1 PE3PE3 First broadcast onlyالبث الأول فقط b1, b3, b5b1, b3, b5 no contributionلا مساهمة PE1, PE3, PE1PE1, PE3, PE1 Never touchedلم تُلمس أبدًا What each output entry receivedما تلقّاه كل مدخل من مدخلات المخرج كان الضرب الكثيف (dense) سيجري 8 x 4 = 32 عملية ضرب وجمع. أما EIE فأجرى 3 + 4 = 7، أي نحو 22%، ولم يلمس إلا الأوزان التي كان تفعيلها وقيمتها كلاهما غير صفريين. بعد ذلك يعمل ReLU على b: الشريحة ترسم b2 وb4 وb7 سالبة، فتصبح أصفارًا، وسيتخطاها كاشف الطبقة التالية بدوره.Outputالمخرج Contributionsالمساهمات Ownerالمالك Whenمتى b0b0 w01 a1 + w03 a3w01 a1 + w03 a3 PE0PE0 Both broadcastsعمليتا البث كلتاهما b2b2 w21 a1 + w23 a3w21 a1 + w23 a3 PE2PE2 Both broadcastsعمليتا البث كلتاهما b4b4 w43 a3w43 a3 PE0PE0 Second broadcast onlyالبث الثاني فقط b6b6 w63 a3w63 a3 PE2PE2 Second broadcast onlyالبث الثاني فقط b7b7 w71 a1w71 a1 PE3PE3 First broadcast onlyالبث الأول فقط b1, b3, b5b1, b3, b5 no contributionلا مساهمة PE1, PE3, PE1PE1, PE3, PE1 Never touchedلم تُلمس أبدًا What each output entry receivedما تلقّاه كل مدخل من مدخلات المخرج
Written as a rule, each output is a sum over only the intersection of two index sets. X_i is the set of columns where row i has a nonzero weight, fixed once pruning is done, and Y is the set of nonzero activations, which changes with every input. That is the static versus dynamic distinction from part 07 written into the arithmetic: weight sparsity shrinks X_i before deployment, activation sparsity shrinks Y at run time, and the hardware only pays for pairs in both.
إذا كتبناها كقاعدة، فكل مخرج هو مجموع على تقاطع مجموعتين من الفهارس فقط. X_i هي مجموعة الأعمدة التي يملك فيها الصف i وزنًا غير صفري، وهي ثابتة بمجرد انتهاء التقليم، وY هي مجموعة التفعيلات غير الصفرية، وهي تتغير مع كل دخل. هذا هو التمييز بين التناثر الساكن والديناميكي (static versus dynamic) من الجزء 07 مكتوبًا داخل الحساب نفسه: تناثر الأوزان (weight sparsity) يقلّص X_i قبل النشر، وتناثر التفعيلات (activation sparsity) يقلّص Y وقت التشغيل، والعتاد لا يدفع إلا ثمن الأزواج الموجودة في المجموعتين معًا.
The S[I_ij] inside the sum is a reminder that the PE never stores the weight itself, only a 4-bit code into a shared table, which the third concept unpacks. Notice also what the four PEs did not do: they never exchanged a partial sum. Every product for row i is produced in the one PE that owns row i, so the only communication in the whole layer is the broadcast of (a_j, j) pairs, which the paper carries on an H-tree so that every PE receives it in the same cycle (Han et al., 2016).
الحد S[I_ij] داخل المجموع تذكير بأن الـ PE لا يخزن الوزن نفسه أبدًا، بل يخزن فقط رمزًا من 4 بتات يشير إلى جدول مشترك، وهذا ما تفصّله الفكرة الثالثة. لاحظ أيضًا ما لم تفعله الـ PEs الأربعة: لم تتبادل أي مجموع جزئي (partial sum) على الإطلاق. كل ناتج ضرب يخص الصف i يُنتَج داخل الـ PE الوحيد الذي يملك الصف i، لذا فالاتصال الوحيد في الطبقة كلها هو بث أزواج (a_j, j)، وتنقلها الورقة عبر شجرة H-tree كي يستقبلها كل PE في الدورة نفسها (Han et al., 2016).
Recall
What does the central control unit broadcast, and what does each PE do with it?ماذا تبث وحدة التحكم المركزية، وماذا يفعل كل PE بما يصله؟
Recall
In the 8 x 4 example with a = (0, a1, 0, a3), which output entries receive a contribution, and how many multiplies happen in total?في مثال 8 x 4 مع a = (0, a1, 0, a3)، أي مدخلات المخرج تتلقى مساهمة، وكم عملية ضرب تحدث إجمالًا؟
Quick checkاختبار سريع
In EIE, how is the weight matrix divided among the processing elements?في EIE، كيف تُقسَّم مصفوفة الأوزان على عناصر المعالجة؟
Now stand inside PE0 while (a3, 3) arrives. The pair lands in a small queue at the front of the PE. The index 3 is used to look up where column 3 starts and ends in this PE's compressed storage. Those two addresses fetch the entries for the column, each an encoded weight plus a relative row index. The weight code is expanded to a real number, the relative index is turned into an absolute row, the multiply and add happen, and the result is written into the destination register for that row. When the layer is complete, ReLU and a leading nonzero detector turn the destination registers into the next layer's input. The slide draws this as the queue, then four dashed regions, then a ReLU and detector tail, and every EIE exam answer should be able to name the five stages in order.
الآن قف داخل PE0 لحظة وصول (a3, 3). يدخل الزوج إلى طابور صغير في مقدمة الـ PE. يُستخدم الفهرس 3 لمعرفة أين يبدأ العمود 3 وأين ينتهي في التخزين المضغوط (compressed storage) الخاص بهذا الـ PE. هذان العنوانان يجلبان مدخلات العمود، وكل مدخل وزن مرمَّز مع فهرس صف نسبي. يُوسَّع رمز الوزن إلى عدد حقيقي، ويُحوَّل الفهرس النسبي إلى صف مطلق، ويحدث الضرب والجمع، وتُكتب النتيجة في سجل الوجهة الخاص بذلك الصف. وعند اكتمال الطبقة، يحوّل ReLU وكاشف أول قيمة غير صفرية سجلات الوجهة إلى دخل الطبقة التالية. ترسم الشريحة هذا على شكل الطابور، ثم أربع مناطق منقّطة، ثم ذيل فيه ReLU والكاشف، ويجب أن تستطيع كل إجابة امتحان عن EIE تسمية المراحل الخمس بالترتيب.
Holds broadcast (a_j, j) pairs so this PE can lag or lead the others.
تحتفظ بأزواج البث (a_j, j) حتى تتمكن هذه الـ PE من التأخر عن الوحدات الأخرى أو سبقها.
Reads p_j and p_(j+1), the start and end of column j, in one cycle.
تقرأ p_j وp_(j+1)، أي بداية العمود j ونهايته، في دورة واحدة.
Fetches 8-bit entries, one 4-bit code and one 4-bit relative index each.
تجلب مدخلات بطول 8-bit، في كل منها رمز بطول 4-bit وفهرس نسبي بطول 4-bit.
Code becomes a 16-bit weight, relative index becomes an absolute address, product is added with a bypass for back-to-back hits.
يصبح الرمز وزنًا بطول 16-bit، ويصبح الفهرس النسبي عنوانًا مطلقًا، ويُجمع حاصل الضرب مع مسار تجاوز (bypass) للإصابات المتتالية.
Destination file collects this layer, source file feeds it; they swap roles at the next layer.
يجمع ملف الوجهة خرج هذه الطبقة ويغذيها ملف المصدر، ثم يتبادلان الدورين في الطبقة التالية.
Clamps negatives to zero and finds the next nonzero to broadcast.
تقص القيم السالبة إلى صفر وتجد القيمة غير الصفرية التالية لبثها.
The same trace, with the paper's bit widthsالتتبّع نفسه، مع عرض البتات كما في الورقة
The queue head is (a3, 3). The pointer unit reads two 16-bit pointers, p3 and p4. In PE0's arrays for the running example they are 3 and 5 (the third concept derives them), so column 3 occupies entries 3 and 4. The sparse matrix unit fetches those entries. Each is 8 bits: a 4-bit weight code and a 4-bit relative index. The SRAM is 64 bits wide, so a single read returns eight entries; the high 13 bits of a pointer select the SRAM row and the low 3 bits select the entry inside it, and the unit hands one entry per cycle to the arithmetic unit (Han et al., 2016). Why eight? With 64 PEs and about 10 percent density, a column of length 4096 leaves each PE about 6.4 nonzeros per column, so one 64-bit read usually covers a whole column.
رأس الطابور هو (a3, 3). تقرأ وحدة المؤشرات مؤشرين بعرض 16 بت، هما p3 وp4. وفي مصفوفات PE0 للمثال المستمر قيمتاهما 3 و5 (تستنتجهما الفكرة الثالثة)، أي أن العمود 3 يشغل المدخلين 3 و4. تجلب وحدة المصفوفة المتناثرة هذين المدخلين. كل مدخل بعرض 8 bits: رمز وزن من 4 بتات وفهرس نسبي من 4 بتات. عرض الـ SRAM هو 64 bits، لذا تُرجع قراءة واحدة ثمانية مدخلات؛ وأعلى 13 bits من المؤشر تختار صف الـ SRAM وأدنى 3 bits تختار المدخل داخله، وتسلّم الوحدة مدخلًا واحدًا في كل دورة إلى الوحدة الحسابية (Han et al., 2016). لماذا ثمانية؟ مع 64 من الـ PEs وكثافة تقارب 10 percent، يترك عمود طوله 4096 لكل PE نحو 6.4 قيمة غير صفرية في العمود، لذا تغطي قراءة واحدة بعرض 64 بت عادةً العمود كله.
The two entries for column 3 are (code of w03, x = 0) and (code of w43, x = 0). The weight decoder expands each 4-bit code through the layer's 16-entry table into a 16-bit fixed-point value. The address accumulator keeps a running sum of the relative indices plus one per entry, producing local rows 0 and 1, which are absolute rows 0 and 4 for PE0. The multiplier forms a3 x w03, the adder adds it to destination register 0, then a3 x w43 is added to destination register 1. Had two consecutive entries hit the same register, the adder's output would have been routed straight back to its input through the bypass path instead of waiting for the register write (Han et al., 2016).
مدخلا العمود 3 هما (code of w03, x = 0) و(code of w43, x = 0). يوسّع فاكّ ترميز الأوزان (weight decoder) كل رمز من 4 بتات عبر جدول الطبقة ذي الـ 16 مدخلًا إلى قيمة ثابتة الفاصلة بعرض 16 بت. ويحتفظ مُراكِم العناوين (address accumulator) بمجموع جارٍ للفهارس النسبية مضافًا إليه واحد لكل مدخل، فينتج الصفين المحليين 0 و1، وهما الصفان المطلقان 0 و4 في PE0. يكوّن المضاعِف a3 x w03، ويضيفه الجامع إلى سجل الوجهة 0، ثم يُضاف a3 x w43 إلى سجل الوجهة 1. ولو أصاب مدخلان متتاليان السجل نفسه، لأُعيد خرج الجامع مباشرة إلى دخله عبر مسار التجاوز (bypass) بدلًا من انتظار الكتابة في السجل (Han et al., 2016).
The activation read and write unit is two register files, source and destination, each holding 64 activations of 16 bits, enough for a 4096-long vector across 64 PEs. The destination file collects this layer's outputs while the source file supplies this layer's inputs; when the layer is done they exchange roles, so no activation is ever copied between layers. Vectors longer than 4096 spill into a 2 KB activation SRAM and are processed in batches (Han et al., 2016).
وحدة قراءة وكتابة التفعيلات عبارة عن ملفّي سجلات، مصدر ووجهة، يحمل كل منهما 64 تفعيلًا بعرض 16 bits، وهذا يكفي لمتجه طوله 4096 موزع على 64 من الـ PEs. يجمع ملف الوجهة مخرجات هذه الطبقة بينما يزوّد ملف المصدر مدخلاتها؛ وعند انتهاء الطبقة يتبادلان الدورين، فلا يُنسخ أي تفعيل بين الطبقات أبدًا. المتجهات الأطول من 4096 تفيض إلى SRAM تفعيلات بحجم 2 KB وتُعالج على دفعات (Han et al., 2016).
The pointer read deserves one more sentence, because it is a favorite exam question. A single-ported SRAM serves one read per cycle, but every column needs two pointers. EIE stores the pointers in two banks and uses the least significant bit of the address to choose the bank. Since p_j and p_(j+1) are adjacent addresses, they always land in different banks, and both are read in the same cycle without paying for a dual-ported (larger, hotter) memory (Han et al., 2016).
قراءة المؤشرات تستحق جملة إضافية، لأنها سؤال امتحان مفضّل. الـ SRAM أحادية المنفذ (single-ported) تخدم قراءة واحدة في كل دورة، لكن كل عمود يحتاج مؤشرين. يخزن EIE المؤشرات في بنكين ويستخدم البت الأقل أهمية (least significant bit) من العنوان لاختيار البنك. ولأن p_j وp_(j+1) عنوانان متجاوران، فإنهما يقعان دائمًا في بنكين مختلفين، ويُقرآن كلاهما في الدورة نفسها دون دفع ثمن ذاكرة ثنائية المنفذ (dual-ported) أكبر حجمًا وأشد حرارة (Han et al., 2016).
What one PE holdsما يحمله PE واحد
- Activation valueقيمة التفعيل
- 16-bit fixed pointثابتة الفاصلة بعرض 16 بت
- Column pointerمؤشر العمود
- 16 bits16 بت
- Sparse matrix entryمدخل المصفوفة المتناثرة
- 8 bits = 4-bit code v + 4-bit relative index x8 بتات = رمز v من 4 بتات + فهرس نسبي x من 4 بتات
- One SRAM readقراءة SRAM واحدة
- 64 bits = 8 entries64 بت = 8 مدخلات
- Pointer splitتقسيم المؤشر
- 13 high bits pick the SRAM row, 3 low bits pick the entryأعلى 13 بتًا تختار صف الـ SRAM، وأدنى 3 بتات تختار المدخل
- Activation register filesملفات سجلات التفعيلات
- 2 files x 64 entries x 16 bits (source and destination)ملفان x 64 مدخلًا x 16 بت (مصدر ووجهة)
- Activation SRAMSRAM التفعيلات
- 2 KB2 KB
- Pointer SRAMSRAM المؤشرات
- 32 KB (two banks)32 KB (بنكان)
- Sparse matrix SRAMSRAM المصفوفة المتناثرة
- 128 KB128 KB
- SRAM per PESRAM لكل PE
- 162 KB (93% of PE area, 59% of PE power)162 KB (93% من مساحة الـ PE، و59% من قدرته)
- Area and power per PEالمساحة والقدرة لكل PE
- 0.638 mm², 9.157 mW at 800 MHz, TSMC 45 nm0.638 mm²، و9.157 mW عند 800 MHz، بتقنية TSMC 45 nm
The last two rows explain the shape of the whole chip. SRAM is 93 percent of a PE's area and 59 percent of its power, and 64 PEs fill about 40.8 mm² at 590 mW (Han et al., 2016). That is the point, not a flaw: the paper's energy argument starts from the fact that a 32-bit DRAM access costs 640 pJ against 5 pJ for SRAM, about 128 times, which the paper rounds to a 120x energy saving, so a compressed model that fits entirely on chip wins before any arithmetic trick is counted. Everything in this PE is arranged to keep the model small enough to stay there.
يفسّر الصفّان الأخيران شكل الشريحة كلها. تشغل الـ SRAM نسبة 93 percent من مساحة الـ PE و59 percent من قدرته، و64 من الـ PEs تملأ نحو 40.8 mm² باستهلاك 590 mW (Han et al., 2016). وهذا هو المقصود وليس عيبًا: حجة الطاقة في الورقة تبدأ من أن الوصول إلى DRAM بعرض 32 بت يكلّف 640 pJ مقابل 5 pJ للـ SRAM، أي نحو 128 ضعفًا، وتقرّبها الورقة إلى توفير في الطاقة قدره 120x، لذا فالنموذج المضغوط الذي يتسع بالكامل على الشريحة يربح قبل احتساب أي حيلة حسابية. كل شيء في هذا الـ PE مرتّب لإبقاء النموذج صغيرًا بما يكفي ليبقى هناك.
Recall
Why can p_j and p_(j+1) always be read in one cycle?لماذا يمكن دائمًا قراءة p_j وp_(j+1) في دورة واحدة؟
Quick checkاختبار سريع
What do the even and odd pointer SRAM banks make possible?ما الذي يتيحه بنكا SRAM المؤشرات الزوجي والفردي؟
Go back to the worked example and count the multiplies per PE: 3, 0, 3, 1. That uneven count is the first of four problems the PE design must solve, and the slides walk through the solutions one dashed region at a time: a queue for load balance, a detector for activation sparsity, a compressed format for weight sparsity, a decoder for weight sharing, and finally the arithmetic and write-back that ties them together. The storage format is the thread through all of them, so this concept ends with its bit widths.
ارجع إلى المثال المحلول واحسب عمليات الضرب لكل PE: 3, 0, 3, 1. هذا العدد غير المتساوي هو أول أربع مشكلات يجب أن يحلها تصميم الـ PE، والشرائح تمرّ على الحلول منطقةً منقّطةً تلو الأخرى: طابور لـ موازنة الحمل (load balance)، وكاشف لـ تناثر التفعيلات (activation sparsity)، وصيغة مضغوطة لـ تناثر الأوزان (weight sparsity)، وفاكّ ترميز لـ مشاركة الأوزان (weight sharing)، وأخيرًا الحساب والكتابة الراجعة (write-back) اللذان يربطان كل ذلك معًا. صيغة التخزين هي الخيط الذي يمر عبرها جميعًا، لذا تنتهي هذه الفكرة بعرض حقولها بالبتات.
Load balance: let the fast PEs run aheadموازنة الحمل: دع الـ PEs السريعة تتقدّم
Because rows are interleaved, each PE may hold a different number of nonzeros in any given column. In the example, the a3 broadcast gives PE0 and PE2 two multiplies each and PE1 and PE3 none. If the controller waited for every PE before broadcasting the next activation, PE1 and PE3 would idle for two cycles on every such column. The activation queue is the fix. Each PE holds a FIFO of broadcast (value, index) pairs, the controller keeps broadcasting as long as no queue is full, and a PE with little to do in one column simply moves on to the next pair in its queue while a busier PE catches up. The paper puts it plainly: the queue lets each PE build up a backlog of work to even out load imbalance, and the broadcast is disabled only if some PE's queue is full (Han et al., 2016).
لأن الصفوف موزعة بالتناوب، قد يحمل كل PE عددًا مختلفًا من القيم غير الصفرية في أي عمود. في المثال، يعطي بث a3 كلًّا من PE0 وPE2 عمليتي ضرب، ولا يعطي PE1 وPE3 شيئًا. لو انتظرت وحدة التحكم كل الـ PEs قبل بث التفعيل التالي، لبقي PE1 وPE3 خاملين دورتين في كل عمود من هذا النوع. طابور التفعيلات هو الحل. يحمل كل PE طابور FIFO من أزواج (value, index) المبثوثة، وتستمر وحدة التحكم في البث ما دام لا يوجد طابور ممتلئ، والـ PE الذي لديه عمل قليل في عمود ما ينتقل ببساطة إلى الزوج التالي في طابوره بينما يلحق به PE أكثر انشغالًا. وتقولها الورقة صراحة: الطابور يتيح لكل PE أن يبني رصيدًا متراكمًا من العمل (backlog) لموازنة عدم توازن الحمل، ولا يُعطَّل البث إلا إذا امتلأ طابور أحد الـ PEs (Han et al., 2016).
The paper measured this. It swept the queue depth from 1 to 256 and defined load balance efficiency as one minus the starvation bubble cycles over the total. At depth 1, around half of all cycles are idle; efficiency climbs steeply to depth 8 and flattens afterwards, so 8 was chosen as the queue depth (Han et al., 2016, Figure 8). The visual above is illustrative and uses small integer loads, but the shape of the result is the paper's: a shallow queue wastes about half the machine.
قاست الورقة هذا فعلًا. غيّرت عمق الطابور من 1 إلى 256، وعرّفت كفاءة موازنة الحمل (load balance efficiency) بأنها واحد ناقص نسبة دورات الفقاعات الناتجة عن التجويع (starvation bubble cycles) إلى إجمالي الدورات. عند العمق 1 يكون نحو نصف الدورات كلها خاملًا؛ وترتفع الكفاءة بحدة حتى العمق 8 ثم تستوي بعده، لذا اختير 8 عمقًا للطابور (Han et al., 2016, Figure 8). الشكل أعلاه توضيحي ويستخدم أحمالًا صحيحة صغيرة، لكن شكل النتيجة هو ما في الورقة: الطابور الضحل يهدر نحو نصف الآلة.
Activation sparsity: never queue a zeroتناثر التفعيلات: لا تضع صفرًا في الطابور أبدًا
The queue only helps if what enters it is worth doing. Zero activations must be filtered out before the broadcast, and this is the job of leading nonzero detection. It is distributed, not central: each group of four PEs does a local detection over the activations it stores, the results feed up a quadtree of detector nodes, and the root of that tree is the central control unit, which selects the next nonzero and broadcasts it over an H-tree so that every PE receives it in the same cycle. For64 PEs that is 21 detector units (16 leaves, 4 intermediate, 1 root), each tiny at about 189 µm² and 0.023 mW (Han et al., 2016). Since about 70 percent of activations are zero after ReLU, this alone removes roughly two thirds of the potential broadcasts, which is the 3x factor in the paper's energy accounting.
الطابور لا يفيد إلا إذا كان ما يدخله يستحق التنفيذ. يجب تصفية التفعيلات الصفرية قبل البث، وهذه مهمة كشف أول قيمة غير صفرية (leading nonzero detection). وهو موزّع وليس مركزيًا: كل مجموعة من أربعة PEs تجري كشفًا محليًا على التفعيلات التي تخزنها، وتُغذّى النتائج صعودًا في شجرة رباعية (quadtree) من عُقد الكشف، وجذر تلك الشجرة هو وحدة التحكم المركزية، التي تختار القيمة غير الصفرية التالية وتبثها عبر شجرة H-tree كي يستقبلها كل PE في الدورة نفسها. ومع 64 من الـ PEs يكون ذلك 21 وحدة كشف (16 ورقة، و4 وسيطة، وجذر واحد)، كل منها صغيرة جدًا بنحو 189 µm² و0.023 mW (Han et al., 2016). ولأن نحو 70 percent من التفعيلات تكون أصفارًا بعد ReLU، فهذا وحده يزيل قرابة ثلثي عمليات البث المحتملة، وهو عامل الـ 3x في حساب الطاقة في الورقة.
Weight sparsity: CSC with a relative indexتناثر الأوزان: CSC بفهرس نسبي
The pointer read and sparse matrix access regions implement the compressed format, a variation of compressed sparse column. Standard CSC, as in SciPy's csc_matrix, stores three arrays: the nonzero values, the row index of each, and a pointer array such that column j occupies positions p_j to p_(j+1) - 1 (SciPy). EIE keeps the values and the pointers but replaces the absolute row index with a relative one: for each nonzero, the number of zeros since the previous nonzero in that PE's slice of the column. Both the value and the relative index are 4 bits. When more than 15 zeros precede a nonzero, the encoder inserts a padding entry with value 0 and index 15 and continues counting from there (Han et al., 2016).
منطقتا قراءة المؤشرات والوصول إلى المصفوفة المتناثرة تنفّذان الصيغة المضغوطة، وهي تنويع على العمود المتناثر المضغوط (compressed sparse column). صيغة CSC القياسية، كما في csc_matrix من SciPy، تخزن ثلاث مصفوفات: القيم غير الصفرية، وفهرس الصف لكل منها، ومصفوفة مؤشرات بحيث يشغل العمود j المواضع من p_j إلى p_(j+1) - 1 (SciPy). يحتفظ EIE بالقيم والمؤشرات لكنه يستبدل فهرس الصف المطلق بفهرس نسبي: لكل قيمة غير صفرية، عدد الأصفار منذ القيمة غير الصفرية السابقة في شريحة ذلك الـ PE من العمود. القيمة والفهرس النسبي كلاهما بعرض 4 bits. وعندما يسبق قيمةً غير صفرية أكثر من 15 صفرًا، يُدخل المرمِّز مدخل حشو (padding) قيمته 0 وفهرسه 15 ثم يواصل العد من هناك (Han et al., 2016).
Worked exampleمثال محلول
Encode PE0's slice of the 8 x 4 exampleرمِّز شريحة PE0 من مثال 8 x 4
Write PE0's two rowsاكتب صفّي PE0
PE0 owns absolute rows 0 and 4, which are local rows 0 and 1. Its slice of the matrix is [w00, w01, 0, w03] over [0, 0, w42, w43].يملك PE0 الصفين المطلقين 0 و4، وهما الصفان المحليان 0 و1. شريحته من المصفوفة هي [w00, w01, 0, w03] فوق [0, 0, w42, w43].Walk the columnsامشِ على الأعمدة
Column 0: w00 at local row 0, no zeros before it, relative index 0. Column 1: w01, index 0. Column 2: local row 0 is zero, then w42 at local row 1, so index 1. Column 3: w03 with index 0, then w43 immediately after with index 0.العمود 0: w00 في الصف المحلي 0، ولا أصفار قبله، فالفهرس النسبي 0. العمود 1: w01، بفهرس 0. العمود 2: الصف المحلي 0 صفر، ثم w42 في الصف المحلي 1، فالفهرس 1. العمود 3: w03 بفهرس 0، ثم w43 بعده مباشرة بفهرس 0.Build the pointersابنِ المؤشرات
Column lengths are 1, 1, 1, 2, so the pointer array is the running sum with a final end marker: p = [0, 1, 2, 3, 5]. That is where the p3 = 3 and p4 = 5 of the previous concept came from.أطوال الأعمدة هي 1, 1, 1, 2، لذا فمصفوفة المؤشرات هي المجموع الجاري مع علامة نهاية أخيرة: p = [0, 1, 2, 3, 5]. ومن هنا جاء p3 = 3 وp4 = 5 في الفكرة السابقة.PE0's three arraysمصفوفات PE0 الثلاث
v = [w00, w01, w42, w03, w43], x = [0, 0, 1, 0, 0], p = [0, 1, 2, 3, 5]. Five 8-bit entries and five 16-bit pointers for a slice that would take eight 16-bit weights dense.Read the last column across the rows and you are looking at load imbalance in the data: for column 3, PE0 and PE2 have two entries while PE1 and PE3 have none. The pointer arrays are where the queue's job is written down.PEPE Pointer array pمصفوفة المؤشرات p Entries per column (p(j+1) minus p(j))المدخلات لكل عمود (p(j+1) ناقص p(j)) PE0 (rows 0, 4)PE0 (الصفان 0 و4) [0, 1, 2, 3, 5][0, 1, 2, 3, 5] 1, 1, 1, 21, 1, 1, 2 PE1 (rows 1, 5)PE1 (الصفان 1 و5) [0, 1, 1, 2, 2][0, 1, 1, 2, 2] 1, 0, 1, 01, 0, 1, 0 PE2 (rows 2, 6)PE2 (الصفان 2 و6) [0, 0, 1, 1, 3][0, 0, 1, 1, 3] 0, 1, 0, 20, 1, 0, 2 PE3 (rows 3, 7)PE3 (الصفان 3 و7) [0, 0, 1, 1, 1][0, 0, 1, 1, 1] 0, 1, 0, 00, 1, 0, 0 All four PEs: pointers and the per-column entry counts they implyالـ PEs الأربعة: المؤشرات وعدد المدخلات لكل عمود الناتج عنها v = [w00, w01, w42, w03, w43]، x = [0, 0, 1, 0, 0]، p = [0, 1, 2, 3, 5]. خمسة مدخلات بعرض 8 بت وخمسة مؤشرات بعرض 16 بت لشريحة كانت ستحتاج ثمانية أوزان بعرض 16 بت في الصيغة الكثيفة.اقرأ العمود الأخير عبر الصفوف وسترى عدم توازن الحمل في البيانات نفسها: في العمود 3، لدى PE0 وPE2 مدخلان لكل منهما بينما لا يملك PE1 وPE3 شيئًا. مصفوفات المؤشرات هي المكان الذي تُكتب فيه مهمة الطابور.PEPE Pointer array pمصفوفة المؤشرات p Entries per column (p(j+1) minus p(j))المدخلات لكل عمود (p(j+1) ناقص p(j)) PE0 (rows 0, 4)PE0 (الصفان 0 و4) [0, 1, 2, 3, 5][0, 1, 2, 3, 5] 1, 1, 1, 21, 1, 1, 2 PE1 (rows 1, 5)PE1 (الصفان 1 و5) [0, 1, 1, 2, 2][0, 1, 1, 2, 2] 1, 0, 1, 01, 0, 1, 0 PE2 (rows 2, 6)PE2 (الصفان 2 و6) [0, 0, 1, 1, 3][0, 0, 1, 1, 3] 0, 1, 0, 20, 1, 0, 2 PE3 (rows 3, 7)PE3 (الصفان 3 و7) [0, 0, 1, 1, 1][0, 0, 1, 1, 1] 0, 1, 0, 00, 1, 0, 0 All four PEs: pointers and the per-column entry counts they implyالـ PEs الأربعة: المؤشرات وعدد المدخلات لكل عمود الناتج عنها
- pos 2موضع 2v70111z20010
- pos 7موضع 7v30011z40100
- p00
- end2
Each nonzero becomes one 8-bit entry: a 4-bit code v and a 4-bit relative index z counting the zeros since the previous entry. Whenever that count would pass 15, the encoder inserts a padding entry (teal) with v = 0 and z = 15, exactly as the EIE paper describes, and the padding entry is multiplied like any other. The pointer array holds one 16-bit start address per column plus one end marker, so p[j+1] minus p[j] is the number of entries the PE walks for column j. At low density the compressed bits fall well below the dense 4-bit total; at high density the index overhead makes compression a loss, which is why EIE only pays off on pruned layers.تصبح كل قيمة غير صفرية مدخلًا واحدًا بطول 8-bit: رمز v بطول 4-bit وفهرس نسبي z بطول 4-bit يعد الأصفار منذ المدخل السابق. وكلما كاد هذا العدد يتجاوز 15، يُدرج المرمِّز مدخل حشو (باللون الأزرق المخضر) فيه v = 0 وz = 15، تمامًا كما تصف ورقة EIE، ويُضرب مدخل الحشو كأي مدخل آخر. تحمل مصفوفة المؤشرات عنوان بداية واحدًا بطول 16-bit لكل عمود، إضافة إلى علامة نهاية واحدة، لذا فإن p[j+1] minus p[j] هو عدد المدخلات التي تمر عليها الـ PE للعمود j. عند الكثافة المنخفضة تقل البتات المضغوطة كثيرًا عن مجموع الرموز الكثيفة ذات 4-bit، وعند الكثافة العالية يجعل عبء الفهارس الضغط خسارة، ولهذا لا تؤتي EIE ثمارها إلا على الطبقات المقلّمة.
Why a relative index at all? For a layer with 4096 rows split across 64 PEs, each PE-local row still needs 6 bits to name absolutely, and the absolute row across the whole matrix needs 12. A 4-bit relative index cuts even the local figure by a third, and, more importantly, matches the 4-bit weight code so that one 8-bit entry carries both. The price is the occasional padding entry, and the paper notes that padding zeros are treated as nonzeros and lead to wasted computation; its Figure 12 shows that more PEs mean fewer padding zeros, because each PE's slice of a column is shorter and long gaps become rarer (Han et al., 2016).
لماذا الفهرس النسبي أصلًا؟ في طبقة ذات 4096 صفًّا مقسّمة على 64 من الـ PEs، يحتاج كل صف محلي داخل الـ PE إلى 6 bits لتسميته بشكل مطلق، والصف المطلق عبر المصفوفة كلها يحتاج 12. الفهرس النسبي بعرض 4 بتات يقلّص حتى الرقم المحلي بمقدار الثلث، والأهم أنه يطابق رمز الوزن ذا الـ 4 بتات بحيث يحمل مدخل واحد بعرض 8-bit الاثنين معًا. الثمن هو مدخل الحشو العرَضي، وتذكر الورقة أن أصفار الحشو تُعامل كقيم غير صفرية وتؤدي إلى حساب مهدر؛ ويبيّن الشكل 12 فيها أن زيادة عدد الـ PEs تعني أصفار حشو أقل، لأن شريحة كل PE من العمود تصبح أقصر وتصبح الفجوات الطويلة أندر (Han et al., 2016).
Weight sharing: 4-bit codes, 16-bit arithmeticمشاركة الأوزان: رموز من 4 بتات وحساب بـ 16 بت
The value stored in each entry is not a weight. It is a 4-bit index into a per-layer table of 16 shared weights, the codebook produced by the k-means quantization of Deep Compression (Han, Mao and Dally, 2016). The weight decoder reads the code out of the sparse matrix entry and looks up the 16-bit fixed-point value it stands for, every cycle, on the way to the multiplier. This is the 8x memory factor in the paper's accounting: the SRAM holds 4-bit codes, the multiplier sees 16-bit numbers, and the layer's whole set of distinct weight values is 16 entries long.
القيمة المخزنة في كل مدخل ليست وزنًا. إنها فهرس من 4 بتات يشير إلى جدول خاص بالطبقة من 16 وزنًا مشتركًا، وهو جدول الترميز (codebook) الناتج عن التكميم بخوارزمية k-means في Deep Compression (Han, Mao and Dally, 2016). يقرأ فاكّ ترميز الأوزان الرمز من مدخل المصفوفة المتناثرة ويبحث عن القيمة ثابتة الفاصلة ذات الـ 16 بت التي يمثلها، في كل دورة، في الطريق إلى المضاعِف. هذا هو عامل الذاكرة 8x في حسابات الورقة: الـ SRAM تحمل رموزًا من 4 بتات، والمضاعِف يرى أعدادًا بعرض 16 بت، ومجموعة قيم الأوزان المختلفة للطبقة كلها لا يتجاوز طولها 16 مدخلًا.
| Precisionالدقة الحسابية | Prediction accuracyدقة التنبؤ | Readingالقراءة |
|---|---|---|
| 32-bit floating pointفاصلة عائمة بعرض 32 بت | 80.3%80.3% | Referenceالمرجع |
| 16-bit fixed pointفاصلة ثابتة بعرض 16 بت | 79.8%79.8% | EIE's choice, half a point lostاختيار EIE، بخسارة نصف نقطة |
| 8-bit fixed pointفاصلة ثابتة بعرض 8 بت | 53.0%53.0% | Collapses, unusable at this widthتنهار، غير صالحة للاستخدام بهذا العرض |
The 16-bit choice is not arbitrary. The paper reports that 16-bit fixed point costs half a percentage point against 32-bit floating point, while 8-bit fixed point collapses to 53 percent, and that a 16-bit fixed multiply uses about 5 times less energy than a 32-bit fixed multiply and 6.2 times less than a 32-bit floating point one (Han et al., 2016). Four bits of storage and sixteen bits of arithmetic is the compromise that keeps both the SRAM and the accuracy where they need to be.
اختيار 16 بت ليس اعتباطيًا. تذكر الورقة أن تمثيل 16 بت ثابت الفاصلة يكلّف نصف نقطة مئوية مقارنة بالفاصلة العائمة (floating point) بعرض 32 بت، بينما ينهار تمثيل 8 بت ثابت الفاصلة إلى 53 percent، وأن الضرب ثابت الفاصلة بعرض 16 بت يستهلك طاقة أقل بنحو 5 مرات من الضرب ثابت الفاصلة بعرض 32 بت، وأقل بـ 6.2 مرة من الضرب بالفاصلة العائمة بعرض 32 بت (Han et al., 2016). أربعة بتات للتخزين وستة عشر بتًا للحساب هي التسوية التي تُبقي الـ SRAM والدقة كلتيهما حيث ينبغي أن تكونا.
Arithmetic and write-backالحساب والكتابة الراجعة
The last region closes the loop. The arithmetic unit computes b_x = b_x + v x a_j, where the address x comes from the address accumulator's running sum of relative indices and v from the decoder. The destination register selected by x is read, the product is added, and the sum is written back. If two adjacent cycles select the same accumulator, the bypass path forwards the adder output directly to its input so the second add does not wait on the register (Han et al., 2016). At the end of the layer the destination file becomes the source file, ReLU and the detector run over it, and the first nonzero of the next layer enters the queue.
المنطقة الأخيرة تُغلق الحلقة. تحسب الوحدة الحسابية b_x = b_x + v x a_j، حيث يأتي العنوان x من المجموع الجاري للفهارس النسبية في مُراكِم العناوين، وتأتي v من فاكّ الترميز. يُقرأ سجل الوجهة الذي يختاره x، ويُضاف إليه الناتج، ويُكتب المجموع مرة أخرى. وإذا اختارت دورتان متجاورتان المُراكِم نفسه، يمرّر مسار التجاوز (bypass) خرج الجامع مباشرة إلى دخله كي لا تنتظر عملية الجمع الثانية السجل (Han et al., 2016). وفي نهاية الطبقة يصبح ملف الوجهة ملف المصدر، ويعمل عليه ReLU والكاشف، وتدخل أول قيمة غير صفرية من الطبقة التالية إلى الطابور.
Storage formats and bit widthsصيغ التخزين وعرضها بالبتات
- Weight code vرمز الوزن v
- 4 bits, index into the layer's 16-entry codebook4 بتات، فهرس يشير إلى جدول ترميز الطبقة ذي الـ 16 مدخلًا
- Relative index x (or z)الفهرس النسبي x (أو z)
- 4 bits, zeros since the previous entry, at most 154 بتات، عدد الأصفار منذ المدخل السابق، بحد أقصى 15
- Padding ruleقاعدة الحشو
- gap above 15: insert v = 0, x = 15, then continue countingفجوة أكبر من 15: أدخِل v = 0 وx = 15، ثم واصل العد
- Pointer p(j)المؤشر p(j)
- 16 bits, start of column j; p(j+1) minus p(j) is the entry count16 بت، بداية العمود j؛ وp(j+1) ناقص p(j) هو عدد المدخلات
- Codebookجدول الترميز (codebook)
- 16 entries x 16-bit fixed point, one table per layer16 مدخلًا x قيم ثابتة الفاصلة بعرض 16 بت، جدول واحد لكل طبقة
- Activationالتفعيل
- 16-bit fixed pointثابت الفاصلة بعرض 16 بت
- Activation queueطابور التفعيلات
- depth 8, holds (value, index) pairsعمقه 8، ويحمل أزواج (value, index)
Recall
Encode the column [0, 0, 5, 0, 0, 0, 0, 7] in EIE's relative format.رمِّز العمود [0, 0, 5, 0, 0, 0, 0, 7] بالصيغة النسبية في EIE.
Recall
What did the paper measure at FIFO depth 1, and which depth did it choose?ماذا قاست الورقة عند عمق FIFO يساوي 1، وأي عمق اختارت؟
Quick checkاختبار سريع
A column in one PE's slice has 18 zeros before its next nonzero weight. What does the encoder store?عمود في شريحة PE واحد فيه 18 صفرًا قبل الوزن غير الصفري التالي. ماذا يخزن المرمِّز؟
Quick checkاختبار سريع
According to the paper, what happens to load balance at an activation FIFO depth of one?بحسب الورقة، ماذا يحدث لموازنة الحمل عند عمق FIFO للتفعيلات يساوي واحدًا؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- The CCU broadcasts only nonzero activations with their index; every PE multiplies that value by the nonzeros in its own slice of that column and accumulates locally.وحدة التحكم المركزية (CCU) تبث التفعيلات غير الصفرية فقط مع فهرس كل منها، وكل PE يضرب هذه القيمة في القيم غير الصفرية الموجودة في شريحته الخاصة من ذلك العمود ويجمع النتيجة محليًا.
- Rows are interleaved across PEs (row i belongs to PE i mod N); activations are broadcast, never partitioned.الصفوف موزعة بالتناوب على الـ PEs (الصف i يتبع الـ PE رقم i mod N)، أما التفعيلات فتُبث للجميع ولا تُقسَّم أبدًا.
- The PE pipeline is Act Queue, Pointer Read, Sparse Matrix Access, Arithmetic Unit, Act R/W, then ReLU and leading nonzero detection.خط المعالجة داخل الـ PE هو: Act Queue، ثم Pointer Read، ثم Sparse Matrix Access، ثم Arithmetic Unit، ثم Act R/W، وبعدها ReLU وكشف أول قيمة غير صفرية.
- Weights live in relative-index CSC: a 4-bit code plus a 4-bit gap in one 8-bit entry, a padding zero whenever a gap exceeds 15, and 16-bit pointers with p(j+1) minus p(j) giving the column's entry count.الأوزان مخزنة بصيغة CSC ذات الفهرس النسبي: رمز من 4 بتات وفجوة من 4 بتات داخل مدخل واحد من 8 بتات، مع صفر حشو كلما تجاوزت الفجوة 15، ومؤشرات من 16 بت يعطي فيها p(j+1) ناقص p(j) عدد مدخلات العمود.
- Even and odd pointer banks read both bounds of a column in one cycle from single-ported SRAM.بنكا المؤشرات الزوجي والفردي يقرآن حدّي العمود كليهما في دورة واحدة من SRAM أحادية المنفذ (single-ported).
- The 16-entry codebook decodes 4-bit codes to 16-bit fixed point at compute time; 16-bit fixed point costs about half a percentage point of AlexNet accuracy.جدول الترميز ذو الـ 16 مدخلًا يفك الرموز ذات الـ 4 بتات إلى قيم ثابتة الفاصلة بـ 16 بت وقت الحساب، وتمثيل 16 بت ثابت الفاصلة يكلف نحو نصف نقطة مئوية فقط من دقة AlexNet.
- Load imbalance comes from uneven nonzero counts per column per PE; a FIFO of depth 8 hides it, while depth 1 leaves about half of all cycles idle.عدم توازن الحمل ينشأ من اختلاف عدد القيم غير الصفرية في كل عمود لكل PE، وطابور FIFO بعمق 8 يخفيه، بينما يترك العمق 1 نحو نصف الدورات كلها خاملة.
- The bypass path handles back-to-back updates to the same accumulator; source and destination register files swap roles between layers.مسار التجاوز (bypass) يعالج التحديثات المتتالية على المُراكِم (accumulator) نفسه، وملفّا السجلات المصدر والوجهة يتبادلان دوريهما بين الطبقات.
- SRAM is 93 percent of PE area; one PE is 0.638 mm² and 9.157 mW at 800 MHz in 45 nm.تشغل SRAM نسبة 93 بالمئة من مساحة الـ PE، والـ PE الواحد مساحته 0.638 mm² ويستهلك 9.157 mW عند 800 MHz بتقنية 45 nm.
Sourcesالمصادر
- EIE: Efficient Inference Engine on Compressed Deep Neural NetworkPaperISCA 2016, Han, Liu, Mao, Pu, Pedram, Horowitz and DallySections III-B and III-C for the format and dataflow, IV for the PE, VI-C for the queue depth sweep; Figures 2, 3, 4, 8 and 12; Table II.القسمان III-B وIII-C للصيغة ومسار البيانات، والقسم IV للـ PE، والقسم VI-C لمسح عمق الطابور؛ والأشكال 2 و3 و4 و8 و12؛ والجدول II.(opens in a new tab)(يفتح في تبويب جديد)
- Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman CodingPaperICLR 2016, Han, Mao and DallyThe pruning plus 4-bit codebook weight sharing pipeline whose output EIE executes.سلسلة التقليم مع مشاركة الأوزان عبر جدول ترميز من 4 بتات، والتي ينفّذ EIE مخرجاتها.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Lecture 4: Pruning and Sparsity (Part II)DocsMIT HAN LabThe lecture the COE 592 deck follows; slides and video.المحاضرة التي تتبعها شرائح COE 592؛ الشرائح والفيديو.(opens in a new tab)(يفتح في تبويب جديد)
- Lecture 4: Pruning and Sparsity (Part II), MIT 6.5940 Fall 2024VideoMIT HAN Lab on YouTubeSong Han walking through the EIE dataflow and PE.Song Han يشرح مسار البيانات في EIE والـ PE خطوة بخطوة.(opens in a new tab)(يفتح في تبويب جديد)
- scipy.sparse.csc_matrixDocsSciPy documentationStandard CSC with data, indices and indptr, for contrast with EIE's relative-index variant.صيغة CSC القياسية بمصفوفات data وindices وindptr، للمقارنة مع نسخة EIE ذات الفهرس النسبي.(opens in a new tab)(يفتح في تبويب جديد)
Part 09: EIE results and what came afterنتائج EIE وما جاء بعده
Non-zero detection after ReLU, EIE's special design choices, its throughput and energy lead over CPU, GPU, FPGA and other ASICs, and the retrospective lessons that shaped later sparse hardware.كشف العناصر غير الصفرية بعد ReLU، وخيارات التصميم الخاصة في EIE، وتفوقه في الإنتاجية والطاقة على CPU وGPU وFPGA ودوائر ASIC الأخرى، والدروس المستفادة لاحقًا التي شكّلت عتاد التناثر التالي.
5 concepts5 مفاهيم, ، slides 71-77الشرائح 71-77
Why this part mattersلماذا يهمّ هذا الجزء
Your research on embedded machine learning lives or dies on the memory hierarchy. EIE is the canonical proof that eliminating DRAM traffic, not building faster multipliers, is the lever that moves energy by orders of magnitude.
The previous part built the processing element block by block. This part finishes the pipeline (ReLU and non-zero detection close the loop back to the next layer), then reads the results the way a reviewer would: nine benchmark layers, two log-scale charts, and the headline numbers you must be able to quote and qualify. It ends with the authors' own retrospective seven years later, which is a ready-made map from 2016 fine-grained sparsity to today's 2:4 tensor cores and W4A16 LLM inference. Exam questions on this lecture ask for the headline numbers, the energy breakdown and EIE's limits.
بحثك في تعلّم الآلة المدمج ينجح أو يفشل بحسب هرمية الذاكرة. وEIE هو الدليل المرجعي على أن التخلّص من حركة البيانات إلى DRAM ومنها، لا بناء ضوارب أسرع، هو الرافعة التي تحرّك الطاقة بفارق رتب من المقدار.
بنى الجزء السابق عنصر المعالجة (PE) كتلةً كتلة. أما هذا الجزء فيُكمل خط المعالجة (إذ تُغلق ReLU وكشف القيم غير الصفرية الحلقة عائدةً إلى الطبقة التالية)، ثم يقرأ النتائج كما يقرؤها مُحكِّم: تسع طبقات اختبار، ومخططان بمقياس لوغاريتمي، والأرقام الرئيسية التي يجب أن تستطيع ذكرها وتقييدها بشروطها. وينتهي بمراجعة المؤلفين أنفسهم لعملهم بعد سبع سنوات، وهي خريطة جاهزة تقود من التناثر الدقيق (fine-grained sparsity) في 2016 إلى أنوية الموتّرات بنمط 2:4 اليوم وإلى استدلال LLM بصيغة W4A16. وأسئلة الامتحان على هذه المحاضرة تطلب الأرقام الرئيسية، وتفصيل الطاقة، وحدود EIE.
By the end you canفي نهاية هذا الجزء ستستطيع
- Trace an output activation from the accumulator through ReLU and leading non-zero detection back into the next layer's broadcast.تتبّع تفعيل الخرج من المُراكِم (accumulator) مرورًا بدالة ReLU وكشف أول قيمة غير صفرية (leading non-zero detection) حتى يعود إلى البث (broadcast) في الطبقة التالية.
- Explain each of the four energy factors (120x, 10x, 8x, 3x) and rank them using the Horowitz energy table.اشرح كل عامل من عوامل الطاقة الأربعة (120x و10x و8x و3x) ورتّبها باستخدام جدول الطاقة لـ Horowitz.
- Quote and interpret 189x, 13x, 24,000x and 3,400x, including the batch size 1 caveat.اذكر الأرقام 189x و13x و24,000x و3,400x وفسّرها، مع التحفّظ الخاص بحجم الدفعة (batch size) يساوي 1.
- Read a log-scale cross-platform chart critically, separating order-of-magnitude signal from process-node noise.اقرأ مخططًا لوغاريتميًا يقارن بين المنصات قراءة نقدية، فتفصل إشارة رتبة المقدار عن ضجيج اختلاف عقدة التصنيع (process node).
- List what EIE could not do and name the successor idea for each limitation, ending at 2:4 sparsity.عدّد ما لم يستطع EIE فعله، وسمِّ الفكرة اللاحقة التي عالجت كل قيد، وصولًا إلى تناثر 2:4.
Follow one output row to the end. The accumulator for row i has just finished summing every product of a broadcast activation and a decoded weight from that row. The sum lands in a destination activation register. ReLU clamps it: a negative sum becomes zero, a positive one is kept. Now the leading non-zero detection logic scans the register file and reports the first non-zero it finds, as a pair "value v at index j". For the next layer, the central control unit broadcasts only those pairs. The output of this layer is already the sparse input of the next one, and no dense vector was ever written out.
تتبّع صفّ خرج واحدًا حتى نهايته. انتهى المُراكِم الخاص بالصف i للتو من جمع كل حواصل ضرب تفعيلٍ مبثوث في وزنٍ مفكوك الترميز من ذلك الصف. يستقر المجموع في سجلّ التفعيل الوجهة (destination activation register). ثم تقصّه ReLU: المجموع السالب يصبح صفرًا، والموجب يبقى كما هو. بعد ذلك يمسح منطق leading non-zero detection (كشف أول قيمة غير صفرية) ملف السجلات ويُبلغ عن أول قيمة غير صفرية يجدها، على شكل زوج "القيمة v عند الفهرس j". وفي الطبقة التالية لا تبث وحدة التحكم المركزية إلا هذه الأزواج. خرج هذه الطبقة هو أصلًا الدخل المتناثر للطبقة التالية، ولم يُكتب أي متجه كثيف إلى الخارج في أي لحظة.
That is the loop the slides close. Part 08 showed how a broadcast activation fans out to the processing elements and how each PE walks its CSC column; this part shows how the results become the next broadcast. The detection is hierarchical: each group of four PEs feeds a leading non-zero detection node, those nodes feed another, and the root of the tree sits inside the central control unit and drives the H-tree broadcast. Han et al. report 21 such nodes for 64 PEs (16 + 4 + 1), each about 0.023 mW and 189 µm², well under 0.3% of one PE. The machinery that keeps both ends of the datapath sparse is almost free.
هذه هي الحلقة التي تُغلقها الشرائح. أوضح الجزء 08 كيف ينتشر التفعيل المبثوث إلى processing elements (عناصر المعالجة) وكيف يمرّ كل PE على عمود CSC الخاص به؛ أما هذا الجزء فيوضح كيف تصبح النتائج هي البث التالي. الكشف هرمي: كل مجموعة من أربعة PE تغذّي عقدة كشفٍ لأول قيمة غير صفرية، وهذه العقد تغذّي عقدةً أخرى، وجذر الشجرة موجود داخل وحدة التحكم المركزية ويقود broadcast (البث) عبر شجرة H-tree. يذكر Han et al. وجود 21 عقدة من هذا النوع لكل 64 عنصر معالجة (16 + 4 + 1)، تستهلك كل منها نحو 0.023 mW ومساحتها 189 µm²، أي أقل بكثير من 0.3% من عنصر معالجة واحد. فالآلية التي تُبقي طرفي مسار البيانات متناثرين تكاد تكون مجانية.
Sum of activation times decoded weight per row
مجموع حواصل ضرب التنشيط في الوزن المفكوك ترميزه لكل صف
Negatives become zero; typical density falls to about 30%
تصبح القيم السالبة صفرًا، وتنخفض الكثافة عادة إلى نحو 30%
Report the next non-zero and its index
أبلغ عن القيمة غير الصفرية التالية وفهرسها
Only non-zero (value, index) pairs are queued
لا تدخل الطابور إلا أزواج (value, index) غير الصفرية
The four special aspects, and the saving each one buysالجوانب الخاصة الأربعة، والتوفير الذي يحققه كل منها
The lecturer highlights four blocks on the PE diagram as EIE's special aspects. Each of them is a concrete piece of hardware, and each maps onto one of the four factors in the paper's energy breakdown. Reading them as pairs is what turns the block diagram into an argument.
يُبرز المحاضر أربع كتل على مخطط عنصر المعالجة باعتبارها الجوانب الخاصة في EIE. كل واحدة منها قطعة عتادية ملموسة، وكل واحدة تقابل عاملًا من العوامل الأربعة في تفصيل الطاقة في الورقة. وقراءتها أزواجًا (الكتلة وعاملها) هي ما يحوّل المخطط الكتلي إلى حُجّة.
Special aspect, hardware block, and the factor it enablesالجانب الخاص، والكتلة العتادية، والعامل الذي تتيحه
- Activation queue and LNZDطابور التفعيلات وLNZD
- Broadcast only non-zero activations, about 70% of them are zero after ReLU (the 3x factor); the FIFO of depth 8 adds load balance so PEs with more non-zeros do not stall the restلا تُبث إلا التفعيلات غير الصفرية، إذ إن نحو 70% منها أصفار بعد ReLU (عامل 3x)؛ وتضيف FIFO بعمق 8 موازنةً للحمل حتى لا تُعطّل عناصر المعالجة التي لديها قيم غير صفرية أكثر بقيةَ العناصر
- Sparse matrix SRAM per PEذاكرة SRAM للمصفوفة المتناثرة في كل PE
- Every compressed weight lives in the PE's own SRAM, 131K weights per PE across 64 PEs, so no DRAM access happens during inference (120x, the largest factor)كل وزن مضغوط موجود في ذاكرة SRAM الخاصة بعنصر المعالجة، بواقع 131K وزن لكل عنصر عبر 64 عنصرًا، فلا يحدث أي وصول إلى DRAM أثناء الاستدلال (120x، وهو أكبر العوامل)
- Weight decoder in the datapathمفكّك ترميز الأوزان في مسار البيانات
- A 4-bit codebook index is expanded to a 16-bit weight right before the multiplier, so memory holds indices and arithmetic sees real values (8x)يُوسَّع فهرس كتاب الرموز (codebook) بطول 4-bit إلى وزن بطول 16-bit قبل الضارب مباشرة، فتحمل الذاكرة الفهارس بينما يرى الحساب القيم الحقيقية (8x)
- Address accumulatorمُراكِم العناوين
- Adds each 4-bit relative index to a running absolute row address, so only stored non-zeros are ever fetched or multiplied (10x from 10% weight density)يضيف كل فهرس نسبي بطول 4-bit إلى عنوان صف مطلق متراكم، فلا يُجلب ولا يُضرب إلا ما خُزِّن من قيم غير صفرية (10x من كثافة أوزان 10%)
The FIFO deserves one extra sentence because it is easy to miss. Columns have different numbers of non-zeros, so PEs finish at different times. Han et al. swept the queue depth and found that at depth 1 some benchmarks lose about half their cycles to imbalance, while the gain flattens past depth 8, which is what they built. That is load balance bought with a few registers rather than with a different pruning pattern, and the retrospective will show why that trade did not scale.
تستحق FIFO جملةً إضافية لأنها سهلة التجاهل. تختلف الأعمدة في عدد قيمها غير الصفرية، لذلك تنتهي عناصر المعالجة في أوقات مختلفة. جرّب Han et al. أعماقًا مختلفة للطابور، فوجدوا أنه عند العمق 1 تخسر بعض الاختبارات نحو نصف دوراتها بسبب عدم التوازن، بينما يتسطّح الكسب بعد العمق 8، وهو ما بنوه فعلًا. هذا load balance (موازنة الحمل) مُشترًى ببضعة سجلات بدلًا من نمط تقليم مختلف، وستُظهر المراجعة اللاحقة لماذا لم تتوسّع هذه المقايضة.
Why on-chip SRAM is the whole storyلماذا تختصر SRAM على الشريحة القصة كلها
The factors multiply, but they are far from equal. Table I of the EIE paper restates Horowitz's 45 nm energy table from ISSCC 2014, the same table lecture 04-1 opened with. A 32-bit integer add costs 0.1 pJ, a 32-bit integer multiply 3.1 pJ, a 32-bit SRAM cache read 5 pJ, and a 32-bit DRAM access 640 pJ. The caption says it plainly: DRAM uses three orders of magnitude more energy than simple arithmetic and 128x more than SRAM; the paper rounds this 128x table ratio to the 120x it uses in its energy breakdown. A multiplier that is twice as efficient saves picojoules. A weight that never leaves the chip saves hundreds of them, on every fetch, for every weight.
العوامل تتضاعف، لكنها أبعد ما تكون عن التساوي. يعيد الجدول I في ورقة EIE عرض جدول الطاقة لـ Horowitz عند 45 nm من ISSCC 2014، وهو الجدول نفسه الذي افتُتحت به المحاضرة 04-1. جمع عددين صحيحين بطول 32-bit يكلّف 0.1 pJ، وضربهما 3.1 pJ، وقراءة 32-bit من ذاكرة SRAM المخبئية 5 pJ، ووصول 32-bit إلى DRAM يكلّف 640 pJ. والتعليق على الجدول يقولها صراحة: DRAM تستهلك طاقة أكثر بثلاث رتب من الحساب البسيط، وأكثر بـ 128x من SRAM؛ وتقرّب الورقة نسبة الجدول هذه 128x إلى 120x التي تستعملها في تفصيل الطاقة. الضارب الأكفأ بمرتين يوفّر بضعة بيكوجولات. أما الوزن الذي لا يغادر الشريحة أبدًا فيوفّر المئات منها، في كل عملية جلب، ولكل وزن.
Pruning and weight sharing matter here for a reason that has nothing to do with arithmetic: they are what make the model small enough to fit. After compression, AlexNet's fully connected layers need about 131K weights per PE, and 64 PEs at 0.638 mm² each hold all of them. Memory takes 93% of a PE's area and 59% of its power, so EIE is, physically, an SRAM chip with a little arithmetic attached. The order of causes is the exam answer: compression makes the model fit on chip, fitting on chip removes DRAM, and removing DRAM is the 120x.
يهمّ التقليم وweight sharing (مشاركة الأوزان) هنا لسبب لا علاقة له بالحساب: فهما ما يجعل النموذج صغيرًا بما يكفي ليتسع. بعد الضغط، تحتاج الطبقات المتصلة بالكامل في AlexNet إلى نحو 131K وزن لكل عنصر معالجة، و64 عنصرًا مساحة كل منها 0.638 mm² تحملها جميعًا. تشغل الذاكرة 93% من مساحة عنصر المعالجة و59% من قدرته، فـ EIE من الناحية الفيزيائية شريحة SRAM أُلحق بها قليل من الحساب. وترتيب الأسباب هو جواب الامتحان: الضغط يجعل النموذج يتسع على الشريحة، واتساعه على الشريحة يلغي DRAM، وإلغاء DRAM هو عامل 120x.
Worked exampleمثال محلول
From 28,800x on paper to 24,000x and 3,400x measuredمن 28,800x على الورق إلى 24,000x و3,400x مقيسة
Multiply the four factorsاضرب العوامل الأربعة
120 x 10 x 8 x 3 = 28,800x. Fetching from SRAM instead of DRAM is 120x; storing 10% of the weights is 10x; 4-bit indices instead of 32-bit weights is 8x; about 70% of activations are zero after ReLU, which the paper measures as 65% energy saved, roughly 3x.120 x 10 x 8 x 3 = 28,800x. الجلب من SRAM بدل DRAM يعطي 120x؛ وتخزين 10% فقط من الأوزان يعطي 10x؛ واستخدام فهارس 4-bit بدل أوزان 32-bit يعطي 8x؛ ونحو 70% من التفعيلات أصفار بعد ReLU، وهو ما تقيسه الورقة بتوفير 65% من الطاقة، أي 3x تقريبًا.Compare with the measurementsقارن بالقياسات
On the nine compressed layers EIE measures 24,000x better energy efficiency than the Core-i7 and 3,400x better than the Titan X (2,700x better than the Tegra K1).على الطبقات المضغوطة التسع يقيس EIE كفاءة طاقة أفضل بـ 24,000x من Core-i7، وأفضل بـ 3,400x من Titan X (وأفضل بـ 2,700x من Tegra K1).Explain the gapفسّر الفجوة
Han et al. say the saving against the GPUs is about 10x below theory (3,400x and 2,700x against 28,800x) for two reasons: index overhead (every 4-bit weight carries a 4-bit index, plus pointers) and process node, since EIE is 45 nm while the GPUs are 28 nm.يقول Han et al. إن التوفير مقابل وحدات GPU أقل من النظرية بنحو 10x (3,400x و2,700x مقابل 28,800x) لسببين: عبء الفهرسة (كل وزن 4-bit يحمل معه فهرسًا 4-bit، إضافةً إلى المؤشرات)، وعقدة التصنيع، إذ إن EIE مصنوع بتقنية 45 nm بينما وحدات GPU بتقنية 28 nm.Where the win comes fromمن أين يأتي المكسب
Removing the SRAM factor collapses the product by two decades; removing any other factor leaves it in the thousands. DRAM elimination is most of the result.Factor removedالعامل المحذوف Productحاصل الضرب SRAM instead of DRAM (120x)SRAM بدل DRAM (120x) 10 x 8 x 3 = 240x10 x 8 x 3 = 240x Weight sparsity (10x)تناثر الأوزان (10x) 120 x 8 x 3 = 2,880x120 x 8 x 3 = 2,880x Weight sharing (8x)مشاركة الأوزان (8x) 120 x 10 x 3 = 3,600x120 x 10 x 3 = 3,600x Activation skipping (3x)تخطّي التفعيلات (3x) 120 x 10 x 8 = 9,600x120 x 10 x 8 = 9,600x Drop one factor from 28,800x and see what remainsاحذف عاملًا واحدًا من 28,800x وانظر ماذا يبقى حذف عامل SRAM يُسقط حاصل الضرب برتبتين عشريتين؛ أما حذف أي عامل آخر فيُبقيه بالآلاف. فإلغاء DRAM هو معظم النتيجة.Factor removedالعامل المحذوف Productحاصل الضرب SRAM instead of DRAM (120x)SRAM بدل DRAM (120x) 10 x 8 x 3 = 240x10 x 8 x 3 = 240x Weight sparsity (10x)تناثر الأوزان (10x) 120 x 8 x 3 = 2,880x120 x 8 x 3 = 2,880x Weight sharing (8x)مشاركة الأوزان (8x) 120 x 10 x 3 = 3,600x120 x 10 x 3 = 3,600x Activation skipping (3x)تخطّي التفعيلات (3x) 120 x 10 x 8 = 9,600x120 x 10 x 8 = 9,600x Drop one factor from 28,800x and see what remainsاحذف عاملًا واحدًا من 28,800x وانظر ماذا يبقى
The four factors and the measured 24,000x and 3,400x come from Han et al. (ISCA 2016), who attribute the gap to index overhead and to EIE's 45 nm process against the GPUs' 28 nm. The 1.6x node penalty is a rough teaching figure, not a number from the paper. Untick the SRAM factor and watch the product fall from 28,800x to 240x.العوامل الأربعة والقيمتان المقيستان 24,000x و3,400x مأخوذة من Han et al. (ISCA 2016)، الذين يعزون الفجوة إلى عبء الفهارس وإلى تقنية تصنيع EIE بدقة 45 nm مقابل 28 nm في وحدات GPU. عقوبة فرق التقنية البالغة 1.6x رقم تعليمي تقريبي وليست من الورقة. ألغِ تحديد عامل SRAM وشاهد الحاصل يهبط من 28,800x إلى 240x.
Quick checkاختبار سريع
In EIE, which unit decides which activations are broadcast to the PEs for the next layer?في EIE، ما الوحدة التي تقرّر أي التفعيلات تُبث إلى عناصر المعالجة من أجل الطبقة التالية؟
Quick checkاختبار سريع
Which factor is the largest in EIE's 120 x 10 x 8 x 3 energy breakdown?أي عامل هو الأكبر في تفصيل الطاقة 120 x 10 x 8 x 3 الخاص بـ EIE؟
Recall
After the accumulators finish, what two steps make the layer output ready for the next layer?بعد أن تنتهي المُراكِمات، ما الخطوتان اللتان تجعلان خرج الطبقة جاهزًا للطبقة التالية؟
Recall
Which single design choice gives EIE most of its energy saving, and how large is that factor?ما قرار التصميم الواحد الذي يمنح EIE معظم توفيره في الطاقة، وما حجم هذا العامل؟
Take AlexNet's FC6 layer: a 4096 x 9216 matrix, 37.7 million weights. After pruning only 9% of the weights survive, and after ReLU only 35% of the input activations are non-zero. A multiply is needed only where a surviving weight meets a non-zero activation, which is 0.09 x 0.35, about 3.2% of the dense count. That is where the 33x FLOP reduction on the slide comes from.
خذ الطبقة FC6 في AlexNet: مصفوفة حجمها 4096 x 9216، أي 37.7 مليون وزن. بعد التقليم لا يبقى إلا 9% من الأوزان، وبعد ReLU لا يكون غير صفري إلا 35% من تفعيلات الدخل. لا نحتاج إلى عملية ضرب إلا حيث يلتقي وزن باقٍ بتفعيل غير صفري، وهذا يساوي 0.09 x 0.35، أي نحو 3.2% من العدد الكثيف. ومن هنا يأتي تخفيض FLOP البالغ 33x في الشريحة.
The general rule is that the two sparsities multiply. Every layer in the benchmark set is a fully connected layer of a real model, and each one has its own pair of densities. Han et al. chose nine of them: three from AlexNet, three from VGG-16, and three from NeuralTalk, an RNN and LSTM image captioning model. The last three are the interesting outliers.
القاعدة العامة أن نوعي التناثر يتضاعفان. كل طبقة في مجموعة الاختبار طبقة متصلة بالكامل من نموذج حقيقي، ولكل منها زوج كثافاتها الخاص. اختار Han et al. تسعًا منها: ثلاثًا من AlexNet، وثلاثًا من VGG-16، وثلاثًا من NeuralTalk، وهو نموذج لتوليد أوصاف الصور مبني على RNN وLSTM. والثلاث الأخيرة هي الحالات الشاذة المثيرة للاهتمام.
| Layerالطبقة | Sizeالحجم | Weight densityكثافة الأوزان | Activation densityكثافة التفعيلات | FLOP reductionتخفيض FLOP | Modelالنموذج |
|---|---|---|---|---|---|
| AlexNet-6AlexNet-6 | 4096 x 92164096 x 9216 | 9%9% | 35%35% | 33x33x | Image classificationتصنيف الصور |
| AlexNet-7AlexNet-7 | 4096 x 40964096 x 4096 | 9%9% | 35%35% | 33x33x | Image classificationتصنيف الصور |
| AlexNet-8AlexNet-8 | 1000 x 40961000 x 4096 | 25%25% | 38%38% | 10x10x | Image classificationتصنيف الصور |
| VGG-6VGG-6 | 4096 x 250884096 x 25088 | 4%4% | 18%18% | 100x100x | Image classificationتصنيف الصور |
| VGG-7VGG-7 | 4096 x 40964096 x 4096 | 4%4% | 37%37% | 50x50x | Image classificationتصنيف الصور |
| VGG-8VGG-8 | 1000 x 40961000 x 4096 | 23%23% | 41%41% | 10x10x | Image classificationتصنيف الصور |
| NeuralTalk-WeNeuralTalk-We | 600 x 4096600 x 4096 | 10%10% | 100%100% | 10x10x | RNN and LSTM captioningتوليد أوصاف الصور بـ RNN وLSTM |
| NeuralTalk-WdNeuralTalk-Wd | 8791 x 6008791 x 600 | 11%11% | 100%100% | 10x10x | RNN and LSTM captioningتوليد أوصاف الصور بـ RNN وLSTM |
| NeuralTalk-LSTMNeuralTalk-LSTM | 2400 x 12012400 x 1201 | 10%10% | 100%100% | 10x10x | RNN and LSTM captioningتوليد أوصاف الصور بـ RNN وLSTM |
Worked exampleمثال محلول
Checking the FLOP reduction columnالتحقق من عمود تخفيض FLOP
AlexNet-6AlexNet-6
1 / (0.09 x 0.35) = 31.7, reported as 33x. The paper first rounds the product of the densities to a whole percent (0.09 x 0.35 = 3.15%, listed as 3% in its FLOP column) and the slide reports 1 over that: 1 / 0.03 = 33x.1 / (0.09 x 0.35) = 31.7، ويُذكر على أنه 33x. فالورقة تقرّب أولًا حاصل ضرب الكثافتين إلى نسبة مئوية صحيحة (0.09 x 0.35 = 3.15%، ويُدرج في عمود FLOP على أنه 3%)، ثم تذكر الشريحة 1 مقسومًا على ذلك: 1 / 0.03 = 33x.VGG-6VGG-6
1 / (0.04 x 0.18) = 139, reported as 100x by the same route: 0.72% rounds to 1%, and 1 / 0.01 = 100x. VGG's first FC layer is the sparsest in both dimensions, and its 25088-wide input still fits the 64 PE design. The slide column is loosely rounded elsewhere too: VGG-8 (9%, so 11x) and the two 11% NeuralTalk rows (9x) all appear as 10x.1 / (0.04 x 0.18) = 139، ويُذكر على أنه 100x بالطريقة نفسها: 0.72% تُقرَّب إلى 1%، و1 / 0.01 = 100x. أول طبقة FC في VGG هي الأكثر تناثرًا في البعدين، ومع ذلك يتسع دخلها بعرض 25088 لتصميم 64 عنصر معالجة. وعمود الشريحة مقرَّب بتساهل في مواضع أخرى أيضًا: VGG-8 (9%، أي 11x) وصفّا NeuralTalk بنسبة 11% (9x) تظهر كلها على أنها 10x.NeuralTalk-WeNeuralTalk-We
1 / (0.10 x 1.00) = 10x exactly. Activation density is 100% because LSTM gates use sigmoid and tanh, which never output exact zeros, so only weight sparsity helps.1 / (0.10 x 1.00) = 10x بالضبط. كثافة التفعيلات 100% لأن بوابات LSTM تستخدم sigmoid وtanh، وهما لا تُخرجان أصفارًا تامة أبدًا، فلا يساعد إلا weight sparsity (تناثر الأوزان).Resultالنتيجة
Activation sparsity is a free multiplier only for ReLU networks. For recurrent models the whole saving must come from pruning, which is why their reductions all sit at 10x.Activation sparsity (تناثر التفعيلات) مُضاعِف مجاني لشبكات ReLU فقط. أما في النماذج التكرارية فيجب أن يأتي التوفير كله من التقليم، ولهذا تستقر تخفيضاتها كلها عند 10x.
What EIE was measured againstما الذي قورن به EIE
The comparison platforms were a desktop CPU (Intel Core-i7 5930k, running Intel MKL: CSRMV for the sparse model and GEMV for the dense one), a desktop GPU (NVIDIA Titan X, cuSPARSE CSRMV and cuBLAS GEMV), and a mobile GPU (the Tegra K1, measured on a Jetson TK1 developer board, which is the same silicon the slide names differently). Each baseline was given the best library available for its case, dense or sparse, so the comparison is against optimized software rather than naive loops.
كانت منصات المقارنة: معالج مكتبي CPU (Intel Core-i7 5930k، يشغّل Intel MKL: CSRMV للنموذج المتناثر وGEMV للنموذج الكثيف)، ومعالج رسوميات مكتبي GPU (NVIDIA Titan X، مع cuSPARSE CSRMV وcuBLAS GEMV)، ومعالج رسوميات للأجهزة المحمولة (Tegra K1، مقيس على لوحة التطوير Jetson TK1، وهي الشريحة نفسها التي تسمّيها الشرائح باسم مختلف). أُعطي كل خط أساس أفضل مكتبة متاحة لحالته، كثيفة أو متناثرة، فالمقارنة إذن مع برمجيات محسَّنة لا مع حلقات ساذجة.
On those nine layers EIE is 189x faster than the CPU and 13x faster than the GPU, while using 24,000x and 3,400x less energy respectively. The paper adds a number that is easy to forget and worth remembering: the same compressed model, run on the CPU or GPU with sparse libraries, gives only about 3x speedup over dense. Compression alone is not the win. Compression plus hardware built for it is.
على هذه الطبقات التسع يكون EIE أسرع بـ 189x من CPU وأسرع بـ 13x من GPU، مع استهلاك طاقة أقل بـ 24,000x و3,400x على الترتيب. وتضيف الورقة رقمًا يُنسى بسهولة ويستحق التذكّر: النموذج المضغوط نفسه، حين يُشغَّل على CPU أو GPU بمكتبات متناثرة، لا يعطي إلا تسريعًا بنحو 3x مقارنة بالنموذج الكثيف. فالضغط وحده ليس هو المكسب. المكسب هو الضغط مع عتاد مبني من أجله.
Quick checkاختبار سريع
A NeuralTalk LSTM layer has 10% weight density and 100% activation density. What FLOP reduction does EIE see on it?طبقة LSTM في NeuralTalk كثافة أوزانها 10% وكثافة تفعيلاتها 100%. ما تخفيض FLOP الذي يحققه EIE عليها؟
Recall
State the four headline numbers and what they compare.اذكر الأرقام الرئيسية الأربعة وما الذي يقارنه كل منها.
Look at the two right-most bars first. The fabricated EIE, 64 PEs at 45 nm, pushes 81,967 matrix-vector products per second through AlexNet FC7 at 0.59 W. DaDianNao, the strongest rival ASIC, reaches 147,938 per second but draws 15.97 W. Divide, and the picture flips: 138,927 frames per joule for EIE against 9,263 for DaDianNao, a 15x gap in EIE's favor at an older process node. The projected 256 PE version at 28 nm would reach 426,230 per second and 180,606 per joule.
انظر أولًا إلى العمودين الأقصى يمينًا. شريحة EIE المصنَّعة، 64 عنصر معالجة بتقنية 45 nm، تمرّر 81,967 عملية ضرب مصفوفة في متجه في الثانية عبر AlexNet FC7 بقدرة 0.59 W. أما DaDianNao، أقوى ASIC منافس، فيبلغ 147,938 في الثانية لكنه يسحب 15.97 W. اقسم، فتنقلب الصورة: 138,927 إطارًا لكل جول لـ EIE مقابل 9,263 لـ DaDianNao، أي فجوة 15x لصالح EIE رغم أنه بعقدة تصنيع أقدم. والنسخة المتوقعة بـ 256 عنصر معالجة بتقنية 28 nm ستبلغ 426,230 في الثانية و180,606 لكل جول.
| Platformالمنصة | Nodeالعقدة | Classالفئة | Weight memoryذاكرة الأوزان | Powerالقدرة | Throughput (frames/s)الإنتاجية (إطار/ث) | Frames/Jإطار/جول |
|---|---|---|---|---|---|---|
| Core-i7 5930KCore-i7 5930K | 22 nm22 nm | CPUCPU | DRAMDRAM | 73 W73 W | 162162 | 2.222.22 |
| GeForce Titan XGeForce Titan X | 28 nm28 nm | GPUGPU | DRAMDRAM | 159 W159 W | 4,1154,115 | 25.925.9 |
| Tegra K1Tegra K1 | 28 nm28 nm | Mobile GPUGPU للأجهزة المحمولة | DRAMDRAM | 5.1 W5.1 W | 173173 | 33.933.9 |
| A-EyeA-Eye | 28 nm28 nm | FPGAFPGA | DRAMDRAM | 9.63 W9.63 W | 3333 | 3.433.43 |
| DaDianNaoDaDianNao | 28 nm28 nm | ASICASIC | eDRAMeDRAM | 15.97 W15.97 W | 147,938147,938 | 9,2639,263 |
| TrueNorthTrueNorth | 28 nm28 nm | ASICASIC | SRAMSRAM | 0.18 W0.18 W | 1,9891,989 | 10,83910,839 |
| EIE, 64 PEsEIE بـ 64 عنصر معالجة | 45 nm45 nm | ASICASIC | SRAMSRAM | 0.59 W0.59 W | 81,96781,967 | 138,927138,927 |
| EIE, 256 PEs (projected)EIE بـ 256 عنصر معالجة (متوقَّع) | 28 nm28 nm | ASICASIC | SRAMSRAM | 2.36 W2.36 W | 426,230426,230 | 180,606180,606 |
Worked exampleمثال محلول
Frames per joule from the tableالإطارات لكل جول من الجدول
EIE, 64 PEsEIE بـ 64 عنصر معالجة
81,967 frames/s / 0.59 W = 138,927 frames/J.81,967 frames/s / 0.59 W = 138,927 frames/J.DaDianNaoDaDianNao
147,938 frames/s / 15.97 W = 9,263 frames/J, of which 6.12 W is eDRAM power alone.147,938 frames/s / 15.97 W = 9,263 frames/J، منها 6.12 W قدرة eDRAM وحدها.Same node, same PE countالعقدة نفسها، وعدد عناصر المعالجة نفسه
Han et al. also compare the projected 28 nm, 256 PE EIE with DaDianNao at its own node: 2.9x throughput, 19x energy efficiency and 3x area efficiency.يقارن Han et al. أيضًا EIE المتوقع بتقنية 28 nm و256 عنصر معالجة مع DaDianNao عند عقدته نفسها: 2.9x في الإنتاجية، و19x في كفاءة الطاقة، و3x في كفاءة المساحة.Resultالنتيجة
In throughput EIE is competitive with the best ASIC; in energy it dominates every platform in the table, including the ASICs, and that is the column to argue from.في الإنتاجية ينافس EIE أفضل ASIC؛ أما في الطاقة فيتفوق على كل منصة في الجدول، بما فيها وحدات ASIC، وهذا هو العمود الذي تبني عليه حجتك.
The reason energy is where EIE separates from the pack is the one from the previous concept, now visible across platforms. A matrix-vector product at batch size 1 is completely memory bound: every weight is used once, so throughput is set by how fast weights can be delivered, and energy by where they come from. DaDianNao's rate in the table is in fact a bandwidth estimate from its eDRAM (Han et al. compute 16 x 4 x 1024 bit / 8 x 606 MHz = 4,964 GB/s), A-Eye pulls every parameter from DDR3, and the CPU and GPUs all stream from DRAM. Only TrueNorth and EIE keep weights in SRAM, and TrueNorth pays for it with 1-bit weights and an asynchronous design measured on a different task.
سبب انفصال EIE عن البقية في الطاقة تحديدًا هو السبب نفسه من المفهوم السابق، وقد صار الآن مرئيًا عبر المنصات. ضرب مصفوفة في متجه بحجم دفعة 1 محدود بالذاكرة تمامًا (memory bound): كل وزن يُستخدم مرة واحدة، فتتحدد الإنتاجية بسرعة توصيل الأوزان، وتتحدد الطاقة بالمكان الذي تأتي منه. ومعدّل DaDianNao في الجدول هو في الحقيقة تقدير مبني على عرض نطاق eDRAM الخاصة به (يحسب Han et al. 16 x 4 x 1024 bit / 8 x 606 MHz = 4,964 GB/s)، وA-Eye يسحب كل معامل من DDR3، ووحدات CPU وGPU كلها تتدفق من DRAM. وحدهما TrueNorth وEIE يُبقيان الأوزان في SRAM، ويدفع TrueNorth ثمن ذلك بأوزان 1-bit وتصميم غير متزامن مقيس على مهمة مختلفة.
Quick checkاختبار سريع
How much faster and more energy efficient than a desktop GPU did EIE report on compressed FC layers?بكم كان EIE أسرع وأكفأ في الطاقة من GPU مكتبي على طبقات FC المضغوطة بحسب ما أعلنه؟
Recall
Why is the slide 74 chart not a like-for-like benchmark? Give at least three reasons.لماذا لا يُعد مخطط الشريحة 74 مقارنة بين متكافئين؟ اذكر ثلاثة أسباب على الأقل.
Consider what a large language model does when it generates one token: it multiplies a single activation vector by weight matrices holding billions of parameters, reads every weight once, and does it again for the next token. That is a matrix-vector product at batch size 1, memory bound on weights, which is exactly the workload EIE was built for in 2016. So EIE's storage trick came back: keep weights in 4 bits, decode to 16, compute in 16. Han et al. call it W4A16 and point at GPTQ, AWQ, llama.cpp and MLC LLM, with one difference: today's engines use linear integer weights rather than a K-means codebook.
تأمّل ما يفعله نموذج لغوي كبير حين يولّد رمزًا (token) واحدًا: يضرب متجه تفعيل واحدًا في مصفوفات أوزان تضم مليارات المعاملات، ويقرأ كل وزن مرة واحدة، ثم يكرر ذلك للرمز التالي. هذا ضرب مصفوفة في متجه بحجم دفعة 1، محدود بالذاكرة بسبب الأوزان، وهو بالضبط عبء العمل الذي بُني EIE من أجله في 2016. لذلك عادت حيلة التخزين في EIE: احفظ الأوزان بـ 4 بتات، وفكّ ترميزها إلى 16، واحسب بـ 16. يسمّيها Han et al. W4A16 ويشيرون إلى GPTQ وAWQ وllama.cpp وMLC LLM، مع فرق واحد: محركات اليوم تستخدم أوزانًا صحيحة خطية بدل كتاب رموز (codebook) مبني بـ K-means.
In 2023, for ISCA's 50th anniversary retrospective collection, the authors wrote down what they think held up and what did not. The slide condenses it to four pros and four cons. The tables below expand each line with the evidence the retrospective gives and the design that replaced or extended the idea.
في 2023، ضمن مجموعة المراجعات بمناسبة الذكرى الخمسين لمؤتمر ISCA، كتب المؤلفون ما يرون أنه صمد وما لم يصمد. تختصر الشريحة ذلك في أربع إيجابيات وأربع سلبيات. والجدولان أدناه يوسّعان كل سطر بالدليل الذي تقدّمه المراجعة والتصميم الذي حلّ محل الفكرة أو مدّدها.
| Proالإيجابية | Evidenceالدليل | Where it lives nowأين تعيش اليوم |
|---|---|---|
| Special-purpose hardware pays off earlyالعتاد المخصص يؤتي ثماره مبكرًا | Sparse operations stay cost-effective up to 50% density on EIE; sparse software libraries only win well below 1%تبقى العمليات المتناثرة مجدية من حيث التكلفة على EIE حتى كثافة 50%؛ أما مكتبات البرمجيات المتناثرة فلا تتفوق إلا عند كثافة أقل بكثير من 1% | Every commercial sparse NPU sinceكل NPU تجارية متناثرة منذ ذلك الحين |
| Both sparsities, cycles and energyنوعا التناثر معًا، في الدورات والطاقة | Skipping a zero weight saves the fetch; skipping a zero activation also saves the cycle that would have computed itتخطّي وزن صفري يوفّر عملية الجلب؛ وتخطّي تفعيل صفري يوفّر أيضًا الدورة التي كانت ستحسبه | NVDLA gates pruned weights, the Samsung NPU skips zero activations, Ambarella CV22 supports weight sparsityيعطّل NVDLA الأوزان المقلَّمة، وتتخطى Samsung NPU التفعيلات الصفرية، ويدعم Ambarella CV22 تناثر الأوزان |
| Fine-grained sparsityالتناثر الدقيق (fine-grained) | Individual weights can be removed, so pruning reaches higher ratios than any structured patternيمكن حذف أوزان مفردة، فيبلغ التقليم نسبًا أعلى من أي نمط مهيكل | Still the highest-ratio option when hardware can afford itما زال الخيار ذا النسبة الأعلى حين يستطيع العتاد تحمّل كلفته |
| W4A16W4A16 | Store 4-bit weights, decode to 16-bit and compute in 16-bit to keep accuracyخزّن الأوزان بـ 4-bit، وفكّ ترميزها إلى 16-bit، واحسب بـ 16-bit للحفاظ على الدقة | GPTQ, AWQ, llama.cpp and MLC LLM for single-batch LLM decodingGPTQ وAWQ وllama.cpp وMLC LLM لفك ترميز LLM بدفعة واحدة |
| Conالسلبية | Why it hurtلماذا أضرّ | What replaced itما حلّ محله |
|---|---|---|
| Hard on arrays of vector processorsصعب على مصفوفات المعالجات المتجهية | Irregular non-zero positions cannot be fed to wide SIMD lanes or tensor coresلا يمكن تغذية مسارات SIMD العريضة أو أنوية الموتّرات بمواضع غير منتظمة للقيم غير الصفرية | Structured N:M sparsity in the Sparse Tensor Core (2:4), load-balance-aware pruning in ESEالتناثر المهيكل N:M في Sparse Tensor Core (2:4)، والتقليم المراعي لموازنة الحمل في ESE |
| Control and storage overheadعبء التحكم والتخزين | Pointer reads, CSC traversal and LNZD around a single MAC; a 4-bit index per 4-bit weight is 50% overheadقراءات المؤشرات والمرور على CSC وLNZD حول عملية MAC واحدة؛ وفهرس 4-bit لكل وزن 4-bit يعني عبئًا بنسبة 50% | Coarse-grained block sparsityالتناثر الكتلي الخشن الحُبيبية (coarse-grained) |
| Fully connected layers onlyالطبقات المتصلة بالكامل فقط | One matrix-vector product at batch size 1; convolutions were out of scopeضرب مصفوفة في متجه واحد بحجم دفعة 1؛ وكانت طبقات الالتفاف خارج النطاق | SCNN, Cambricon-X and Eyeriss v2 for sparse convolution; the M x V pattern itself returned in LLM decodingSCNN وCambricon-X وEyeriss v2 للالتفاف المتناثر؛ وعاد نمط M x V نفسه في فك ترميز LLM |
| Everything in SRAMكل شيء في SRAM | Fine for TinyML and vision models; 10 to 100 billion parameter LLMs do not fit (Cerebras tried this path)مناسب لـ TinyML ونماذج الرؤية؛ أما نماذج LLM ذات 10 إلى 100 مليار معامل فلا تتسع (وقد جرّبت Cerebras هذا الطريق) | None named; the retrospective only notes that 10 to 100 billion parameter LLMs do not fitلا شيء مسمّى؛ تكتفي المراجعة بالإشارة إلى أن نماذج LLM ذات 10 إلى 100 مليار معامل لا تتسع |
The con that matters most for the rest of this lectureالسلبية الأهم لبقية هذه المحاضرة
The first con is the one that shaped GPUs. A vector processor or a tensor core executes the same instruction on many lanes at once, so it needs each lane to have work at the same time. With irregular fine-grained sparsity, one lane may hold a non-zero and its neighbor a zero, and there is no way to line them up. EIE solved this with a private index stream per PE and a FIFO for load balance; ESE (FPGA 2017) went further with load-balance-aware pruning. NVIDIA instead changed the pattern itself: prune so that in every block of four consecutive weights exactly two are zero, a constraint called 2:4 sparsity. The Sparse Tensor Core then reads a 2-bit index per kept weight, selects the matching activations, and doubles math throughput with metadata overhead far below EIE's 50%. NVIDIA's recipe is to train dense, prune to 2:4 by magnitude, and retrain with the original hyperparameters. The next part takes this up in full.
السلبية الأولى هي التي شكّلت وحدات GPU. المعالج المتجهي أو نواة الموتّرات (tensor core) ينفّذ التعليمة نفسها على مسارات (lanes) كثيرة في وقت واحد، فيحتاج أن يكون لكل مسار عمل في اللحظة نفسها. ومع التناثر الدقيق غير المنتظم قد يحمل مسار قيمة غير صفرية وجاره صفرًا، ولا سبيل إلى مواءمتهما. حلّ EIE ذلك بتدفق فهارس خاص بكل عنصر معالجة وبـ FIFO من أجل load balance (موازنة الحمل)؛ وذهب ESE (FPGA 2017) أبعد بتقليم يراعي موازنة الحمل. أما NVIDIA فغيّرت النمط نفسه: قلّم بحيث يكون في كل كتلة من أربعة أوزان متتالية وزنان صفريان بالضبط، وهو قيد يُسمّى 2:4 sparsity. ثم تقرأ Sparse Tensor Core فهرسًا بطول 2-bit لكل وزن محفوظ، وتختار التفعيلات المطابقة، فتضاعف إنتاجية الحساب بعبء بيانات وصفية (metadata) أقل بكثير من 50% في EIE. ووصفة NVIDIA هي: درّب النموذج كثيفًا، ثم قلّمه إلى 2:4 بحسب المقدار (magnitude)، ثم أعد تدريبه بالمعاملات الفائقة (hyperparameters) الأصلية. والجزء التالي يتناول هذا بالكامل.
The second con is the index overhead you met in the energy gap: EIE stores a 4-bit index next to every 4-bit weight, and surrounds a single MAC with pointer reads, CSC traversal and the detector. Coarser granularity, whether 2:4 or whole blocks, amortizes that overhead. The third con, FC layers only, was answered by SCNN, Cambricon-X and Eyeriss v2 for sparse convolution. The fourth is a matter of scale: everything in SRAM is right for TinyML and vision models, and Cerebras pursued it commercially, but a model of 10 to 100 billion parameters does not fit.
السلبية الثانية هي عبء الفهرسة الذي قابلته في فجوة الطاقة: يخزّن EIE فهرسًا 4-bit بجوار كل وزن 4-bit، ويحيط عملية MAC واحدة بقراءات المؤشرات والمرور على CSC والكاشف. وgranularity (الحُبيبية) الأخشن، سواء كانت 2:4 أو كتلًا كاملة، توزّع هذا العبء وتستهلكه. والسلبية الثالثة، أي الطبقات FC فقط، أجابت عنها SCNN وCambricon-X وEyeriss v2 في الالتفاف المتناثر. أما الرابعة فمسألة حجم: وضع كل شيء في SRAM مناسب لـ TinyML ونماذج الرؤية، وقد سلكت Cerebras هذا الطريق تجاريًا، لكن نموذجًا من 10 إلى 100 مليار معامل لا يتسع.
Quick checkاختبار سريع
According to the retrospective, why did structured 2:4 sparsity replace EIE-style fine-grained sparsity on GPUs?بحسب المراجعة، لماذا حلّ التناثر المهيكل 2:4 محل التناثر الدقيق على طريقة EIE في وحدات GPU؟
Recall
Name two things EIE could not accelerate and the designs that fixed them.سمِّ أمرين لم يستطع EIE تسريعهما، والتصاميم التي عالجتهما.
Edit one corner of a generated image and ask the model to redraw it. A dense pipeline recomputes every pixel. SIGE (NeurIPS 2022) computes only the edited region and reuses the rest. Nothing about this is specific to pruned weights, yet it is the same move EIE made: do not spend energy where the answer is already known to be zero or unchanged.
عدّل زاوية واحدة من صورة مولَّدة واطلب من النموذج إعادة رسمها. خط المعالجة الكثيف يعيد حساب كل بكسل. أما SIGE (NeurIPS 2022) فلا يحسب إلا المنطقة المعدَّلة ويعيد استخدام الباقي. لا شيء في ذلك خاص بالأوزان المقلَّمة، ومع ذلك فهي الحركة نفسها التي قام بها EIE: لا تنفق الطاقة حيث يُعرف مسبقًا أن الجواب صفر أو لم يتغيّر.
The retrospective states the move as a principle. The first principle of efficient AI computing is to be lazy: avoid redundant computation, quickly reject the work, or delay the work. Each of the four bullets on the slide is one of those three verbs applied to a different axis of the data, and reading them that way is more useful than memorizing four paper names.
تصوغ المراجعة هذه الحركة مبدأً. المبدأ الأول في الحوسبة الكفؤة للذكاء الاصطناعي هو أن be lazy (تكون كسولًا): تجنّب الحساب الزائد، أو ارفض العمل بسرعة، أو أجّل العمل. وكل نقطة من النقاط الأربع على الشريحة هي أحد هذه الأفعال الثلاثة مطبَّقًا على محور مختلف من البيانات، وقراءتها بهذه الطريقة أنفع من حفظ أسماء أربع أوراق.
| Workloadعبء العمل | Kind of sparsityنوع التناثر | Systemالنظام | The lazy moveالحركة الكسولة |
|---|---|---|---|
| Generative image editingتحرير الصور التوليدي | Spatial sparsityالتناثر المكاني | SIGE (NeurIPS 2022)SIGE (NeurIPS 2022) | Recompute only the edited regionأعد حساب المنطقة المعدَّلة فقط |
| TransformersTransformers | Token sparsity and progressive quantizationتناثر الرموز (tokens) والتكميم التدريجي | SpAtten (HPCA 2021)SpAtten (HPCA 2021) | Prune unimportant tokens; fetch MSBs first, LSBs only if confidence is lowقلّم الرموز غير المهمة؛ اجلب البتات العليا (MSBs) أولًا، والبتات الدنيا (LSBs) فقط إذا كانت الثقة منخفضة |
| Videoالفيديو | Temporal sparsityالتناثر الزمني | TSM (ICCV 2019)TSM (ICCV 2019) | Shift features across frames at zero FLOPs instead of 3D convolutionأزِح الخصائص عبر الإطارات بتكلفة صفر FLOPs بدل الالتفاف الثلاثي الأبعاد |
| Point cloudsالسحب النقطية | Spatial sparsityالتناثر المكاني | TorchSparse (MLSys 2022) and PointAcc (MICRO 2021)TorchSparse (MLSys 2022) وPointAcc (MICRO 2021) | Compute only where points existاحسب فقط حيث توجد نقاط |
- Avoid redundant computation: SIGE skips unedited pixels; TSM replaces a 3D convolution over time with a shift that costs zero FLOPs.تجنّب الحساب الزائد: يتخطى SIGE البكسلات غير المعدَّلة؛ ويستبدل TSM الالتفاف الثلاثي الأبعاد عبر الزمن بإزاحة (shift) تكلفتها صفر FLOPs.
- Quickly reject the work: SpAtten prunes tokens and attention heads that contribute little, before they reach the expensive layers.ارفض العمل بسرعة: يقلّم SpAtten الرموز (tokens) ورؤوس الانتباه (attention heads) قليلة الإسهام قبل أن تصل إلى الطبقات المكلفة.
- Delay the work: SpAtten's progressive quantization fetches the most significant bits first and only fetches the least significant bits when the attention scores are not yet confident.أجّل العمل: التكميم التدريجي (progressive quantization) في SpAtten يجلب البتات الأعلى أهمية أولًا، ولا يجلب البتات الأدنى أهمية إلا حين لا تكون درجات الانتباه واثقة بعد.
The point-cloud line is the bridge to the last parts of this lecture. A LiDAR scan occupies a tiny fraction of its bounding volume, so sparse convolution computes only where points exist. TorchSparse makes that fast on a GPU and PointAcc builds the map generation into hardware. Notice that this is dynamic sparsity of the input, not static sparsity of the weights, which is the static versus dynamic split again: the hardware has to discover the sparsity on the fly, exactly as EIE's leading non-zero detector did for activations.
سطر السحب النقطية هو الجسر إلى الأجزاء الأخيرة من هذه المحاضرة. مسح LiDAR يشغل جزءًا ضئيلًا من الحجم المحيط به، لذلك يحسب sparse convolution (الالتفاف المتناثر) فقط حيث توجد نقاط. ويجعل TorchSparse ذلك سريعًا على GPU، ويبني PointAcc توليد الخرائط (map generation) في العتاد. لاحظ أن هذا تناثر ديناميكي في الدخل، لا تناثر ساكن في الأوزان، وهو التقسيم static versus dynamic (الساكن مقابل الديناميكي) مرة أخرى: على العتاد أن يكتشف التناثر أثناء التشغيل، تمامًا كما فعل كاشف أول قيمة غير صفرية في EIE مع activations (التفعيلات).
Recall
State the be-lazy principle and map each of its three verbs to one system from the slide.اذكر مبدأ الكسل (be lazy)، واربط كل فعل من أفعاله الثلاثة بنظام واحد من الشريحة.
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- After accumulation, ReLU and the LNZD network make the output sparse and broadcast only non-zero (value, index) pairs; the loop closes on chip.بعد التراكم، تجعل ReLU وشبكة LNZD الخرج متناثرًا، ولا يُبث إلا أزواج (القيمة، الفهرس) غير الصفرية؛ فتُغلق الحلقة داخل الشريحة.
- All compressed weights sit in per-PE SRAM; SRAM at 5 pJ against DRAM at 640 pJ per 32-bit access (128x, which the paper rounds to 120x) is the biggest lever.كل الأوزان المضغوطة موجودة في SRAM خاصة بكل PE؛ وصول SRAM بتكلفة 5 pJ مقابل 640 pJ لوصول DRAM لكل كلمة 32-bit (أي 128x، وتقرّبها الورقة إلى 120x) هو الرافعة الأكبر.
- Theoretical saving 120 x 10 x 8 x 3 = 28,800x; measured 24,000x vs CPU and 3,400x vs GPU; speed 189x and 13x; batch size 1.التوفير النظري 120 x 10 x 8 x 3 = 28,800x؛ والمقيس 24,000x مقابل CPU و3,400x مقابل GPU؛ والسرعة 189x و13x؛ بحجم دفعة 1.
- FLOP reduction equals 1 over (weight density times activation density); LSTM layers have 100 percent activation density.تخفيض FLOP يساوي 1 مقسومًا على (كثافة الأوزان مضروبة في كثافة التفعيلات)؛ وطبقات LSTM كثافة تفعيلاتها 100 بالمئة.
- The throughput chart mixes 22, 28 and 45 nm, a projection and a bandwidth estimate; read it as decades, not ratios.مخطط الإنتاجية يخلط بين 22 و28 و45 nm، وبين قيمة متوقعة (projection) وتقدير مبني على عرض النطاق؛ فاقرأه بالرتب العشرية لا بالنسب.
- What held up: co-design, both sparsities, on-chip weights and W4A16, which was reborn in LLM decoding.ما صمد: التصميم المشترك (co-design)، واستغلال نوعي التناثر معًا، والأوزان على الشريحة، وW4A16 الذي وُلد من جديد في فك ترميز LLM.
- What did not: FC only, batch 1, 50 percent index overhead, 16-bit datapath and irregular sparsity on SIMD; successors are SCNN, Cambricon-X, Eyeriss v2, ESE and 2:4 Sparse Tensor Cores.ما لم يصمد: الطبقات FC فقط، والدفعة 1، وعبء فهرسة 50 بالمئة، ومسار بيانات 16-bit، والتناثر غير المنتظم على SIMD؛ والخلفاء هم SCNN وCambricon-X وEyeriss v2 وESE وSparse Tensor Cores بنمط 2:4.
- The first principle is to be lazy: spatial, token, temporal and point-cloud sparsity all apply it.المبدأ الأول هو أن تكون كسولًا: التناثر المكاني، وتناثر الرموز (tokens)، والتناثر الزمني، وتناثر السحب النقطية كلها تطبّقه.
Sourcesالمصادر
- EIE: Efficient Inference Engine on Compressed Deep Neural NetworkPaperISCA 2016, Han, Liu, Mao, Pu, Pedram, Horowitz and DallyTable I (energy costs), Table III (benchmarks), Table V (cross-platform), Section VI (LNZD, FIFO depth) and Section VIII (energy breakdown, batch size).الجدول I (تكاليف الطاقة)، والجدول III (طبقات الاختبار)، والجدول V (المقارنة بين المنصات)، والقسم VI (LNZD وعمق FIFO)، والقسم VIII (تفصيل الطاقة وحجم الدفعة).(opens in a new tab)(يفتح في تبويب جديد)
- Retrospective: EIE: Efficient Inference Engine on Sparse and Compressed Neural NetworkPaperISCA@50 25-Year Retrospective, June 2023, Han et al.Pros and cons, W4A16 in LLM inference, the be-lazy principle and the successor systems named in this part.الإيجابيات والسلبيات، وW4A16 في استدلال LLM، ومبدأ الكسل، والأنظمة اللاحقة المذكورة في هذا الجزء.(opens in a new tab)(يفتح في تبويب جديد)
- Computing's Energy Problem (and what we can do about it)PaperISSCC 2014, Mark HorowitzOrigin of the 45 nm per-operation energy table; EIE's Table I restates it per 32-bit word.أصل جدول الطاقة لكل عملية عند 45 nm؛ ويعيد الجدول I في EIE عرضه لكل كلمة 32-bit.(opens in a new tab)(يفتح في تبويب جديد)
- Accelerating Inference with Sparsity Using the NVIDIA Ampere Architecture and NVIDIA TensorRTDocsNVIDIA Developer Blog2:4 definition, 2x math throughput, low metadata overhead, and the prune-then-retrain recipe.تعريف 2:4، ومضاعفة إنتاجية الحساب 2x، وعبء البيانات الوصفية المنخفض، ووصفة التقليم ثم إعادة التدريب.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2023, Lecture 4: Pruning and Sparsity Part IIVideoMIT HAN LabThe deck these slides follow; lecture video at youtu.be/3t9aGLLaCqs.مجموعة الشرائح التي تتبعها هذه الشرائح؛ وفيديو المحاضرة على youtu.be/3t9aGLLaCqs.(opens in a new tab)(يفتح في تبويب جديد)
Part 10: M:N sparsity on NVIDIA tensor coresتناثر M:N على أنوية NVIDIA tensor cores
Fine-grained structured sparsity keeps exactly N nonzeros in every block of M weights, compresses the matrix to half plus two-bit indices, and lets Ampere sparse tensor cores double GEMM throughput with no accuracy loss.التناثر المهيكل الدقيق يُبقي N عناصر غير صفرية بالضبط في كل كتلة من M وزنًا، ويضغط المصفوفة إلى النصف مع فهارس من بتين، ويسمح لأنوية tensor cores المتناثرة في Ampere بمضاعفة إنتاجية GEMM دون فقدان في الدقة.
4 concepts4 مفاهيم, ، slides 78-83الشرائح 78-83
Why this part mattersلماذا يهمّ هذا الجزء
EIE proved that a sparse network can run faster and cooler than a dense one, but only on a chip nobody could buy. This part is the version you can run today. The same GPUs that train the models in your research project will accept a weight matrix in a fixed 2:4 pattern and double their matrix math, and NVIDIA ships the pruning recipe, the storage format and the library that does it.
Three things are worth taking from it. The exam will ask you to compute the storage of a 2:4 matrix, to explain how the tensor core uses two-bit indices to skip half its multiplies, and to justify why the accuracy tables show no loss. Beyond the exam, 2:4 is the reference point for every future claim you will read about a sparse accelerator: it is what a fixed, mild, hardware-friendly pattern buys, and where it stops.
أثبت EIE أن الشبكة المتناثرة يمكن أن تعمل أسرع وبحرارة أقل من الشبكة الكثيفة، لكن على شريحة لم يكن بوسع أحد شراؤها. هذا الجزء هو النسخة التي يمكنك تشغيلها اليوم. وحدات GPU نفسها التي تدرّب النماذج في مشروعك البحثي تقبل مصفوفة أوزان بنمط ثابت 2:4 وتضاعف سرعة عمليات المصفوفات، وNVIDIA توفّر وصفة التقليم (pruning) وصيغة التخزين والمكتبة التي تنفّذ ذلك.
هناك ثلاثة أشياء تستحق أن تأخذها من هذا الجزء. سيطلب منك الامتحان أن تحسب حجم تخزين مصفوفة 2:4، وأن تشرح كيف تستخدم نواة الـ tensor فهارس من بتين لتتخطى نصف عمليات الضرب، وأن تبرر لماذا لا تُظهر جداول الدقة أي خسارة. وأبعد من الامتحان، يمثّل 2:4 النقطة المرجعية لكل ادعاء ستقرؤه مستقبلًا عن مسرّع متناثر: فهو يُريك ما يشتريه نمط ثابت ومعتدل وملائم للعتاد، وأين تقف حدوده.
By the end you canفي نهاية هذا الجزء ستستطيع
- Define an a:b fine-grained structured pattern, state that 2:4 is 50 percent sparsity, and explain why a fixed count per block is what makes it hardware friendly.تعرّف نمطًا بنيويًا دقيق الحبيبات من الشكل a:b، وتذكر أن 2:4 يعني تناثرًا بنسبة 50 بالمئة، وتشرح لماذا يجعله العدد الثابت في كل كتلة ملائمًا للعتاد.
- Compute the storage of a 2:4 compressed matrix (values plus 2-bit metadata) and the resulting saving for FP16 and INT8 weights.تحسب حجم تخزين مصفوفة مضغوطة بنمط 2:4 (القيم مع بيانات وصفية من بتين) والتوفير الناتج لأوزان FP16 وINT8.
- Trace how a sparse tensor core uses the 2-bit indices to select K/2 activations from a dense operand and halve the multiplies.تتتبّع كيف تستخدم نواة الـ tensor المتناثرة الفهارس ذات البتين لاختيار K/2 من التنشيطات من المعامل الكثيف وتقليص عمليات الضرب إلى النصف.
- Reproduce NVIDIA's train, prune, retrain recipe and explain why it recovers accuracy without a hyper-parameter search.تعيد بناء وصفة NVIDIA (درّب، قلّم، أعد التدريب) وتشرح لماذا تستعيد الدقة دون أي بحث عن المعاملات الفائقة (hyper-parameters).
- Explain why GEMM speedup grows with K toward a 2x ceiling and why end-to-end inference gains are smaller.تشرح لماذا يزداد تسريع GEMM مع K مقتربًا من سقف 2x، ولماذا تكون مكاسب الاستدلال الكامل (end-to-end) أصغر.
Look at the first row of the structured-sparse matrix on the slide. Read it four cells at a time. The first four hold a value, a zero, a zero, a value. The next four hold a zero, a value, a value, a zero. Every group of four consecutive weights along the row has exactly two survivors, and the survivors can sit anywhere inside the group. Mishra et al. write the metadata for that row as [[0, 3], [1, 2]]: the positions of the survivors, group by group.
انظر إلى الصف الأول من المصفوفة المتناثرة البنيوية في الشريحة، واقرأه أربع خلايا في كل مرة. الخلايا الأربع الأولى تحتوي: قيمة، صفر، صفر، قيمة. والأربع التالية تحتوي: صفر، قيمة، قيمة، صفر. كل مجموعة من أربعة أوزان متتالية على طول الصف يبقى فيها وزنان بالضبط، ويمكن أن يقع الناجيان في أي موضع داخل المجموعة. يكتب Mishraوزملاؤه البيانات الوصفية (metadata) لهذا الصف هكذا [[0, 3], [1, 2]]: مواضع الأوزان الباقية، مجموعةً بعد مجموعة.
That is the whole definition of 2:4 sparsity: for each group of four values along a row, at least two must be zero. The general form keeps the same shape. Write a pattern as a:b, where the first number is how many weights survive and the second is the block size. Sparsity is then fixed by the pattern, not by the data.
هذا هو التعريف الكامل لـ 2:4 sparsity: في كل مجموعة من أربع قيم على طول الصف، يجب أن تكون قيمتان على الأقل صفرًا. والصيغة العامة تحافظ على الشكل نفسه. اكتب النمط على هيئة a:b، حيث الرقم الأول هو عدد الأوزان الباقية والثاني هو حجم الكتلة. وبذلك تتحدد نسبة التناثر بالنمط نفسه، لا بالبيانات.
2:4 is the instance that ships. Ampere sparse tensor cores accept it for FP16, BF16 and INT8 weights, and for TF32 the block halves to 1:2, still 50 percent (Mishra et al., section 3.2). NVIDIA describes the pattern as "two non-zero values in every four-entry vector" and calls it fine-grained structured sparsity (NVIDIA Ampere in-depth blog). The A100 whitepaper is explicit that the pattern is enforced along rows.
2:4 هو النمط المطبّق فعليًا في المنتجات. تقبله أنوية الـ tensor المتناثرة في معمارية Ampere لأوزان FP16 وBF16 وINT8، أما في TF32 فتنقسم الكتلة إلى النصف لتصبح 1:2، وتبقى النسبة 50 بالمئة (Mishra et al., section 3.2). تصف NVIDIA النمط بأنه "قيمتان غير صفريتين في كل متجه من أربعة عناصر" وتسمّيه التناثر البنيوي دقيق الحبيبات (fine-grained structured sparsity) (مدونة NVIDIA Ampere in-depth). وتنص الورقة البيضاء لـ A100 صراحةً على أن النمط يُفرض على طول الصفوف.
Fine-grained in what it removes, structured in how manyدقيق الحبيبات في ما يحذفه، بنيوي في عدد ما يحذفه
Lecture 04-1 laid out pruning granularities on a line from irregular fine-grained pruning, which may zero any single weight, to channel pruning, which removes whole filters. 2:4 sits between them and borrows the best of each. It is fine-grained because the unit removed is a single weight, so the pruning criterion still gets to pick within every block, which is why accuracy survives. It is structured because the count per block is constant, so the hardware knows in advance that every four weights hide exactly two multiplies.
عرضت المحاضرة 04-1 مستويات دقة التقليم (pruning granularities) على خط يمتد من التقليم غير المنتظم دقيق الحبيبات، الذي يمكنه تصفير أي وزن منفرد، إلى تقليم القنوات (channel pruning) الذي يحذف مرشحات (filters) كاملة. يقع 2:4 بينهما ويأخذ أفضل ما في كل منهما. فهو دقيق الحبيبات لأن الوحدة المحذوفة وزن واحد، فيبقى معيار التقليم قادرًا على الاختيار داخل كل كتلة، ولهذا تصمد الدقة. وهو بنيوي لأن العدد في كل كتلة ثابت، فيعرف العتاد مسبقًا أن كل أربعة أوزان تخفي عمليتي ضرب بالضبط.
That constancy is the entire engineering payoff. Unstructured sparsity, the kind EIE handles, needs a data-dependent index for every nonzero and a pointer to the start of every column, and the paper notes it leads to poor utilization of cache lines because the survivors land anywhere. With 2:4, the paper points out, the sparsity is constant across the matrix, so no indirection is required: a nonzero's position in memory can be computed directly from the compression rate. Two bits per survivor say which of the four slots it came from, and nothing else needs to be stored.
هذا الثبات هو كل المكسب الهندسي. التناثر غير البنيوي، وهو النوع الذي يتعامل معه EIE، يحتاج إلى فهرس يعتمد على البيانات لكل قيمة غير صفرية، وإلى مؤشر (pointer) لبداية كل عمود، وتذكر الورقة أنه يؤدي إلى استغلال ضعيف لأسطر الذاكرة المخبئية (cache lines) لأن الأوزان الباقية تقع في أي مكان. أما مع 2:4، كما تشير الورقة، فالتناثر ثابت عبر المصفوفة كلها، فلا حاجة إلى أي عنونة غير مباشرة (indirection): يمكن حساب موضع القيمة غير الصفرية في الذاكرة مباشرة من معدل الضغط. بتّان لكل وزن باقٍ تحددان أي خانة من الخانات الأربع جاء منها، ولا حاجة إلى تخزين أي شيء آخر.
| Patternالنمط | What can be removedما يمكن حذفه | Metadataالبيانات الوصفية | Hardware that benefitsالعتاد المستفيد | Flexibility for accuracyمرونة الحفاظ على الدقة |
|---|---|---|---|---|
| Unstructured (EIE)غير بنيوي (EIE) | Any weight, anywhereأي وزن في أي موضع | Index per nonzero, pointers, paddingفهرس لكل قيمة غير صفرية، ومؤشرات، وحشو (padding) | Custom accelerator or slow CPU kernelsمسرّع مخصص أو نوى CPU بطيئة | Highest, chosen per weightالأعلى، تُختار لكل وزن |
| 2:4 fine-grained structuredبنيوي دقيق الحبيبات بنمط 2:4 | Any two of every four in a rowأي اثنين من كل أربعة في الصف | 2 bits per stored value, no pointers2 بت لكل قيمة مخزنة، بلا مؤشرات | Every Ampere and later GPUكل GPU من جيل Ampere وما بعده | High, chosen per blockعالية، تُختار لكل كتلة |
| Channel pruningتقليم القنوات (channel pruning) | Whole output channelsقنوات خرج كاملة | None, matrix just shrinksلا شيء، فالمصفوفة تصغر فحسب | Any dense hardwareأي عتاد كثيف | Lowest, chosen per channelالأدنى، تُختار لكل قناة |
One more fact will matter in the next two concepts: the groups of four run along the row of the weight matrix W. In the GEMM that a layer becomes, that row is the reduction dimension, the axis along which products are summed. The pattern has to live there, because that is the only axis on which skipping a weight also skips a multiply.
هناك حقيقة أخرى ستهمّ في المفهومين التاليين: مجموعات الأربعة تمتد على طول صف مصفوفة الأوزان W. وفي عملية GEMM التي تتحول إليها الطبقة، يكون هذا الصف هو بُعد الاختزال (reduction dimension)، أي المحور الذي تُجمع على طوله حواصل الضرب. يجب أن يقع النمط هناك، لأنه المحور الوحيد الذي يعني فيه تخطي وزن تخطي عملية ضرب أيضًا.
Where this sits among the three case studiesأين يقع هذا بين دراسات الحالة الثلاث
The divider slide that opens this section lists three sparse-hardware case studies. EIE (Efficient Inference Engine) came first: a custom accelerator exploiting Weight sparsity and Activation sparsity at once. This part is the middle one, and it takes the opposite bet. It exploits weight sparsity only, at a fixed and modest 50 percent, in exchange for running on a GPU that already sits in every data center. TorchSparse and PointAcc, which follow, go back to activation sparsity in point clouds. Keeping the three apart by which sparsity they exploit and what hardware they need is the fastest way to remember them.
تسرد الشريحة الفاصلة التي تفتتح هذا القسم ثلاث دراسات حالة لعتاد متناثر. جاء EIE (Efficient Inference Engine) أولًا: مسرّع مخصص يستغل Weight sparsity وActivation sparsity في آن واحد. هذا الجزء هو الأوسط، ويراهن رهانًا معاكسًا. فهو يستغل تناثر الأوزان فقط، بنسبة ثابتة ومتواضعة قدرها 50 بالمئة، مقابل أن يعمل على GPU موجود أصلًا في كل مركز بيانات. ثم يعود TorchSparse وPointAcc، اللذان يليانه، إلى تناثر التنشيطات في السحب النقطية (point clouds). التمييز بين الثلاثة بحسب نوع التناثر الذي يستغله كل منها والعتاد الذي يحتاجه هو أسرع طريقة لتذكّرها.
Recall
Why is 2:4 called fine-grained structured sparsity?لماذا يُسمّى نمط 2:4 تناثرًا بنيويًا دقيق الحبيبات؟
Take one group of four FP16 weights. Dense, it costs 4 x 16 = 64 bits. Under 2:4, only two values are stored, 2 x 16 = 32 bits, plus a 2-bit index for each, 2 x 2 = 4 bits. The group now costs 36 bits, a saving of about 44 percent (Mishra et al., section 3.1). Not 50 percent: the indices are small but they are not free.
خذ مجموعة واحدة من أربعة أوزان FP16. في الصيغة الكثيفة تكلّف 4 x 16 = 64 bits. وتحت نمط 2:4 لا تُخزَّن إلا قيمتان، أي 2 x 16 = 32 bits، مع فهرس من بتين لكل منهما، أي 2 x 2 = 4 bits. فتصبح كلفة المجموعة 36 bits، أي توفير بنحو 44 بالمئة (Mishra et al., section 3.1). ليس 50 بالمئة: الفهارس صغيرة لكنها ليست مجانية.
Scale that to a whole matrix and you get the format on the slide. A structured-sparse W of size R x C is stored as an R x C/2 block of nonzero values and an R x C/2 block of two-bit indices. The slide's instruction is to push all the nonzero elements to the left in memory. The survivors of each row are packed contiguously at half the original width, and the index block, drawn beside them, records where each came from.
عمّم ذلك على مصفوفة كاملة تحصل على الصيغة التي في الشريحة. المصفوفة W المتناثرة بنيويًا بحجم R x C تُخزَّن على هيئة كتلة بحجم R x C/2 من القيم غير الصفرية، وكتلة بحجم R x C/2 من الفهارس ذات البتين. تعليمات الشريحة هي دفع كل العناصر غير الصفرية إلى اليسار في الذاكرة. تُرصّ الأوزان الباقية في كل صف متجاورةً بنصف العرض الأصلي، وكتلة الفهارس المرسومة بجانبها تسجّل من أين جاءت كل قيمة.
Worked exampleمثال محلول
An FP16 layer of 1024 x 1024 weightsطبقة FP16 من 1024 x 1024 وزنًا
Dense storageالتخزين الكثيف
1024 x 1024 x 16 = 16,777,216 bits, which is 2 MiB.1024 x 1024 x 16 = 16,777,216 bits، أي 2 MiB.Stored valuesالقيم المخزّنة
Half the columns survive: 1024 x 512 = 524,288 values at 16 bits each, 8,388,608 bits = 1 MiB.يبقى نصف الأعمدة: 1024 x 512 = 524,288 قيمة، كل منها 16 bits، أي 8,388,608 bits = 1 MiB.Metadataالبيانات الوصفية
One 2-bit index per stored value: 524,288 x 2 = 1,048,576 bits = 128 KiB.فهرس واحد من بتين لكل قيمة مخزّنة: 524,288 x 2 = 1,048,576 bits = 128 KiB.Total and savingالمجموع والتوفير
8,388,608 + 1,048,576 = 9,437,184 bits = 1.125 MiB. The ratio to dense is 9,437,184 / 16,777,216 = 0.5625.8,388,608 + 1,048,576 = 9,437,184 bits = 1.125 MiB. والنسبة إلى الكثيف هي 9,437,184 / 16,777,216 = 0.5625.Resultالنتيجة
43.75% saved. The value array halves; the indices add back an eighth of what remains.توفير بنسبة 43.75%. مصفوفة القيم تنقص إلى النصف، والفهارس تضيف ثُمن ما تبقّى.
| Caseالحالة | Denseكثيف | Valuesالقيم | Metadataالبيانات الوصفية | Totalالمجموع | Savingالتوفير |
|---|---|---|---|---|---|
| FP16, R = C = 1024FP16, R = C = 1024 | 16,777,216 (2 MiB)16,777,216 (2 MiB) | 8,388,608 (1 MiB)8,388,608 (1 MiB) | 1,048,576 (128 KiB)1,048,576 (128 KiB) | 9,437,184 (1.125 MiB)9,437,184 (1.125 MiB) | 43.75%43.75% |
| INT8, R = C = 4096INT8, R = C = 4096 | 134,217,728 (16 MiB)134,217,728 (16 MiB) | 67,108,864 (8 MiB)67,108,864 (8 MiB) | 16,777,216 (2 MiB)16,777,216 (2 MiB) | 83,886,080 (10 MiB)83,886,080 (10 MiB) | 37.5%37.5% |
The index cost is a fixed 2 bits per stored value, so its weight relative to the values depends on the value width: 2 / 16 = 12.5% overhead for FP16 and 2 / 8 = 25% for INT8, which is why the INT8 saving is the smaller 37.5 percent (Mishra et al., section 3.1). Compare that with the format EIE relied on. CSC stores a 4-bit relative index and a 4-bit weight-sharing code per nonzero, a 16-bit pointer per column, and a padding entry whenever a run of zeros exceeds fifteen (Han et al., EIE, section III). Mishra et al. note that a plain CSR with 8-bit weights and 16-bit column indices can spend up to 200 percent of the value bits on metadata. 2:4 spends 12.5 or 25 percent, with no pointers and no padding, because the pattern itself carries most of the position information.
كلفة الفهرس ثابتة عند بتين لكل قيمة مخزّنة، لذا يعتمد وزنها النسبي مقارنةً بالقيم على عرض القيمة: 2 / 16 = 12.5% كلفة إضافية في FP16 و2 / 8 = 25% في INT8، ولهذا يكون توفير INT8 هو الأصغر بنسبة 37.5 بالمئة (Mishra et al., section 3.1). قارن ذلك بالصيغة التي اعتمد عليها EIE. تخزّن صيغة CSC فهرسًا نسبيًا من 4 بتات ورمزًا من 4 بتات لمشاركة الأوزان (weight-sharing) لكل قيمة غير صفرية، ومؤشرًا من 16 بتًا لكل عمود، ومدخل حشو (padding) كلما تجاوزت سلسلة من الأصفار خمسة عشر (Han et al., EIE, section III). ويشير Mishra وزملاؤه إلى أن صيغة CSR عادية بأوزان من 8 بتات وفهارس أعمدة من 16 بتًا قد تنفق ما يصل إلى 200 بالمئة من بتات القيم على البيانات الوصفية. أما 2:4 فينفق 12.5 أو 25 بالمئة، بلا مؤشرات وبلا حشو، لأن النمط نفسه يحمل معظم معلومات المواضع.
One group of four weights under 2:4مجموعة واحدة من أربعة أوزان بنمط 2:4
- FP16 denseFP16 الكثيف
- 4 x 16 = 64 bits4 x 16 = 64 بت
- FP16 compressedFP16 المضغوط
- 2 x 16 + 2 x 2 = 36 bits, about 44% saved2 x 16 + 2 x 2 = 36 بت، أي توفير نحو 44%
- INT8 denseINT8 الكثيف
- 4 x 8 = 32 bits4 x 8 = 32 بت
- INT8 compressedINT8 المضغوط
- 2 x 8 + 2 x 2 = 20 bits, about 38% saved2 x 8 + 2 x 2 = 20 بت، أي توفير نحو 38%
Why insist on pushing everything to the left rather than leaving zeros in place and skipping them? Because memory is read in wide lines. With the survivors contiguous at half width, every byte a memory read brings in is a value the tensor core will use, which the paper describes as letting hardware fully utilize large memory reads. The A100 whitepaper puts the same point as a reduction of memory storage and bandwidth by almost 2x. Zeros left in place would fill half of every line with nothing.
لماذا الإصرار على دفع كل شيء إلى اليسار بدلًا من ترك الأصفار في مكانها وتخطيها؟ لأن الذاكرة تُقرأ في أسطر عريضة. حين تكون الأوزان الباقية متجاورة بنصف العرض، فكل بايت تجلبه عملية قراءة من الذاكرة هو قيمة ستستخدمها نواة الـ tensor، وهو ما تصفه الورقة بأنه يتيح للعتاد استغلال قراءات الذاكرة الكبيرة استغلالًا كاملًا. وتعبّر الورقة البيضاء لـ A100 عن الفكرة نفسها بأنها تقليل لمساحة التخزين وعرض النطاق (bandwidth) بما يقارب 2x. أما الأصفار المتروكة في مكانها فستملأ نصف كل سطر بلا شيء.
Check against Mishra et al.: 43.75 percent, the paper's about 44 percent for FP16.مقارنة بـ Mishra et al.: 43.75 بالمئة، والورقة تذكر نحو 44 بالمئة لـ FP16.
The value array always halves under 2:4, but every stored value drags a 2-bit index with it, so the saving lands at 43.75 percent for 16-bit weights and 37.5 percent for 8-bit weights, never at 50. The MAC count halves exactly, which is the 2x the sparse tensor core can deliver on the matrix math alone. The last readout applies Amdahl to the whole network: with 70 percent of inference time inside GEMMs and a measured 1.8x on those GEMMs, the model runs about 1.45x faster. Drag the GEMM share down to see why memory-bound layers and small batches hide most of the gain.تنكمش مصفوفة القيم دائمًا إلى النصف تحت 2:4، لكن كل قيمة مخزنة تجر معها فهرسًا بطول 2-bit، لذا يستقر التوفير عند 43.75 بالمئة للأوزان ذات 16-bit و37.5 بالمئة للأوزان ذات 8-bit، ولا يبلغ 50 أبدًا. أما عدد عمليات MAC فينخفض إلى النصف تمامًا، وهذا هو التسريع 2x الذي تستطيع sparse tensor core تقديمه في حساب المصفوفات وحده. يطبق المؤشر الأخير قانون Amdahl على الشبكة كلها: إذا كان 70 بالمئة من زمن الاستدلال داخل عمليات GEMM وكان التسريع المقيس عليها 1.8x، يعمل النموذج أسرع بنحو 1.45x. اسحب حصة GEMM إلى الأسفل لترى لماذا تخفي الطبقات المقيدة بالذاكرة والدفعات الصغيرة معظم المكسب.
Quick checkاختبار سريع
A 2:4 sparse FP16 weight matrix has R = 512 rows and C = 1024 columns. How many metadata bits does the compressed format hold?مصفوفة أوزان FP16 متناثرة بنمط 2:4 فيها R = 512 صفًا وC = 1024 عمودًا. كم بتًا من البيانات الوصفية تحتويها الصيغة المضغوطة؟
Recall
For an R x C weight matrix in 2:4 format, how many values and how many metadata bits are stored?في مصفوفة أوزان بحجم R x C بصيغة 2:4، كم قيمة وكم بتًا من البيانات الوصفية تُخزَّن؟
Follow one output element through a small GEMM with K = 8. Dense, the tensor core takes a row of A with eight values, a column of B with eight values, multiplies them pairwise and accumulates eight products. Now store that row of A in 2:4 form: four values and four 2-bit indices. The core reads the indices, pulls exactly the four elements of the B column that sit at those positions, multiplies four pairs, and accumulates. The slide's caption says it in one line: the indices are used to mask out the inputs, and only two multiplications will be done out of four.
تتبّع عنصر إخراج واحدًا خلال GEMM صغيرة بـ K = 8. في الحالة الكثيفة، تأخذ نواة الـ tensor صفًا من A فيه ثماني قيم، وعمودًا من B فيه ثماني قيم، فتضربهما زوجًا زوجًا وتراكم ثمانية حواصل ضرب. الآن خزّن ذلك الصف من A بصيغة 2:4: أربع قيم وأربعة فهارس من بتين. تقرأ النواة الفهارس، وتسحب بالضبط العناصر الأربعة من عمود B الواقعة في تلك المواضع، وتضرب أربعة أزواج، ثم تراكم. ويلخص تعليق الشريحة ذلك في سطر واحد: تُستخدم الفهارس لحجب المدخلات (mask out)، ولا تُنفَّذ إلا عمليتا ضرب من كل أربع.
The rule behind the example is worth stating precisely, because exam questions turn on it. A Sparse tensor core performs sparse matrix times dense matrix equals dense matrix. Only the first operand, A of size M x K, is compressed, to M x K/2 values plus indices. The second operand B (K x N) and the output C (M x N) stay dense (Mishra et al., section 3.2). NVIDIA's TensorRT blog describes the mechanism as using the metadata to pull only the necessary values from the other, uncompressed operand. The metadata belongs to the weights, but it is applied to the activations.
القاعدة وراء المثال تستحق أن تُذكر بدقة، لأن أسئلة الامتحان تدور حولها. تنفّذ Sparse tensor core عملية: مصفوفة متناثرة ضرب مصفوفة كثيفة يساوي مصفوفة كثيفة. المعامل الأول وحده، A بحجم M x K، يُضغط إلى M x K/2 من القيم مع الفهارس. أما المعامل الثاني B (K x N) والإخراج C (M x N) فيبقيان كثيفين (Mishra et al., section 3.2). وتصف مدونة TensorRT من NVIDIA الآلية بأنها تستخدم البيانات الوصفية لسحب القيم الضرورية فقط من المعامل الآخر غير المضغوط. البيانات الوصفية تخص الأوزان، لكنها تُطبَّق على التنشيطات.
The weight row, already packed left.
صف الأوزان، مرصوص إلى اليسار مسبقًا.
A multiplexer over the dense B column.
مُجمِّع انتقائي (multiplexer) على عمود B الكثيف.
Writes a dense element of C.
يكتب عنصرًا كثيفًا من C.
Halving the pairs halves the work, and the hardware is built so that the saving shows up as time. The A100 whitepaper states that a standard MMA on a 16 x 8 x 16 tile takes some number of cycles N, and the sparse MMA on the same tile takes N/2, a 2x speedup. The paper's Table 1 reports the resulting peak rates.
تقليص الأزواج إلى النصف يقلّص العمل إلى النصف، والعتاد مصمَّم بحيث يظهر هذا التوفير في الزمن. تنص الورقة البيضاء لـ A100 على أن عملية MMA عادية على قطعة بحجم 16 x 8 x 16 تستغرق عددًا من الدورات قدره N، وأن عملية MMA المتناثرة على القطعة نفسها تستغرق N/2، أي تسريع 2x. ويعرض الجدول 1 في الورقة المعدلات القصوى الناتجة.
A100 peak dense versus sparse tensor throughput, in TOPS (Mishra et al., Table 1)الإنتاجية القصوى لنوى tensor في A100 كثيفةً مقابل متناثرة، بوحدة TOPS (Mishra وزملاؤه، الجدول 1)
- TF32 (1:2 pattern)TF32 (نمط 1:2)
- 156 dense, 312 sparse156 كثيف، 312 متناثر
- FP16 / BF16
- 312 dense, 624 sparse312 كثيف، 624 متناثر
- INT8
- 624 dense, 1248 sparse624 كثيف، 1248 متناثر
Why must the pattern run along K? Because K is the axis the selector walks. Each output element is a dot product over K, and a zero weight at position k means the product with B[k, n] can be dropped for every n. Zeros arranged along M or N would zero entire rows or columns of the output, which is a smaller network, not a faster GEMM. This is also why the library has shape rules: the reduction dimension must be a multiple of 16 for 16-bit formats and 32 for INT8, and layers that fail the rule, such as the first convolution of an image network with K = 3 x 7 x 7 = 147, are simply left dense (Mishra et al., sections 3.2 and 5.1). cuSPARSELt exposes the compression and the sparse GEMM to programmers, and TensorRT 8 applies them automatically to a network whose weights already follow the pattern.
لماذا يجب أن يمتد النمط على طول K؟ لأن K هو المحور الذي يسير عليه المُنتقي. كل عنصر إخراج هو جداء نقطي (dot product) على K، والوزن الصفري في الموضع k يعني أن حاصل ضربه في B[k, n] يمكن إسقاطه لكل n. أما الأصفار المرتبة على طول M أو N فستصفّر صفوفًا أو أعمدة كاملة من الإخراج، وهذا يعطي شبكة أصغر لا GEMM أسرع. ولهذا أيضًا للمكتبة قواعد للأبعاد: يجب أن يكون بُعد الاختزال مضاعفًا لـ 16 في الصيغ ذات 16 بتًا ولـ 32 في INT8، والطبقات التي لا تحقق القاعدة، مثل الالتفاف (convolution) الأول في شبكة صور حيث K = 3 x 7 x 7 = 147، تُترك ببساطة كثيفة (Mishra et al., sections 3.2 and 5.1). توفّر مكتبة cuSPARSELt الضغط وGEMM المتناثرة للمبرمجين، ويطبّقهما TensorRT 8 تلقائيًا على الشبكة التي تتبع أوزانها النمط مسبقًا.
What changed since EIEما الذي تغيّر منذ EIE
Set the two designs beside each other and the trade becomes visible. EIE (Efficient Inference Engine) reaches for every zero it can find: about 90 percent in the weights and about 70 percent in the activations, both exploited at once. To do that it needs Leading non-zero detection to find the next live activation, a FIFO in front of each Processing element (PE) to keep Load balance across uneven columns, and a custom chip to hold all of it. The sparse tensor core asks for far less sparsity, exactly 50 percent in the weights alone, which is static and known before the run. That is what lets the whole mechanism collapse into a multiplexer driven by 2-bit tags, small enough to add to a tensor core that every GPU already has.
ضع التصميمين جنبًا إلى جنب وستتضح المقايضة. يسعى EIE (Efficient Inference Engine) إلى كل صفر يمكنه إيجاده: نحو 90 بالمئة في الأوزان ونحو 70 بالمئة في التنشيطات، ويستغلهما معًا. ولفعل ذلك يحتاج إلى Leading non-zero detection لإيجاد التنشيط الحي التالي، وإلى طابور FIFO أمام كل Processing element (PE) للحفاظ على Load balance عبر أعمدة غير متساوية، وإلى شريحة مخصصة تحمل كل ذلك. أما نواة الـ tensor المتناثرة فتطلب تناثرًا أقل بكثير، 50 بالمئة بالضبط في الأوزان وحدها، وهو تناثر static (ساكن) معروف قبل التشغيل. وهذا ما يسمح للآلية كلها بأن تنكمش إلى مُنتقٍ تقوده وسوم من بتين، صغير بما يكفي لإضافته إلى نواة tensor موجودة أصلًا في كل GPU.
| Aspectالجانب | EIE (ISCA 2016)EIE (ISCA 2016) | 2:4 sparse tensor core (2020)نواة tensor متناثرة بنمط 2:4 (2020) |
|---|---|---|
| Sparsity exploitedالتناثر المستغَل | Weights (about 90 percent) and activations (about 70 percent)الأوزان (نحو 90 بالمئة) والتنشيطات (نحو 70 بالمئة) | Weights only, exactly 50 percentالأوزان فقط، 50 بالمئة بالضبط |
| Weight formatصيغة الأوزان | CSC: 4-bit relative index plus 4-bit code per nonzero, column pointers, paddingCSC: فهرس نسبي من 4 بت مع رمز من 4 بت لكل قيمة غير صفرية، ومؤشرات أعمدة، وحشو | Contiguous values plus one 2-bit index per stored valueقيم متجاورة مع فهرس واحد من بتين لكل قيمة مخزنة |
| Finding workإيجاد العمل | Leading nonzero detection, activation FIFO for load balanceكشف أول قيمة غير صفرية (leading nonzero detection)، وطابور FIFO للتنشيطات لموازنة الحمل | Multiplexer driven by the 2-bit indices, no searchمُنتقٍ (multiplexer) تقوده الفهارس ذات البتين، بلا بحث |
| Hardwareالعتاد | Custom 45 nm ASIC, never soldشريحة ASIC مخصصة بتقنية 45 nm، لم تُطرح للبيع قط | Every Ampere or later GPU, cuSPARSELt and TensorRTكل GPU من جيل Ampere أو أحدث، مع cuSPARSELt وTensorRT |
| Ceiling on mathسقف تسريع الحساب | Proportional to combined sparsityيتناسب مع التناثر المجمّع | 2x, fixed by the pattern2x، يحدده النمط |
Quick checkاختبار سريع
Which statement about 2:4 sparse GEMMs on Ampere sparse tensor cores is correct?أي العبارات التالية صحيحة عن عمليات GEMM المتناثرة بنمط 2:4 على نوى tensor المتناثرة في Ampere؟
Quick checkاختبار سريع
Compared with EIE, what makes 2:4 sparsity easy to deploy on commodity hardware?مقارنةً بـ EIE، ما الذي يجعل تناثر 2:4 سهل النشر على عتاد تجاري؟
Recall
Which GEMM operand is stored sparse, which is dense, and along which dimension must the 2:4 pattern run?أي معامل في GEMM يُخزَّن متناثرًا، وأيها كثيف، وعلى طول أي بُعد يجب أن يمتد نمط 2:4؟
ResNet-50 on ImageNet scores 76.1 top-1 dense in FP16. After 2:4 pruning and retraining it scores 76.2 in FP16 and 76.2 in INT8 (Mishra et al., Table 2). Half the weights are gone from almost every layer, the GEMMs can run on the sparse path, and the accuracy did not move. The slide's takeaway is the plain version of this: pruning CNNs with 2:4 sparsity brings a large speedup for GEMM workloads and does not incur a performance drop for the models. The rest of this concept explains how that is achieved, how large the speedup really is, and where both claims stop.
تحقق ResNet-50 على ImageNet دقة top-1 قدرها 76.1 وهي كثيفة بصيغة FP16. وبعد التقليم بنمط 2:4 وإعادة التدريب تحقق 76.2 في FP16 و76.2 في INT8 (Mishra et al., Table 2). اختفى نصف الأوزان من كل الطبقات تقريبًا، وصار بإمكان عمليات GEMM أن تعمل على المسار المتناثر، ولم تتحرك الدقة. والخلاصة في الشريحة هي الصيغة المبسطة لهذا: تقليم شبكات CNN بنمط 2:4 يجلب تسريعًا كبيرًا لأحمال GEMM ولا يسبب تراجعًا في أداء النماذج. بقية هذا المفهوم تشرح كيف يتحقق ذلك، وما حجم التسريع الحقيقي، وأين يتوقف كل من الادعاءين.
The recipe: one prune, one retrain, no searchالوصفة: تقليم واحد، وإعادة تدريب واحدة، ولا بحث
The deck does not show the procedure itself, so take it from the paper (Mishra et al., section 4) and from the A100 whitepaper, which calls it a simple and universal recipe. It has three steps.
لا تعرض الشرائح الإجراء نفسه، لذا خذه من الورقة (Mishra et al., section 4) ومن الورقة البيضاء لـ A100 التي تسمّيه وصفة بسيطة وعامة. وله ثلاث خطوات.
- Train the model without sparsity, exactly as you normally would.درّب النموذج دون تناثر، تمامًا كما تفعل عادةً.
- Prune it to 2:4 by magnitude: in every group of four weights along the row, zero the two with the smallest absolute value.قلّمه إلى 2:4 بحسب المقدار (magnitude): في كل مجموعة من أربعة أوزان على طول الصف، صفّر الوزنين صاحبي أصغر قيمة مطلقة.
- Retrain from those weights using the same optimizer, learning-rate schedule and number of epochs as step 1, with the zeros held fixed so the pattern survives. Optimizer state such as momentum is reset.أعد التدريب انطلاقًا من تلك الأوزان باستخدام المُحسِّن (optimizer) نفسه وجدول معدل التعلم نفسه وعدد الحقب (epochs) نفسه كما في الخطوة 1، مع تثبيت الأصفار كي يبقى النمط. وتُعاد حالة المُحسِّن، مثل الزخم (momentum)، إلى البداية.
Two things distinguish this from the Fine-tuning and Iterative pruning you met earlier in this lecture. It is one-shot: a single prune straight to the target, then a full second training run rather than a short low-learning-rate touch-up. And it needs no hyper-parameter search, because step 3 reuses step 1 wholesale. The paper is candid about the cost, a second full training, and argues it is worth paying once for a workflow with nothing to tune, since deployment amortizes it. NVIDIA packages the procedure as the ASP library for PyTorch.
أمران يميّزان هذا عن Fine-tuning وIterative pruning اللذين قابلتهما سابقًا في هذه المحاضرة. فهو أحادي الخطوة (one-shot): تقليم واحد مباشرة إلى الهدف، ثم جولة تدريب ثانية كاملة بدلًا من تحسين قصير بمعدل تعلم منخفض. ولا يحتاج إلى أي بحث عن المعاملات الفائقة، لأن الخطوة 3 تعيد استخدام الخطوة 1 بالكامل. والورقة صريحة بشأن الكلفة، وهي تدريب كامل ثانٍ، وترى أنها تستحق أن تُدفع مرة واحدة مقابل سير عمل لا شيء فيه يحتاج إلى ضبط، لأن النشر يوزّع هذه الكلفة على المدى. وتحزم NVIDIA هذا الإجراء في مكتبة ASP لـ PyTorch.
How much faster: a staircase toward 2xكم أسرع: درج يصعد نحو 2x
The chart on the slide compares INT8 GEMMs from cuSPARSELt, with one operand in 2:4 form, against dense cuBLAS GEMMs on an A100, at M = N = 10240 and K sweeping from 1280 to 20480. The bars start near 1.2x and climb toward 2x without reaching it. Mishra et al. read it the same way: larger GEMMs achieve nearly a 2x speedup with sparse tensor cores.
يقارن المخطط في الشريحة عمليات GEMM بـ INT8 من cuSPARSELt، حيث أحد المعاملين بصيغة 2:4، مع عمليات GEMM كثيفة من cuBLAS على A100، عند M = N = 10240 وK يتدرج من 1280 إلى 20480. تبدأ الأعمدة قرب 1.2x وتصعد نحو 2x دون أن تبلغه. ويقرأ Mishra وزملاؤه المخطط بالطريقة نفسها: عمليات GEMM الأكبر تحقق تسريعًا يقارب 2x باستخدام sparse tensor cores.
| GEMM-KGEMM-K | Speedupالتسريع |
|---|---|
| 12801280 | about 1.2xنحو 1.2x |
| 25602560 | about 1.5xنحو 1.5x |
| 38403840 | about 1.7xنحو 1.7x |
| 76807680 | about 1.8xنحو 1.8x |
| 1280012800 | about 1.9xنحو 1.9x |
| 2048020480 | about 1.95xنحو 1.95x |
Why does the speedup depend on K at all, when the pattern halves the multiplies at every size? Because the sparse tensor core halves only the arithmetic. A GEMM also has to move its operands in and its result out, and it pays fixed launch and scheduling costs. A small GEMM has low arithmetic intensity: few operations per byte moved, so its time is dominated by memory traffic and overheads that 2:4 does not touch. As K grows, the operations per output element grow while the output traffic does not, the GEMM becomes math bound, and halving the math approaches halving the time. The paper says exactly this: larger GEMMs tend to have higher arithmetic intensity, so they get closer to the 2x speedup.
لماذا يعتمد التسريع على K أصلًا، في حين أن النمط يقلّص عمليات الضرب إلى النصف عند كل حجم؟ لأن نواة الـ tensor المتناثرة لا تقلّص إلا العمليات الحسابية. فعملية GEMM يجب أيضًا أن تنقل معاملاتها إلى الداخل ونتيجتها إلى الخارج، وتدفع كلفة ثابتة للإطلاق والجدولة. لعملية GEMM الصغيرة arithmetic intensity (شدة حسابية) منخفضة: عمليات قليلة لكل بايت منقول، فيهيمن على زمنها نقل البيانات من الذاكرة والكلفة الإضافية التي لا يمسّها 2:4. ومع نمو K تزداد العمليات لكل عنصر إخراج بينما لا يزداد نقل الإخراج، فتصبح GEMM محكومة بالحساب (math bound)، ويقترب تقليص الحساب إلى النصف من تقليص الزمن إلى النصف. والورقة تقول هذا بالضبط: عمليات GEMM الأكبر تميل إلى شدة حسابية أعلى، لذا تقترب أكثر من تسريع 2x.
Worked exampleمثال محلول
From GEMM speedup to model speedup with Amdahlمن تسريع GEMM إلى تسريع النموذج باستخدام قانون Amdahl
Name the fraction that improvesحدّد الجزء الذي يتحسن
Suppose GEMMs take 70% of inference time (f = 0.7) and the sparse path makes them 1.8x faster (k = 1.8), a typical large-K reading from the chart.افترض أن عمليات GEMM تستغرق 70% من زمن الاستدلال (f = 0.7) وأن المسار المتناثر يجعلها أسرع بمقدار 1.8x (k = 1.8)، وهي قراءة نموذجية من المخطط عند K كبير.Apply Amdahl's lawطبّق قانون Amdahl
S = 1 / ((1 - 0.7) + 0.7 / 1.8) = 1 / (0.3 + 0.389) = 1 / 0.689.S = 1 / ((1 - 0.7) + 0.7 / 1.8) = 1 / (0.3 + 0.389) = 1 / 0.689.Repeat for a small-K layerكرّر الحساب لطبقة ذات K صغير
With k = 1.2 the GEMM term is 0.7 / 1.2 = 0.583, so S = 1 / 0.883 = 1.13x.مع k = 1.2 يصبح حدّ GEMM هو 0.7 / 1.2 = 0.583، إذن S = 1 / 0.883 = 1.13x.Resultالنتيجة
About 1.45x end to end at 1.8x on the GEMMs, and only 1.13x when the GEMMs are small. The pattern is doing its job on the math either way; the rest of the network decides what the user sees.نحو 1.45x على مستوى النموذج كاملًا عند 1.8x في عمليات GEMM، و1.13x فقط حين تكون عمليات GEMM صغيرة. النمط يؤدي عمله في الحساب في الحالتين؛ أما بقية الشبكة فهي التي تحدد ما يراه المستخدم.
Accuracy: the table that justifies the claimالدقة: الجدول الذي يبرر الادعاء
The right half of the slide is the paper's Table 2: twenty ImageNet classifiers, each in dense FP16, sparse FP16 and sparse INT8. Read down any row and the three numbers agree to within a few tenths of a point; the widest spread is SUNet-128 at 75.6, 76.0 and 75.4. The paper states that the differences are within run-to-run variation, which is the honest way to say zero loss.
النصف الأيمن من الشريحة هو الجدول 2 في الورقة: عشرون مصنِّفًا على ImageNet، كل منها بصيغة FP16 كثيفة وFP16 متناثرة وINT8 متناثرة. اقرأ أي صف وستجد الأرقام الثلاثة متفقة في حدود بضعة أعشار النقطة؛ وأوسع فارق هو SUNet-128 عند 75.6 و76.0 و75.4. وتنص الورقة على أن الفروق تقع ضمن التفاوت بين التشغيلات (run-to-run variation)، وهذه هي الطريقة الأمينة لقول: لا خسارة.
| Networkالشبكة | Dense FP16FP16 كثيف | Sparse FP16FP16 متناثر | Sparse INT8INT8 متناثر |
|---|---|---|---|
| ResNet-34ResNet-34 | 73.773.7 | 73.973.9 | 73.773.7 |
| ResNet-50ResNet-50 | 76.176.1 | 76.276.2 | 76.276.2 |
| ResNet-101ResNet-101 | 77.777.7 | 78.078.0 | 77.977.9 |
| ResNeXt-101-32x16 (WSL)ResNeXt-101-32x16 (WSL) | 84.284.2 | 84.084.0 | 84.284.2 |
| DenseNet-121DenseNet-121 | 75.575.5 | 75.375.3 | 75.375.3 |
| Inception v3Inception v3 | 77.177.1 | 77.177.1 | 77.177.1 |
| VGG-16VGG-16 | 74.074.0 | 74.174.1 | 74.174.1 |
| DRN-105DRN-105 | 79.479.4 | 79.579.5 | 79.479.4 |
Two details in that table repay attention. Sparse INT8 matches sparse FP16, so the pruning and INT8 quantization, which this course turns to after pruning, compose without compounding their losses, at least on these networks. And the largest model, ResNeXt-101-32x16 trained with weak supervision, loses 0.2 in FP16 and nothing in INT8, so the pattern is not exploiting a weakness of small or old architectures. VGG, DenseNet, Inception, Xception and the dilated residual networks all behave the same way.
تفصيلان في ذلك الجدول يستحقان الانتباه. أولًا، INT8 المتناثر يطابق FP16 المتناثر، أي أن التقليم والتكميم (quantization) إلى INT8، الذي ينتقل إليه هذا المقرر بعد التقليم، يجتمعان دون أن تتراكم خسائرهما، على الأقل في هذه الشبكات. وثانيًا، أكبر نموذج، ResNeXt-101-32x16 المدرَّب بإشراف ضعيف (weak supervision)، يخسر 0.2 في FP16 ولا شيء في INT8، فالنمط لا يستغل نقطة ضعف في المعماريات الصغيرة أو القديمة. وتتصرف VGG وDenseNet وInception وXception والشبكات المتبقية الموسَّعة (dilated residual networks) كلها بالطريقة نفسها.
| Networkالشبكة | Denseكثيف | 2:4, plain recipe2:4، الوصفة العادية | 2:4 with permutation2:4 مع تبديل الترتيب |
|---|---|---|---|
| MobileNet v2MobileNet v2 | 71.5571.55 | 69.5669.56 | 71.5671.56 |
| EfficientNet B0EfficientNet B0 | 77.2577.25 | 75.9875.98 | 77.2977.29 |
Quick checkاختبار سريع
On the A100 chart, why does the sparse versus dense INT8 GEMM speedup climb toward 2x only as GEMM-K grows?في مخطط A100، لماذا لا يقترب تسريع GEMM بـ INT8 المتناثر مقابل الكثيف من 2x إلا مع ازدياد GEMM-K؟
Recall
State the three steps of NVIDIA's 2:4 recipe and the one hyper-parameter search it needs.اذكر الخطوات الثلاث لوصفة 2:4 من NVIDIA، وبحث المعاملات الفائقة الوحيد الذي تحتاجه.
Recall
Why is the INT8 speedup only about 1.2x at K = 1280 but about 1.95x at K = 20480?لماذا يكون تسريع INT8 نحو 1.2x فقط عند K = 1280 لكنه نحو 1.95x عند K = 20480؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- 2:4 keeps at most two nonzeros in every four consecutive weights along a row: 50 percent sparsity, fine-grained in what it removes, structured in how many it removes.يُبقي نمط 2:4 على قيمتين غير صفريتين على الأكثر في كل أربعة أوزان متتالية على طول الصف: تناثر بنسبة 50 بالمئة، دقيق الحبيبات في ما يحذفه، وبنيوي في عدد ما يحذفه.
- Compressed W = R x C/2 values plus R x C/2 two-bit indices. Per group of four, 64 bits become 36 (FP16, about 44 percent saving) and 32 become 20 (INT8, about 38 percent).المصفوفة W المضغوطة = R x C/2 من القيم مع R x C/2 من الفهارس ذات البتين. في كل مجموعة من أربعة، تصبح 64 بت 36 بت (FP16، توفير نحو 44 بالمئة) وتصبح 32 بت 20 بت (INT8، توفير نحو 38 بالمئة).
- The pattern runs along GEMM-K. The sparse tensor core uses the indices to pick K/2 matching elements of the dense B operand, so only half the multiplies run.يمتد النمط على طول البعد K في GEMM. تستخدم نواة الـ tensor المتناثرة الفهارس لاختيار K/2 من العناصر المقابلة في المعامل الكثيف B، فلا يُنفَّذ إلا نصف عمليات الضرب.
- Peak A100 throughput doubles: FP16 312 to 624 TOPS, INT8 624 to 1248 TOPS.تتضاعف الإنتاجية القصوى لـ A100: في FP16 من 312 إلى 624 TOPS، وفي INT8 من 624 إلى 1248 TOPS.
- Recipe: train dense, prune the two smallest of every four, retrain with the identical schedule keeping the zeros fixed. No hyper-parameter search.الوصفة: درّب النموذج كثيفًا، ثم احذف أصغر وزنين في كل أربعة، ثم أعد التدريب بالجدول نفسه تمامًا مع تثبيت الأصفار. لا حاجة إلى بحث عن المعاملات الفائقة.
- Sparse FP16 and INT8 match dense FP16 within run-to-run noise on 20 ImageNet CNNs (ResNet-50 76.1 versus 76.2). Small nets like MobileNet v2 need channel permutation to recover.يطابق FP16 وINT8 المتناثران نموذج FP16 الكثيف ضمن حدود التفاوت بين التشغيلات على 20 شبكة CNN على ImageNet (ResNet-50: 76.1 مقابل 76.2). الشبكات الصغيرة مثل MobileNet v2 تحتاج إلى تبديل ترتيب القنوات (channel permutation) لاستعادة دقتها.
- INT8 GEMM speedup rises from about 1.2x at K = 1280 to about 1.95x at K = 20480. The 2x caps the math only; end-to-end gains are smaller (about 1.2x for ResNeXt-101 in NVIDIA's blog).يرتفع تسريع GEMM بـ INT8 من نحو 1.2x عند K = 1280 إلى نحو 1.95x عند K = 20480. سقف 2x يخص الحساب الرياضي فقط؛ أما المكاسب الكاملة فأصغر (نحو 1.2x لـ ResNeXt-101 في مدونة NVIDIA).
- Versus EIE: a fixed pattern and 2-bit tags on a commodity GPU instead of per-value indices, load balancing and a custom ASIC.مقارنةً بـ EIE: نمط ثابت ووسوم من بتين على GPU تجاري، بدلًا من فهرس لكل قيمة وموازنة حمل وشريحة ASIC مخصصة.
Sourcesالمصادر
- Accelerating Sparse Deep Neural NetworksPaperMishra, Albericio Latorre, Pool, Stosic, Stosic, Venkatesh, Yu and Micikevicius, arXiv 20212:4 definition and Fig. 1 format, 36 versus 64 bits, Fig. 2 mapping onto tensor cores, Table 1 TOPS, Fig. 3 speedups, Section 4 recipe, Table 2 accuracy, Table 3 permutation.تعريف 2:4 وصيغة الشكل 1، و36 مقابل 64 بت، والشكل 2 لتوزيع العمل على نوى tensor، والجدول 1 لقيم TOPS، والشكل 3 للتسريع، والقسم 4 للوصفة، والجدول 2 للدقة، والجدول 3 لتبديل الترتيب.(opens in a new tab)(يفتح في تبويب جديد)
- Accelerating Inference with Sparsity Using the NVIDIA Ampere Architecture and NVIDIA TensorRTArticleNVIDIA Technical BlogThree-step recipe, pulling only the necessary values from the uncompressed operand, 1248 versus 624 INT8 TOPS, ResNeXt-101_32x8d up to 20 percent end to end and 36 percent performance per watt.الوصفة ذات الخطوات الثلاث، وسحب القيم اللازمة فقط من المعامل غير المضغوط، و1248 مقابل 624 TOPS بـ INT8، وتسريع ResNeXt-101_32x8d حتى 20 بالمئة على المستوى الكامل (end to end) وتحسّن 36 بالمئة في الأداء لكل واط.(opens in a new tab)(يفتح في تبويب جديد)
- NVIDIA Ampere Architecture In-DepthArticleNVIDIA Technical BlogFine-grained structured sparsity, two nonzero values in every four-entry vector, almost 2x memory reduction and doubled tensor core throughput.التناثر البنيوي دقيق الحبيبات، وقيمتان غير صفريتين في كل متجه من أربعة عناصر، وتقليل الذاكرة بما يقارب 2x، ومضاعفة إنتاجية نوى tensor.(opens in a new tab)(يفتح في تبويب جديد)
- NVIDIA A100 Tensor Core GPU Architecture whitepaperDocsNVIDIASparse MMA on a 16 x 8 x 16 tile in N/2 cycles, 2:4 structured sparsity on rows, the simple and universal recipe.عملية MMA متناثرة على بلاطة 16 x 8 x 16 في N/2 دورة، وتناثر بنيوي 2:4 على الصفوف، والوصفة البسيطة والعامة.(opens in a new tab)(يفتح في تبويب جديد)
- cuSPARSELt documentationDocsNVIDIALibrary for GEMMs where one operand is 50 percent structured sparse; FP16, BF16, INT8 and TF32 on SM 8.0 and later, FP8 from SM 9.0.مكتبة لعمليات GEMM التي يكون فيها أحد المعاملين متناثرًا بنيويًا بنسبة 50 بالمئة؛ تدعم FP16 وBF16 وINT8 وTF32 على SM 8.0 وما بعده، وFP8 بدءًا من SM 9.0.(opens in a new tab)(يفتح في تبويب جديد)
- EIE: Efficient Inference Engine on Compressed Deep Neural NetworkPaperHan, Liu, Mao, Pu, Pedram, Horowitz and Dally, ISCA 2016CSC with 4-bit relative index and 4-bit weight-sharing code, activation queue for load balance, custom 45 nm ASIC, used for the contrast.صيغة CSC بفهرس نسبي من 4 بت ورمز مشاركة أوزان من 4 بت، وطابور تنشيطات لموازنة الحمل، وشريحة ASIC مخصصة بتقنية 45 nm، واستُخدم للمقارنة.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2024, Lecture 4: Pruning and Sparsity (Part II)DocsMIT HAN LabThe course these slides follow.المقرر الذي تتبعه هذه الشرائح.(opens in a new tab)(يفتح في تبويب جديد)
- Validity of the Single Processor Approach to Achieving Large Scale Computing CapabilitiesPaperAFIPS Conference Proceedings, Vol. 30, 1967The argument behind the end-to-end speedup worked example.الحجة التي يقوم عليها المثال المحلول عن التسريع الكامل (end to end).(opens in a new tab)(يفتح في تبويب جديد)
Part 11: Sparse inputs and sparse convolutionالمدخلات المتناثرة والالتفاف المتناثر
Point clouds are mostly empty space, so convolution should compute only where inputs exist: sparse convolution keeps output sparsity equal to input sparsity and is a sparse set of dense matrix multiplies driven by an input, output and weight map.سحب النقاط (point clouds) في معظمها فضاء فارغ، لذا يجب أن يحسب الالتفاف فقط حيث توجد مدخلات: الالتفاف المتناثر يُبقي تناثر المخرج مساويًا لتناثر المدخل، وهو مجموعة متناثرة من عمليات ضرب مصفوفات كثيفة تقودها خريطة للمدخل والمخرج والوزن.
3 concepts3 مفاهيم, ، slides 84-96الشرائح 84-96
Why this part mattersلماذا يهمّ هذا الجزء
The sparsity in this part is not something you create by pruning or by passing activations through ReLU. It is handed to you by the physical world. A LiDAR scanner on a car returns a few hundred thousand points inside a volume of billions of voxels, and the winning entries on SemanticKITTI, nuScenes and Waymo all process those points with sparse convolution (Tang et al., 2022). If your research project puts 3D perception on an embedded board, this is the operator you will be optimizing.
The part has one story with three turns. First, why an ordinary convolution is the wrong tool for a point cloud: it dilates the empty space into a dense blur within a few layers. Second, the fix, which computes outputs only where inputs exist, and the small bookkeeping structure that describes exactly which multiplications remain. Third, how a GPU actually runs that bookkeeping as a handful of dense matrix multiplies, which is where parts 12 and 13 pick up with TorchSparse and PointAcc. Every idea rests on one list of tuples, so by the end you should be able to write that list for a small grid by hand.
التناثر (sparsity) في هذا الجزء ليس شيئًا تصنعه بالتقليم (pruning) أو بتمرير التفعيلات عبر ReLU، بل يقدّمه لك العالم الفيزيائي جاهزًا. ماسح LiDAR على سيارة يُرجع بضع مئات الآلاف من النقاط داخل حجم يضم مليارات الـ voxels، وكل الحلول الفائزة على SemanticKITTI وnuScenes وWaymo تعالج هذه النقاط بالالتفاف المتناثر (sparse convolution) (Tang et al., 2022). إذا كان مشروعك البحثي يضع الإدراك ثلاثي الأبعاد (3D perception) على لوحة مدمجة (embedded board)، فهذا هو المعامل (operator) الذي ستعمل على تحسينه.
للجزء قصة واحدة بثلاث محطات. أولًا: لماذا يكون الالتفاف العادي أداة خاطئة للسحابة النقطية (point cloud)، فهو يمدد الفراغ الفارغ ويحوّله إلى ضبابية كثيفة خلال بضع طبقات. ثانيًا: الحل، وهو حساب المخرجات فقط حيث توجد مدخلات، مع بنية محاسبية صغيرة تصف بالضبط عمليات الضرب التي تبقى. ثالثًا: كيف تنفّذ الـ GPU فعليًا هذه البنية على شكل عدد قليل من عمليات ضرب المصفوفات الكثيفة، وهنا يكمل الجزآن 12 و13 مع TorchSparse وPointAcc. كل فكرة تقوم على قائمة واحدة من الثلاثيات (tuples)، لذلك يُفترض أن تستطيع في النهاية كتابة هذه القائمة يدويًا لشبكة صغيرة.
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain the submanifold dilation problem with the 1, then 3^d, then 5^d rule and the 17-of-20 example from the slides.اشرح مشكلة تمدد الـ submanifold (submanifold dilation) بقاعدة 1 ثم 3^d ثم 5^d، ومثال 17 من 20 خلية في الشرائح.
- Define submanifold sparse convolution and state why the output point set equals the input point set.عرّف الالتفاف المتناثر على الـ submanifold (submanifold sparse convolution) ووضّح لماذا تساوي مجموعة نقاط المخرج مجموعة نقاط المدخل.
- Write the update rule f_out = f_out + f_in x W_(dx,dy) and build the (In, Out, Wgt) map for a small grid by hand.اكتب قاعدة التحديث f_out = f_out + f_in x W_(dx,dy) وابنِ الخريطة (In, Out, Wgt) لشبكة صغيرة يدويًا.
- Group a map by weight offset and cost the resulting gather, matmul, scatter pipeline in MACs.جمّع الخريطة حسب إزاحة الوزن (weight offset) واحسب كلفة خط المعالجة الناتج، أي gather ثم matmul ثم scatter، بعدد عمليات MAC.
- Distinguish point-cloud sparsity from ReLU activation sparsity and from pruned weight sparsity.ميّز بين تناثر السحابة النقطية (point cloud) وتناثر التفعيلات الناتج عن ReLU وتناثر الأوزان الناتج عن التقليم (pruning).
Start with a number. Voxelize an outdoor LiDAR frame into a regular 3D grid and count how many cells hold at least one point. PointAcc (Lin et al., MICRO 2021) reports that outdoor point clouds usually have a density below 0.01 percent, while a conventional CNN takes in a 100 percent dense image. That is the ~0.01% written above the sparse column of the slide. Indoor scans and single objects sit below 1 percent. Even after ReLU, an ImageNet network still keeps about half of its activations nonzero, so an image is up to four orders of magnitude denser than a LiDAR scan.
ابدأ برقم. حوّل إطار LiDAR خارجيًا إلى شبكة 3D منتظمة من الـ voxels، وعُدّ كم خلية تحتوي على نقطة واحدة على الأقل. تذكر PointAcc (Lin et al., MICRO 2021) أن كثافة السحب النقطية الخارجية عادةً أقل من 0.01 percent، بينما تستقبل الـ CNN التقليدية صورة كثيفة بنسبة 100 percent. هذه هي قيمة ~0.01% المكتوبة فوق عمود الـ sparse في الشريحة. أما المسوح الداخلية والأجسام المفردة فكثافتها أقل من 1 percent. وحتى بعد ReLU، تبقي شبكة ImageNet نحو نصف تفعيلاتها غير صفرية، لذلك قد تكون الصورة أكثف من مسح LiDAR بما يصل إلى أربع رتب عشرية (orders of magnitude).
How dense the input really is (Lin et al., 2021)ما مدى كثافة المدخل فعلًا (Lin et al., 2021)
- ImageNet image at the inputصورة ImageNet عند المدخل
- 100 percent of pixels carry a valueكل البكسلات تحمل قيمة، أي 100 بالمئة
- Same network after ReLUالشبكة نفسها بعد ReLU
- about 50 percent nonzero on averageنحو 50 بالمئة غير صفرية في المتوسط
- Indoor scene or single object, voxelizedمشهد داخلي أو جسم مفرد بعد تحويله إلى voxels
- below 1 percent of voxels occupiedأقل من 1 بالمئة من الـ voxels مشغولة
- Outdoor LiDAR frame, voxelizedإطار LiDAR خارجي بعد تحويله إلى voxels
- below 0.01 percent of voxels occupiedأقل من 0.01 بالمئة من الـ voxels مشغولة
The roadmap places this under activation sparsity, next to EIE and the M:N tensor cores, and that is correct as far as it goes: the zeros are in the data, not the weights. But the source is different in a way that changes everything downstream. ReLU zeros and pruned weight zeros land wherever the arithmetic puts them. Point-cloud zeros are the empty air between surfaces. PointAcc calls this sparsity "fundamentally different" because "the sparsity pattern is constrained by the physical objects in the real world", and draws the consequence that matters here: the nonzero points should never dilate during computation. In the vocabulary of part 07 it is still dynamic, since every frame has a new pattern, but it is a pattern with geometric meaning.
تضع خريطة الطريق هذا الموضوع تحت activation sparsity، بجانب EIE وأنوية الـ tensor من نوع M:N، وهذا صحيح إلى حد ما: الأصفار موجودة في البيانات لا في الأوزان. لكن مصدرها مختلف بطريقة تغيّر كل ما يأتي بعدها. أصفار ReLU وأصفار الأوزان المقلّمة (weight) تقع حيثما تضعها العمليات الحسابية، أما أصفار السحابة النقطية فهي الهواء الفارغ بين الأسطح. تصف PointAcc هذا التناثر بأنه "مختلف جوهريًا" (fundamentally different) لأن "نمط التناثر مقيّد بالأجسام الفيزيائية في العالم الحقيقي"، وتستنتج النتيجة المهمة هنا: يجب ألا تتمدد النقاط غير الصفرية أبدًا أثناء الحساب. وبمصطلحات الجزء 07 يبقى هذا التناثر dynamic، لأن لكل إطار نمطًا جديدًا، لكنه نمط له معنى هندسي.
What a dense convolution does to empty spaceماذا يفعل الالتفاف الكثيف بالفراغ
Now apply an ordinary 3 x 3 convolution to a grid with a single active cell. The kernel window touches that cell from nine different positions, so nine outputs become nonzero. Apply a second layer and the nine become twenty-five. Graham, Engelcke and van der Maaten (CVPR 2018) state the rule in d dimensions: a single active site becomes 3^d active sites after one convolution and 5^d after two. In 3D that is 1, then 27, then 125. They name it the submanifold dilation problem, because a surface (a 2D submanifold in 3D space) thickens into a slab and the sparsity that made the input cheap is gone within a few layers.
الآن طبّق التفافًا عاديًا بحجم 3 x 3 على شبكة فيها خلية نشطة واحدة. نافذة النواة تلمس تلك الخلية من تسعة مواقع مختلفة، لذلك تصبح تسعة مخرجات غير صفرية. طبّق طبقة ثانية فتصبح التسعة خمسًا وعشرين. يصوغ Graham وEngelcke وvan der Maaten (CVPR 2018) القاعدة في d أبعاد: موقع نشط واحد يصبح 3^d مواقع نشطة بعد التفاف واحد، و5^d بعد التفافين. في 3D يعني ذلك 1 ثم 27 ثم 125. ويسمّونها submanifold dilation problem (مشكلة تمدد الـ submanifold)، لأن السطح (وهو submanifold ثنائي الأبعاد داخل فضاء ثلاثي الأبعاد) يتضخم إلى لوح سميك، ويختفي خلال بضع طبقات التناثر الذي جعل المدخل رخيصًا.
The slide shows the same effect on a small grid you can check by eye. The input is 4 rows by 5 columns with four active cells at rows and columns (1, 1), (2, 2), (2, 4) and (3, 3). Each active cell activates every output its 3 x 3 window touches, clipped to the grid: nine for the first two points, six each for the two that sit against an edge. The union of those windows is 17 of 20 cells, exactly the orange region drawn on the conventional side. Only (0, 3), (0, 4) and (3, 0) stay empty, and a second layer would fill those too.
تعرض الشريحة الأثر نفسه على شبكة صغيرة يمكنك التحقق منها بالنظر. المدخل 4 صفوف في 5 أعمدة، وفيه أربع خلايا نشطة عند (الصف، العمود) (1, 1) و(2, 2) و(2, 4) و(3, 3). كل خلية نشطة تنشّط كل مخرج تلمسه نافذتها 3 x 3، مع قصّ ما يخرج عن حدود الشبكة: تسعة لكل من النقطتين الأوليين، وستة لكل من النقطتين الملاصقتين للحافة. اتحاد هذه النوافذ هو 17 خلية من 20، وهي بالضبط المنطقة البرتقالية المرسومة في الجانب التقليدي (conventional). لا يبقى فارغًا إلا (0, 3) و(0, 4) و(3, 0)، وطبقة ثانية ستملؤها أيضًا.
| Stageالمرحلة | Active cellsالخلايا النشطة | Densityالكثافة | Whyالسبب |
|---|---|---|---|
| Inputالمدخل | 4 of 204 of 20 | 20 percent20 percent | The four teal cellsالخلايا الأربع ذات اللون الأخضر المزرق |
| After one dense 3 by 3 layerبعد طبقة كثيفة واحدة 3 في 3 | 17 of 2017 of 20 | 85 percent85 percent | Union of the four 3 by 3 windows, clipped to the gridاتحاد النوافذ الأربع بحجم 3 في 3، مقصوصًا عند حدود الشبكة |
| After one submanifold 3 by 3 layerبعد طبقة submanifold واحدة 3 في 3 | 4 of 204 of 20 | 20 percent20 percent | Only the four input positionsمواقع المدخل الأربعة فقط |
| After a second dense layerبعد طبقة كثيفة ثانية | 20 of 2020 of 20 | 100 percent100 percent | Every cell now sits within one step of an active cellكل خلية أصبحت الآن على بعد خطوة واحدة من خلية نشطة |
The fix: compute only where an input existsالحل: احسب فقط حيث يوجد مدخل
Sparse convolution, in the submanifold form the deck uses, changes one rule. An output site is computed if and only if the input site at the same coordinate is active. Graham et al. define it exactly that way: the filter size is odd, the input is padded so the output keeps the input's size, and an output is active only when the central site of its receptive field is active. TorchSparse writes the same fact as a set equation, P_in = P_out, against the dense case where P_in is only a subset of P_out. On the slide grid the sparse side stays at four orange cells, and after a hundred layers it would still be four.
الالتفاف المتناثر (Sparse convolution)، بصيغة الـ submanifold التي تستخدمها الشرائح، يغيّر قاعدة واحدة: يُحسب موقع المخرج إذا وفقط إذا كان موقع المدخل عند الإحداثي نفسه نشطًا. هكذا يعرّفه Graham et al. تمامًا: حجم المرشح (filter) فردي، ويُحشى المدخل (padding) بحيث يحافظ المخرج على حجم المدخل، ولا يكون المخرج نشطًا إلا إذا كان الموقع المركزي في مجال استقباله (receptive field) نشطًا. وتكتب TorchSparse الحقيقة نفسها كمعادلة مجموعات، P_in = P_out، مقابل الحالة الكثيفة حيث P_in مجرد مجموعة جزئية من P_out. على شبكة الشريحة يبقى الجانب المتناثر عند أربع خلايا برتقالية، وبعد مئة طبقة سيبقى أربعًا.
The pair of ring images at the bottom of the slide comes from two different figures of the Graham papers. The left ring is Figure 2 of the CVPR 2018 paper (Figure 1 of the 2017 arXiv version): a thin curve pushed through two ordinary 3 x 3 convolutions has smeared into a grey band. The right ring is Figure 3 of the CVPR 2018 paper: the submanifold receptive field centred on one active site, drawn in green, with the empty sites it ignores in red, so the ring stays a ring. That is the whole motivation in one picture: the operator must respect the geometry, or the geometry disappears.
صورتا الحلقة أسفل الشريحة مأخوذتان من شكلين مختلفين في أوراق Graham. الحلقة اليسرى هي الشكل 2 في ورقة CVPR 2018 (الشكل 1 في نسخة arXiv لعام 2017): منحنى رفيع مرّ عبر التفافين عاديين بحجم 3 x 3 فتلطّخ وأصبح شريطًا رماديًا. والحلقة اليمنى هي الشكل 3 في ورقة CVPR 2018: مجال الاستقبال في الـ submanifold متمركزًا على موقع نشط واحد، مرسومًا بالأخضر، والمواقع الفارغة التي يتجاهلها بالأحمر، فتبقى الحلقة حلقة. هذا هو الدافع كله في صورة واحدة: يجب أن يحترم المعامل الهندسة، وإلا اختفت الهندسة.
Why a whole part on one operator? TorchSparse's introduction lists the stakes. All top five segmentation submissions on SemanticKITTI and nine of the top ten on nuScenes are built on sparse convolution, yet the operator is not supported by TensorRT or TVM, and the best library of the day ran MinkowskiNet at 8 FPS on a GTX 1080Ti, a desktop GPU far above anything on an embedded board. The gap between what the algorithm avoids and what the hardware delivers is the research territory of parts 12 and 13.
لماذا جزء كامل لمعامل واحد؟ مقدمة TorchSparse تسرد ما على المحك. كل الحلول الخمسة الأولى في التقسيم الدلالي (segmentation) على SemanticKITTI، وتسعة من العشرة الأولى على nuScenes، مبنية على الالتفاف المتناثر، ومع ذلك لا يدعم TensorRT ولا TVM هذا المعامل، وأفضل مكتبة في وقتها شغّلت MinkowskiNet بسرعة 8 FPS على GTX 1080Ti، وهي GPU مكتبية أقوى بكثير من أي شيء على لوحة مدمجة. الفجوة بين ما تتجنبه الخوارزمية وما يقدمه العتاد هي الميدان البحثي للجزأين 12 و13.
Recall
Why is the output of a submanifold sparse convolution exactly as sparse as its input, and what happens to one active site under two dense 3 by 3 layers instead?لماذا يكون مخرج الالتفاف المتناثر على الـ submanifold متناثرًا تمامًا بقدر مدخله، وماذا يحدث لموقع نشط واحد إذا مر بدلًا من ذلك عبر طبقتين كثيفتين بحجم 3 في 3؟
Quick checkاختبار سريع
A 3 by 3 submanifold sparse convolution runs over four active cells of a 4 by 5 grid. How many output cells are nonzero?يعمل التفاف متناثر على الـ submanifold بحجم 3 في 3 على أربع خلايا نشطة في شبكة 4 في 5. كم خلية مخرج غير صفرية؟
Follow the boxed point P0 at row 1, column 1 through a 3 x 3 convolution. A 3 x 3 kernel is not one weight; it is nine weight matrices, one per tap, each of shape C_in x C_out. TorchSparse writes them as W_δ for each offset δ in {-1, 0, 1}^2. The deck names them W_(dx,dy), with dx the row offset and dy the column offset, and the visual and simulator below use the same labels. Every time P0 lands in an output's window, exactly one of those nine matrices multiplies its feature vector, and which one depends only on where the output sits relative to P0.
تتبّع النقطة المؤطّرة P0 في الصف 1 والعمود 1 عبر التفاف 3 x 3. النواة 3 x 3 ليست وزنًا واحدًا، بل تسع مصفوفات أوزان، واحدة لكل نقرة (tap)، وشكل كل منها C_in x C_out. تكتبها TorchSparse على شكل W_δ لكل إزاحة δ في {-1, 0, 1}^2. وتسميها الشرائح W_(dx,dy)، حيث dx إزاحة الصف وdy إزاحة العمود، والرسم والمحاكي أدناه يستخدمان التسميات نفسها. كلما وقعت P0 داخل نافذة أحد المخرجات، تضرب مصفوفة واحدة فقط من هذه المصفوفات التسع متجه خصائصها (feature vector)، وأيّ مصفوفة منها يعتمد فقط على موقع المخرج بالنسبة إلى P0.
The deck's convention, consistent across all nine slides, is that the input P sits at the output Q shifted by the offset: P = Q + (dx, dy) in (row, column). The first entry on the slide makes it concrete. Output Q0 is the top-left corner of P0's window at (0, 0), so P0 = Q0 + (1, 1) and the weight is W_(1,1). The centre entry, where Q4 is P0's own position, uses W_(0,0). The bottom-right corner at (2, 2) uses W_(-1,-1).
الاصطلاح في الشرائح، وهو ثابت عبر الشرائح التسع كلها، أن المدخل P يقع عند المخرج Q مزاحًا بمقدار الإزاحة: P = Q + (dx, dy) بترتيب (الصف، العمود). المدخل الأول في الشريحة يوضح ذلك. المخرج Q0 هو الزاوية العلوية اليسرى من نافذة P0 عند (0, 0)، لذلك P0 = Q0 + (1, 1) والوزن هو W_(1,1). والمدخل المركزي، حيث Q4 هو موقع P0 نفسه، يستخدم W_(0,0). والزاوية السفلية اليمنى عند (2, 2) تستخدم W_(-1,-1).
The map is the computationالخريطة هي الحساب
Each such relation is one tuple, and the list of all of them is what the slides call the maps, written (In, Out, Wgt). TorchSparse defines the map for a layer as the set M = {(p_j, q_k, W_δ)} and describes the whole layer as one loop: iterate over the map and, for each entry, accumulate the input feature vector times the entry's weight matrix into the output feature vector. That is the update rule printed at the bottom-left of every slide in this run.
كل علاقة من هذا النوع ثلاثية واحدة (tuple)، وقائمتها كاملة هي ما تسميه الشرائح الخرائط (maps)، وتُكتب (In, Out, Wgt). تعرّف TorchSparse خريطة الطبقة بأنها المجموعة M = {(p_j, q_k, W_δ)}، وتصف الطبقة كلها بحلقة واحدة: مرّ على الخريطة، ولكل مدخل اجمع حاصل ضرب متجه خصائص المدخل في مصفوفة وزن ذلك المدخل داخل متجه خصائص المخرج. هذه هي قاعدة التحديث المطبوعة أسفل يسار كل شريحة في هذه السلسلة.
Read the indicator as the map-building test. For each output q_k and each offset δ, look up the coordinate s·q_k + δ. If an input point p_j sits there, the triple (p_j, q_k, W_δ) joins the map; if not, nothing is added and nothing is computed. TorchSparse's Algorithm 1 is exactly this double loop with a hash-table lookup on coordinates. The heading of the slides now reads correctly: a sparse convolution is a sparse set of dense matrix multiply-accumulates, and the sparsity lives entirely in which tuples exist.
اقرأ دالة المؤشر (indicator) على أنها اختبار بناء الخريطة. لكل مخرج q_k ولكل إزاحة δ، ابحث عن الإحداثي s·q_k + δ. إذا كانت هناك نقطة مدخل p_j، ينضم الثلاثي (p_j, q_k, W_δ) إلى الخريطة؛ وإلا فلا يُضاف شيء ولا يُحسب شيء. الخوارزمية 1 في TorchSparse هي بالضبط هذه الحلقة المزدوجة مع بحث في جدول تجزئة (hash table) على الإحداثيات. والآن يصبح عنوان الشرائح مفهومًا: الالتفاف المتناثر مجموعة متناثرة من عمليات ضرب وتجميع مصفوفات كثيفة (dense matrix multiply-accumulates)، والتناثر كله يكمن في أي الثلاثيات موجودة.
Nine entries become twoتسعة مدخلات تصبح اثنين
Now compare the two columns of the slide for P0. The conventional column lists one entry per tap, nine in all, because every cell of P0's window is an output that a dense layer computes. The sparse column applies the submanifold rule from the previous concept: an output must itself be an input position. Inside P0's window only two cells qualify, P0's own position and (2, 2), where P1 sits. So the map keeps exactly two tuples and marks the other seven "No compute".
قارن الآن بين عمودي الشريحة للنقطة P0. العمود التقليدي يسرد مدخلًا لكل نقرة، تسعة في المجموع، لأن كل خلية في نافذة P0 مخرج تحسبه الطبقة الكثيفة. أما العمود المتناثر فيطبق قاعدة الـ submanifold من المفهوم السابق: يجب أن يكون المخرج نفسه موقع مدخل. داخل نافذة P0 تتأهل خليتان فقط: موقع P0 نفسه، و(2, 2) حيث تقع P1. لذلك تحتفظ الخريطة بثلاثيتين بالضبط وتضع على السبع الأخرى علامة "No compute".
| Conventional entryالمدخل التقليدي | Output positionموقع المخرج | Conventionalالطريقة التقليدية | Submanifold sparseالالتفاف المتناثر على الـ submanifold |
|---|---|---|---|
| (P0, Q0, W1,1)(P0, Q0, W1,1) | (0, 0)(0, 0) | computedيُحسب | no computeلا حساب |
| (P0, Q1, W1,0)(P0, Q1, W1,0) | (0, 1)(0, 1) | computedيُحسب | no computeلا حساب |
| (P0, Q2, W1,-1)(P0, Q2, W1,-1) | (0, 2)(0, 2) | computedيُحسب | no computeلا حساب |
| (P0, Q3, W0,1)(P0, Q3, W0,1) | (1, 0)(1, 0) | computedيُحسب | no computeلا حساب |
| (P0, Q4, W0,0)(P0, Q4, W0,0) | (1, 1)(1, 1) | computedيُحسب | kept as (P0, Q0, W0,0)يبقى بصيغة (P0, Q0, W0,0) |
| (P0, Q5, W0,-1)(P0, Q5, W0,-1) | (1, 2)(1, 2) | computedيُحسب | no computeلا حساب |
| (P0, Q8, W-1,1)(P0, Q8, W-1,1) | (2, 0)(2, 0) | computedيُحسب | no computeلا حساب |
| (P0, Q9, W-1,0)(P0, Q9, W-1,0) | (2, 1)(2, 1) | computedيُحسب | no computeلا حساب |
| (P0, Q10, W-1,-1)(P0, Q10, W-1,-1) | (2, 2)(2, 2) | computedيُحسب | kept as (P0, Q1, W-1,-1)يبقى بصيغة (P0, Q1, W-1,-1) |
Costing the whole grid, not just P0حساب كلفة الشبكة كلها، لا P0 وحدها
The slide follows one point, so extend it to all four. Conventionally each point contributes one entry per in-grid tap: 9 for P0, 9 for the point at (2, 2), 6 for (2, 4) against the right edge and 6 for (3, 3) against the bottom, 30 in total. The submanifold map has one centre entry per point plus one entry for every ordered pair of points within one step of each other. Three such pairs exist, (1, 1) with (2, 2), (2, 2) with (3, 3) and (2, 4) with (3, 3), each counted in both directions, giving 4 + 6 = 10 entries. Each entry is a (1 x C_in)(C_in x C_out) product, so with C_in = C_out = 64 an entry costs 4,096 MACs.
تتتبع الشريحة نقطة واحدة، فلنوسّع ذلك إلى النقاط الأربع. في الطريقة التقليدية تساهم كل نقطة بمدخل لكل نقرة داخل الشبكة: 9 للنقطة P0، و9 للنقطة عند (2, 2)، و6 للنقطة (2, 4) الملاصقة للحافة اليمنى، و6 للنقطة (3, 3) الملاصقة للحافة السفلى، أي 30 في المجموع. أما خريطة الـ submanifold ففيها مدخل مركزي واحد لكل نقطة، إضافة إلى مدخل لكل زوج مرتب من النقاط تفصل بينهما خطوة واحدة. توجد ثلاثة أزواج كهذه: (1, 1) مع (2, 2)، و(2, 2) مع (3, 3)، و(2, 4) مع (3, 3)، وكل زوج يُحسب في الاتجاهين، فيكون المجموع 4 + 6 = 10 مدخلات. كل مدخل حاصل ضرب (1 x C_in)(C_in x C_out)، لذلك مع C_in = C_out = 64 يكلّف المدخل الواحد 4,096 MACs.
| Methodالطريقة | Entriesالمدخلات | MACsعمليات MAC | What is countedما الذي يُعدّ |
|---|---|---|---|
| Fully dense 3 by 3 over 20 outputsالتفاف كثيف بالكامل 3 في 3 على 20 مخرجًا | 20 x 9 = 18020 x 9 = 180 | 737,280737,280 | Every output visits every tap, zeros includedكل مخرج يزور كل نقرة، بما في ذلك الأصفار |
| Conventional, skipping zero inputsالطريقة التقليدية مع تخطي المدخلات الصفرية | 9 + 9 + 6 + 6 = 309 + 9 + 6 + 6 = 30 | 122,880122,880 | Each point feeds every in-grid output its window touchesكل نقطة تغذي كل مخرج داخل الشبكة تلمسه نافذتها |
| Submanifold sparseالالتفاف المتناثر على الـ submanifold | 4 + 3 x 2 = 104 + 3 x 2 = 10 | 40,96040,960 | Four centre entries plus three neighbouring pairs in both directionsأربعة مدخلات مركزية إضافة إلى ثلاثة أزواج متجاورة في الاتجاهين |
Two lessons hide in that table. Zero-skipping alone, the trick EIE relied on, already removes most of the work on this grid, but it still writes the dilated 17-cell output and so the next layer starts from 17 points instead of 4. The submanifold map is the only row whose cost stays proportional to the number of points layer after layer. On a real LiDAR frame with hundreds of thousands of points in a grid of billions of voxels, the fully dense row is not merely slow; it does not fit in memory.
في هذا الجدول درسان. تخطي الأصفار وحده (zero-skipping)، وهي الحيلة التي اعتمد عليها EIE، يزيل بالفعل معظم العمل على هذه الشبكة، لكنه ما زال يكتب مخرجًا متمددًا من 17 خلية، فتبدأ الطبقة التالية من 17 نقطة بدلًا من 4. خريطة الـ submanifold هي الصف الوحيد الذي تبقى كلفته متناسبة مع عدد النقاط طبقة بعد طبقة. وفي إطار LiDAR حقيقي فيه مئات الآلاف من النقاط داخل شبكة من مليارات الـ voxels، لا يكون الصف الكثيف بالكامل بطيئًا فحسب، بل لا يتسع في الذاكرة أصلًا.
Symmetry check: W-1,-1 has 2 entries and W1,1 has 2.فحص التماثل: لـ W-1,-1 عدد 2 من المدخلات، ولـ W1,1 عدد 2.
Click cells to place or remove points, then pick a kernel offset. The list shows every map entry for that weight using the deck's convention: input P sits at output Q shifted by the row and column offset (dx, dy), and the output must itself be an input position. The counts in the offset picker are the row counts of the gathered matrices on slide 96, so the number of non-empty offsets is the number of separate matmuls the existing GPU implementation launches. Compare the three MAC readouts: fully dense visits every cell, conventional zero-skipping still fills the dilated set, and submanifold pays only for entries whose output is a real point.انقر الخلايا لوضع النقاط أو إزالتها، ثم اختر إزاحة نواة. تعرض القائمة كل مدخل في الخريطة لذلك الوزن وفق اصطلاح الشرائح: الإدخال P يقع عند الخرج Q مزاحًا بإزاحة الصف والعمود (dx, dy)، ويجب أن يكون الخرج نفسه موضع إدخال. الأعداد في منتقي الإزاحة هي عدد صفوف المصفوفات المجمّعة في الشريحة 96، لذا فعدد الإزاحات غير الفارغة هو عدد عمليات matmul المنفصلة التي يطلقها تنفيذ GPU الحالي. قارن مؤشرات MAC الثلاثة: الكثيف كليًا يزور كل خلية، وتخطي الأصفار التقليدي ما زال يملأ المجموعة المتمددة، والالتفاف submanifold لا يدفع إلا ثمن المدخلات التي خرجها نقطة حقيقية.
Recall
Write the sparse convolution update rule and name every symbol in it.اكتب قاعدة التحديث في الالتفاف المتناثر وسمِّ كل رمز فيها.
Recall
On slide 95, how many map entries does P0 have conventionally and sparsely, and why?في الشريحة 95، كم مدخلًا في الخريطة للنقطة P0 بالطريقة التقليدية وبالطريقة المتناثرة، ولماذا؟
Quick checkاختبار سريع
In the entry (P0, Q1, W-1,-1) with the deck's convention P = Q + (dx, dy), where is Q1 relative to P0?في المدخل (P0, Q1, W-1,-1) وفق اصطلاح الشرائح P = Q + (dx, dy)، أين تقع Q1 بالنسبة إلى P0؟
Quick checkاختبار سريع
Which statement about submanifold sparse convolution is correct?أي عبارة عن الالتفاف المتناثر على الـ submanifold صحيحة؟
Slide 95 closes the P0 story with a count, nine matrix multiplications against two, and slide 96 asks the practical question: how does a GPU run a list of tuples? Take its workload, a 5 x 5 grid with five points P0 at (1, 1), P1 at (2, 2), P2 at (2, 4), P3 at (3, 2) and P4 at (4, 3). Its map has eleven entries, and the box on the slide lists them not in point order but sorted by weight offset. That ordering is the whole idea.
تختم الشريحة 95 قصة P0 بعدد: تسع عمليات ضرب مصفوفات مقابل اثنتين، ثم تطرح الشريحة 96 السؤال العملي: كيف تنفّذ الـ GPU قائمة من الثلاثيات؟ خذ حِمل العمل فيها: شبكة 5 x 5 فيها خمس نقاط، P0 عند (1, 1)، وP1 عند (2, 2)، وP2 عند (2, 4)، وP3 عند (3, 2)، وP4 عند (4, 3). خريطتها فيها أحد عشر مدخلًا، والمربع في الشريحة لا يسردها بترتيب النقاط بل مرتبة حسب إزاحة الوزن. وهذا الترتيب هو الفكرة كلها.
Running the update rule one entry at a time means eleven vector-matrix products, each a single row of C_in values against a C_in x C_out matrix. TorchSparse notes that the utilization of matrix-vector multiplication is rather low on a GPU, whose tensor cores want tall matrices on both sides. The escape is to notice that entries sharing the same offset share the same matrix. Stack their input rows into one contiguous matrix, multiply it by that one W_δ, and you have turned several vector-matrix products into one matrix-matrix product. Grouping by output or by input would not work: entries with the same output use different weights, and so do entries with the same input.
تنفيذ قاعدة التحديث مدخلًا مدخلًا يعني أحد عشر حاصل ضرب متجه في مصفوفة، كل منها صف واحد من C_in قيمة مقابل مصفوفة C_in x C_out. تلاحظ TorchSparse أن نسبة استغلال ضرب المصفوفة في المتجه منخفضة جدًا على الـ GPU، التي تريد أنوية الـ tensor فيها مصفوفات طويلة على الجانبين. والمخرج هو ملاحظة أن المدخلات التي تشترك في الإزاحة نفسها تشترك في المصفوفة نفسها. رصّ صفوف مدخلاتها في مصفوفة واحدة متصلة في الذاكرة، واضربها في تلك الـ W_δ الواحدة، وبذلك تحوّل عدة حواصل ضرب متجه في مصفوفة إلى حاصل ضرب واحد لمصفوفة في مصفوفة. التجميع حسب المخرج أو حسب المدخل لا ينجح: المدخلات التي تشترك في المخرج نفسه تستخدم أوزانًا مختلفة، وكذلك المدخلات التي تشترك في المدخل نفسه.
| Weightالوزن | Entries (In, Out)المدخلات (In, Out) | Rows gatheredالصفوف المجمّعة | Noteملاحظة |
|---|---|---|---|
| W-1,-1W-1,-1 | (P0, Q1), (P3, Q4)(P0, Q1), (P3, Q4) | 22 | highlighted on the slideمظللة في الشريحة |
| W-1,0W-1,0 | (P1, Q3)(P1, Q3) | 11 | mirror of W1,0معاكسة لـ W1,0 |
| W0,0W0,0 | (P0, Q0), (P1, Q1), (P2, Q2), (P3, Q3), (P4, Q4)(P0, Q0), (P1, Q1), (P2, Q2), (P3, Q3), (P4, Q4) | 55 | one entry per point, no data movementمدخل واحد لكل نقطة، دون أي نقل للبيانات |
| W1,0W1,0 | (P3, Q1)(P3, Q1) | 11 | mirror of W-1,0معاكسة لـ W-1,0 |
| W1,1W1,1 | (P1, Q0), (P4, Q3)(P1, Q0), (P4, Q3) | 22 | mirror of W-1,-1معاكسة لـ W-1,-1 |
| W-1,1, W0,1, W0,-1, W1,-1W-1,1, W0,1, W0,-1, W1,-1 | noneلا يوجد | 00 | no kernel launch at allلا يُطلق أي kernel على الإطلاق |
Five of the nine offsets have entries, so this layer launches five matmuls with 2, 1, 5, 1 and 2 rows. The other four offsets have empty maps and launch nothing. Notice too that P2 at (2, 4) has no neighbour within one step, so it appears only in the W_(0,0) group: an isolated point costs exactly one entry.
خمس من الإزاحات التسع لها مدخلات، لذلك تطلق هذه الطبقة خمس عمليات matmul بعدد صفوف 2 و1 و5 و1 و2. الإزاحات الأربع الأخرى خرائطها فارغة ولا تطلق شيئًا. ولاحظ أيضًا أن P2 عند (2, 4) ليس لها جار على بعد خطوة واحدة، لذلك لا تظهر إلا في مجموعة W_(0,0): النقطة المعزولة تكلّف مدخلًا واحدًا بالضبط.
Gather, matmul, scatterالتجميع، ثم ضرب المصفوفات، ثم التوزيع (gather, matmul, scatter)
The pipeline on slide 96 is the gather, matmul, scatter flow that every existing GPU implementation follows, written out for the highlighted offset W_(-1,-1). Its two entries are (P0, Q1) and (P3, Q4). Gather copies rows P0 and P3 out of the 5 x C_in input feature matrix into a 2 x C_in buffer. Matmul multiplies that buffer by the C_in x C_out weight to produce a 2 x C_out partial sum. Scatter adds row one into output Q1 and row two into Q4, which is the pair of equations under the figure: f1 = f1 + f0 x W_(-1,-1) and f4 = f4 + f3 x W_(-1,-1). Then the next offset takes its turn with its own rows.
خط المعالجة في الشريحة 96 هو تدفق gather, matmul, scatter الذي يتبعه كل تنفيذ موجود على الـ GPU، مكتوبًا للإزاحة المظللة W_(-1,-1). مدخلاها هما (P0, Q1) و(P3, Q4). التجميع (Gather) ينسخ الصفين P0 وP3 من مصفوفة خصائص المدخل 5 x C_in إلى ذاكرة مؤقتة 2 x C_in. ثم يضرب الـ Matmul هذه الذاكرة المؤقتة في مصفوفة الوزن C_in x C_out لينتج مجموعًا جزئيًا 2 x C_out. ثم يضيف التوزيع (Scatter) الصف الأول إلى المخرج Q1 والصف الثاني إلى Q4، وهذا هو زوج المعادلتين تحت الشكل: f1 = f1 + f0 x W_(-1,-1) وf4 = f4 + f3 x W_(-1,-1). ثم تأتي الإزاحة التالية بصفوفها الخاصة.
Worked exampleمثال محلول
Costing the W(-1,-1) group with C_in = C_out = 64حساب كلفة مجموعة W(-1,-1) مع C_in = C_out = 64
Gatherالتجميع (Gather)
Read rows P0 and P3 of the 5 x 64 input matrix into a 2 x 64 buffer: 128 values moved, no arithmetic.اقرأ الصفين P0 وP3 من مصفوفة المدخل 5 x 64 إلى ذاكرة مؤقتة 2 x 64: نقل 128 قيمة، دون أي عمليات حسابية.Matmulضرب المصفوفات (Matmul)
Multiply the 2 x 64 buffer by the 64 x 64 matrix W_(-1,-1): 2 x 64 x 64 = 8,192 MACs, producing a 2 x 64 partial sum.اضرب الذاكرة المؤقتة 2 x 64 في المصفوفة 64 x 64 وهي W_(-1,-1): 2 x 64 x 64 = 8,192 MACs، والناتج مجموع جزئي 2 x 64.Scatter-addالإضافة بالتوزيع (Scatter-add)
Add partial-sum row one into f1 and row two into f4: 128 additions into the 5 x 64 output matrix.أضف الصف الأول من المجموع الجزئي إلى f1 والصف الثاني إلى f4: 128 عملية جمع في مصفوفة المخرج 5 x 64.Repeat for the other four non-empty offsetsكرّر للإزاحات الأربع الأخرى غير الفارغة
Rows gathered are 1, 5, 1 and 2, so the layer does 11 row-matrix products in five kernel launches.عدد الصفوف المجمّعة 1 و5 و1 و2، لذلك تنفّذ الطبقة 11 حاصل ضرب صف في مصفوفة عبر خمس عمليات إطلاق للـ kernel.Layer costكلفة الطبقة
11 x 4,096 = 45,056 MACs, against 159,744 for a zero-skipping conventional convolution on the same five points and 921,600 for a fully dense 3 x 3 over all 25 cells.11 x 4,096 = 45,056 MACs، مقابل 159,744 لالتفاف تقليدي يتخطى الأصفار على النقاط الخمس نفسها، و921,600 لالتفاف كثيف بالكامل 3 x 3 على كل الخلايا الـ 25.
| Methodالطريقة | Entriesالمدخلات | MACsعمليات MAC |
|---|---|---|
| Fully dense 3 by 3 over 25 outputsالتفاف كثيف بالكامل 3 في 3 على 25 مخرجًا | 25 x 9 = 22525 x 9 = 225 | 921,600921,600 |
| Conventional, skipping zero inputsالطريقة التقليدية مع تخطي المدخلات الصفرية | 9 + 9 + 6 + 9 + 6 = 399 + 9 + 6 + 9 + 6 = 39 | 159,744159,744 |
| Submanifold sparse, 5 matmulsالالتفاف المتناثر على الـ submanifold، بخمس عمليات matmul | 2 + 1 + 5 + 1 + 2 = 112 + 1 + 5 + 1 + 2 = 11 | 45,05645,056 |
The slide's heading calls this weight-stationary: the weight matrix for one offset stays put while the gathered rows stream through it, and a separate matmul runs for each different weight. TorchSparse's Algorithm 2 is literally a loop over offsets that performs gather, matmul and scatter for each. The rule book in Graham et al. is the same design described from the sparse-convolution side: for each row (j, k) in the rule for offset i, multiply row j of the input matrix by W^i and add it to row k of the output, which they note runs efficiently on a GPU precisely because it is a matrix-matrix multiply-add. SECOND (Yan et al., 2018) moved the rule generation itself from a CPU hash table to the GPU, since the CPU version was slow and required data transfer between CPU and GPU on every layer.
يسمي عنوان الشريحة هذا الأسلوب weight-stationary: تبقى مصفوفة الوزن الخاصة بإزاحة واحدة ثابتة في مكانها بينما تتدفق عبرها الصفوف المجمّعة، وتُنفَّذ عملية matmul منفصلة لكل وزن مختلف. الخوارزمية 2 في TorchSparse هي حرفيًا حلقة على الإزاحات تنفّذ gather وmatmul وscatter لكل منها. و"كتاب القواعد" (rule book) عند Graham et al. هو التصميم نفسه موصوفًا من جهة الالتفاف المتناثر: لكل صف (j, k) في قاعدة الإزاحة i، اضرب الصف j من مصفوفة المدخل في W^i وأضفه إلى الصف k من المخرج، ويلاحظون أن هذا يعمل بكفاءة على الـ GPU تحديدًا لأنه عملية ضرب وجمع مصفوفة في مصفوفة. ثم نقل SECOND (Yan et al., 2018) توليد القواعد نفسه من جدول تجزئة على الـ CPU إلى الـ GPU، لأن نسخة الـ CPU كانت بطيئة وتتطلب نقل بيانات بين الـ CPU والـ GPU في كل طبقة.
A symmetry you can check on the slideتناظر يمكنك التحقق منه على الشريحة
Look at the row counts again: W_(-1,-1) and W_(1,1) both have two rows, W_(-1,0) and W_(1,0) both have one. That is not luck. If (P, Q, W_δ) is an entry, then P and Q are both points and Q = P + (-δ), so (Q, P, W_(-δ)) is also an entry. TorchSparse section 4.2.1 proves this one-to-one correspondence for any odd kernel at stride 1, and the (0, 0) map is special for a second reason: every point maps to itself, so it needs no gather and no scatter at all. Part 12 builds its first optimization on exactly this pairing, and the simulator above reports the check on every grid you draw.
انظر إلى أعداد الصفوف مرة أخرى: W_(-1,-1) وW_(1,1) لكل منهما صفان، وW_(-1,0) وW_(1,0) لكل منهما صف واحد. هذا ليس مصادفة. إذا كان (P, Q, W_δ) مدخلًا، فإن P وQ كلتاهما نقطتان وQ = P + (-δ)، لذلك يكون (Q, P, W_(-δ)) مدخلًا أيضًا. يثبت القسم 4.2.1 في TorchSparse هذا التقابل واحد لواحد لأي نواة فردية عند stride يساوي 1، وخريطة (0, 0) مميزة لسبب ثانٍ: كل نقطة ترتبط بنفسها، لذلك لا تحتاج أي gather ولا أي scatter على الإطلاق. يبني الجزء 12 أول تحسين له على هذا الاقتران بالضبط، والمحاكي أعلاه يعرض هذا الفحص على كل شبكة ترسمها.
Recall
Name the three stages of the existing GPU implementation and explain why entries are grouped by weight offset.سمِّ المراحل الثلاث في التنفيذ الحالي على الـ GPU، واشرح لماذا تُجمَّع المدخلات حسب إزاحة الوزن.
Recall
From the slide 96 list, how many matmuls does the layer launch and with how many rows each?من قائمة الشريحة 96، كم عملية matmul تطلقها الطبقة، وكم صفًا في كل منها؟
Quick checkاختبار سريع
Why does the GPU implementation group map entries by weight offset before multiplying?لماذا يجمّع التنفيذ على الـ GPU مدخلات الخريطة حسب إزاحة الوزن قبل الضرب؟
- Entries: for stride 1 with an odd kernel, count(δ) = count(-δ), and the (0, 0) map has exactly one entry per point.المدخلات: عند stride يساوي 1 ونواة فردية، count(δ) = count(-δ)، وخريطة (0, 0) فيها مدخل واحد بالضبط لكل نقطة.
- Matmuls per layer: the number of offsets whose map is non-empty, at most K^D.عدد عمليات الـ matmul في الطبقة: عدد الإزاحات التي خريطتها غير فارغة، وهو على الأكثر K^D.
- MACs per layer: total entries times C_in x C_out, independent of how the entries are grouped. Grouping changes utilization and data movement, never the arithmetic count.عدد الـ MACs في الطبقة: إجمالي المدخلات مضروبًا في C_in x C_out، ولا يعتمد على طريقة تجميع المدخلات. التجميع يغيّر نسبة الاستغلال ونقل البيانات، ولا يغيّر أبدًا عدد العمليات الحسابية.
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Outdoor LiDAR voxel grids are below 0.01 percent dense; ImageNet inputs are 100 percent dense and about 50 percent after ReLU.شبكات الـ voxel لإطارات LiDAR الخارجية كثافتها أقل من 0.01 بالمئة، أما مدخلات ImageNet فكثيفة بنسبة 100 بالمئة وتصبح نحو 50 بالمئة بعد ReLU.
- Dense convolution dilates: one active site becomes 3^d, then 5^d; on the slide grid 4 of 20 cells become 17 of 20 after one 3 by 3 layer.الالتفاف الكثيف يسبب التمدد: موقع نشط واحد يصبح 3^d ثم 5^d، وعلى شبكة الشريحة تصبح 4 خلايا من 20 هي 17 من 20 بعد طبقة 3 في 3 واحدة.
- Submanifold sparse convolution computes outputs only at input positions, so P_out = P_in and nothing dilates.الالتفاف المتناثر على الـ submanifold يحسب المخرجات فقط عند مواقع المدخل، لذلك P_out = P_in ولا يحدث أي تمدد.
- The computation is a map of (In, Out, Wgt) entries with P = Q + (dx, dy); each entry does f_out = f_out + f_in x W_(dx,dy).الحساب هو خريطة من مدخلات (In, Out, Wgt) حيث P = Q + (dx, dy)، وكل مدخل ينفذ f_out = f_out + f_in x W_(dx,dy).
- For P0 on slide 95: 9 conventional entries, 2 sparse entries. Whole 4 by 5 grid: 30 versus 10.للنقطة P0 في الشريحة 95: تسعة مدخلات بالطريقة التقليدية ومدخلان بالطريقة المتناثرة. وللشبكة 4 في 5 كاملة: 30 مقابل 10.
- Entries sharing W_(dx,dy) are gathered into one matrix, multiplied once, then scatter-added (weight-stationary). Slide 96: 11 entries, five matmuls with 2, 1, 5, 1, 2 rows.المدخلات التي تشترك في W_(dx,dy) تُجمع (gather) في مصفوفة واحدة، وتُضرب مرة واحدة، ثم تُضاف بالتوزيع (scatter-add)، وهذا هو أسلوب weight-stationary. الشريحة 96: 11 مدخلًا، وخمس عمليات matmul بعدد صفوف 2 و1 و5 و1 و2.
- At stride 1 with an odd kernel, the maps for an offset and its mirror always have equal size.عند stride يساوي 1 ونواة (kernel) فردية الحجم، يتساوى دائمًا حجم خريطة الإزاحة وحجم خريطة الإزاحة المعاكسة لها.
- Per-offset matmuls are irregular and gather plus scatter can take up to 50 percent of runtime: the problems TorchSparse and PointAcc attack in parts 12 and 13.عمليات الـ matmul لكل إزاحة غير منتظمة، وقد يستهلك gather مع scatter حتى 50 بالمئة من زمن التشغيل: وهذه هي المشكلات التي تعالجها TorchSparse وPointAcc في الجزأين 12 و13.
Sourcesالمصادر
- TorchSparse: Efficient Point Cloud Inference EnginePaperMLSys 2022, Tang, Liu, Li, Lin and HanEq. 1, the map definition, Algorithms 1 and 2, gather-matmul-scatter, symmetric offsets in section 4.2.1, the 8 FPS and 50 percent figures.المعادلة 1، وتعريف الخريطة، والخوارزميتان 1 و2، وخط gather ثم matmul ثم scatter، والإزاحات المتناظرة في القسم 4.2.1، ورقما 8 FPS و50 بالمئة.(opens in a new tab)(يفتح في تبويب جديد)
- 3D Semantic Segmentation with Submanifold Sparse Convolutional NetworksPaperCVPR 2018, Graham, Engelcke and van der MaatenSubmanifold dilation problem, 3^d then 5^d, the SSC definition, the receptive-field figure on the right of slide 86 and the rule book.مشكلة تمدد الـ submanifold، وقاعدة 3^d ثم 5^d، وتعريف SSC، وشكل مجال الاستقبال على يمين الشريحة 86، وكتاب القواعد (rule book).(opens in a new tab)(يفتح في تبويب جديد)
- Submanifold Sparse Convolutional NetworksPaperarXiv 2017, Graham and van der MaatenOrigin of the ring-dilation figure reproduced on the left of slide 86.مصدر شكل تمدد الحلقة المنقول على يسار الشريحة 86.(opens in a new tab)(يفتح في تبويب جديد)
- Sparse 3D convolutional neural networksPaperBMVC 2015, GrahamThe paper the slide credit actually points to; its convolutions still dilate.الورقة التي يشير إليها سطر الاعتماد في الشريحة فعلًا، والتفافاتها ما زالت تتمدد.(opens in a new tab)(يفتح في تبويب جديد)
- PointAcc: Efficient Point Cloud AcceleratorPaperMICRO 2021, Lin, Zhang, Tang, Wang and HanDensity below 0.01 percent outdoors, sparsity constrained by physical objects, nonzero points never dilate.كثافة أقل من 0.01 بالمئة في المشاهد الخارجية، وتناثر مقيّد بالأجسام الفيزيائية، ونقاط غير صفرية لا تتمدد أبدًا.(opens in a new tab)(يفتح في تبويب جديد)
- SECOND: Sparsely Embedded Convolutional DetectionPaperSensors 2018, Yan, Mao and LiGPU rule generation replacing the CPU hash table, and the gather, GEMM, scatter flow.توليد القواعد على الـ GPU بدلًا من جدول التجزئة على الـ CPU، وتدفق gather ثم GEMM ثم scatter.(opens in a new tab)(يفتح في تبويب جديد)
- 4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural NetworksPaperCVPR 2019, Choy, Gwak and SavareseGeneralized sparse convolution and the MinkowskiNet model that TorchSparse benchmarks at 8 FPS on a GTX 1080Ti.الالتفاف المتناثر المعمّم، ونموذج MinkowskiNet الذي تقيسه TorchSparse بسرعة 8 FPS على GTX 1080Ti.(opens in a new tab)(يفتح في تبويب جديد)
- SparseConvNetDocsFacebook Research, GitHubStates that the set of active sites is unchanged by submanifold convolution and that inactive sites carry no computational overhead.يذكر أن مجموعة المواقع النشطة لا يغيّرها التفاف الـ submanifold، وأن المواقع غير النشطة لا تحمل أي عبء حسابي.(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse repositoryDocsMIT HAN Lab, GitHubReference implementation of the maps and the gather-matmul-scatter pipeline.التنفيذ المرجعي للخرائط ولخط المعالجة gather ثم matmul ثم scatter.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Lecture 4DocsMIT HAN LabThe lecture whose slides 84 to 96 this deck mirrors, including the BMVC 2015 credit line.المحاضرة التي تحاكي هذه الشرائح شرائحها من 84 إلى 96، بما في ذلك سطر الاعتماد الخاص بـ BMVC 2015.(opens in a new tab)(يفتح في تبويب جديد)
Part 12: TorchSparse: regular computation from irregular sparsityTorchSparse: حساب منتظم من تناثر غير منتظم
The gather, matmul, scatter pipeline on GPUs, why separate small matmuls waste the GPU, and how TorchSparse trades a little padding for regularity with adaptive grouping, locality-aware access and, in TorchSparse++, overlapped memory and compute.خط عمل gather ثم matmul ثم scatter على GPU، ولماذا تهدر عمليات الضرب الصغيرة المنفصلة قدرة GPU، وكيف يقايض TorchSparse قليلًا من الحشو مقابل الانتظام عبر التجميع التكيفي والوصول الواعي بالمحلية (locality)، وفي TorchSparse++ عبر تداخل الذاكرة مع الحساب.
3 concepts3 مفاهيم, ، slides 97-109الشرائح 97-109
Why this part mattersلماذا يهمّ هذا الجزء
Your research on embedded machine learning will meet sparse, irregular workloads long before it meets a textbook dense matrix: LiDAR sweeps, radar returns, event cameras, pruned weights. This part is about a systems pattern rather than a library. Irregular work is made regular by paying a controlled amount of redundant computation, and the right amount is found by measurement, not by assuming zero.
Part 11 ended with the map: the list of (input, output, weight offset) tuples that turns sparse convolution into a sparse set of dense matrix multiplies. Here we follow how a GPU actually executes that list, why the obvious execution wastes most of the device, and how TorchSparse and its successor recover the loss. The same reasoning returns whenever you schedule uneven work on an edge GPU such as a Jetson Orin, and the exam angle is direct: name the phases, explain the waste, describe the fix.
سيقابل بحثك في تعلّم الآلة على الأنظمة المدمجة أحمال عمل متناثرة وغير منتظمة قبل أن يقابل مصفوفة كثيفة كالتي في الكتب بوقت طويل: مسحات LiDAR، وارتدادات الرادار، وكاميرات الأحداث (event cameras)، والأوزان المقلّمة. هذا الجزء يدور حول نمط في تصميم الأنظمة لا حول مكتبة بعينها: العمل غير المنتظم يُجعل منتظمًا بدفع قدر مضبوط من الحساب الزائد، والقدر الصحيح يُكتشف بالقياس، لا بافتراض أنه صفر.
انتهى الجزء 11 عند الـ map: قائمة الثلاثيات (input, output, weight offset) التي تحوّل الالتفاف المتناثر إلى مجموعة متناثرة من عمليات ضرب مصفوفات كثيفة. هنا نتتبع كيف ينفّذ الـ GPU هذه القائمة فعليًا، ولماذا يهدر التنفيذ البديهي معظم قدرة الجهاز، وكيف يستعيد TorchSparse وخلفه هذه الخسارة. يعود المنطق نفسه كلما جدولت عملًا غير متساوٍ على GPU طرفي مثل Jetson Orin، وزاوية الاختبار مباشرة: سمِّ المراحل، واشرح الهدر، وصِف الحل.
By the end you canفي نهاية هذا الجزء ستستطيع
- Trace one weight offset through gather, matmul and scatter using the map, giving the buffer and partial-sum shapes.تتبّع إزاحة وزن واحدة عبر مراحل gather وmatmul وscatter باستخدام الـ map، مع ذكر أبعاد الـ buffer وأبعاد المجاميع الجزئية (partial sums).
- Explain why 27 small matmuls and per-offset gathers underuse a GPU, quoting the paper's utilization figure.اشرح لماذا تستغل 27 عملية matmul صغيرة وعمليات gather المنفصلة لكل إزاحة الـ GPU استغلالًا ضعيفًا، مستشهدًا بنسبة الاستغلال التي ذكرتها الورقة.
- Place separate computation, dense convolution and adaptive grouping on the overhead versus regularity spectrum and compute pad rows for a small example.ضع الحساب المنفصل والالتفاف الكثيف (dense convolution) والتجميع التكيفي (adaptive grouping) على طيف الكلفة الإضافية مقابل الانتظام، واحسب صفوف الحشو (pad rows) لمثال صغير.
- Read the matmul ablation and say why TFLOP/s and speedup can disagree.اقرأ تجربة الـ ablation الخاصة بمرحلة الـ matmul وبيّن لماذا قد يختلف TFLOP/s عن التسريع (speedup).
- Describe what TorchSparse++ overlaps and name its two components.صِف ما الذي يجعله TorchSparse++ متداخلًا (overlap)، واذكر مكوّنيه.
Keep the small example from part 11 in view. Five input points P0 to P4, five output points Q0 to Q4, a 3 x 3 kernel, so nine weight offsets from W(-1,-1) to W(1,1). The map for this layer has eleven tuples. Two of them belong to W(-1,-1), one to W(-1,0), five to W(0,0), one to W(1,0), two to W(1,1), and the other four offsets have no entry at all in this tiny cloud.
أبقِ المثال الصغير من الجزء 11 أمام عينيك. خمس نقاط إدخال من P0 إلى P4، وخمس نقاط إخراج من Q0 إلى Q4، وkernel بحجم 3 x 3، أي تسع إزاحات وزن من W(-1,-1) إلى W(1,1). الـ map لهذه الطبقة فيه أحد عشر ثلاثيًا (tuple). اثنان منها يخصّان W(-1,-1)، وواحد يخصّ W(-1,0)، وخمسة تخصّ W(0,0)، وواحد يخصّ W(1,0)، واثنان يخصّان W(1,1)، أما الإزاحات الأربع الباقية فليس لها أي مدخل إطلاقًا في هذه السحابة الصغيرة.
The existing GPU implementation walks that list one weight at a time. It is weight-stationary: pick an offset, hold its C_in x C_out matrix still, and stream every map entry for that offset through it. Take W(-1,0). Its only entry is (P1, Q3), so the engine copies the single feature row f1 into a buffer of shape 1 x C_in, multiplies it by W(-1,0) to get one partial sum of shape 1 x C_out, and adds that row into Q3. Now take W(0,0). With stride 1 every input point sits on top of its own output, so the centre map contains all five entries. The buffer is the whole 5 x C_in input, the matmul is full height, and five partial sums land one to one in Q0 to Q4. Then W(1,0) with only (P3, Q1), then W(1,1) with (P1, Q0) and (P4, Q3), a 2 x C_in buffer whose two results go to two different output rows.
يمرّ التنفيذ الحالي على الـ GPU على هذه القائمة وزنًا واحدًا في كل مرة. إنه weight-stationary (الوزن ثابت): اختر إزاحة، وثبّت مصفوفتها ذات الأبعاد C_in x C_out، ومرّر عبرها كل مدخلات الـ map الخاصة بهذه الإزاحة. خذ W(-1,0). مدخلها الوحيد هو (P1, Q3)، لذلك ينسخ المحرك صف الخصائص الوحيد f1 إلى buffer أبعاده 1 x C_in، ويضربه في W(-1,0) ليحصل على مجموع جزئي واحد أبعاده 1 x C_out، ثم يضيف هذا الصف إلى Q3. الآن خذ W(0,0). مع stride 1 تقع كل نقطة إدخال فوق نقطة الإخراج الخاصة بها، لذلك يحتوي الـ map المركزي على المدخلات الخمسة كلها. الـ buffer هو الإدخال الكامل 5 x C_in، وعملية الـ matmul بكامل الارتفاع، وتصل خمسة مجاميع جزئية واحدًا لواحد إلى Q0 حتى Q4. ثم W(1,0) ومعها (P3, Q1) فقط، ثم W(1,1) ومعها (P1, Q0) و(P4, Q3)، أي buffer أبعاده 2 x C_in تذهب نتيجتاه إلى صفّي إخراج مختلفين.
That is the whole rule, and it is the same three phases every time. The names are the ones the lecture and the paper use: gather, matmul, scatter. For each weight offset delta, gather the |M_delta| input rows named by the map into a contiguous buffer, run one dense matrix multiplication of the |M_delta| x C_in buffer by the C_in x C_out weight, and scatter-accumulate the |M_delta| x C_out partial sums into the output rows named by the map. Written as an update rule over the whole map:
هذه هي القاعدة كاملة، وهي المراحل الثلاث نفسها في كل مرة. الأسماء هي التي تستخدمها المحاضرة والورقة: gather, matmul, scatter. لكل إزاحة وزن delta، اجمع (gather) صفوف الإدخال الـ |M_delta| التي يسمّيها الـ map في buffer متصل، ونفّذ عملية ضرب مصفوفات كثيفة واحدة للـ buffer ذي الأبعاد |M_delta| x C_in في الوزن ذي الأبعاد C_in x C_out، ثم وزّع مع التجميع (scatter-accumulate) المجاميع الجزئية ذات الأبعاد |M_delta| x C_out على صفوف الإخراج التي يسمّيها الـ map. وبصيغة قاعدة تحديث على الـ map كله:
The three phases and what bounds each oneالمراحل الثلاث وما الذي يحدّ كل واحدة منها
- Gather
- Read the |M_delta| input rows named by the map into a contiguous buffer. Random reads, bound by memory bandwidth.اقرأ صفوف الإدخال الـ |M_delta| التي يسمّيها الـ map إلى buffer متصل. قراءات عشوائية، محدودة بعرض نطاق الذاكرة.
- Matmul
- Multiply the |M_delta| x C_in buffer by the C_in x C_out weight. Dense FLOPs, but small and uneven per offset.اضرب الـ buffer ذا الأبعاد |M_delta| x C_in في الوزن ذي الأبعاد C_in x C_out. FLOPs كثيفة، لكنها صغيرة وغير متساوية من إزاحة إلى أخرى.
- Scatter-accumulate
- Add the |M_delta| x C_out partial sums into the output rows named by the map. Random writes with accumulation, bound by memory bandwidth.أضف المجاميع الجزئية ذات الأبعاد |M_delta| x C_out إلى صفوف الإخراج التي يسمّيها الـ map. كتابات عشوائية مع تجميع، محدودة بعرض نطاق الذاكرة.
In three dimensions the loop is longer. A 3 x 3 x 3 kernel has 27 offsets, and slide 105 notes that the centre (0,0,0) is usually computed separately because, at stride 1, its map is simply the identity over all points, leaving 26 irregular offsets. Because point-cloud occupancy is dynamic sparsity, the maps are built at run time for every scan, so the engine cannot precompute a fixed schedule the way it could for pruned weights.
في الأبعاد الثلاثة تكون الحلقة أطول. الـ kernel بحجم 3 x 3 x 3 له 27 إزاحة، وتشير الشريحة 105 إلى أن المركز (0,0,0) يُحسب عادة بشكل منفصل لأن الـ map الخاص به عند stride 1 هو ببساطة التطابق (identity) على كل النقاط، فيبقى 26 إزاحة غير منتظمة. ولأن إشغال سحابة النقاط هو dynamic sparsity (تناثر ديناميكي)، تُبنى الـ maps وقت التشغيل لكل مسحة، فلا يستطيع المحرك أن يحسب مسبقًا جدولًا ثابتًا كما كان يمكنه مع الأوزان المقلّمة.
Why this wastes most of the GPUلماذا يهدر هذا معظم قدرة الـ GPU
The baseline is correct and simple, and Tang et al. measured exactly where it loses. Two bottlenecks share the blame. First, the matmuls are non-uniform. The paper reports that map sizes for different weights can differ by an order of magnitude and that most map sizes are small, so each launch is a short, narrow matrix that cannot fill the device: MinkUNet 0.5x on an RTX 2080 Ti in FP16 reaches 8.1 TFLOP/s, only about 30 percent device utilization, with the matmul phase taking 20 to 50 percent of runtime (Tang et al., MLSys 2022, section 3). NVIDIA's own cuBLAS guidance says the same thing from the other side: when the matrices are small, the small matrix size prevents the GPU from being fully utilized, and launching them one after another produces many kernels launched in sequence (NVIDIA Developer Blog).
خط الأساس صحيح وبسيط، وقد قاس Tang et al. بدقة أين يخسر. يتقاسم اللوم عنقا زجاجة. الأول أن عمليات الـ matmul غير متجانسة. تذكر الورقة أن أحجام الـ maps للأوزان المختلفة قد تختلف بمرتبة عشرية كاملة وأن معظمها صغير، فيصبح كل تشغيل مصفوفة قصيرة وضيقة لا تستطيع ملء الجهاز: MinkUNet 0.5x على RTX 2080 Ti بدقة FP16 يصل إلى 8.1 TFLOP/s، أي نحو 30% فقط من استغلال الجهاز، بينما تستهلك مرحلة الـ matmul من 20% إلى 50% من زمن التشغيل (Tang et al., MLSys 2022، القسم 3). وإرشادات cuBLAS من NVIDIA نفسها تقول الشيء ذاته من الجهة الأخرى: عندما تكون المصفوفات صغيرة فإن صغر حجمها يمنع الاستغلال الكامل للـ GPU، وتشغيلها واحدة تلو الأخرى ينتج عددًا كبيرًا من الـ kernels المُطلقة بالتتابع (NVIDIA Developer Blog).
Second, and larger, gather and scatter are memory-bound. Each one is a random access pattern over the feature tensor, bottlenecked by GPU memory bandwidth rather than by computation resources, and together they take 40 to 50 percent of runtime. Worse, because every offset gathers and scatters on its own, the data movement is completely separated from one offset to the next: a row like f1 that appears in the maps of W(-1,0), W(0,0) and W(1,1) is fetched three times from off-chip memory with nothing reused (Tang et al., MLSys 2022, section 3).
الثاني، وهو الأكبر، أن مرحلتي gather وscatter محدودتان بالذاكرة (memory-bound). كل منهما نمط وصول عشوائي على مصفوفة الخصائص، عنق الزجاجة فيه عرض نطاق ذاكرة الـ GPU لا موارد الحساب، ومعًا تستهلكان من 40% إلى 50% من زمن التشغيل. والأسوأ أنه لأن كل إزاحة تنفّذ gather وscatter وحدها، فإن نقل البيانات منفصل تمامًا من إزاحة إلى التي تليها: صف مثل f1 يظهر في الـ maps الخاصة بـ W(-1,0) وW(0,0) وW(1,1) يُجلب ثلاث مرات من الذاكرة خارج الشريحة دون أي إعادة استخدام (Tang et al., MLSys 2022، القسم 3).
Worked exampleمثال محلول
Nine offsets, eleven map entriesتسع إزاحات وأحد عشر مدخلًا في الـ map
Group the map by offsetجمّع الـ map حسب الإزاحة
W(-1,-1): (P0, Q1), (P3, Q4). W(-1,0): (P1, Q3). W(0,0): all five. W(1,0): (P3, Q1). W(1,1): (P1, Q0), (P4, Q3). Four offsets are empty.W(-1,-1): (P0, Q1)، (P3, Q4). W(-1,0): (P1, Q3). W(0,0): المدخلات الخمسة كلها. W(1,0): (P3, Q1). W(1,1): (P1, Q0)، (P4, Q3). أربع إزاحات فارغة.Shape each launchحدّد أبعاد كل تشغيل
Buffers are 2 x C_in, 1 x C_in, 5 x C_in, 1 x C_in and 2 x C_in. Each matmul has the same C_in x C_out weight but a different row count, and each writes exactly as many partial-sum rows as it read.أبعاد الـ buffers هي 2 x C_in و1 x C_in و5 x C_in و1 x C_in و2 x C_in. كل عملية matmul لها الوزن نفسه C_in x C_out لكن بعدد صفوف مختلف، وكل منها تكتب من صفوف المجاميع الجزئية بقدر ما قرأت تمامًا.Count the kernelsعُدّ الـ kernels
Five non-empty offsets means five gathers, five matmuls and five scatters, fifteen launches for eleven accumulations. In a real layer with 26 non-centre offsets and maps of thousands of rows the count is 78 launches per layer, most of them short.خمس إزاحات غير فارغة تعني خمس عمليات gather وخمس عمليات matmul وخمس عمليات scatter، أي خمسة عشر تشغيلًا مقابل أحد عشر تجميعًا فقط. وفي طبقة حقيقية فيها 26 إزاحة غير مركزية وmaps من آلاف الصفوف، يصبح العدد 78 تشغيلًا لكل طبقة، معظمها قصير.Where the time goesأين يذهب الوقت
Roughly half of it in gather and scatter, memory-bound and unshared between offsets, and the rest in matmuls that run the tensor cores at a fraction of capacity because the rows per launch are few and uneven.نحو نصفه في gather وscatter، وهما محدودتان بالذاكرة ولا تتشاركان شيئًا بين الإزاحات، والباقي في عمليات matmul تشغّل الـ tensor cores بجزء صغير من طاقتها لأن الصفوف في كل تشغيل قليلة وغير متساوية.
Recall
Name the three phases of the baseline GPU sparse convolution and say which two are memory-bound.سمِّ المراحل الثلاث للالتفاف المتناثر الأساسي على الـ GPU، وبيّن أيّ اثنتين منها محدودتان بالذاكرة.
Recall
In a 3D 3x3x3 layer, how many separate matmuls does the baseline launch, and why do they underuse the GPU?في طبقة ثلاثية الأبعاد 3x3x3، كم عملية matmul منفصلة يطلقها خط الأساس، ولماذا تستغل الـ GPU استغلالًا ضعيفًا؟
Quick checkاختبار سريع
Why does the baseline gather-matmul-scatter pipeline underuse a GPU?لماذا يستغل خط الأساس gather-matmul-scatter الـ GPU استغلالًا ضعيفًا؟
Look at the same five features one more time, now the way TorchSparse runs them. The gather step still builds one buffer per offset, but adaptive grouping pads those buffers to a shared height, so the four small offsets become four buffers of exactly two rows each: {F0, F3} for W(-1,-1), {F1, pad} for W(-1,0), {F3, pad} for W(1,0) and {F1, F4} for W(1,1). Two of those rows are dashed: a pad, a row of zeros inserted so that every buffer has the same height. Because the four buffers now share a shape, one batched matrix multiplication (bmm, batch 4) runs all four at once. The centre weight W(0,0), whose buffer holds all five rows, runs as an ordinary matrix multiplication (mm). Partial sums PSUM 0 to PSUM 4 are scattered back with the same locality-aware access, and the two pad rows produce two blank partial-sum slots that nobody reads.
انظر إلى الخصائص الخمس نفسها مرة أخرى، لكن هذه المرة بالطريقة التي يشغّلها بها TorchSparse. ما زالت خطوة الـ gather تبني buffer واحدًا لكل إزاحة، لكن التجميع التكيفي يحشو هذه الـ buffers إلى ارتفاع مشترك، فتصبح الإزاحات الأربع الصغيرة أربعة buffers في كل منها صفّان بالضبط: {F0, F3} لـ W(-1,-1)، و{F1, pad} لـ W(-1,0)، و{F3, pad} لـ W(1,0)، و{F1, F4} لـ W(1,1). صفّان من هذه الصفوف مرسومان بخط متقطع: إنهما حشو (pad)، أي صف من الأصفار يُدرج كي يصبح لكل buffer الارتفاع نفسه. ولأن الـ buffers الأربعة صارت بالشكل نفسه، تشغّلها عملية ضرب مصفوفات مجمّعة واحدة (bmm، batch 4) دفعة واحدة. أما الوزن المركزي W(0,0)، الذي يحمل الـ buffer الخاص به الصفوف الخمسة كلها، فيعمل كعملية ضرب مصفوفات عادية (mm). تُوزَّع المجاميع الجزئية من PSUM 0 إلى PSUM 4 بالوصول نفسه المراعي للمحلية (locality-aware)، وينتج صفّا الحشو خانتين فارغتين من المجاميع الجزئية لا يقرؤهما أحد.
Those two dashed rows are the price. Two zero rows were multiplied for nothing so that five matmul launches became two. That is the entire idea of this concept, and the paper names it in the slide title: trading computation for regularity. The overview on slide 101 lists three techniques, locality-aware gather, adaptive grouping of the matmuls, and locality-aware scatter-accumulate. The first and last attack the memory-bound half of the runtime by reading and writing feature rows in an order that keeps neighbouring accesses close and by fusing and vectorizing them; the paper reports the cost of memory movement cut by 2.7x that way (Tang et al., MLSys 2022, abstract). The middle technique, grouping, is what the rest of this concept builds up.
هذان الصفّان المتقطعان هما الثمن. ضُرب صفّا أصفار بلا فائدة كي تصبح خمسة تشغيلات matmul تشغيلين فقط. هذه هي فكرة المفهوم كلها، والورقة تسمّيها في عنوان الشريحة: مقايضة الحساب بالانتظام (trading computation for regularity). تعرض النظرة العامة في الشريحة 101 ثلاث تقنيات: locality-aware gather، وadaptive grouping (التجميع التكيفي) لعمليات الـ matmul، وlocality-aware scatter-accumulate. الأولى والأخيرة تعالجان النصف المحدود بالذاكرة من زمن التشغيل بقراءة صفوف الخصائص وكتابتها بترتيب يُبقي عمليات الوصول المتجاورة قريبة من بعضها، وبدمجها وتحويلها إلى عمليات متجهة (vectorizing)، وتذكر الورقة أن كلفة نقل الذاكرة انخفضت بذلك بمقدار 2.7x (Tang et al., MLSys 2022، الملخص). أما التقنية الوسطى، التجميع، فهي ما يبنيه باقي هذا المفهوم.
The spectrum: separate, dense, groupedالطيف: منفصل، كثيف، مجمّع
Slides 102 to 104 draw seven weight offsets as seven columns of unequal height, one row per map entry, and put each execution strategy on two sliders: computation overhead and computation regularity. Separate computation, the baseline of the previous concept, launches one mm per column. Nothing is padded, so its overhead slider sits at best, but seven uneven kernels put its regularity at worst: many kernel calls, low device utilization. Dense convolution goes to the other end. Pad every column up to the tallest and run a single bmm with batch 7. Regularity is perfect, one launch, but the dashed rows now outnumber the real ones in the short columns, and overhead sits at worst. Computation with grouping refuses both extremes. The tallest column keeps its own mm. The four columns of similar height are padded by a total of two rows and run as one bmm with batch 4. The two shortest, equal already, form a bmm with batch 2. Slide 104 counts the cost: extra computation of 2 / 28, about 7 percent, for cutting seven launches to three.
ترسم الشرائح من 102 إلى 104 سبع إزاحات وزن على شكل سبعة أعمدة غير متساوية الارتفاع، صف لكل مدخل في الـ map، وتضع كل استراتيجية تنفيذ على مؤشرين: كلفة الحساب الإضافية (computation overhead) وcomputation regularity (انتظام الحساب). الحساب المنفصل، وهو خط الأساس في المفهوم السابق، يطلق عملية mm واحدة لكل عمود. لا شيء محشو، فمؤشر الكلفة الإضافية عنده في الأفضل، لكن سبعة kernels غير متساوية تضع انتظامه في الأسوأ: استدعاءات kernel كثيرة واستغلال منخفض للجهاز. الالتفاف الكثيف يذهب إلى الطرف الآخر: احشُ كل عمود حتى ارتفاع أطولها وشغّل عملية bmm واحدة بـ batch 7. الانتظام مثالي، تشغيل واحد، لكن الصفوف المتقطعة صارت أكثر من الحقيقية في الأعمدة القصيرة، والكلفة الإضافية في الأسوأ. أما الحساب مع التجميع فيرفض الطرفين. يحتفظ العمود الأطول بعملية mm خاصة به. تُحشى الأعمدة الأربعة المتقاربة في الارتفاع بصفّين إجمالًا وتعمل كعملية bmm واحدة بـ batch 4. والعمودان الأقصر، المتساويان أصلًا، يشكّلان bmm بـ batch 2. تحسب الشريحة 104 الكلفة: حساب إضافي قدره 2 / 28، أي نحو 7%، مقابل خفض سبعة تشغيلات إلى ثلاثة.
| Strategyالاستراتيجية | Kernel launchesتشغيلات الـ kernel | Padded rowsصفوف الحشو | Computation overheadكلفة الحساب الإضافية | Computation regularityانتظام الحساب |
|---|---|---|---|---|
| Separate computationالحساب المنفصل | 77 | 00 | Best (none)الأفضل (لا شيء) | Worst (many tiny kernels)الأسوأ (kernels صغيرة كثيرة) |
| Dense convolutionالالتفاف الكثيف | 11 | Every column padded to the tallestكل عمود محشو حتى ارتفاع أطولها | Worstالأسوأ | Best (one bmm, batch 7)الأفضل (bmm واحدة، batch 7) |
| Computation with groupingالحساب مع التجميع | 33 | 2 pad rows in the batch-4 group (2 / 28)صفّا حشو في المجموعة ذات batch 4 (2 / 28) | Smallصغيرة | High (mm, bmm x4, bmm x2)مرتفع (mm، bmm x4، bmm x2) |
How the groups are chosenكيف تُختار المجموعات
Grouping only pays when the columns in a group really are similar, so the question becomes how similar is similar enough. TorchSparse answers with two auto-tuned parameters. The first, epsilon, is the tolerance of redundant computation. Walk the offsets in kernel order and scan them once with two pointers, extending the current group while the redundant computation ratio stays at or below epsilon and starting a new group the moment adding the next offset would exceed it (Tang et al., MLSys 2022, section 4.2.3). The groups are therefore contiguous runs of weight indices, which is why the red boxes on slide 105 sit side by side along the weight axis; the tuner below and the slide 104 figure instead order the offsets by map size first, a simplification that makes the pad rows easier to see.
لا يفيد التجميع إلا إذا كانت الأعمدة داخل المجموعة متشابهة فعلًا، فيصبح السؤال: ما مقدار التشابه الكافي؟ يجيب TorchSparse بمعاملين يُضبطان آليًا. الأول، epsilon، هو حد التسامح مع الحساب الزائد. امشِ على الإزاحات بترتيب الـ kernel وامسحها مرة واحدة بمؤشرين (two pointers)، فتمدّ المجموعة الحالية ما دامت redundant computation ratio (نسبة الحساب الزائد) أقل من epsilon أو مساوية لها، وتبدأ مجموعة جديدة في اللحظة التي تتجاوزها فيها إضافة الإزاحة التالية (Tang et al., MLSys 2022، القسم 4.2.3). لذلك تكون المجموعات سلاسل متصلة من أرقام الأوزان، وهذا سبب ظهور المربعات الحمراء في الشريحة 105 متجاورة على محور الأوزان؛ أما أداة الضبط أدناه وشكل الشريحة 104 فيرتّبان الإزاحات حسب حجم الـ map أولًا، وهو تبسيط يجعل صفوف الحشو أسهل رؤية.
The second parameter, S, is a workload threshold. A group runs as bmm only if its largest map is below S; otherwise it runs as mm, because bmm improves device utilization for small workloads but has little benefit once a single matmul is already large enough to fill the GPU. The two knobs contain the whole spectrum as special cases: epsilon = 1 with S unbounded is dense convolution, S = 0 is separate computation, and epsilon = 0 with S unbounded is what the paper calls symmetric grouping. That last case is free: for an odd kernel size at stride 1 the map for offset (a, b, c) has exactly the same size as the map for (-a, -b, -c), since every pair of neighbours appears once in each direction, so 26 offsets collapse into 13 groups of two with no padding at all, worth up to about 1.2x (Tang et al., MLSys 2022, section 4.2.2).
المعامل الثاني، S، عتبة لحجم العمل. لا تعمل المجموعة كـ bmm إلا إذا كان أكبر map فيها أقل من S؛ وإلا تعمل كـ mm، لأن bmm يحسّن استغلال الجهاز في الأحمال الصغيرة لكن فائدته ضئيلة حين تكون عملية matmul واحدة كبيرة بما يكفي لملء الـ GPU. يحتوي هذان المقبضان الطيف كله كحالات خاصة: epsilon = 1 مع S بلا حد هو الالتفاف الكثيف، وS = 0 هو الحساب المنفصل، وepsilon = 0 مع S بلا حد هو ما تسمّيه الورقة التجميع المتماثل (symmetric grouping). وهذه الحالة الأخيرة مجانية: مع kernel فردي الحجم وstride 1، يكون حجم الـ map للإزاحة (a, b, c) مساويًا تمامًا لحجم الـ map للإزاحة (-a, -b, -c)، لأن كل زوج من الجيران يظهر مرة في كل اتجاه، فتنضغط 26 إزاحة إلى 13 مجموعة من اثنتين دون أي حشو، بتسريع يصل إلى نحو 1.2x (Tang et al., MLSys 2022، القسم 4.2.2).
Worked exampleمثال محلول
Nine offsets on a 100-point cloudتسع إزاحات على سحابة من 100 نقطة
Map sizesأحجام الـ maps
N = 100 points, stride 1, so W(0,0) maps all 100. Symmetric pairs share sizes: W(-1,0) = W(1,0) = 40, W(0,-1) = W(0,1) = 38, W(-1,-1) = W(1,1) = 12, W(-1,1) = W(1,-1) = 11. Real rows: 100 + 2(40 + 38 + 12 + 11) = 302.N = 100 نقطة وstride 1، لذلك يغطي W(0,0) النقاط الـ 100 كلها. الأزواج المتماثلة تتشارك الأحجام: W(-1,0) = W(1,0) = 40، وW(0,-1) = W(0,1) = 38، وW(-1,-1) = W(1,1) = 12، وW(-1,1) = W(1,-1) = 11. الصفوف الحقيقية: 100 + 2(40 + 38 + 12 + 11) = 302.Separate computationالحساب المنفصل
Nine launches, 302 rows computed, zero pad rows, overhead 0 percent.تسعة تشغيلات، و302 صف محسوب، وصفر صفوف حشو، وكلفة إضافية 0%.Dense convolutionالالتفاف الكثيف
One bmm of batch 9 with every offset padded to 100: 900 rows computed, 598 of them pad, overhead 598 / 900 = 66.4 percent. The redundant ratio is 1 - 302 / 900, the same number.عملية bmm واحدة بـ batch 9 مع حشو كل إزاحة حتى 100: 900 صف محسوب، منها 598 صف حشو، والكلفة الإضافية 598 / 900 = 66.4%. ونسبة الحساب الزائد هي 1 - 302 / 900، وهي الرقم نفسه.Adaptive grouping with epsilon 0.05 and S = 50التجميع التكيفي مع epsilon = 0.05 وS = 50
W(0,0) exceeds S, so it runs alone as mm: 100 rows. Group A {40, 40, 38, 38} padded to 40: 160 rows, 4 pad, ratio 1 - 156 / 160 = 0.025. Adding a 12 would push the ratio to 0.16, so a new group starts. Group B {12, 12, 11, 11} padded to 12: 48 rows, 2 pad, ratio 0.042.W(0,0) يتجاوز S، لذلك يعمل وحده كـ mm: 100 صف. المجموعة A {40, 40, 38, 38} محشوة حتى 40: 160 صفًا، منها 4 حشو، والنسبة 1 - 156 / 160 = 0.025. إضافة 12 سترفع النسبة إلى 0.16، لذلك تبدأ مجموعة جديدة. المجموعة B {12, 12, 11, 11} محشوة حتى 12: 48 صفًا، منها 2 حشو، والنسبة 0.042.Three launches for two percentثلاثة تشغيلات مقابل اثنين بالمئة
3 launches, 308 rows computed, 6 pad rows, overhead 6 / 308 = 1.9 percent. Nine launches shrink to three at a cost that rounds to nothing.3 تشغيلات، و308 صفوف محسوبة، و6 صفوف حشو، وكلفة إضافية 6 / 308 = 1.9%. تنكمش تسعة تشغيلات إلى ثلاثة بكلفة تكاد تُقرّب إلى لا شيء.
| Strategyالاستراتيجية | Launchesالتشغيلات | Rows computedالصفوف المحسوبة | Pad rowsصفوف الحشو | Overheadالكلفة الإضافية |
|---|---|---|---|---|
| Separate (one mm per offset)منفصل (mm واحدة لكل إزاحة) | 99 | 302302 | 00 | 0%0% |
| Dense (one bmm, batch 9, padded to 100)كثيف (bmm واحدة، batch 9، محشو حتى 100) | 11 | 900900 | 598598 | 66.4%66.4% |
| Adaptive (epsilon 0.05, S = 50)تكيفي (epsilon 0.05، S = 50) | 33 | 308308 | 66 | 1.9%1.9% |
Try the knobs yourself. The tuner below starts from exactly this example, and rerolling draws new map sizes so you can watch which groups form as epsilon and S move.
جرّب المقابض بنفسك. تبدأ أداة الضبط أدناه من هذا المثال بالضبط، وإعادة السحب (reroll) ترسم أحجام maps جديدة كي ترى أي المجموعات تتشكل مع تحريك epsilon وS.
- mm100
- bmm x440, 40, 38, 38 +4 pad+4 حشو
- bmm x412, 12, 11, 11 +2 pad+2 حشو
The tuner sorts the offsets by map size for clarity; the paper's Algorithm 4 scans them in kernel order. Either way the scan is a single pass. A new group starts whenever adding the next offset would push the redundant computation ratio, 1 minus real rows over computed rows, above epsilon. Any offset whose map is larger than S runs alone as a plain mm, because batching only helps small workloads. Dashed teal blocks are pad rows: real multiplications on zero rows, bought to turn several launches into one. The time model is a teaching device, not a measurement; the shape it produces (zero padding is not the optimum, and neither is one group) is what slide 105 measured on a real GPU.يرتب الضابط الإزاحات حسب حجم الخريطة للوضوح، أما الخوارزمية 4 في الورقة فتمسحها بترتيب النواة. وفي الحالتين يكون المسح مرورًا واحدًا. تبدأ مجموعة جديدة كلما كانت إضافة الإزاحة التالية سترفع نسبة الحساب الزائد، أي 1 ناقص الصفوف الحقيقية على الصفوف المحسوبة، فوق epsilon. وأي إزاحة خريطتها أكبر من S تعمل وحدها كعملية mm عادية، لأن التجميع في دفعات لا يفيد إلا أحمال العمل الصغيرة. الكتل الزرقاء المخضرة المتقطعة هي صفوف حشو: عمليات ضرب حقيقية على صفوف صفرية، ندفع ثمنها لنحول عدة إطلاقات إلى إطلاق واحد. نموذج الزمن أداة تعليمية وليس قياسًا، لكن الشكل الذي ينتجه (الحشو الصفري ليس الأمثل، ولا المجموعة الواحدة كذلك) هو ما قاسته الشريحة 105 على GPU حقيقية.
Measured: neither zero padding nor one group winsبالقياس: لا الحشو الصفري يفوز ولا المجموعة الواحدة
Slide 105 is the experiment that settles the question. On the first sparse convolution layer of MinkUNet on SemanticKITTI, the paper sweeps the number of groups from 26 (no padding, the separate baseline at 1.0x) down to 1 (fully dense). Going from 26 to 13 groups gives about 1.2x, the symmetric pairing. At 6 groups the speedup peaks near 1.5x. Then it collapses: 3 groups fall below the baseline and 1 group runs at about 0.35x, worse than doing nothing. The slide annotates the two slopes as increasing regularity helps improve latency, then padding overhead hurts latency (Tang et al., MLSys 2022, Figure 7).
الشريحة 105 هي التجربة التي تحسم السؤال. على أول طبقة التفاف متناثر في MinkUNet على SemanticKITTI، تمسح الورقة عدد المجموعات من 26 (بلا حشو، أي خط الأساس المنفصل عند 1.0x) نزولًا إلى 1 (كثيف بالكامل). الانتقال من 26 إلى 13 مجموعة يعطي نحو 1.2x، وهو الاقتران المتماثل. عند 6 مجموعات يبلغ التسريع ذروته قرب 1.5x. ثم ينهار: 3 مجموعات تهبط تحت خط الأساس، ومجموعة واحدة 1 تعمل بنحو 0.35x، أي أسوأ من عدم فعل أي شيء. تعلّق الشريحة على المنحدرين بأن زيادة الانتظام تحسّن زمن الاستجابة (latency)، ثم كلفة الحشو تضرّ به (Tang et al., MLSys 2022، الشكل 7).
The two bar charts under the curve explain why the answer is adaptive rather than fixed. They plot map size against weight index 1 to 27 for a MinkUNet layer on two datasets, with red boxes marking the groups the tuner chose. SemanticKITTI maps are large, mostly in the thousands, and the boxes are narrow: 10 groups. nuScenes maps are an order of magnitude smaller, hundreds rather than thousands, so each launch is even less able to fill the GPU and the tuner groups more aggressively: 8 groups with wider boxes (Tang et al., MLSys 2022, Figure 12). The right amount of padding is a property of the data, which is why it is searched per model and per dataset instead of fixed in code.
يشرح المخططان العموديان تحت المنحنى لماذا الجواب تكيفي لا ثابت. يرسمان حجم الـ map مقابل رقم الوزن من 1 إلى 27 لطبقة من MinkUNet على مجموعتي بيانات، مع مربعات حمراء تحدد المجموعات التي اختارتها أداة الضبط. الـ maps في SemanticKITTI كبيرة، معظمها بالآلاف، والمربعات ضيقة: 10 مجموعات. أما في nuScenes فالـ maps أصغر بمرتبة عشرية، بالمئات لا بالآلاف، فيكون كل تشغيل أقل قدرة على ملء الـ GPU، وتجمّع أداة الضبط بشكل أشد: 8 مجموعات بمربعات أعرض (Tang et al., MLSys 2022، الشكل 12). القدر الصحيح من الحشو خاصية من خصائص البيانات، ولهذا يُبحث عنه لكل نموذج ولكل مجموعة بيانات بدل أن يُثبَّت في الكود.
Recall
What do epsilon and S control in adaptive grouping?بماذا يتحكم epsilon وS في التجميع التكيفي؟
Quick checkاختبار سريع
In adaptive grouping, what happens when you raise the tolerance epsilon?في التجميع التكيفي، ماذا يحدث عندما ترفع حد التسامح epsilon؟
Slides 106 and 107 isolate the matmul phase and ask a sharp question: on an RTX 2080 Ti in FP16, how much did grouping actually buy? Three strategies are compared, the separate baseline, a fixed grouping with three hand-made groups per layer type padded to their maximum, and adaptive grouping. Each is reported twice, as throughput in TFLOP/s and as normalized speedup, and the two columns disagree in an instructive way.
تعزل الشريحتان 106 و107 مرحلة الـ matmul وتطرحان سؤالًا حادًا: على RTX 2080 Ti بدقة FP16، كم كسب التجميع فعلًا؟ تُقارَن ثلاث استراتيجيات: خط الأساس المنفصل، وتجميع ثابت (fixed grouping) بثلاث مجموعات مصنوعة يدويًا لكل نوع طبقة ومحشوة حتى حدها الأقصى، وadaptive grouping (التجميع التكيفي). تُعرض كل واحدة مرتين، كإنتاجية بوحدة TFLOP/s وكتسريع منسوب (normalized speedup)، والعمودان يختلفان بطريقة مفيدة للفهم.
| Datasetمجموعة البيانات | Strategyالاستراتيجية | TFLOP/sTFLOP/s | Normalized speedupالتسريع المنسوب |
|---|---|---|---|
| SemanticKITTISemanticKITTI | Baseline (separate)خط الأساس (منفصل) | 8.18.1 | 1.00x1.00x |
| SemanticKITTISemanticKITTI | Fixed groupingتجميع ثابت | 8.78.7 | 0.87x0.87x |
| SemanticKITTISemanticKITTI | Adaptive groupingتجميع تكيفي | 11.911.9 | 1.39x1.39x |
| nuScenesnuScenes | Baseline (separate)خط الأساس (منفصل) | 10.410.4 | 1.00x1.00x |
| nuScenesnuScenes | Fixed groupingتجميع ثابت | 21.121.1 | 1.50x1.50x |
| nuScenesnuScenes | Adaptive groupingتجميع تكيفي | 16.916.9 | 1.54x1.54x |
On SemanticKITTI (MinkUNet 0.5x) adaptive grouping lifts throughput from 8.1 to 11.9 TFLOP/s and finishes 1.39x faster. Fixed grouping is the trap: it posts a higher throughput than the baseline, 8.7 TFLOP/s, yet is slower, 0.87x. On nuScenes (MinkUNet, three frames) the trap is sharper still. Fixed grouping reaches the best throughput of the whole table, 21.1 TFLOP/s, and adaptive grouping only 16.9, yet adaptive is the faster of the two at 1.54x against 1.50x. Slide 107 gives the reason in one line: fixed grouping introduced a large amount of redundant computation. TFLOP/s counts every multiply the tensor cores performed, pad rows included. A strategy can therefore look excellent on throughput while spending that throughput on zeros. Latency counts only the clock, and the paper's caption puts it precisely: as we trade FLOPs for regularity, TFLOP/s and speedup are non-proportional (Tang et al., MLSys 2022, Table 2). Device utilization for the matmul phase rose from about 30 percent to 44.2 percent with adaptive grouping.
على SemanticKITTI (MinkUNet 0.5x) يرفع التجميع التكيفي الإنتاجية من 8.1 إلى 11.9 TFLOP/s وينتهي أسرع بمقدار 1.39x. التجميع الثابت هو الفخ: يسجّل إنتاجية أعلى من خط الأساس، 8.7 TFLOP/s، ومع ذلك هو أبطأ، 0.87x. وعلى nuScenes (MinkUNet، ثلاثة إطارات) يصبح الفخ أوضح. يصل التجميع الثابت إلى أعلى إنتاجية في الجدول كله، 21.1 TFLOP/s، والتجميع التكيفي إلى 16.9 فقط، ومع ذلك فالتكيفي هو الأسرع بين الاثنين، 1.54x مقابل 1.50x. تعطي الشريحة 107 السبب في سطر واحد: التجميع الثابت أدخل كمية كبيرة من الحساب الزائد. فـ TFLOP/s يعدّ كل عملية ضرب نفّذتها الـ tensor cores، بما فيها صفوف الحشو. لذلك قد تبدو استراتيجية ممتازة في الإنتاجية بينما تنفق هذه الإنتاجية على أصفار. أما زمن الاستجابة (latency) فلا يعدّ إلا الساعة، وتعليق الورقة يقولها بدقة: حين نقايض FLOPs بالانتظام، لا يتناسب TFLOP/s مع التسريع (Tang et al., MLSys 2022، الجدول 2). وارتفع استغلال الجهاز في مرحلة الـ matmul من نحو 30% إلى 44.2% مع التجميع التكيفي.
End to end, with locality-aware gather and scatter included, the paper reports 1.6x over MinkowskiEngine and 1.5x over SpConv across seven models and three datasets, measured on GTX 1080 Ti, RTX 2080 Ti and RTX 3090, with up to 2.16x on segmentation models over MinkowskiEngine on the RTX 3090 (Tang et al., MLSys 2022, abstract and section 5). These figures are not on the slides; the slides show only the matmul ablation, so quote them as the paper's, and note that the MLSys 2022 evaluation used desktop GPUs only. The edge numbers come with the successor.
من البداية إلى النهاية (end to end)، ومع احتساب gather وscatter المراعيين للمحلية، تذكر الورقة تسريعًا 1.6x مقارنة بـ MinkowskiEngine و1.5x مقارنة بـ SpConv عبر سبعة نماذج وثلاث مجموعات بيانات، مقيسًا على GTX 1080 Ti وRTX 2080 Ti وRTX 3090، ويصل إلى 2.16x في نماذج التقطيع (segmentation) مقارنة بـ MinkowskiEngine على RTX 3090 (Tang et al., MLSys 2022، الملخص والقسم 5). هذه الأرقام ليست في الشرائح؛ فالشرائح تعرض تجربة الـ matmul فقط، لذلك انسبها إلى الورقة عند ذكرها، ولاحظ أن تقييم MLSys 2022 استخدم بطاقات GPU مكتبية فقط. أرقام الأجهزة الطرفية تأتي مع الخلف.
Recall
Fixed grouping reached 21.1 TFLOP/s on nuScenes and adaptive grouping only 16.9. Which was faster, and why?وصل التجميع الثابت إلى 21.1 TFLOP/s على nuScenes والتجميع التكيفي إلى 16.9 فقط. أيهما كان أسرع، ولماذا؟
Quick checkاختبار سريع
On nuScenes, fixed grouping posted the highest TFLOP/s yet adaptive grouping finished faster. Why?على nuScenes، سجّل التجميع الثابت أعلى TFLOP/s ومع ذلك أنهى التجميع التكيفي أسرع. لماذا؟
TorchSparse++: overlap memory with computationTorchSparse++: تداخل الذاكرة مع الحساب
Grouping fixed the matmul phase, but the baseline still has a structural flaw that no grouping removes: the three phases of gather, matmul and scatter run one after another. Gather must finish before the matmul starts, and the matmul must finish before scatter starts, three separate CUDA kernel calls in each iteration of the host loop. While the memory system is busy gathering, the tensor cores wait; while the tensor cores multiply, the memory system idles. The MICRO 2023 paper calls gather-GEMM-scatter fundamentally inefficient due to the lack of overlap between computation and memory access (Tang, Yang et al., MICRO 2023, section 2.2). The remedy in TorchSparse++ is to stop treating the phases as separate kernels.
أصلح التجميع مرحلة الـ matmul، لكن خط الأساس ما زال فيه عيب بنيوي لا يزيله أي تجميع: المراحل الثلاث gather, matmul and scatter تعمل واحدة بعد الأخرى. يجب أن تنتهي gather قبل أن تبدأ matmul، ويجب أن تنتهي matmul قبل أن تبدأ scatter، أي ثلاثة استدعاءات CUDA kernel منفصلة في كل دورة من حلقة المضيف (host loop). وبينما نظام الذاكرة مشغول بالجمع، تنتظر الـ tensor cores؛ وبينما تضرب الـ tensor cores، يبقى نظام الذاكرة خاملًا. تصف ورقة MICRO 2023 أسلوب gather-GEMM-scatter بأنه غير فعال جوهريًا بسبب غياب التداخل بين الحساب والوصول إلى الذاكرة (Tang, Yang et al., MICRO 2023، القسم 2.2). والعلاج في TorchSparse++ هو التوقف عن معاملة المراحل كـ kernels منفصلة.
Two fused dataflows already existed in other engines, and TorchSparse++ builds on both. Fetch-on-demand, used by MinkowskiEngine, merges gather, multiply and scatter into a single kernel that loads only the input rows it needs straight into shared memory, multiplies on chip and scatters results from registers, with zero redundant computation but heavy output write traffic, 4x to 10x more than the theoretical minimum of one write per output row, since each point has 4 to 10 neighbours and every partial sum is written back individually. Implicit GEMM, used by SpConv v2, is output-stationary: each thread block owns a tile of output rows, walks the nine (or 27) weights, and fetches the matching input rows on demand, the way im2col does for dense convolution. It writes each output once and hides memory latency by pipelining, so the loads for the next tile are already in flight while the tensor cores work on the current tile (Tang, Yang et al., MICRO 2023, section 2.2 and Figure 3). That in-kernel double buffering is the overlap the slide title refers to.
كان هناك أصلًا مساران مدمجان للبيانات (fused dataflows) في محركات أخرى، ويبني TorchSparse++ على كليهما. الأول fetch-on-demand (الجلب عند الطلب)، ويستخدمه MinkowskiEngine، ويدمج gather والضرب وscatter في kernel واحد يحمّل صفوف الإدخال التي يحتاجها فقط مباشرة إلى الذاكرة المشتركة (shared memory)، ويضرب على الشريحة، ويوزّع النتائج من المسجلات (registers)، بلا أي حساب زائد لكن مع حركة كتابة ثقيلة للإخراج، أكثر بـ 4x إلى 10x من الحد الأدنى النظري وهو كتابة واحدة لكل صف إخراج، لأن لكل نقطة من 4 إلى 10 جيران وكل مجموع جزئي يُكتب وحده. والثاني Implicit GEMM، ويستخدمه SpConv v2، وهو output-stationary (الإخراج ثابت): كل thread block يملك قطعة (tile) من صفوف الإخراج، ويمرّ على الأوزان التسعة (أو 27)، ويجلب صفوف الإدخال المطابقة عند الطلب، كما يفعل im2col في الالتفاف الكثيف. يكتب كل إخراج مرة واحدة ويخفي تأخر الذاكرة بالتنفيذ المتتابع (pipelining)، بحيث تكون عمليات تحميل القطعة التالية جارية بالفعل بينما تعمل الـ tensor cores على القطعة الحالية (Tang, Yang et al., MICRO 2023، القسم 2.2 والشكل 3). هذا التخزين المزدوج داخل الـ kernel (double buffering) هو التداخل الذي يشير إليه عنوان الشريحة.
| Dataflowمسار البيانات | Stationaryالثابت | Kernel structureبنية الـ kernel | Memory and computeالذاكرة والحساب | Redundant computationالحساب الزائد |
|---|---|---|---|---|
| Gather-GEMM-scatterGather-GEMM-scatter | Weightالوزن | Three kernels per offset, vendor GEMMثلاثة kernels لكل إزاحة، وGEMM من مكتبة المصنّع | No overlap between memory access and computeلا تداخل بين الوصول إلى الذاكرة والحساب | Zeroصفر |
| Fetch-on-demandFetch-on-demand | Weight (fused per offset)الوزن (مدمج لكل إزاحة) | One fused kernel, rows fetched into shared memorykernel واحد مدمج، تُجلب فيه الصفوف إلى الذاكرة المشتركة (shared memory) | Loads overlap with on-chip multiplyعمليات التحميل تتداخل مع الضرب على الشريحة | Zero, but 4x to 10x more output writesصفر، لكن مع كتابات إخراج أكثر بـ 4x إلى 10x |
| Implicit GEMMImplicit GEMM | Outputالإخراج | One fused kernel, im2col style, pipelined tileskernel واحد مدمج، على طريقة im2col، بقطع (tiles) متتابعة التنفيذ | Loads for the next tile overlap the current oneعمليات تحميل القطعة التالية تتداخل مع القطعة الحالية | Lockstep redundancy inside each warpتكرار ناتج عن التنفيذ المتزامن (lockstep) داخل كل warp |
The catch with implicit GEMM is a new kind of redundancy, and slide 109 shows it. Rows are output points B0 to B7, columns are the nine weights, and a grey cell is a real multiply because the input neighbour A_j exists. Threads in a warp execute in lockstep, so if any row in a thread block needs a weight, every row in that block runs it. The red cells are those wasted lockstep multiplies: 12 in the vanilla layout. Row reordering sorts the outputs by their neighbour bitmask so rows with similar patterns share a block, cutting the count to 10. Column splitting then divides the loop over the nine weights into three parts, each sorted on its own, so a row is grouped with different neighbours for different weight subsets: 8. The paper's own example runs 34 to 26 to 22 multiplies and reports that bitmask sorting can cut redundancy by up to 3x (Tang, Yang et al., MICRO 2023, Figures 5, 6 and 10). The fused kernel keeps its overlap; these two reorderings trim what it pays for it.
المشكلة في implicit GEMM نوع جديد من التكرار، والشريحة 109 تعرضه. الصفوف هي نقاط الإخراج من B0 إلى B7، والأعمدة هي الأوزان التسعة، والخلية الرمادية عملية ضرب حقيقية لأن الجار A_j في الإدخال موجود. الـ threads في الـ warp تنفّذ بخطوة متزامنة (lockstep)، فإذا احتاج أي صف في الـ thread block وزنًا ما، نفّذه كل صف في ذلك الـ block. الخلايا الحمراء هي عمليات الضرب المهدرة بسبب التزامن: 12 في الترتيب الأصلي (vanilla). إعادة ترتيب الصفوف (row reordering) ترتّب الإخراج حسب قناع الجيران (bitmask) بحيث تتشارك الصفوف ذات الأنماط المتشابهة block واحدًا، فينخفض العدد إلى 10. ثم يقسم تقسيم الأعمدة (column splitting) الحلقة على الأوزان التسعة إلى ثلاثة أجزاء، كل جزء مرتّب وحده، فيُجمع الصف مع جيران مختلفين لمجموعات أوزان مختلفة: 8. ومثال الورقة نفسها ينتقل من 34 إلى 26 إلى 22 عملية ضرب، وتذكر أن الترتيب بالـ bitmask قد يخفض التكرار حتى 3x (Tang, Yang et al., MICRO 2023، الأشكال 5 و6 و10). يحتفظ الـ kernel المدمج بتداخله، وهاتان الطريقتان في إعادة الترتيب تقلّصان ما يدفعه ثمنًا لذلك.
Writing such kernels by hand is expensive. SpConv v2 needed more than 40,000 lines re-implementing CUTLASS. TorchSparse++ therefore contributes two components, both drawn on slide 108. The Sparse Kernel Generator produces the fused, pipelined kernels automatically at under a tenth of that engineering cost, adapting dense GEMM templates to sparse gather (dense-to-sparse adaptation) and static shapes to run-time maps (static-to-dynamic adaptation). The Sparse Autotuner widens the design space (gather-GEMM-scatter with grouping, fetch-on-demand, implicit GEMM, and their tile and split parameters) and tunes a configuration per group of layers rather than per layer, so the search stays cheap (Tang, Yang et al., MICRO 2023, sections 3 and 4).
كتابة مثل هذه الـ kernels يدويًا مكلفة. احتاج SpConv v2 إلى أكثر من 40,000 سطر لإعادة تنفيذ CUTLASS. لذلك يقدّم TorchSparse++ مكوّنين، كلاهما مرسوم في الشريحة 108. الأول Sparse Kernel Generator (مولّد الـ kernels المتناثرة)، وينتج الـ kernels المدمجة المتتابعة آليًا بأقل من عُشر تلك الكلفة الهندسية، بتكييف قوالب GEMM الكثيفة مع الجمع المتناثر (dense-to-sparse adaptation) وتكييف الأشكال الثابتة مع الـ maps التي تُبنى وقت التشغيل (static-to-dynamic adaptation). والثاني Sparse Autotuner (الضابط الآلي المتناثر)، ويوسّع فضاء التصميم (gather-GEMM-scatter مع التجميع، وfetch-on-demand، وimplicit GEMM، ومعاملات الـ tile والتقسيم الخاصة بها) ويضبط إعدادًا لكل مجموعة من الطبقات لا لكل طبقة، كي يبقى البحث رخيصًا (Tang, Yang et al., MICRO 2023، القسمان 3 و4).
| GPUGPU | MinkowskiEngineMinkowskiEngine | SpConv 1.2.1SpConv 1.2.1 | TorchSparseTorchSparse | SpConv 2.3.5SpConv 2.3.5 | TorchSparse++TorchSparse++ |
|---|---|---|---|---|---|
| A100A100 | 0.340.34 | 0.300.30 | 0.450.45 | 0.600.60 | 1.001.00 |
| Jetson OrinJetson Orin | 0.190.19 | 0.290.29 | 0.400.40 | 0.800.80 | 1.001.00 |
Reading the A100 column the other way round, TorchSparse++ is 2.9x faster than MinkowskiEngine, 3.3x faster than SpConv 1.2.1, 2.2x faster than TorchSparse and 1.7x faster than SpConv 2.3.5, the four numbers the paper's abstract reports. The Orin column is the one that matters for this course: on the Jetson Orin edge GPU, the strongest baseline, SpConv 2.3.5, sits at 0.80, so TorchSparse++ is 1.25x faster on average, with a consistent 1.3x to 1.4x on detection workloads (Tang, Yang et al., MICRO 2023, section 5). The chart also shows training columns and a TF32 column; the same engine covers all of them.
بقراءة أرقام A100 بالاتجاه المعاكس، يكون TorchSparse++ أسرع بمقدار 2.9x من MinkowskiEngine، و3.3x من SpConv 1.2.1، و2.2x من TorchSparse، و1.7x من SpConv 2.3.5، وهي الأرقام الأربعة التي يذكرها ملخص الورقة. وأرقام Orin هي المهمة لهذا المقرر: على الـ GPU الطرفي Jetson Orin، يقف أقوى خط أساس، SpConv 2.3.5، عند 0.80، فيكون TorchSparse++ أسرع بمقدار 1.25x في المتوسط، مع تسريع ثابت من 1.3x إلى 1.4x في أحمال الكشف (detection) (Tang, Yang et al., MICRO 2023، القسم 5). ويعرض المخطط أيضًا أعمدة للتدريب وعمودًا لـ TF32؛ والمحرك نفسه يغطيها كلها.
One more step remains beyond software. Every engine in this part still spends time building the maps themselves, a hashing or sorting problem the GPU is not shaped for. Part 13 moves that step into hardware with PointAcc, whose mapping unit produces the tuples with merge sort.
تبقى خطوة أخرى أبعد من البرمجيات. كل محرك في هذا الجزء ما زال يقضي وقتًا في بناء الـ maps نفسها، وهي مسألة hashing أو ترتيب لم يُصمَّم الـ GPU لها. ينقل الجزء 13 هذه الخطوة إلى العتاد مع PointAcc، الذي تنتج وحدة الربط (mapping unit) فيه الثلاثيات باستخدام merge sort.
Recall
What does TorchSparse++ overlap, and with which two components?ما الذي يجعله TorchSparse++ متداخلًا، وبأي مكوّنين؟
Quick checkاختبار سريع
What does TorchSparse++ change about the three phases?ما الذي يغيّره TorchSparse++ في المراحل الثلاث؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- The baseline runs gather, matmul and scatter once per weight offset: 27 offsets in 3D, each a separate small kernel.يشغّل خط الأساس (baseline) مراحل gather وmatmul وscatter مرة واحدة لكل إزاحة وزن: 27 إزاحة في الحالة ثلاثية الأبعاد، كل منها kernel صغير مستقل.
- Gather and scatter are memory-bandwidth bound (40 to 50 percent of runtime); the matmuls are dense but tiny and uneven (about 30 percent utilization).مرحلتا gather وscatter محدودتان بعرض نطاق الذاكرة (40 إلى 50 بالمئة من زمن التشغيل)، أما عمليات matmul فكثيفة لكنها صغيرة وغير متساوية (استغلال نحو 30 بالمئة).
- Padding offsets of similar size into one batched matmul trades FLOPs for regularity; dense batching pads everything and loses.حشو الإزاحات المتقاربة في الحجم ضمن عملية matmul مجمّعة واحدة (batched) يقايض FLOPs بالانتظام، أما التجميع الكثيف (dense batching) فيحشو كل شيء ويخسر.
- Adaptive grouping scans map sizes with a tolerance epsilon and a threshold S; 6 groups beat both 26 and 1 on SemanticKITTI, about 1.5x.يمسح التجميع التكيفي أحجام الـ maps بحد تسامح epsilon وعتبة S، و6 مجموعات تتفوق على 26 مجموعة وعلى مجموعة واحدة في SemanticKITTI، بتسريع نحو 1.5x.
- Matmul ablation: adaptive grouping 1.39x on SemanticKITTI and 1.54x on nuScenes; fixed grouping can post higher TFLOP/s and still be slower.تجربة الـ ablation للـ matmul: التجميع التكيفي 1.39x على SemanticKITTI و1.54x على nuScenes، والتجميع الثابت قد يسجّل TFLOP/s أعلى ويبقى مع ذلك أبطأ.
- TorchSparse end to end: 1.6x over MinkowskiEngine and 1.5x over SpConv, with 2.7x less memory movement cost.TorchSparse من البداية إلى النهاية (end to end): أسرع بمقدار 1.6x من MinkowskiEngine و1.5x من SpConv، مع كلفة نقل ذاكرة أقل بمقدار 2.7x.
- TorchSparse++ fuses the phases so memory access overlaps computation, generates the kernels automatically and autotunes the dataflow: 2.9x, 3.3x, 2.2x and 1.7x on A100, 1.25x over SpConv v2 on Jetson Orin.يدمج TorchSparse++ المراحل بحيث يتداخل الوصول إلى الذاكرة مع الحساب، ويولّد الـ kernels آليًا، ويضبط الـ dataflow آليًا (autotune): 2.9x و3.3x و2.2x و1.7x على A100، و1.25x أسرع من SpConv v2 على Jetson Orin.
- Row reordering and column splitting cut implicit-GEMM redundancy from 12 to 10 to 8 on the slide's example.إعادة ترتيب الصفوف (row reordering) وتقسيم الأعمدة (column splitting) يخفضان التكرار في implicit GEMM من 12 إلى 10 ثم إلى 8 في مثال الشريحة.
Sourcesالمصادر
- TorchSparse: Efficient Point Cloud Inference EnginePaperProceedings of MLSys 2022, Tang, Liu, Li, Lin and HanSection 3 bottleneck analysis, section 4.2 adaptive grouping with epsilon and S, Table 2 ablation, Figures 7 and 12.تحليل عنق الزجاجة في القسم 3، والتجميع التكيفي مع epsilon وS في القسم 4.2، وتجربة الـ ablation في الجدول 2، والشكلان 7 و12.(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse: Efficient Point Cloud Inference Engine (arXiv abstract)PaperarXiv1.4 to 1.5x matmul speedup, 2.7x lower memory movement cost, 1.6x and 1.5x end to end over MinkowskiEngine and SpConv.تسريع للـ matmul من 1.4x إلى 1.5x، وكلفة نقل ذاكرة أقل بمقدار 2.7x، وتسريع من البداية إلى النهاية 1.6x و1.5x مقارنة بـ MinkowskiEngine وSpConv.(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse++: Efficient Training and Inference Framework for Sparse Convolution on GPUsPaperMICRO 2023, Tang, Yang, Liu, Tang, Zhu, Lu, Ren, Wang, Xu, HanThree dataflows and their overlap (section 2.2, Figure 3), row reordering and column splitting (Figures 5, 6, 10), kernel generator and autotuner, 2.9x, 3.3x, 2.2x, 1.7x on A100 and 1.25x on Jetson Orin.مسارات البيانات الثلاثة وتداخلها (القسم 2.2، الشكل 3)، وإعادة ترتيب الصفوف وتقسيم الأعمدة (الأشكال 5 و6 و10)، ومولّد الـ kernels والضابط الآلي، و2.9x و3.3x و2.2x و1.7x على A100، و1.25x على Jetson Orin.(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse++ (ACM DL record)PaperACM, MICRO 2023Publisher's version of the MICRO 2023 paper.نسخة الناشر من ورقة MICRO 2023.(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse repositoryDocsMIT HAN Lab, GitHubReference implementation of both engines.التنفيذ المرجعي للمحرّكين كليهما.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Fall 2024, Lecture 4: Pruning and Sparsity Part IIDocsMIT HAN LabSource deck for slides 101 to 109, including the 12, 10, 8 redundancy example on slide 109.العرض الأصلي للشرائح من 101 إلى 109، بما فيه مثال التكرار 12 ثم 10 ثم 8 في الشريحة 109.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 Lecture 4 recordingVideoMIT HAN Lab, YouTubeSong Han walks through the TorchSparse slides.يشرح Song Han شرائح TorchSparse خطوة بخطوة.(opens in a new tab)(يفتح في تبويب جديد)
- cuBLAS Strided Batched Matrix MultiplyArticleNVIDIA Developer BlogSmall GEMMs cannot fill the GPU, and sequential launches of many small kernels are slow; the motivation for batched matmul.عمليات GEMM الصغيرة لا تستطيع ملء الـ GPU، وإطلاق kernels صغيرة كثيرة بالتتابع بطيء؛ وهذا هو الدافع إلى الـ matmul المجمّع (batched).(opens in a new tab)(يفتح في تبويب جديد)
- cuBLAS documentation: batched GEMMDocsNVIDIAThe bmm primitive that grouped offsets are executed with.عملية bmm الأساسية التي تُنفَّذ بها الإزاحات المجمّعة.(opens in a new tab)(يفتح في تبويب جديد)
- CUDA C++ Best Practices GuideDocsNVIDIACoalesced memory access and latency hiding, the principles behind locality-aware access and pipelined fused kernels.الوصول المدمج إلى الذاكرة (coalesced) وإخفاء التأخر، وهما المبدآن وراء الوصول المراعي للمحلية والـ kernels المدمجة المتتابعة التنفيذ.(opens in a new tab)(يفتح في تبويب جديد)
Part 13: PointAcc, the lecture summary and referencesPointAcc وملخص المحاضرة والمراجع
PointAcc builds the sparse convolution map in hardware with a merge-sort based mapping unit, then the lecture closes with what was covered and what quantization brings next.يبني PointAcc خريطة الالتفاف المتناثر في العتاد بوحدة ربط قائمة على الفرز بالدمج (merge sort)، ثم تُختتم المحاضرة بما غُطّي وما يقدمه التكميم (quantization) لاحقًا.
4 concepts4 مفاهيم, ، slides 110-115الشرائح 110-115
Why this part mattersلماذا يهمّ هذا الجزء
Every accelerator in this lecture so far assumed the hard part was the multiply. PointAcc is the case where it is not. When the input is a point cloud, the network spends most of its time deciding which inputs multiply which weights, and that decision has to be remade for every frame because the sparsity is in the data. Your embedded work will hit the same wall the moment your inputs stop being dense grids.
افترض كل مسرّع في هذه المحاضرة حتى الآن أن الجزء الصعب هو عملية الضرب. أما PointAcc فهو الحالة التي لا يكون فيها الأمر كذلك. عندما يكون الدخل سحابة نقطية (point cloud)، تقضي الشبكة معظم وقتها في تحديد أي المدخلات يُضرب في أي الأوزان، ويجب إعادة هذا القرار لكل إطار (frame) لأن التناثر موجود في البيانات نفسها. وعملك في الأنظمة المدمجة سيصطدم بالجدار نفسه في اللحظة التي تتوقف فيها مدخلاتك عن كونها شبكات كثيفة (dense grids).
This closing part does three things. It shows how PointAcc turns map construction into a sorting problem the hardware can stream, with the five-point example from slides 111 and 112 worked out to the last tuple. It reads the results slide the way the paper intends, with the right baselines. Then it folds the whole lecture into one table, so that the exam question "which system exploits which sparsity" has a single place to be answered from, and it checks the reference slide against what the deck actually cited.
يقوم هذا الجزء الختامي بثلاثة أشياء. أولًا، يبيّن كيف يحوّل PointAcc بناء الخريطة إلى مسألة فرز يستطيع العتاد معالجتها كتدفق متسلسل (stream)، مع حل مثال النقاط الخمس من الشريحتين 111 و112 حتى آخر ثلاثية. ثانيًا، يقرأ شريحة النتائج كما تقصدها الورقة، مع خطوط الأساس الصحيحة. ثالثًا، يجمع المحاضرة كلها في جدول واحد، بحيث يكون لسؤال الامتحان «أي نظام يستغل أي نوع من التناثر» مكان واحد يُجاب منه، ثم يراجع شريحة المراجع مقابل ما استشهدت به الشرائح فعلًا.
By the end you canفي نهاية هذا الجزء ستستطيع
- Explain why building the (In, Out, Wgt) map dominates point-cloud inference and why a hash table is a poor fit for silicon.اشرح لماذا يستهلك بناء خريطة (In, Out, Wgt) معظم وقت الاستدلال على السحب النقطية (point cloud)، ولماذا لا يناسب جدول التجزئة (hash table) السيليكون.
- Run the shift, merge sort, compare, emit procedure by hand on a five-point cloud and recover the tuples on slides 111 and 112.نفّذ إجراء الإزاحة ثم الفرز بالدمج (merge sort) ثم المقارنة ثم الإخراج يدويًا على سحابة من خمس نقاط، واستخرج الثلاثيات (tuples) نفسها التي في الشريحتين 111 و112.
- Read slide 113 correctly: the three baselines, the geometric means, and why the TPU column swings so widely.اقرأ الشريحة 113 قراءة صحيحة: خطوط الأساس (baselines) الثلاثة، والمتوسطات الهندسية، ولماذا يتأرجح عمود TPU هذا التأرجح الكبير.
- Map every sparsity type of this lecture to the system that exploits it and the granularity it needs.اربط كل نوع من أنواع التناثر (sparsity) في هذه المحاضرة بالنظام الذي يستغله وبالحبيبية (granularity) التي يحتاجها.
- State what the next lecture adds (numeric types, the idea of quantization, its common methods) and spot the references the deck cites but never lists.اذكر ما تضيفه المحاضرة التالية (أنواع البيانات العددية، وفكرة التكميم (quantization)، وطرقه الشائعة)، وحدّد المراجع التي تستشهد بها الشرائح دون أن تدرجها في القائمة.
The roadmap on slide 110 puts PointAcc in the last row, next to TorchSparse, under the heading activation sparsity. Read the row as a pair: TorchSparse is the software answer to sparse inputs, and PointAcc is the hardware answer to the same inputs. Both start from the Sparse convolution of part 11, where a layer is driven by maps of (In, Out, Wgt) tuples and each tuple contributes f_out = f_out + f_in × W_wgt.
خريطة الطريق في الشريحة 110 تضع PointAcc في الصف الأخير، بجانب TorchSparse، تحت عنوان تناثر التفعيلات (activation sparsity). اقرأ الصف كزوج: TorchSparse هو الحل البرمجي للمدخلات المتناثرة، وPointAcc هو الحل العتادي للمدخلات نفسها. وكلاهما ينطلق من الالتفاف المتناثر (sparse convolution) في الجزء 11، حيث تُقاد الطبقة بـخرائط (maps) من ثلاثيات (In, Out, Wgt)، وتساهم كل ثلاثية بـ f_out = f_out + f_in × W_wgt.
What changes between the two is where the time goes. On a GPU, the multiplies are batched into matmuls and run well once the map exists. Building the map is the problem. A point cloud has dynamic sparsity: which coordinates are occupied depends on the scene, so the map cannot be precomputed and must be rebuilt on every input. The PointAcc paper measures that cost on PointNet++-based networks and reports that more than half of the total runtime on general-purpose hardware goes to mapping operations, and that existing neural accelerators simply do not support them, so a TPU has to ship the coordinates back to its host CPU, where data movement then takes 60 to 90 percent of the runtime (Lin et al., 2021, section 3).
ما يتغير بين الاثنين هو أين يذهب الوقت. على GPU، تُجمَّع عمليات الضرب في عمليات ضرب مصفوفات (matmul) وتعمل جيدًا بمجرد وجود الخريطة. المشكلة هي بناء الخريطة. فالسحابة النقطية لها تناثر ديناميكي (dynamic sparsity): الإحداثيات المشغولة تعتمد على المشهد، لذلك لا يمكن حساب الخريطة مسبقًا ويجب إعادة بنائها مع كل دخل. تقيس ورقة PointAcc هذه التكلفة على شبكات مبنية على PointNet++، وتذكر أن أكثر من نصف زمن التشغيل الكلي على العتاد العام يذهب إلى عمليات الربط (mapping)، وأن مسرّعات الشبكات العصبية الحالية لا تدعمها أصلًا، فيضطر TPU إلى إرسال الإحداثيات إلى المعالج المضيف (host CPU)، حيث يستهلك نقل البيانات عندها 60 to 90 percent من زمن التشغيل (Lin et al., 2021, section 3).
The pairing rule, and how to turn it into an equality testقاعدة الاقتران، وكيف نحوّلها إلى اختبار تساوٍ
A 3 × 3 kernel has nine weight offsets, W−1,−1 through W1,1. Input point p contributes to output point q through offset δ exactly when p sits at q + δ. On a GPU the natural code is a loop over outputs that asks a hash table "is there an input at q + δ?". PointAcc rewrites the same condition so that no lookup is needed.
النواة (kernel) بحجم 3 × 3 لها تسع إزاحات للأوزان، من W−1,−1 إلى W1,1. نقطة الدخل p تساهم في نقطة الخرج q عبر الإزاحة δ إذا وفقط إذا كانت p واقعة عند q + δ. على GPU يكون الكود الطبيعي حلقة على المخرجات تسأل جدول تجزئة: «هل يوجد دخل عند q + δ؟». أما PointAcc فيعيد صياغة الشرط نفسه بحيث لا يحتاج إلى أي بحث في جدول (lookup).
Subtract δ from every input coordinate and the question becomes "which shifted inputs land on an output coordinate?", which is a set intersection. If both sets are sorted, an intersection is found by merging them and looking at adjacent elements: any input and output that coincide must end up side by side. This is why slide 112 adds (−1, −1) to the inputs for W1,1 and slide 111 adds (1, 1) for W−1,−1. The shift is always −δ, so the sign flips relative to the offset name.
اطرح δ من كل إحداثي دخل، فيصبح السؤال: «أي المدخلات المُزاحة تقع على إحداثي خرج؟»، وهذا تقاطع مجموعتين (set intersection). إذا كانت المجموعتان مرتبتين، نجد التقاطع بدمجهما والنظر إلى العناصر المتجاورة: أي دخل وخرج متطابقين لا بد أن ينتهيا متجاورين. لهذا تضيف الشريحة 112 القيمة (−1, −1) إلى المدخلات من أجل W1,1، وتضيف الشريحة 111 القيمة (1, 1) من أجل W−1,−1. الإزاحة دائمًا −δ، لذلك تنقلب الإشارة مقارنةً باسم الإزاحة.
Worked exampleمثال محلول
Finding the pairs for W1,1 on slide 112إيجاد الأزواج الخاصة بـ W1,1 في الشريحة 112
Shiftالإزاحة
The inputs are P0 (1,1), P1 (2,2), P2 (2,4), P3 (3,2), P4 (4,3). With stride 1 the outputs Q0 to Q4 sit at the same five coordinates. For δ = (1, 1) add (−1, −1) to every input: (0,0) (1,1) (1,3) (2,1) (3,2).المدخلات هي P0 (1,1) وP1 (2,2) وP2 (2,4) وP3 (3,2) وP4 (4,3). ومع خطوة (stride) تساوي 1 تقع المخرجات Q0 إلى Q4 عند الإحداثيات الخمسة نفسها. من أجل δ = (1, 1) أضف (−1, −1) إلى كل دخل: (0,0) (1,1) (1,3) (2,1) (3,2).Merge sortالفرز بالدمج
Both lists are already sorted by x then y, so one pass merges them: P0 (0,0), Q0 (1,1), P1 (1,1), P2 (1,3), P3 (2,1), Q1 (2,2), Q2 (2,4), Q3 (3,2), P4 (3,2), Q4 (4,3).القائمتان مرتبتان مسبقًا حسب x ثم y، لذلك يكفي مرور واحد لدمجهما: P0 (0,0)، Q0 (1,1)، P1 (1,1)، P2 (1,3)، P3 (2,1)، Q1 (2,2)، Q2 (2,4)، Q3 (3,2)، P4 (3,2)، Q4 (4,3).Compare neighborsمقارنة الجيران
Ten cells give nine adjacent comparisons. Two of them are equal across owners: positions 2 and 3 (Q0 and P1, both (1,1)) and positions 8 and 9 (Q3 and P4, both (3,2)).عشر خلايا تعطي تسع مقارنات متجاورة. اثنتان منها متساويتان بين مالكين مختلفين (دخل وخرج): الموضعان 2 و3 (Q0 وP1، وكلاهما (1,1))، والموضعان 8 و9 (Q3 وP4، وكلاهما (3,2)).Emit tuplesإخراج الثلاثيات
(P1, Q0, W1,1) and (P4, Q3, W1,1). Check against the rule: P1 = (2,2) = Q0 + (1,1) and P4 = (4,3) = Q3 + (1,1).(P1, Q0, W1,1) و(P4, Q3, W1,1). تحقّق منهما بالقاعدة: P1 = (2,2) = Q0 + (1,1) وP4 = (4,3) = Q3 + (1,1).Resultالنتيجة
Two map entries out of 25 possible input-output pairs, found with 9 comparators and zero random memory accesses.مدخلان في الخريطة من أصل 25 زوجًا ممكنًا بين الدخل والخرج، عُثر عليهما بـ 9 مقارنات ودون أي وصول عشوائي إلى الذاكرة.
| Positionالموضع | Ownerالمالك | Coordinateالإحداثي | Equal neighborالجار المتساوي |
|---|---|---|---|
| 11 | P0P0 | 0,00,0 | noلا |
| 22 | Q0Q0 | 1,11,1 | yes, with 3نعم، مع 3 |
| 33 | P1P1 | 1,11,1 | yes, with 2نعم، مع 2 |
| 44 | P2P2 | 1,31,3 | noلا |
| 55 | P3P3 | 2,12,1 | noلا |
| 66 | Q1Q1 | 2,22,2 | noلا |
| 77 | Q2Q2 | 2,42,4 | noلا |
| 88 | Q3Q3 | 3,23,2 | yes, with 9نعم، مع 9 |
| 99 | P4P4 | 3,23,2 | yes, with 8نعم، مع 8 |
| 1010 | Q4Q4 | 4,34,3 | noلا |
Slide 111 runs the identical procedure for the opposite corner of the kernel. The table below puts the two passes side by side. Notice the symmetry: the pairs for W1,1 are the pairs for W−1,−1 with the roles of input and output exchanged, P1 with Q0 against P0 with Q1. That is exactly what p = q + δ predicts, because if p = q + δ then q = p − δ, and with the input and output clouds sharing coordinates the same two points swap places.
تنفّذ الشريحة 111 الإجراء نفسه تمامًا للزاوية المقابلة من النواة. الجدول أدناه يضع المرورين جنبًا إلى جنب. لاحظ التناظر: أزواج W1,1 هي أزواج W−1,−1 نفسها مع تبادل دوري الدخل والخرج، أي P1 with Q0 مقابل P0 with Q1. وهذا بالضبط ما تتنبأ به p = q + δ، لأنه إذا كان p = q + δ فإن q = p − δ، وبما أن سحابتي الدخل والخرج تتشاركان الإحداثيات، تتبادل النقطتان نفسهما مكانيهما.
| W1,1 (slide 112)W1,1 (الشريحة 112) | W−1,−1 (slide 111)W−1,−1 (الشريحة 111) | |
|---|---|---|
| Offset δالإزاحة δ (offset) | (1, 1)(1, 1) | (−1, −1)(−1, −1) |
| Shift applied to inputsالإزاحة المضافة إلى المدخلات (shift) | + (−1, −1)+ (−1, −1) | + (1, 1)+ (1, 1) |
| Shifted inputs P0 to P4المدخلات المُزاحة P0 إلى P4 | (0,0) (1,1) (1,3) (2,1) (3,2)(0,0) (1,1) (1,3) (2,1) (3,2) | (2,2) (3,3) (3,5) (4,3) (5,4)(2,2) (3,3) (3,5) (4,3) (5,4) |
| Merged orderالترتيب بعد الدمج | P0 Q0 P1 P2 P3 Q1 Q2 Q3 P4 Q4P0 Q0 P1 P2 P3 Q1 Q2 Q3 P4 Q4 | Q0 Q1 P0 Q2 Q3 P1 P2 Q4 P3 P4Q0 Q1 P0 Q2 Q3 P1 P2 Q4 P3 P4 |
| Equal neighborsالجيران المتساويان | Q0 = P1, Q3 = P4Q0 = P1, Q3 = P4 | Q1 = P0, Q4 = P3Q1 = P0, Q4 = P3 |
| Tuples emittedالثلاثيات الناتجة | (P1, Q0, W1,1), (P4, Q3, W1,1)(P1, Q0, W1,1), (P4, Q3, W1,1) | (P0, Q1, W−1,−1), (P3, Q4, W−1,−1)(P0, Q1, W−1,−1), (P3, Q4, W−1,−1) |
- P00,0
- P11,1
- P21,3
- P32,1
- P43,2
- Q01,1
- Q12,2
- Q22,4
- Q33,2
- Q44,3
- P00,0
- Q01,1
- P11,1
- P21,3
- P32,1
- Q12,2
- Q22,4
- Q33,2
- P43,2
- Q44,3
- (P1, Q0, W1,1)
- (P4, Q3, W1,1)
Input p and output q pair up for offset δ exactly when p = q + δ, so subtracting δ from every input turns the search into an equality test. The merge reads the two sorted strips once, head against head, and the only checks are between adjacent cells of the merged strip, which is why the comparator count is the strip length minus one. A hash table would instead probe a random address once per output point. With stride 2 the output coordinates are quantized to the stride grid by clearing the low log2(ts) bits, which the same unit separates from kernel mapping.يقترن الإدخال p بالخرج q للإزاحة δ عندما يكون p = q + δ بالضبط، لذا فطرح δ من كل إدخال يحول البحث إلى اختبار تساوٍ. يقرأ الدمج الشريطين المرتبين مرة واحدة، رأسًا مقابل رأس، ولا تجري المقارنات إلا بين الخلايا المتجاورة في الشريط المدموج، ولهذا يساوي عدد المقارِنات طول الشريط ناقص واحد. أما جدول التجزئة فيستعلم عنوانًا عشوائيًا مرة لكل نقطة خرج. ومع الخطوة 2 تُكمَّم إحداثيات الخرج إلى شبكة الخطوة بمسح أدنى log2(ts) من البتات، وهي عملية تفصلها الوحدة نفسها عن ربط النواة.
Why a hash table is the wrong tool for siliconلماذا جدول التجزئة أداة خاطئة للسيليكون
The GPU library that PointAcc compares against builds its maps with a hash table, and on a GPU that is a reasonable choice: memory is large and random access is cheap enough. Neither holds on chip. The paper puts two numbers on it. First, a hash table sized for a real point cloud at a sensible load factor can reach 160 MB, which no accelerator can hold in SRAM. Second, to serve N lookups in parallel the SRAM needs an N-by-N crossbar so that any lane can reach any bank, and that crossbar grows as O(N²) in area (Lin et al., 2021, section 4.1).
مكتبة GPU التي يقارن PointAcc نفسه بها تبني خرائطها بجدول تجزئة، وهذا خيار معقول على GPU: الذاكرة كبيرة والوصول العشوائي رخيص بما يكفي. ولا يصح أي من الأمرين على الشريحة (on chip). وتضع الورقة رقمين على ذلك. أولًا، جدول التجزئة المصمم لسحابة نقطية حقيقية بمعامل تحميل (load factor) معقول قد يصل إلى 160 MB، وهذا ما لا يستطيع أي مسرّع حمله في SRAM. ثانيًا، لخدمة N عملية بحث على التوازي تحتاج SRAM إلى مصفوفة توصيل (crossbar) بحجم N في N حتى يصل أي مسار (lane) إلى أي بنك (bank)، وتنمو مساحة هذه المصفوفة بمقدار O(N²) (Lin et al., 2021, section 4.1).
Merging has neither problem. The Mapping Unit feeds window-sized chunks of the two sorted lists to a fixed-size bitonic merger, a parallel comparator network, and a forwarding loop carries leftover elements into the next cycle, so the lists are read in order and never probed at random. Detecting the intersection is just as local: the paper describes feeding each pair of adjacent elements of the merged array to a comparator that checks whether their coordinates are equal. With |I| shifted inputs and |O| outputs the strip has |I| + |O| cells and |I| + |O| − 1 adjacent comparisons, all independent, so they can run in a single cycle. The Mapping unit builds this from a bitonic sorting network feeding a merger of fixed length, and the paper reports that at the same parallelism the merge-sort design is 1.4x faster than the hash-table design while saving up to 14x in area (Lin et al., 2021, section 4.1).
الدمج لا يعاني من أي من المشكلتين. وحدة الربط (Mapping Unit) تغذّي دمّاجًا بيتونيًا (bitonic merger) ثابت الحجم، وهو شبكة مقارنات متوازية، بمقاطع بحجم النافذة من القائمتين المرتبتين، وتحمل حلقة تمرير (forwarding loop) العناصر المتبقية إلى الدورة التالية، فتُقرأ القوائم بالترتيب ولا يُبحث فيها عشوائيًا أبدًا. واكتشاف التقاطع محلي بالقدر نفسه: تصف الورقة تغذية كل زوج من العناصر المتجاورة في المصفوفة المدموجة إلى مقارن يتحقق من تساوي إحداثياتهما. مع |I| دخلًا مُزاحًا و|O| خرجًا، يحتوي الشريط على |I| + |O| خلية و|I| + |O| − 1 مقارنة متجاورة، كلها مستقلة، فيمكن تنفيذها في دورة واحدة. تبني وحدة الربط (mapping unit) ذلك من شبكة فرز بيتونية (bitonic sorting network) تغذّي دمّاجًا ثابت الطول، وتذكر الورقة أن تصميم الفرز بالدمج، عند التوازي نفسه، أسرع بمقدار 1.4x من تصميم جدول التجزئة ويوفّر ما يصل إلى 14x من المساحة (Lin et al., 2021, section 4.1).
| Hash tableجدول التجزئة | Merge sortالفرز بالدمج | |
|---|---|---|
| Memory access patternنمط الوصول إلى الذاكرة | Random probes, one per output point per offsetاستعلامات عشوائية، واحد لكل نقطة خرج ولكل إزاحة | Two sequential streams, read onceتدفقان متسلسلان، يُقرأ كل منهما مرة واحدة |
| Parallel read hardwareعتاد القراءة المتوازية | N-by-N crossbar, O(N²) areaمصفوفة توصيل (crossbar) بحجم N في N، ومساحتها O(N²) | Fixed-size bitonic merger with a forwarding loopدمّاج بيتوني (bitonic merger) ثابت الحجم مع حلقة تمرير (forwarding loop) |
| On-chip storageالتخزين على الشريحة | Table can reach 160 MB at realistic load factorsقد يصل الجدول إلى 160 MB عند معاملات تحميل واقعية | Sorted coordinate lists, no tableقوائم إحداثيات مرتبة، دون جدول |
| Result at equal parallelismالنتيجة عند التوازي نفسه | Baselineخط الأساس (baseline) | 1.4x faster, up to 14x less areaأسرع بمقدار 1.4x، ومساحة أقل بما يصل إلى 14x |
One sorting unit, four point-cloud operationsوحدة فرز واحدة، وأربع عمليات على السحب النقطية
The reason PointAcc calls this block a mapping unit rather than a convolution helper is that sorting turns out to be the common core of every irregular operation a point-cloud network needs. Kernel mapping is an equality after a shift. Building the output cloud under a stride s is quantizing coordinates to the stride grid and then deduplicating, which sorting does by putting duplicates next to each other. Farthest point sampling picks the point with the largest distance, a top-1 of a ranking. k-nearest-neighbor search is a top-k of the same ranking, and ball query is a threshold on the sorted distances. The paper lists these as the operations the single ranking-based unit implements (Lin et al., 2021, sections 2.1 and 4.1). Flip the simulator above to stride 2 to see the output construction case: the five inputs collapse to fewer outputs before any offset is tried.
السبب في أن PointAcc يسمي هذه الكتلة وحدة ربط لا مساعد التفاف، هو أن الفرز يتبيّن أنه النواة المشتركة لكل عملية غير منتظمة تحتاجها شبكة السحب النقطية. ربط النواة (kernel mapping) هو تساوٍ بعد إزاحة. وبناء سحابة الخرج مع خطوة s هو تكميم الإحداثيات إلى شبكة الخطوة ثم إزالة التكرار، والفرز يفعل ذلك بوضع المكررات بجانب بعضها. وأخذ العينات بأبعد نقطة (farthest point sampling) يختار النقطة ذات المسافة الأكبر، أي أعلى عنصر (top-1) في ترتيب. والبحث عن أقرب k جيران (k-nearest-neighbor) هو أعلى k عناصر (top-k) في الترتيب نفسه، واستعلام الكرة (ball query) هو عتبة على المسافات المرتبة. وتدرج الورقة هذه العمليات على أنها ما تنفّذه الوحدة الواحدة القائمة على الترتيب (Lin et al., 2021, sections 2.1 and 4.1). غيّر المحاكي أعلاه إلى خطوة 2 لترى حالة بناء الخرج: تنهار المدخلات الخمسة إلى مخرجات أقل قبل تجربة أي إزاحة.
Recall
State the condition that makes input p and output q a pair for offset δ, and say what PointAcc does to turn it into an equality test.اذكر الشرط الذي يجعل الدخل p والخرج q زوجًا للإزاحة δ، وقل ماذا يفعل PointAcc لتحويله إلى اختبار تساوٍ.
Recall
For W−1,−1 on slide 111, which tuples come out, and why does the shift carry a plus sign?بالنسبة لـ W−1,−1 في الشريحة 111، ما الثلاثيات الناتجة، ولماذا تحمل الإزاحة إشارة موجبة؟
Recall
Give two reasons a hash table is a poor mapping unit on chip.أعطِ سببين يجعلان جدول التجزئة وحدة ربط سيئة على الشريحة.
Quick checkاختبار سريع
For weight offset W1,1, the PointAcc mapping unit adds which vector to every input coordinate?بالنسبة لإزاحة الوزن W1,1، أي متجه تضيفه وحدة الربط في PointAcc إلى كل إحداثي دخل؟
Quick checkاختبار سريع
A parallel hash table is rejected as the mapping unit mainly because it needsيُستبعد جدول التجزئة المتوازي كوحدة للربط أساسًا لأنه يحتاج إلى
Slide 113 is a pair of bar charts with three baselines, and the baselines matter more than the bars. Red is an NVIDIA RTX 2080Ti, the server GPU that already runs TorchSparse-style code well. Dark grey is an Intel Xeon Skylake host paired with a TPU V3, a dense-matmul accelerator that has to send every mapping operation back to the host. Light grey is an Intel Xeon Gold 6130 CPU alone. The right-most group, GeoMean, is the geometric mean across the eight networks, so no single network dominates the average.
الشريحة 113 زوج من المخططات الشريطية بثلاثة خطوط أساس، وخطوط الأساس أهم من الأعمدة نفسها. الأحمر هو NVIDIA RTX 2080Ti، وهو GPU خوادم يشغّل كود على نمط TorchSparse جيدًا أصلًا. والرمادي الداكن هو معالج مضيف Intel Xeon Skylake مقترن بـ TPU V3، وهو مسرّع لضرب المصفوفات الكثيفة يضطر إلى إرسال كل عملية ربط إلى المضيف. والرمادي الفاتح هو معالج Intel Xeon Gold 6130 وحده. والمجموعة في أقصى اليمين، GeoMean، هي المتوسط الهندسي عبر الشبكات الثماني، فلا تهيمن شبكة واحدة على المتوسط.
Start with the GeoMean row and read the two charts together. Against the GPU, PointAcc is 3.7x faster and 22x more energy efficient. Against the TPU system it is 53x faster and saves 210x energy. Against the CPU it is 90x faster and saves 176x (the slide prints 193x, see the errata below). The paper's abstract leads with the GPU pair, 3.7x and 22x over an RTX 2080Ti, evaluated on eight models across four applications (Lin et al., 2021).
ابدأ بصف GeoMean واقرأ المخططين معًا. مقارنةً بـ GPU، يكون PointAcc أسرع بمقدار 3.7x وأكفأ في الطاقة بمقدار 22x. ومقارنةً بنظام TPU يكون أسرع بمقدار 53x ويوفّر 210x من الطاقة. ومقارنةً بـ CPU يكون أسرع بمقدار 90x ويوفّر 176x (تطبع الشريحة 193x، انظر تصحيح الشريحة أدناه). ويبدأ ملخص الورقة بزوج GPU: 3.7x و22x مقارنةً بـ RTX 2080Ti، مع تقييم على ثمانية نماذج عبر أربعة تطبيقات (Lin et al., 2021).
| Networkالشبكة | Speedup vs 2080Tiالتسريع مقارنةً بـ 2080Ti | Speedup vs TPU V3التسريع مقارنةً بـ TPU V3 | Speedup vs Gold 6130التسريع مقارنةً بـ Gold 6130 | Energy vs 2080Tiالطاقة مقارنةً بـ 2080Ti | Energy vs TPU V3الطاقة مقارنةً بـ TPU V3 | Energy vs Gold 6130الطاقة مقارنةً بـ Gold 6130 |
|---|---|---|---|---|---|---|
| PointNetPointNet | 3.73.7 | 2727 | 127127 | 1818 | 1,3191,319 | 172172 |
| PointNet++ (c)PointNet++ (c) | 2.82.8 | 113113 | 9797 | 1414 | 169169 | 119119 |
| PointNet++ (ps)PointNet++ (ps) | 2.82.8 | 3737 | 8282 | 2525 | 9999 | 152152 |
| DGCNNDGCNN | 3.73.7 | 3.43.4 | 6565 | 2727 | 3838 | 9191 |
| F-PointNet++F-PointNet++ | 3.73.7 | 269269 | 131131 | 1616 | 682682 | 394394 |
| PointNet++ (s)PointNet++ (s) | 4.74.7 | 8888 | 106106 | 4545 | 161161 | 221221 |
| MinkNet(i)MinkNet(i) | 8.38.3 | 102102 | 9494 | 3636 | 324324 | 268268 |
| MinkNet(o)MinkNet(o) | 2.42.4 | 7171 | 5151 | 1313 | 127127 | 139139 |
| GeoMeanGeoMean | 3.73.7 | 5353 | 9090 | 2222 | 210210 | 193 (paper: 176)193 (في الورقة: 176) |
The network names encode the benchmark. The PointNet++ suffixes are (c) classification, (ps) part segmentation and (s) semantic segmentation. F-PointNet++ is the frustum detector built on PointNet++. MinkNet(i) and MinkNet(o) are MinkowskiUNet on an indoor dataset (S3DIS) and an outdoor dataset (SemanticKITTI), the two sparse-convolution workloads closest to part 11 (Lin et al., 2021, Table 2).
أسماء الشبكات تشير إلى معيار القياس (benchmark). لواحق PointNet++ هي (c) للتصنيف (classification)، و(ps) لتقسيم الأجزاء (part segmentation)، و(s) للتقسيم الدلالي (semantic segmentation). وF-PointNet++ هو كاشف المخروط الناقص (frustum detector) المبني على PointNet++. وMinkNet(i) وMinkNet(o) هما MinkowskiUNet على مجموعة بيانات داخلية (S3DIS) ومجموعة بيانات خارجية (SemanticKITTI)، وهما أقرب أحمال الالتفاف المتناثر إلى الجزء 11 (Lin et al., 2021, Table 2).
Why the TPU column swings from 3.4x to 269xلماذا يتأرجح عمود TPU من 3.4x إلى 269x
The GPU column is flat, between 2.4x and 8.3x, because a GPU handles both the mapping and the matmuls in the same memory. The TPU column ranges from 3.4x on DGCNN to 269x on F-PointNet++, and the spread is the lesson of the whole part. The paper attributes the gain over the TPU mainly to supporting mapping operations on chip (Lin et al., 2021, section 5.2). The paper does not break that number down per network, so the following is a reading of the chart, not a quoted result. DGCNN's neighbor search is a pairwise-distance computation in feature space, recomputed inside every EdgeConv layer, and a dense matmul unit already runs that well, so it has the least mapping work to move on chip. F-PointNet++ and the segmentation variants of PointNet++ are dominated by sampling, neighbor search and gathering, exactly the operations the TPU must hand back to the host, so removing that round trip is worth two orders of magnitude.
عمود GPU مستوٍ تقريبًا، بين 2.4x و8.3x، لأن GPU يتعامل مع الربط وضرب المصفوفات في الذاكرة نفسها. أما عمود TPU فيتراوح من 3.4x على DGCNN إلى 269x على F-PointNet++، وهذا التفاوت هو درس الجزء كله. تنسب الورقة المكسب مقارنةً بـ TPU أساسًا إلى دعم عمليات الربط على الشريحة (Lin et al., 2021, section 5.2). ولا تفصّل الورقة هذا الرقم لكل شبكة، لذا فما يلي قراءة للمخطط وليس نتيجة منقولة. البحث عن الجيران في DGCNN هو حساب مسافات زوجية في فضاء الخصائص، يُعاد حسابه داخل كل طبقة EdgeConv، ووحدة ضرب المصفوفات الكثيفة تنفّذ ذلك جيدًا أصلًا، فيكون لديه أقل قدر من عمل الربط الذي يُنقل إلى الشريحة. أما F-PointNet++ ونسخ التقسيم من PointNet++ فتهيمن عليها عمليات أخذ العينات والبحث عن الجيران والجمع (gathering)، وهي بالضبط العمليات التي يجب على TPU إعادتها إلى المضيف، لذلك فإن إزالة هذه الرحلة ذهابًا وإيابًا تساوي رتبتين عشريتين من التحسين.
Recall
Slide 113 prints 193 for the CPU energy GeoMean. Using the definition of a geometric mean and the eight per-network bars, how would you check it?تطبع الشريحة 113 القيمة 193 لـ GeoMean طاقة CPU. باستخدام تعريف المتوسط الهندسي والأعمدة الثمانية لكل شبكة، كيف تتحقق منها؟
Recall
Quote PointAcc's geometric-mean speedup and energy saving over the RTX 2080Ti, and name the other two baselines on slide 113.اذكر التسريع وتوفير الطاقة بالمتوسط الهندسي لـ PointAcc مقارنةً بـ RTX 2080Ti، وسمِّ خطّي الأساس الآخرين في الشريحة 113.
Quick checkاختبار سريع
On slide 113, what is PointAcc's speedup on DGCNN over the Xeon Skylake plus TPU V3 system, the smallest entry in that column?في الشريحة 113، ما تسريع PointAcc على DGCNN مقارنةً بنظام Xeon Skylake مع TPU V3، وهو أصغر قيمة في ذلك العمود؟
Slide 114 compresses the lecture into two bullets: automated ways to find pruning ratios, and system and hardware support for different granularities. Those two bullets are two separate questions from the five that opened the deck. The first asks how much to remove from each layer. The second asks how the zeros you created turn into time and energy actually saved. Neither is worth much without the other.
تضغط الشريحة 114 المحاضرة في نقطتين: طرق مؤتمتة لإيجاد نسب التقليم (pruning ratios)، ودعم الأنظمة والعتاد للحبيبيات المختلفة. هاتان النقطتان سؤالان منفصلان من الأسئلة الخمسة التي افتُتحت بها الشرائح. الأول يسأل كم نزيل من كل طبقة. والثاني يسأل كيف تتحول الأصفار التي صنعتها إلى وقت وطاقة موفّرين فعلًا. ولا قيمة كبيرة لأي منهما دون الآخر.
Thread one: choosing the ratioالخيط الأول: اختيار النسبة
Sensitivity analysis prunes one layer at a time across a sweep of ratios, plots accuracy against ratio, and reads each layer's rate where its curve crosses an accuracy threshold. It is cheap and transparent, and its weakness is that it ignores Layer interaction: the compounding loss when many layers are pruned together, which is why its per-layer rates are only a starting point. AMC (AutoML for Model Compression) replaces the human with a DDPG agent that sees a layer embedding and emits a continuous sparsity ratio, rewarded by accuracy under a FLOPs or latency budget. NetAdapt keeps a rule instead of a policy: cut latency by a fixed step, choose the layer whose short-term fine-tuned accuracy is highest, consult a measured latency lookup table rather than FLOPs, repeat until the budget is met, then long-term fine-tune. Whichever chooses the ratios, Fine-tuning and Iterative pruning are what recover the accuracy afterwards.
تحليل الحساسية (sensitivity analysis) يقلّم طبقة واحدة في كل مرة عبر مجموعة من النسب، ويرسم الدقة مقابل النسبة، ويقرأ معدل كل طبقة عند النقطة التي يعبر فيها منحناها عتبة الدقة (accuracy threshold). وهو رخيص وشفاف، ونقطة ضعفه أنه يتجاهل تفاعل الطبقات (layer interaction): الخسارة المتراكمة عندما تُقلَّم طبقات كثيرة معًا، ولهذا فإن معدلاته لكل طبقة ليست إلا نقطة بداية. أما AMC فيستبدل الإنسان بوكيل DDPG يرى تمثيلًا (embedding) للطبقة ويُخرج نسبة تناثر متصلة، ويُكافأ بالدقة تحت ميزانية من FLOPs أو زمن الاستجابة (latency). وNetAdapt يحتفظ بقاعدة بدلًا من سياسة: اخفض زمن الاستجابة بخطوة ثابتة، واختر الطبقة التي تكون دقتها بعد الضبط الدقيق قصير المدى (short-term fine-tuning) هي الأعلى، واستعن بجدول بحث (lookup table) لزمن الاستجابة المقيس بدلًا من FLOPs، وكرّر حتى تتحقق الميزانية، ثم طبّق الضبط الدقيق طويل المدى (long-term fine-tuning). وأيًّا كان من يختار النسب، فإن الضبط الدقيق (fine-tuning) والتقليم التكراري (iterative pruning) هما ما يستعيد الدقة بعد ذلك.
Thread two: making the zeros payالخيط الثاني: جعل الأصفار مُربحة
A pruned weight is only free if the hardware skips it. EIE (Efficient Inference Engine) skips two kinds at once: static Weight sparsity stored in CSC form across an array of processing elements, and dynamic activation sparsity caught by leading non-zero detection so that a zero activation is never broadcast. NVIDIA Ampere tensor cores accept 2:4 sparsity only, and in return the Sparse tensor core uses the two-bit metadata to select operands and doubles math throughput (Mishra et al., 2021). TorchSparse handles the sparsity of point-cloud inputs in software by trading a little padding for regular batched matmuls through Adaptive grouping, and TorchSparse++ overlaps the gather and scatter with compute. PointAcc moves the same problem into hardware, with the merge-sort mapping unit of the previous concept. The granularity is the thread joining all four: the finer the sparsity, the more bookkeeping the system must do to skip it, and the coarser the sparsity, the more the pruning method must give up to fit the pattern.
الوزن المقلَّم لا يكون مجانيًا إلا إذا تخطّاه العتاد. EIE يتخطى نوعين معًا: تناثر الأوزان (weight sparsity) الثابت المخزّن بصيغة CSC عبر مصفوفة من عناصر المعالجة (processing elements)، وتناثر التفعيلات الديناميكي الذي يُلتقط بـكشف أول قيمة غير صفرية (leading non-zero detection) بحيث لا يُبث تفعيل صفري أبدًا. وأنوية NVIDIA Ampere الموترية لا تقبل إلا تناثر 2:4، وفي المقابل تستخدم النواة الموترية المتناثرة (sparse tensor core) البيانات الوصفية ذات البتين لاختيار المعاملات (operands) وتضاعف إنتاجية الحساب (Mishra et al., 2021). ويتعامل TorchSparse مع تناثر مدخلات السحب النقطية برمجيًا، مقايضًا قليلًا من الحشو (padding) بعمليات ضرب مصفوفات منتظمة ومجمّعة عبر التجميع التكيفي (adaptive grouping)، ويُداخل TorchSparse++ عمليتي الجمع والتوزيع (gather وscatter) مع الحساب. وينقل PointAcc المسألة نفسها إلى العتاد، بوحدة الربط القائمة على الفرز بالدمج من المفهوم السابق. والحبيبية (granularity) هي الخيط الذي يربط الأربعة: كلما كان التناثر أدق، زادت المحاسبة التي يجب أن يقوم بها النظام لتخطيه، وكلما كان التناثر أخشن، زاد ما يجب أن تتنازل عنه طريقة التقليم لتلائم النمط.
| Sparsityالتناثر | Where it comes fromمصدره | Granularity neededالحبيبية المطلوبة | Systemالنظام | Mechanismالآلية |
|---|---|---|---|---|
| Fine-grained weightتناثر الأوزان الدقيق (fine-grained) | Pruning, staticالتقليم، ثابت | Irregular, individual weightsغير منتظم، على مستوى الأوزان المفردة | EIEEIE | CSC storage, PE array, weight sharing, skip zero weightsتخزين CSC، ومصفوفة عناصر معالجة (PE array)، ومشاركة الأوزان (weight sharing)، وتخطي الأوزان الصفرية |
| M:N weight (2:4)تناثر الأوزان M:N (2:4) | Pruning with a pattern, staticالتقليم وفق نمط، ثابت | 2 nonzeros in every 4 along a rowقيمتان غير صفريتين في كل 4 على امتداد الصف | NVIDIA Ampere sparse tensor coresأنوية NVIDIA Ampere الموترية المتناثرة | 2-bit metadata selects the paired activations, 2x math throughputبيانات وصفية (metadata) من بتين تختار التفعيلات المقابلة، وإنتاجية حساب مضاعفة 2x |
| Activation (ReLU zeros)تناثر التفعيلات (أصفار ReLU) | ReLU at run time, dynamicدالة ReLU أثناء التشغيل، ديناميكي | Element levelعلى مستوى العنصر | EIEEIE | Leading non-zero detection, never broadcast a zeroكشف أول قيمة غير صفرية (leading non-zero detection)، وعدم بث أي صفر أبدًا |
| Activation (sparse point-cloud inputs)تناثر التفعيلات (مدخلات السحب النقطية المتناثرة) | Data occupancy, dynamicإشغال البيانات، ديناميكي | Point (coordinate) levelعلى مستوى النقطة (الإحداثي) | TorchSparse (software), PointAcc (hardware)TorchSparse (برمجيات)، وPointAcc (عتاد) | Maps plus gather, matmul, scatter with adaptive grouping; merge-sort mapping unitخرائط مع الجمع ثم ضرب المصفوفات ثم التوزيع (gather, matmul, scatter) بالتجميع التكيفي (adaptive grouping)؛ ووحدة ربط بالفرز بالدمج |
The bridge to the next lectureالجسر إلى المحاضرة التالية
Pruning removes weights. Quantization shrinks the ones that stay. Slide 114 sets the order for the next lecture: first the numeric data types modern computer systems actually offer, then the basic concept of neural network quantization, then the common quantization methods. The two techniques are complementary in the deep compression sense: after pruning left AlexNet with a ninth of its connections, quantizing and coding the survivors is what pushed the total to 35x in Han et al.'s pipeline, and both will show up together in the memory and energy arguments of the next lecture (Han, Mao and Dally, 2016).
التقليم يزيل الأوزان. والتكميم يقلّص الأوزان التي تبقى. تحدد الشريحة 114 ترتيب المحاضرة التالية: أولًا أنواع البيانات العددية التي توفرها أنظمة الحاسوب الحديثة فعلًا، ثم المفهوم الأساسي لتكميم الشبكات العصبية، ثم طرق التكميم الشائعة. والتقنيتان متكاملتان بمعنى الضغط العميق (deep compression): بعد أن ترك التقليم شبكة AlexNet بتُسع وصلاتها، كان تكميم الأوزان الباقية وترميزها هو ما دفع الإجمالي إلى 35x في خط معالجة Han et al.، وستظهر التقنيتان معًا في حجج الذاكرة والطاقة في المحاضرة التالية (Han, Mao and Dally, 2016).
Recall
Name the three automated ways to find pruning ratios from this lecture and one weakness of the first.سمِّ الطرق المؤتمتة الثلاث لإيجاد نسب التقليم في هذه المحاضرة، ونقطة ضعف واحدة للأولى.
Recall
Which two topics open the next lecture before the quantization methods?ما الموضوعان اللذان تبدأ بهما المحاضرة التالية قبل طرق التكميم؟
Quick checkاختبار سريع
Which system on slide 55 is paired with M:N weight sparsity?أي نظام في الشريحة 55 يقترن بتناثر الأوزان M:N؟
Slide 115 lists nineteen references. Read as a map of the lecture they fall into six groups: foundations of model compression and energy (items 1, 2, 4, 5, 6), pruning criteria (3, 12, 13, 15), structured and channel pruning (7, 10, 11, 14, 16, 17), automated ratio search (9), hardware support (8), and one-shot pruning of large language models (18), with Prof. Han's TinyML course (19) as the source the whole deck follows. The Sources block at the end of this part gives a link for each one that has an archival home.
تدرج الشريحة 115 تسعة عشر مرجعًا. وإذا قرأتها كخريطة للمحاضرة فهي تنقسم إلى ست مجموعات: أسس ضغط النماذج والطاقة (البنود 1, 2, 4, 5, 6)، ومعايير التقليم (3, 12, 13, 15)، والتقليم المهيكل وتقليم القنوات (7, 10, 11, 14, 16, 17)، والبحث المؤتمت عن النسب (9)، ودعم العتاد (8)، والتقليم دفعة واحدة (one-shot) لنماذج اللغة الكبيرة (18)، مع مقرر TinyML للبروفيسور Han (19) بوصفه المصدر الذي تتبعه الشرائح كلها. وكتلة المصادر في نهاية هذا الجزء تعطي رابطًا لكل مرجع له موطن أرشيفي.
Where the references land in this lectureأين تقع المراجع في هذه المحاضرة
- Foundationsالأسس
- Deng et al. 2020 survey; Horowitz 2014 on the energy of memory access; Han et al. 2015; Han's Stanford thesis; Walsh 2013 on Huttenlocher's synapse countsالمسح الذي أعدّه Deng et al. 2020؛ وHorowitz 2014 عن طاقة الوصول إلى الذاكرة؛ وHan et al. 2015؛ وأطروحة Han في Stanford؛ وWalsh 2013 عن أعداد المشابك العصبية لدى Huttenlocher
- Criteriaمعايير التقليم
- LeCun et al. 1989 Optimal Brain Damage; Molchanov et al. 2017 and 2019 Taylor ranking; Wang's first-order Taylor noteLeCun et al. 1989 Optimal Brain Damage؛ والترتيب بمتسلسلة تايلور (Taylor ranking) لدى Molchanov et al. في 2017 و2019؛ ومذكرة Wang عن تايلور من الرتبة الأولى
- Structured pruningالتقليم المهيكل
- Mao et al. on granularity; Wen et al. 2016; Liu et al. 2017 Network Slimming; Hu et al. Network Trimming; He et al. 2017 channel pruning; Luo et al. 2017 ThiNetMao et al. عن الحبيبية؛ وWen et al. 2016؛ وLiu et al. 2017 Network Slimming؛ وHu et al. Network Trimming؛ وتقليم القنوات لدى He et al. 2017؛ وLuo et al. 2017 ThiNet
- Automationالأتمتة
- He et al. 2018 AMCHe et al. 2018 AMC
- Hardwareالعتاد
- NVIDIA Ampere and TensorRT sparsity blogتدوينة NVIDIA عن التناثر في Ampere وTensorRT
- Large modelsالنماذج الكبيرة
- Frantar and Alistarh 2023 SparseGPTFrantar and Alistarh 2023 SparseGPT
- Courseالمقرر
- Prof. Han's TinyML course (MIT 6.5940)مقرر TinyML للبروفيسور Han (MIT 6.5940)
The list is also worth checking against the slides themselves, because several of the papers this lecture leaned on hardest are cited in slide footers but never make it to the reference page. Every hardware system in the second half of the deck is in that position. If you cite from this lecture in your own writing, take the references from the Sources below rather than from slide 115.
تستحق القائمة أيضًا أن تُراجع مقابل الشرائح نفسها، لأن عدة أوراق اعتمدت عليها هذه المحاضرة أكثر من غيرها مذكورة في تذييلات الشرائح لكنها لا تصل أبدًا إلى صفحة المراجع. وكل نظام عتادي في النصف الثاني من الشرائح في هذا الوضع. وإذا استشهدت من هذه المحاضرة في كتاباتك، فخذ المراجع من المصادر أدناه لا من الشريحة 115.
Recall
Which two hardware papers from this lecture are missing from the reference slide?ما ورقتا العتاد في هذه المحاضرة الغائبتان عن شريحة المراجع؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- Sparse convolution pairs input p with output q for offset δ exactly when p = q + δ. PointAcc tests this as an equality after shifting every input by −δ.الالتفاف المتناثر (sparse convolution) يقرن الدخل p بالخرج q عبر الإزاحة δ إذا وفقط إذا كان p = q + δ. ويختبر PointAcc هذا الشرط كتساوٍ بعد إزاحة كل دخل بمقدار −δ.
- The mapping unit merge-sorts the shifted inputs with the outputs. Equal adjacent neighbors are map entries, found with |I| + |O| − 1 local comparisons and no random SRAM reads.وحدة الربط (mapping unit) تفرز بالدمج المدخلاتِ المُزاحة مع المخرجات. والجيران المتجاوران المتساويان هم مدخلات الخريطة، ويُعثر عليهم بعدد |I| + |O| − 1 من المقارنات المحلية دون أي قراءة عشوائية من SRAM.
- On slide 112, W_1,1 yields (P1, Q0) and (P4, Q3). On slide 111, W_-1,-1 yields (P0, Q1) and (P3, Q4). The two lists are the same pairs with roles swapped.في الشريحة 112، تعطي W_1,1 الزوجين (P1, Q0) و(P4, Q3). وفي الشريحة 111، تعطي W_-1,-1 الزوجين (P0, Q1) و(P3, Q4). والقائمتان هما الأزواج نفسها مع تبادل الأدوار.
- A parallel hash table needs an O(N²) crossbar and a table that can reach 160 MB. The merge-sort unit is 1.4x faster and up to 14x smaller at equal parallelism.جدول التجزئة المتوازي يحتاج إلى مصفوفة توصيل (crossbar) بحجم O(N²) وجدول قد يصل إلى 160 MB. أما وحدة الفرز بالدمج فأسرع بمقدار 1.4x وأصغر بما يصل إلى 14x عند التوازي نفسه.
- One ranking kernel also serves farthest point sampling, kNN and ball query. Stride downsampling uses coordinate quantization instead.نواة ترتيب (ranking) واحدة تخدم أيضًا أخذ العينات بأبعد نقطة (farthest point sampling) وبحث kNN واستعلام الكرة (ball query). أما تقليل الدقة بالخطوة (stride downsampling) فيستخدم تكميم الإحداثيات بدلًا من ذلك.
- PointAcc geomean: 3.7x, 53x and 90x speedup and 22x, 210x and 176x energy saving (slide 113 prints 193x for the last one) over an RTX 2080Ti, a Xeon Skylake plus TPU V3, and a Xeon Gold 6130.المتوسط الهندسي لـ PointAcc: تسريع 3.7x و53x و90x، وتوفير طاقة 22x و210x و176x (تطبع الشريحة 113 القيمة 193x للأخير) مقارنةً بـ RTX 2080Ti، وXeon Skylake مع TPU V3، وXeon Gold 6130.
- Ratio methods: sensitivity analysis, AMC, NetAdapt. Systems: EIE (weight plus activation), Ampere tensor cores (M:N), TorchSparse and PointAcc (activation sparsity from sparse inputs).طرق تحديد النسب: تحليل الحساسية (sensitivity analysis)، وAMC، وNetAdapt. والأنظمة: EIE (الأوزان مع التفعيلات)، وأنوية Ampere الموترية (M:N)، وTorchSparse وPointAcc (تناثر التفعيلات الناتج عن المدخلات المتناثرة).
- Next lecture: numeric data types, the basic concept of quantization, common quantization methods.المحاضرة التالية: أنواع البيانات العددية، والمفهوم الأساسي للتكميم، وطرق التكميم الشائعة.
- Slide 115 omits NetAdapt, EIE, Mishra et al. 2021, TorchSparse, TorchSparse++ and PointAcc, and dates Hu et al. to 2017 when the paper appeared in 2016.تُغفل الشريحة 115 كلًا من NetAdapt وEIE وMishra et al. 2021 وTorchSparse وTorchSparse++ وPointAcc، وتؤرّخ Hu et al. بعام 2017 مع أن الورقة ظهرت عام 2016.
Sourcesالمصادر
- PointAcc: Efficient Point Cloud AcceleratorPaperMICRO 2021, Lin, Zhang, Tang, Wang and HanMapping bottleneck (section 3), hash table critique and merge-sort mapping unit (section 4.1), 3.7x and 22x over an RTX 2080Ti, results (section 5.2, Figure 13, Table 2).عنق زجاجة الربط (section 3)، ونقد جدول التجزئة ووحدة الربط بالفرز بالدمج (section 4.1)، و3.7x و22x مقارنةً بـ RTX 2080Ti، والنتائج (section 5.2، Figure 13، Table 2).(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse: Efficient Point Cloud Inference EnginePaperMLSys 2022, Tang, Liu, Li, Lin and HanCited on slides 87 to 107, absent from slide 115.مستشهد به في الشرائح 87 إلى 107، وغائب عن الشريحة 115.(opens in a new tab)(يفتح في تبويب جديد)
- TorchSparse++: Efficient Training and Inference Framework for Sparse Convolution on GPUsPaperMICRO 2023, Tang et al.Cited on slides 108 and 109, absent from slide 115.مستشهد به في الشريحتين 108 و109، وغائب عن الشريحة 115.(opens in a new tab)(يفتح في تبويب جديد)
- EIE: Efficient Inference Engine on Compressed Deep Neural NetworkPaperISCA 2016, Han et al.Cited on slides 57 to 77, absent from slide 115.مستشهد به في الشرائح 57 إلى 77، وغائب عن الشريحة 115.(opens in a new tab)(يفتح في تبويب جديد)
- Submanifold Sparse Convolutional NetworksPaperarXiv, Graham and van der Maaten, 2017Cited on slide 86 as Graham, BMVC 2015 (that venue is Graham's earlier Sparse 3D Convolutional Neural Networks, arXiv 1505.02890), absent from slide 115.مستشهد به في الشريحة 86 على أنه Graham, BMVC 2015 (وذلك المؤتمر يخص ورقة Graham الأسبق Sparse 3D Convolutional Neural Networks، arXiv 1505.02890)، وغائب عن الشريحة 115.(opens in a new tab)(يفتح في تبويب جديد)
- NetAdapt: Platform-Aware Neural Network Adaptation for Mobile ApplicationsPaperECCV 2018, Yang et al.Cited on slides 33 to 40, absent from slide 115.مستشهد به في الشرائح 33 إلى 40، وغائب عن الشريحة 115.(opens in a new tab)(يفتح في تبويب جديد)
- Accelerating Sparse Deep Neural NetworksPaperNVIDIA, Mishra et al., 20212:4 sparsity giving twice the math throughput on Ampere tensor cores.تناثر 2:4 الذي يضاعف إنتاجية الحساب على أنوية Ampere الموترية.(opens in a new tab)(يفتح في تبويب جديد)
- Accelerating Inference with Sparsity Using the NVIDIA Ampere Architecture and NVIDIA TensorRTArticleNVIDIA Technical Blog, Pool, Sawarkar and Rodge, 2021Slide 115 item 8.الشريحة 115، البند 8.(opens in a new tab)(يفتح في تبويب جديد)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Lecture 4: Pruning and Sparsity (Part II)DocsMIT HAN LabSlide 115 item 19. The deck follows this lecture.الشريحة 115، البند 19. والشرائح تتبع هذه المحاضرة.(opens in a new tab)(يفتح في تبويب جديد)
- 4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural NetworksPaperCVPR 2019, Choy, Gwak and SavareseMinkowskiNet, the MinkNet(i) and MinkNet(o) workloads on slide 113.MinkowskiNet، أي حملا MinkNet(i) وMinkNet(o) في الشريحة 113.(opens in a new tab)(يفتح في تبويب جديد)
- PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric SpacePaperNeurIPS 2017, Qi, Yi, Su and GuibasThe PointNet++ variants on slide 113 and their sampling and grouping operations.نسخ PointNet++ في الشريحة 113 وعمليات أخذ العينات والتجميع فيها.(opens in a new tab)(يفتح في تبويب جديد)
- Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman CodingPaperICLR 2016, Han, Mao and DallyPruning and quantization combined, 35x on AlexNet, the bridge to the next lecture.التقليم والتكميم معًا، 35x على AlexNet، وهو الجسر إلى المحاضرة التالية.(opens in a new tab)(يفتح في تبويب جديد)
- The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural NetworksPaperICLR 2019, Frankle and CarbinRelated reading, not covered in the deck.قراءة ذات صلة، لا تغطيها الشرائح.(opens in a new tab)(يفتح في تبويب جديد)
- Model Compression and Hardware Acceleration for Neural Networks: A Comprehensive SurveyPaperProceedings of the IEEE 108(4), 2020, Deng, Li, Han, Shi and XieSlide 115 item 1.الشريحة 115، البند 1.(opens in a new tab)(يفتح في تبويب جديد)
- Computing's Energy Problem (and What We Can Do About It)PaperISSCC 2014, HorowitzSlide 115 item 2.الشريحة 115، البند 2.(opens in a new tab)(يفتح في تبويب جديد)
- Optimal Brain DamagePaperNIPS 1989, LeCun, Denker and SollaSlide 115 item 3.الشريحة 115، البند 3.(opens in a new tab)(يفتح في تبويب جديد)
- Learning Both Weights and Connections for Efficient Neural NetworksPaperNeurIPS 2015, Han, Pool, Tran and DallySlide 115 item 4, and the before and after pruning figure on slide 114.الشريحة 115، البند 4، وشكل ما قبل التقليم وما بعده في الشريحة 114.(opens in a new tab)(يفتح في تبويب جديد)
- Efficient Methods and Hardware for Deep LearningPaperStanford University PhD thesis, Han, 2017Slide 115 item 5.الشريحة 115، البند 5.(opens in a new tab)(يفتح في تبويب جديد)
- Peter Huttenlocher (1931 to 2013)ArticleNature 502, 2013, WalshSlide 115 item 6.الشريحة 115، البند 6.(opens in a new tab)(يفتح في تبويب جديد)
- Exploring the Regularity of Sparse Structure in Convolutional Neural NetworksPaperCVPR Workshops 2017, Mao et al.Slide 115 item 7, listed there under its workshop title.الشريحة 115، البند 7، مدرج هناك بعنوان نسخة الورشة.(opens in a new tab)(يفتح في تبويب جديد)
- AMC: AutoML for Model Compression and Acceleration on Mobile DevicesPaperECCV 2018, He, Lin, Liu, Wang, Li and HanSlide 115 item 9.الشريحة 115، البند 9.(opens in a new tab)(يفتح في تبويب جديد)
- Learning Structured Sparsity in Deep Neural NetworksPaperNeurIPS 2016, Wen et al.Slide 115 item 10.الشريحة 115، البند 10.(opens in a new tab)(يفتح في تبويب جديد)
- Learning Efficient Convolutional Networks through Network SlimmingPaperICCV 2017, Liu et al.Slide 115 item 11.الشريحة 115، البند 11.(opens in a new tab)(يفتح في تبويب جديد)
- Importance Estimation for Neural Network PruningPaperCVPR 2019, Molchanov et al.Slide 115 item 13.الشريحة 115، البند 13.(opens in a new tab)(يفتح في تبويب جديد)
- Network Trimming: A Data-Driven Neuron Pruning Approach towards Efficient Deep ArchitecturesPaperarXiv, Hu, Peng, Tai and Tang, July 2016Slide 115 item 14, dated 2017 on the slide.الشريحة 115، البند 14، مؤرَّخ بعام 2017 في الشريحة.(opens in a new tab)(يفتح في تبويب جديد)
- Pruning Convolutional Neural Networks for Resource Efficient InferencePaperICLR 2017, Molchanov et al.Slide 115 item 15.الشريحة 115، البند 15.(opens in a new tab)(يفتح في تبويب جديد)
- Channel Pruning for Accelerating Very Deep Neural NetworksPaperICCV 2017, He, Zhang and SunSlide 115 item 16.الشريحة 115، البند 16.(opens in a new tab)(يفتح في تبويب جديد)
- ThiNet: A Filter Level Pruning Method for Deep Neural Network CompressionPaperICCV 2017, Luo, Wu and LinSlide 115 item 17.الشريحة 115، البند 17.(opens in a new tab)(يفتح في تبويب جديد)
- SparseGPT: Massive Language Models Can Be Accurately Pruned in One-ShotPaperICML 2023, Frantar and AlistarhSlide 115 item 18.الشريحة 115، البند 18.(opens in a new tab)(يفتح في تبويب جديد)