How Much to Prune, and How to Recover
1. Where we stopped last time
In Part 1 we saw what pruning is: delete the weights the network does not need. In Part 2 we answered two of the four questions: in what shape do we delete (granularity), and which weights go (criterion).
Two questions are left, and they are the ones you meet first when you actually prune a model:
How much do we prune in each layer? Pruning every layer by the same amount is simple, but it is not the best. Some layers can lose 90% of their weights and not care; others break at 30%.
How do we get the accuracy back? After pruning, accuracy drops. Fine-tuning brings it back, but it is not the same as the original training.
At the end, a short look at the hardware side: a pruned model is only faster on paper until the hardware knows how to skip the zeros.

في الجزأين السابقين عرفنا ما هو التشذيب، وبأي شكل نحذف، وأي الأوزان نختار. بقي سؤالان: كم نحذف من كل طبقة، وكيف نستعيد الدقة بعد الحذف. وفي النهاية نظرة سريعة على العتاد Hardware: النموذج المشذّب أسرع على الورق فقط حتى يعرف الهاردوير كيف يتخطى الأصفار.
2. Pruning ratio: how much do we prune in each layer?
2.1 Why not the same amount everywhere?
The simplest plan is uniform pruning: cut every layer by the same percentage, say 50% everywhere. It is easy, and it works, but it is the wrong amount for almost every layer: too much for the layers that cannot afford it, too little for the layers that could give more.
Layers are not equal.
Some are sensitive: remove a little and the whole network's accuracy drops. Some are redundant: remove most of their weights and nothing happens. A rough rule: small layers with few weights tend to be sensitive, because each weight carries a lot; big layers with thousands of similar filters tend to be redundant, because many of those filters do almost the same job.
So instead of one number for the whole network, we want one number per layer: cut the sensitive layers a little and the redundant layers a lot. Same total size, much better accuracy. The rest of this section is about how to find those numbers.

الطبقات ليست متساوية: بعضها تتحمل حذف 90% من أوزانها، وبعضها تنهار عند 30%. لذلك الحذف بنسبة واحدة لكل الطبقات سهل لكنه يضيّع الكثير.
2.2 Sensitivity analysis: the manual way
Ask each layer, one at a time, “how much can you lose?”
Pick one layer; leave the others untouched.
Prune it by 10%, 20% … 90%, and test the whole network’s accuracy each time.
Plot accuracy against pruning ratio. A flat curve is a robust layer; one that falls early is a sensitive layer.
Repeat for every layer.
Pick the accuracy loss you can accept and draw it as a horizontal line. Where each curve crosses the line is that layer’s ratio: a sensitive layer might cross at 70%, a robust one at 90%.

Good: no training, only forward passes; easy to explain.
Bad: slow (about 10 tests per layer, for every layer), and it looks at each layer alone. Pruning layer 3 and layer 7 together can hurt far more than the two losses added up, because layers interact.
نسأل كل طبقة على حدة: نحذف منها 10%، 20%، حتى 90%، ونقيس دقة الشبكة كل مرة. ثم نختار حدًّا للخسارة المقبولة، وحيث يقطع منحنى كل طبقة هذا الحد تكون نسبة حذفها. طريقة بسيطة بلا تدريب، لكنها بطيئة وتتجاهل تأثير الطبقات في بعضها.
2.3 AMC: let an agent choose the ratios
If a human needs a week of trial and error per model, and you have many models, you need an army of engineers. AMC (AutoML for Model Compression) replaces the human with a learning agent.
Think of it as a game. The agent walks through the network layer by layer. At each layer it sees a short description (which layer, how many channels, kernel size, how many MACs) and picks one number: the pruning ratio for this layer, anywhere from 0 to 1. When it reaches the end, the pruned network is tested and the agent gets a score. A good score is a low error; if the network is bigger than the target size, the score is the worst possible. The agent plays many rounds and learns which layers to spare and which to cut.
Two details worth knowing:
The score uses the log of the compute, not the compute itself. Accuracy grows roughly with the log of the operations: the first few MACs buy a lot of accuracy, the last ones buy very little. So the reward is written as error × log(FLOPs).
It can target real latency, not just MACs. Doubling the MACs does not double the time on a real chip. AMC can use a lookup table built in advance ("this layer with this many channels takes this many ms on this phone") and optimize the measured time.

في AMC يستبدل المهندس بوكيل agent يتعلم، كأنه يلعب لعبة. يمر على الطبقات واحدة واحدة؛ عند كل طبقة يرى معلومات بسيطة عنها (حجمها، عدد قنواتها، كم عملية ضرب تحتاج) ويختار رقمًا واحدًا: كم نحذف من هذه الطبقة. عندما ينتهي من كل الطبقات تُختبر الشبكة الناتجة ويحصل على درجة: عالية إن بقيت الدقة جيدة وصار الحجم ضمن الهدف، وصفر إن تجاوز الهدف. يكرر اللعبة جولات كثيرة، وفي كل جولة يتعلم من درجته أي الطبقات تتحمل الحذف وأيها لا. وبذلك اكتشف وحده أن الطبقات الكبيرة ذات الفلاتر المتشابهة تتحمل حذفًا كبيرًا، بينما الطبقات الرفيعة التي لا فائض فيها يجب أن تُترك تقريبًا كما هي.
2.4 NetAdapt: shrink step by step until you hit the budget
NetAdapt asks a different question: not "what ratio per layer?" but "I have a latency budget; which layer do I cut next?"
Decide a small latency step, say 1 ms per round.
For every layer, find how many channels you would need to remove from that layer alone to save 1 ms (from a lookup table, so no phone needed), remove them, fine-tune briefly (around 10k steps), and note the accuracy.
Keep only the layer whose cut hurt accuracy the least. Throw the other trials away.
Repeat until the total latency meets the budget.
Fine-tune for a long time once, at the very end.
The short fine-tune in step 2 is the trick: a full fine-tune inside the loop would be far too slow, and a short one is enough to rank the layers.
A nice side effect: every round produces a working model, so one run gives you a whole family of models at different speeds. Full battery, run the big one; low battery, run the small one.

فكرة NetAdapt يسير خطوة خطوة: في كل جولة يجرب حذفًا صغيرًا من كل طبقة على حدة بحيث يوفر القدر نفسه من الزمن، ويبقي الطبقة التي خسرت أقل دقة، ثم يكرر حتى يبلغ الميزانية. كل جولة تعطي نموذجًا صالحًا، فنحصل على عائلة من النماذج بسرعات مختلفة.
2.5 The three side by side
Sensitivity analysis | AMC | NetAdapt | |
Who decides | A person with a threshold | A learning agent | A greedy loop |
Sees layer interaction | No | Yes | Partly (one layer per round, but on the already-pruned model) |
Training inside | None | Fine-tune after | Short fine-tune every round |
Target | Accuracy loss | Model size, FLOPs or latency | Latency or energy |
Cost | Hours of testing | Hours of agent rounds | Hours, grows with the number of layers |
Extra | Simple to explain | Finds patterns a human misses | Gives a family of models |
مقارنة سريعة بين الثلاث طرق :
تحليل الحساسية: يغيّر طبقة واحدة بدون تغيير باقي الطبقات ثم ويقيس الأداء/الحساسية إلى أن يصل إلى نسبة تشذيب مناسبة لا تخل بالأداء. يثبت الرقم هذا بشكل خارجي ويرجع الطبقة مثل ماكانت بدون تشذيب، ينتقل للطبقة الي بعدها ويجرب مرة أخرى ، ويسجل نسبة التشذيب والأداء المناسبة وهكذا مع كل الطبقات. كل طبقة تُختبر وحدها والباقي بدون تغيير.
طريقة NetAdapt: يجرّب حذفًا صغيرًا من الطبقة الأولى ، إذا الأداء مناسب يثبت هذا التغيير ، وينتقل للطبقة الي بعدها ، يبقي الأفضل، ثم يكرر.
طريقة AMC: يمرّ على كل الطبقات ويختار نسبة لكل واحدة دون أن يرى أي نتيجة تأثير تشذيب طبقة معينة بعينها. يقيس الدرجة الإجمالية الدرجة تأتي في النهاية، بعد أن تُحذف كل الطبقات معًا وتُختبر الشبكة كاملة. ثم يبدأ جولة جديدة من أول طبقة بخيارات مختلفة قليلًا. بعد مئات الجولات يتعلم أي مجموعة من النسب تعطي أعلى درجة.
3. Fine-tuning: getting the accuracy back
Pruning alone gives a smaller model, but it costs accuracy, and past a certain point it costs a lot. Fine-tuning brings it back.
The weights that survived still have their old values, but their deleted neighbours are gone. So we train the pruned network a little more, on the same data, with the deleted weights kept at zero. The survivors adjust and take over the missing work.
The order is train → prune → fine-tune, and if we go step by step, → prune more → fine-tune again. It is not training from scratch; it is a short re-training of what is left, with three differences from normal training.
Three differences from normal training:
A much smaller learning rate (1/10 to 1/100). The pruned model is already near a good solution; big steps would push it away.
Prune a little, train, repeat. Cutting 70% at once damages the network too much to recover. Cut 30%, train, cut to 50%, train, cut to 70%, train: each step is small enough to heal. Each round also removes only weights that became small after the previous training, not weights that were small in the original model.
A small penalty on non-zero weights (regularization). Added to the loss, it pushes weights toward zero, so the network learns to work with smaller weights, and small weights are exactly what the next round deletes. L1 or L2; the choice is engineering, not theory.

الحذف وحده يعطي نموذجًا أصغر، لكنه يخسر دقة، وبعد نسبة معينة يخسر الكثير. الضبط الدقيق هو طريقة الاستعادة: الأوزان الباقية ما زالت تحمل قيمها من التدريب الأصلي، لكن جيرانها المحذوفين اختفوا، فندرّب الشبكة بضع دورات إضافية على البيانات نفسها مع إبقاء المحذوف صفرًا، فتتكيف الأوزان الباقية وتعوّض عمل الغائبة.
الترتيب: تدريب ← حذف ← ضبط دقيق، وإن تدرّجنا: حذف أكثر ← ضبط مرة أخرى. ليس تدريبًا من الصفر، بل إعادة تدريب قصيرة لما تبقى. ، تختلف عن التدريب العادي في ثلاثة أمور:
معدل تعلم أصغر بكثير (1/10 إلى 1/100 من الأصلي). النموذج المشذّب قريب أصلًا من حل جيد، والخطوات الكبيرة تبعده عنه.
حذف قليل، ثم تدريب، ثم تكرار. حذف 70% دفعة واحدة يضر الشبكة فلا تتعافى. أما 30% ثم تدريب، ثم 50% ثم تدريب، ثم 70% ثم تدريب، فكل خطوة صغيرة بما يكفي للتعافي. وكل جولة تحذف الأوزان التي صغُرت بعد التدريب السابق، لا التي كانت صغيرة في النموذج الأصلي.
عقوبة صغيرة على الأوزان غير الصفرية (regularization). تُضاف إلى دالة الخسارة فتدفع الأوزان نحو الصفر، فتتعلم الشبكة أداء عملها بأوزان أصغر، والأوزان الصغيرة هي بالضبط ما تحذفه الجولة التالية. الشكلان الشائعان L1 وL2، والاختيار بينهما هندسي لا نظري.
4. From paper to speed: who skips the zeros?
4. From paper to speed: who skips the zeros?
A pruned model has fewer MACs on paper. A plain GPU still multiplies the zeros (Part 2). Three ways to make the saving real:
A chip built for zeros (EIE). One rule: anything × 0 = 0, so neither store it nor compute it. It skips zero weights (known in advance) and zero activations (checked on the fly), and the two savings multiply. Price: a lot of bookkeeping per multiply, and it only fits small, fully connected models.
A fixed pattern the GPU understands (2:4). In every 4 weights, exactly 2 are zero. Store the 2 kept values plus 2 bits saying where they sat; the GPU uses those bits to pick the 2 matching inputs and skip the rest. Half the storage, half the multiplies, every thread equally busy, about 2× faster with almost no accuracy loss.
Zeros in the data, not the weights. A 3D point cloud is mostly empty. Sparse convolution computes only where there is a point, so the emptiness is never filled in. Same rule, different source of zeros.
The one-sentence lesson: be lazy. Avoid redundant work, reject it quickly, or delay it.

النموذج المشذّب أسرع على الورق فقط حتى يعرف العتاد كيف يتخطى الأصفار. ثلاث طرق: شريحة خاصة تتخطى أصفار الأوزان والمدخلات معًا لكنها تناسب النماذج الصغيرة فقط؛ نمط ثابت (صفران من كل أربعة) يفهمه الـ GPU فيعطي ضعف السرعة تقريبًا بلا خسارة دقة؛ وتخطي الفراغ في البيانات نفسها كسحب النقاط. الدرس: كن كسولًا، لا تحسب ما لا تحتاجه.
5. Closing
That completes the four questions. Pruning a model in practice looks like this:
Choose a shape (Part 2): fine-grained for the smallest model, 2:4 or channel-level for real speed.
Choose a criterion (Part 2): magnitude by default, Wanda for large language models.
Choose how much per layer: a sensitivity sweep if you have one model, AMC or NetAdapt if you have many or a hard latency budget.
Fine-tune, with a small learning rate, in a few prune-and-train rounds, with a light penalty on the weights.
Then check that the hardware you ship on can actually skip your zeros. If it cannot, the model is smaller but not faster.
Next in the series: quantization, where we keep every weight but store each one in fewer bits.
اكتملت الأسئلة الأربعة: الشكل، المعيار، النسبة لكل طبقة، ثم الضبط الدقيق. وقبل النشر تأكد أن الهاردوير يستطيع تخطي الأصفار، وإلا فالنموذج أصغر لكنه ليس أسرع.
Sources
MIT 6.5940 Lecture 4: Pruning and Sparsity, Part II (slides and transcript)
Han et al., Learning Both Weights and Connections for Efficient Neural Networks, NeurIPS 2015
He et al., AMC: AutoML for Model Compression and Acceleration on Mobile Devices, ECCV 2018
Yang et al., NetAdapt: Platform-Aware Neural Network Adaptation for Mobile Applications, ECCV 2018
Han et al., EIE: Efficient Inference Engine on Compressed Deep Neural Network, ISCA 2016
Mishra et al., Accelerating Sparse Deep Neural Networks, 2021 (2:4 sparsity)
I hope you enjoyed this article ♥




Comments