Lecture 04-2 · Pruning and Sparsity IIالمحاضرة 04-2 · التقليم والتناثر II

TorchSparse grouping and PointAcc

التجميع في TorchSparse وPointAcc

Slides 97–115الشرائح 97–115 P3 SKIM

The 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.

Skim levelمستوى التصفح

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) النتائج الجزئية في صفوف الخرج.

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) واحد. ثلاث نقاط على طيف:

redundant ratio of group G:   r = 1 - (sum of |M_δ| in G) / (|G| x max |M_δ| in G)

نسبة الحساب الزائد للمجموعة G هي واحد ناقص (مجموع الصفوف الحقيقية) مقسوماً على (عدد الإزاحات في المجموعة مضروباً في أكبر حجم فيها).

MAP SIZES, 100 POINTS, STRIDE 1 mm (above S) bmm x4, pad to 40 bmm x4, pad to 12 100 W0,0 40 W-1,0 40 W1,0 38 W0,-1 38 W0,1 12 W-1,-1 12 W1,1 11 W-1,1 11 W1,-1 real rows 302 pad rows 6 launches 9 to 3 pad rows dense batching: 900 rows, 598 pad (66%)
Symmetric offsets have equal map sizes (40 and 40, 12 and 12). Adaptive grouping (ε = 0.05, S = 50) pads only 6 of 308 computed rows while cutting nine launches to three.الإزاحات المتناظرة لها أحجام map متساوية (40 و40، و12 و12). التجميع التكيفي (ε = 0.05, S = 50) يحشو 6 صفوف فقط من 308 صفاً محسوباً، ويخفض الإطلاقات من تسعة إلى ثلاثة.
Workedمثال محلول
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) على matmulTFLOP/sTFLOP/sSpeedupالتسريع
SemanticKITTI, separateSemanticKITTI، منفصل8.11.00x
SemanticKITTI, fixed groupingSemanticKITTI، تجميع ثابت8.70.87x
SemanticKITTI, adaptiveSemanticKITTI، تكيفي11.91.39x
nuScenes, separatenuScenes، منفصل10.41.00x
nuScenes, fixed groupingnuScenes، تجميع ثابت21.11.50x
nuScenes, adaptivenuScenes، تكيفي16.91.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 مقارنة، بتدفقين تسلسليين.

δ = (1,1): SHIFTED INPUTS P - δ 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)D WITH OUTPUTS Q 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) (P1, Q0, W1,1) (P4, Q3, W1,1)
Slide 112: five inputs and five outputs, 9 adjacent comparisons, two matches. Thick borders mark the equal neighbours.الشريحة 112: خمسة مدخلات وخمسة مخرجات، و9 مقارنات بين عناصر متجاورة، وتطابقان. الحدود السميكة تحدد الجارين المتساويين.

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، وطرقه الشائعة.

Trapفخ

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 الصغيرة غير المتساوية، أما المراحل المحكومة بالذاكرة فتحسينها منفصل.

Memory hookمفتاح للحفظ

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.