Lecture 04-2 · Pruning and Sparsity IIالمحاضرة 04-2 · التقليم والتناثر II
TorchSparse grouping and PointAcc
التجميع في TorchSparse وPointAcc
P3 SKIMThe map turns sparse convolution into many small matmuls. On a GPU that is slow for two reasons: gather and scatter are memory bound, and the matmuls are tiny and uneven. TorchSparse fixes the second by grouping offsets; PointAcc builds the map itself in hardware with a merge sort.
الـ map يحوّل sparse convolution إلى عدد كبير من matmuls الصغيرة. وعلى GPU هذا بطيء لسببين: gather وscatter محكومان بالذاكرة، وmatmuls صغيرة وغير متساوية. يعالج TorchSparse السبب الثاني بتجميع الإزاحات، ويبني PointAcc الـ map نفسه في العتاد باستخدام merge sort.
Know the three phases and where time goes, the idea of trading padding FLOPs for regularity, the headline speedups, and how a merge sort finds map entries. Detailed tuning parameters are unlikely to be examined.
اعرف المراحل الثلاث وأين يذهب الوقت، وفكرة مقايضة FLOPs الحشو بالانتظام، وأرقام التسريع الرئيسية، وكيف يجد merge sort مدخلات map. أما معاملات الضبط التفصيلية فاحتمال السؤال عنها ضعيف.
The baseline: gather, matmul, scatter per offset
خط الأساس: gather ثم matmul ثم scatter لكل إزاحة
For each weight offset δ (27 in 3D, 9 in 2D): gather the |Mδ| input rows named by the map into a buffer, run one matmul (|Mδ| x Cin) by (Cin x Cout), then scatter-accumulate the partial sums into the output rows.
لكل إزاحة وزن δ (27 في ثلاثة أبعاد، 9 في بعدين): اجمع (gather) صفوف الدخل الـ |Mδ| المذكورة في map في buffer، ونفّذ matmul واحداً (|Mδ| x Cin) في (Cin x Cout)، ثم وزّع مع الجمع (scatter-accumulate) النتائج الجزئية في صفوف الخرج.
- Gather and scatter are random memory accesses, bandwidth bound, and take 40 to 50 percent of runtime.
gather وscatter وصول عشوائي للذاكرة، محكوم بعرض النطاق، ويستهلكان 40 إلى 50% من زمن التشغيل.
- Matmuls are dense but small and uneven across offsets: about 30 percent GPU utilization.
الـ matmuls كثيفة لكنها صغيرة وغير متساوية بين الإزاحات: نحو 30% فقط من استغلال GPU.
Grouping: trade FLOPs for regularity
التجميع: نقايض FLOPs بالانتظام
Pad offsets with similar map sizes to the same height and run them as one batched matmul (bmm). Three points on a spectrum:
احشُ الإزاحات ذات أحجام map المتقاربة إلى نفس الارتفاع، ونفّذها كـ batched matmul (bmm) واحد. ثلاث نقاط على طيف:
- Separate: one matmul per offset. Zero padding, many tiny kernels.
منفصل: matmul لكل إزاحة. لا حشو، لكن نوى صغيرة كثيرة.
- Dense batching: pad every offset to the largest, one bmm. Most regular, but so much wasted compute that it loses.
تجميع كثيف: احشُ كل إزاحة إلى أكبرها، bmm واحد. الأكثر انتظاماً، لكن الحساب المهدور كبير لدرجة أنه يخسر.
- Adaptive grouping: group neighbours while the redundant ratio stays under a tolerance ε; run any offset above a size threshold S alone. About 6 groups on SemanticKITTI beat both 26 and 1, about 1.5x.
adaptive grouping: اجمع الإزاحات المتجاورة ما دامت نسبة الحساب الزائد تحت تسامح ε، ونفّذ أي إزاحة فوق عتبة الحجم S وحدها. نحو 6 مجموعات على SemanticKITTI تتفوق على 26 وعلى 1، بنحو 1.5x.
redundant ratio of group G: r = 1 - (sum of |M_δ| in G) / (|G| x max |M_δ| in G)
نسبة الحساب الزائد للمجموعة G هي واحد ناقص (مجموع الصفوف الحقيقية) مقسوماً على (عدد الإزاحات في المجموعة مضروباً في أكبر حجم فيها).
map sizes: W0,0 = 100; others 40 40 38 38 12 12 11 11 real rows = 302
separate 9 launches, 302 rows, 0 pad
dense 1 bmm (batch 9) padded to 100: 900 rows, 598 pad
r = 1 - 302/900 = 66.4%
adaptive W0,0 alone (mm) 100 rows
{40,40,38,38} pad to 40 160 rows, 4 pad, r = 1 - 156/160 = 2.5%
{12,12,11,11} pad to 12 48 rows, 2 pad, r = 1 - 46/48 = 4.2%
3 launches, 308 rows, 6 pad (1.9%)
Adding a 12 to the first group would make r = 1 - 168/200 = 16 percent, above ε, so a new group starts.
إضافة 12 إلى المجموعة الأولى تجعل r = 1 - 168/200 = 16%، وهذا فوق ε، فتبدأ مجموعة جديدة.
| Matmul ablationتجربة حذف (ablation) على matmul | TFLOP/sTFLOP/s | Speedupالتسريع |
|---|---|---|
| SemanticKITTI, separateSemanticKITTI، منفصل | 8.1 | 1.00x |
| SemanticKITTI, fixed groupingSemanticKITTI، تجميع ثابت | 8.7 | 0.87x |
| SemanticKITTI, adaptiveSemanticKITTI، تكيفي | 11.9 | 1.39x |
| nuScenes, separatenuScenes، منفصل | 10.4 | 1.00x |
| nuScenes, fixed groupingnuScenes، تجميع ثابت | 21.1 | 1.50x |
| nuScenes, adaptivenuScenes، تكيفي | 16.9 | 1.54x |
لاحظ أن fixed grouping يسجّل TFLOP/s أعلى في الحالتين لكنه أبطأ: على SemanticKITTI هو 8.7 مقابل 8.1 ومع ذلك 0.87x، وعلى nuScenes هو 21.1 مقابل 16.9 لـ adaptive ومع ذلك أبطأ قليلاً.
End to end, TorchSparse is 1.6x faster than MinkowskiEngine and 1.5x faster than SpConv, also cutting memory movement cost by 2.7x through better gather and scatter.
على مستوى النظام كاملاً، TorchSparse أسرع بـ 1.6x من MinkowskiEngine وبـ 1.5x من SpConv، ويقلّص كلفة حركة الذاكرة بـ 2.7x عبر تحسين gather وscatter.
PointAcc: build the map with a merge sort
PointAcc: بناء الخريطة بـ merge sort
Building the map means finding, for every offset δ, every pair with P = Q + δ. A GPU or a naive accelerator uses a hash table, which in parallel hardware needs an O(N2) crossbar and random SRAM reads. PointAcc instead shifts every input by -δ, merge-sorts the shifted inputs with the outputs, and reads off equal neighbours as map entries: |I| + |O| - 1 comparisons, two sequential streams.
بناء map يعني إيجاد كل زوج يحقق P = Q + δ لكل إزاحة δ. يستخدم GPU أو مسرّع بسيط جدول hash، وهو في العتاد المتوازي يحتاج crossbar بحجم O(N2) وقراءات SRAM عشوائية. أما PointAcc فيزيح كل دخل بـ -δ، ثم يدمج المدخلات المزاحة مع المخرجات بـ merge sort، ويقرأ الجيران المتساوين كمدخلات map: |I| + |O| - 1 مقارنة، بتدفقين تسلسليين.
The merge-sort mapping unit is 1.4x faster and up to 14x smaller than a hash-table unit at equal parallelism. Overall PointAcc reaches geomean 3.7x, 53x and 90x speedup over an RTX 2080Ti GPU, a Xeon plus TPU V3, and a Xeon Gold CPU (energy savings 22x, 210x and 176x; the slide prints 193x for the last).
وحدة الربط بـ merge sort أسرع بـ 1.4x وأصغر حتى 14x من وحدة جدول hash عند نفس التوازي. وإجمالاً يحقق PointAcc متوسطاً هندسياً للتسريع 3.7x و53x و90x مقارنة بـ RTX 2080Ti وXeon + TPU V3 وXeon Gold (وتوفير طاقة 22x و210x و176x، والشريحة تطبع 193x للأخير).
Lecture summary (slide 114)
ملخص المحاضرة (الشريحة 114)
This lecture covered automated ways to find pruning ratios (sensitivity analysis, AMC, NetAdapt) and system and hardware support for different granularities: EIE for weight plus activation sparsity, Ampere tensor cores for M:N, TorchSparse and PointAcc for point-cloud activation sparsity. Next: numeric data types, the basic concept of quantization, and common quantization methods.
غطّت هذه المحاضرة الطرق الآلية لإيجاد نسب التقليم (sensitivity analysis وAMC وNetAdapt)، ودعم الأنظمة والعتاد لمستويات الدقة المختلفة: EIE لتناثر الأوزان والتنشيطات، وtensor cores من جيل Ampere لنمط M:N، وTorchSparse وPointAcc لتناثر تنشيطات point cloud. التالي: أنواع البيانات العددية، والمفهوم الأساسي للـ quantization، وطرقه الشائعة.
Higher TFLOP/s can still be slower. Padded rows count as FLOPs but do no useful work. Fixed grouping on SemanticKITTI posts 8.7 TFLOP/s versus 8.1 for the baseline and is still 0.87x. Judge by wall-clock speedup, never by throughput alone.
TFLOP/s الأعلى قد يكون أبطأ مع ذلك. صفوف الحشو تُحسب FLOPs لكنها لا تنجز عملاً مفيداً. fixed grouping على SemanticKITTI يسجّل 8.7 TFLOP/s مقابل 8.1 للأساس ومع ذلك 0.87x. احكم بالتسريع الزمني الفعلي، لا بالإنتاجية وحدها.
Grouping does not fix gather and scatter. It attacks the small, uneven matmuls; the memory-bound phases are a separate optimization.
التجميع لا يعالج gather وscatter. هو يستهدف matmuls الصغيرة غير المتساوية، أما المراحل المحكومة بالذاكرة فتحسينها منفصل.
TorchSparse pays a little padding for regularity; PointAcc sorts instead of hashing. 1.6x and 1.5x over MinkowskiEngine and SpConv; 3.7x over a 2080Ti.
TorchSparse يدفع قليلاً من الحشو مقابل الانتظام، وPointAcc يرتّب بدل أن يستخدم hash. 1.6x و1.5x على MinkowskiEngine وSpConv، و3.7x على 2080Ti.
Check yourself
اختبر نفسك
Why does the baseline gather, matmul, scatter implementation underuse a GPU?
لماذا يستغل تنفيذ gather, matmul, scatter الأساسي GPU استغلالاً ضعيفاً؟
Gather and scatter take 40 to 50 percent of runtime and are bandwidth bound; each per-offset matmul is dense but too small to fill the device, about 30 percent utilization. D is false by definition.
gather وscatter يستهلكان 40 إلى 50% من الزمن وهما محكومان بعرض النطاق، وكل matmul لإزاحة واحدة كثيف لكنه أصغر من أن يملأ الجهاز، نحو 30% استغلال. الخيار D خاطئ بالتعريف.
Four offsets with map sizes 40, 40, 38, 38 are padded to 40 and run as one bmm. What is the redundant computation ratio?
أربع إزاحات بأحجام map هي 40, 40, 38, 38 تُحشى إلى 40 وتُنفّذ كـ bmm واحد. ما نسبة الحساب الزائد؟
r = 1 - 156 / (4 x 40) = 1 - 156/160 = 0.025. Option D confuses the 4 pad rows with a percentage.
r = 1 - 156 / (4 x 40) = 1 - 156/160 = 0.025. الخيار D يخلط بين صفوف الحشو الأربعة ونسبة مئوية.
On SemanticKITTI, fixed grouping reaches 8.7 TFLOP/s against 8.1 for the baseline, yet its speedup is 0.87x. Why?
على SemanticKITTI، يصل fixed grouping إلى 8.7 TFLOP/s مقابل 8.1 للأساس، ومع ذلك تسريعه 0.87x. لماذا؟
Time = FLOPs / throughput. If padding raises the FLOP count by more than the throughput rises, the layer gets slower even at a higher TFLOP/s.
الزمن يساوي FLOPs مقسومة على الإنتاجية. إذا رفع الحشو عدد FLOPs بأكثر مما ترتفع الإنتاجية، تصبح الطبقة أبطأ رغم TFLOP/s أعلى.
PointAcc's mapping unit merges 5 shifted inputs with 5 outputs. How many comparisons does it need, and why is it preferred over a hash table?
وحدة الربط في PointAcc تدمج 5 مدخلات مزاحة مع 5 مخرجات. كم مقارنة تحتاج، ولماذا تُفضَّل على جدول hash؟
|I| + |O| - 1 = 5 + 5 - 1 = 9. A parallel hash table needs an N-by-N crossbar; the merge-sort unit is 1.4x faster and up to 14x smaller.
|I| + |O| - 1 = 5 + 5 - 1 = 9. جدول hash المتوازي يحتاج crossbar بحجم N x N، ووحدة merge sort أسرع بـ 1.4x وأصغر حتى 14x.