Majid Al-RaimiGroup quantization: VS-Quant and shared micro-exponent formatsالتكميم بالمجموعات: VS-Quant وصيغ الأس الدقيق المشترك (MX)

COE 592Lecture 5.3المحاضرة 5.3Part 02الجزء 02

Group quantization: VS-Quant and shared micro-exponent formatsالتكميم بالمجموعات: VS-Quant وصيغ الأس الدقيق المشترك (MX)

Going finer than a channel: give small groups of elements their own scale. VS-Quant uses a cheap integer per-vector scale under a floating-point per-tensor or per-channel scale, and the MX formats share tiny exponents across 2 and 16 elements; the cost is counted as effective bit width.الذهاب إلى ما هو أدق من القناة: إعطاء مجموعات صغيرة من العناصر مقياسها الخاص. يستخدم VS-Quant مقياسًا صحيحًا رخيصًا لكل متجه تحت مقياس عائم لكل موتر أو لكل قناة، وتشارك صيغ MX أسسًا صغيرة عبر 2 و16 عنصرًا؛ وتُحسب الكلفة بوصفها عرض بت فعّالًا.

Conceptsالمفاهيم
4
Slidesالشرائح
14-21
Readingمدة القراءة
24 min24 دقيقة
Understoodما فهمته
0/4 conceptsمفاهيم

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

Part 1 ended with per-channel scales beating a single per-tensor scale. That is the whole story at 8 bits. At 4 bits it is not, and 4 bits is exactly where modern edge accelerators and data-center GPUs are heading. This part shows the next step down the granularity ladder: give small groups of weights their own scale, then pay for those extra scales cleverly with a second, coarser level. The one number to carry into the exam is the Effective bit width, and you will be able to compute it for any scheme in seconds.

انتهى الجزء 1 بتفوّق مقاييس كل قناة (per-channel) على مقياس واحد للموتر كله (per-tensor). هذه هي القصة كاملة عند 8 بت. أما عند 4 بت فليست كذلك، و4 بت هو بالضبط الاتجاه الذي تسير إليه مسرّعات الحافة (edge) الحديثة ووحدات GPU في مراكز البيانات. يعرض هذا الجزء الدرجة التالية نزولًا في سلّم الدقة الحبيبية (granularity): نعطي مجموعات صغيرة من الأوزان مقياسًا خاصًا بكل منها، ثم ندفع ثمن هذه المقاييس الإضافية بذكاء عبر مستوى ثانٍ أخشن. الرقم الوحيد الذي يجب أن تحمله معك إلى الاختبار هو effective bit width (عرض البت الفعلي)، وستتمكن من حسابه لأي مخطط في ثوانٍ.

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

  1. Explain why per-channel scales stop being enough at 4 bits and what a group scale buys.تشرح لماذا لا تعود مقاييس كل قناة (per-channel) كافية عند 4 بت، وما الذي يكسبه مقياس المجموعة (group scale).
  2. Write the VS-Quant two-level form r = gamma * S_q (q - Z) and say which scale is integer and which is floating point, and why.تكتب الصيغة ثنائية المستوى في VS-Quant وهي r = gamma * S_q (q - Z)، وتحدد أي المقياسين عدد صحيح وأيهما فاصلة عائمة (floating point)، ولماذا.
  3. Generalize to r = (q - z) * s_l0 * s_l1 * ... and compute the effective bit width of any scheme.تعمّم إلى الصيغة r = (q - z) * s_l0 * s_l1 * ... وتحسب عرض البت الفعلي (effective bit width) لأي مخطط.
  4. Reproduce the slide 21 table: per-channel 4, VSQ 4.25, MX4 4, MX6 6, MX9 9.تعيد بناء جدول الشريحة 21: per-channel يساوي 4، وVSQ يساوي 4.25، وMX4 يساوي 4، وMX6 يساوي 6، وMX9 يساوي 9.
  5. Tell the paper's MX4/MX6/MX9 apart from the OCP MXFP4 and NVIDIA NVFP4 formats that Blackwell runs.تميّز صيغ MX4 وMX6 وMX9 الواردة في الورقة البحثية عن صيغتي MXFP4 من OCP وNVFP4 من NVIDIA اللتين تشغّلهما معالجات Blackwell.

Start with one output channel of eight weights, quantized to symmetric INT4. Symmetric INT4 gives you integers from -7 to 7, so qmax⁡=7q_{\max} = 7. Split the channel into two groups of four: group A is [0.13, -0.21, 0.17, 0.06] and group B is [3.15, -0.3, 0.4, 0.1]. The 3.15 is an outlier, the kind every trained layer has a few of.

ابدأ بقناة إخراج واحدة فيها ثمانية أوزان، مكمّمة إلى INT4 متماثل. يعطيك INT4 المتماثل أعدادًا صحيحة من -7 إلى 7، أي أن qmax⁡=7q_{\max} = 7. قسّم القناة إلى مجموعتين من أربعة أوزان: المجموعة A هي [0.13, -0.21, 0.17, 0.06] والمجموعة B هي [3.15, -0.3, 0.4, 0.1]. القيمة 3.15 قيمة شاذة (outlier)، من النوع الذي يوجد منه القليل في كل طبقة مدرَّبة.

Worked exampleمثال محلول

One outlier, two choices of scaleقيمة شاذة واحدة وخياران للمقياس

  1. Per-channel scaleمقياس لكل قناة

    Per-channel quantization uses one scale for all eight weights: S=3.15/7=0.45S = 3.15 / 7 = 0.45. Group A divided by 0.45 gives 0.29, -0.47, 0.38, 0.13, and every one rounds to 0. Group A is erased.
    يستخدم per-channel quantization مقياسًا واحدًا للأوزان الثمانية كلها: S=3.15/7=0.45S = 3.15 / 7 = 0.45. قسمة المجموعة A على 0.45 تعطي 0.29, -0.47, 0.38, 0.13، وكل واحدة منها تُقرَّب إلى 0. المجموعة A تُمحى تمامًا.
  2. Per-group scalesمقياس لكل مجموعة

    Give each group of four its own scale. Group A: SA=0.21/7=0.03S_A = 0.21 / 7 = 0.03, so q = [4, -7, 6, 2] and the reconstruction is [0.12, -0.21, 0.18, 0.06]. Group B keeps SB=0.45S_B = 0.45 because it holds the outlier.
    أعطِ كل مجموعة من أربعة أوزان مقياسها الخاص. المجموعة A: SA=0.21/7=0.03S_A = 0.21 / 7 = 0.03، إذن q = [4, -7, 6, 2] وإعادة البناء تساوي [0.12, -0.21, 0.18, 0.06]. أما المجموعة B فتحتفظ بـ SB=0.45S_B = 0.45 لأنها تحتوي القيمة الشاذة.
  3. Compare the errorsقارن الأخطاء

    Group B is identical in both schemes (squared error 0.035). Group A costs 0.0935 under the channel scale and 0.0002 under its own scale. Total: 0.1285 versus 0.0352.
    المجموعة B متطابقة في المخططين (الخطأ التربيعي 0.035). أما المجموعة A فتكلّف 0.0935 تحت مقياس القناة و0.0002 تحت مقياسها الخاص. المجموع: 0.1285 مقابل 0.0352.
  4. Resultالنتيجة

    The group scale cuts the squared error by more than 3.5x, and it does so by keeping the outlier's damage inside its own group.
    مقياس المجموعة يخفّض الخطأ التربيعي بأكثر من 3.5x، ويفعل ذلك بحصر ضرر القيمة الشاذة داخل مجموعتها.
One channel of 16 weights with an outlier. Grey bars: one channel scale (S = 0.45) rounds most small weights to 0. Hover: four groups of 4, each with its own scale, restore them.قناة واحدة من 16 وزنًا فيها قيمة شاذة. الأعمدة الرمادية: مقياس قناة واحد (S = 0.45) يقرّب معظم الأوزان الصغيرة إلى 0. عند التمرير: أربع مجموعات من 4 أوزان، لكل منها مقياسها، تعيد هذه الأوزان.

That is Group quantization. Slides 14 and 15 place it on the Quantization granularity ladder: Per-tensor quantization shares one scale across the whole tensor, per-channel shares one across each output channel, and group quantization shares one across a small group of elements, typically 16 to 64, inside a channel. The slides name two concrete families: per-vector quantization (VS-Quant) and the shared micro-exponent (MX) data types.

هذا هو group quantization (التكميم بالمجموعات). تضعه الشريحتان 14 و15 على سلّم quantization granularity: per-tensor quantization يشارك مقياسًا واحدًا عبر الموتر كله، وper-channel يشارك مقياسًا واحدًا عبر كل قناة إخراج، والتكميم بالمجموعات يشارك مقياسًا واحدًا عبر مجموعة صغيرة من العناصر داخل القناة، عادة من 16 إلى 64 عنصرًا. تسمّي الشرائح عائلتين محددتين: التكميم لكل متجه (VS-Quant) وأنواع بيانات الأسس الدقيقة المشتركة (MX).

The general rule: the fewer quantization levels you have, the more each scale has to be fitted to its local neighbourhood. At 8 bits you have 255 levels and a channel scale wastes a few of them. At 4 bits you have 15, and wasting most of them on one outlier leaves the bulk of the weights with one or two levels, or none.

القاعدة العامة: كلما قلّ عدد مستويات التكميم، وجب أن يُضبط كل مقياس أكثر على جواره المحلي. عند 8 بت لديك 255 مستوى، ومقياس القناة يهدر بضعة منها فقط. عند 4 بت لديك 15 مستوى فقط، وإهدار معظمها على قيمة شاذة واحدة يترك أغلب الأوزان بمستوى أو مستويين، أو بلا مستوى إطلاقًا.

Why the hardware vendors careلماذا يهتم صانعو العتاد

Slide 16 frames the goal as a balance between quantization accuracy and hardware efficiency, and uses NVIDIA Blackwell as the evidence. Blackwell tensor cores support "micro-tensor scaling" to keep FP4 accurate, and the FP4 path has twice the theoretical throughput of the FP8/FP6/INT8 path: an HGX B200 board (eight GPUs) is rated at 144 PFLOPS FP4 versus 72 PFLOPS FP8/FP6 and 72 POPS INT8. Halving the bits doubles the math per cycle, but only if accuracy survives, and at 4 bits accuracy survives only with fine-grained scales. So the vendor built the group scaling into the tensor core itself: the hardware reads a block of FP4 values together with its scale and applies the scale during the dot product.

تصوغ الشريحة 16 الهدف على أنه توازن بين دقة التكميم وكفاءة العتاد، وتستخدم NVIDIA Blackwell دليلًا على ذلك. تدعم أنوية الموترات (tensor cores) في Blackwell ما يسمى "micro-tensor scaling" للحفاظ على دقة FP4، ومسار FP4 له ضعف الإنتاجية النظرية لمسار FP8/FP6/INT8: لوحة HGX B200 (ثماني وحدات GPU) مصنّفة بـ 144 PFLOPS في FP4 مقابل 72 PFLOPS في FP8/FP6 و72 POPS في INT8. تقليل عدد البتات إلى النصف يضاعف الحساب في كل دورة، لكن فقط إذا صمدت الدقة، وعند 4 بت لا تصمد الدقة إلا بمقاييس دقيقة الحبيبات. لذلك بنى الصانع التحجيم بالمجموعات داخل نواة الموترات نفسها: يقرأ العتاد كتلة من قيم FP4 مع مقياسها، ويطبّق المقياس أثناء حساب الضرب النقطي (dot product).

Recall

Why is a per-channel scale usually fine at INT8 but often not at INT4?لماذا يكون مقياس القناة الواحدة (per-channel) كافيًا عادةً في INT8 لكنه كثيرًا ما لا يكفي في INT4؟

INT8 has 255 levels, so even when an outlier stretches the range, small weights still get many levels. INT4 has only 15 symmetric levels, so an outlier in a long channel makes the scale so large that most small weights round to 0 or ±1. Smaller groups restore a scale that fits their own values.

يملك INT8 عدد 255 مستوى، فحتى عندما تمدّ قيمة شاذة المدى، تبقى للأوزان الصغيرة مستويات كثيرة. أما INT4 فلا يملك إلا 15 مستوى متماثلًا، فالقيمة الشاذة في قناة طويلة تجعل المقياس كبيرًا إلى حد أن معظم الأوزان الصغيرة تُقرَّب إلى 0 أو ±1. المجموعات الأصغر تعيد مقياسًا يناسب قيمها الخاصة.

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

Why does group quantization beat per-channel quantization at 4 bits?لماذا يتفوق التكميم بالمجموعات على التكميم لكل قناة عند 4 بت؟

Back to the example. Group A wanted SA=0.03S_A = 0.03 and group B wanted SB=0.45S_B = 0.45. Stored as FP16 numbers, these scales would cost 16 bits per group, which for groups of 16 INT4 weights adds a full 1 bit per weight. Worse, the hardware would need a floating-point multiplier next to every small vector unit. VS-Quant (Dai et al., NVIDIA) avoids both by noticing that the per-vector scales inside one channel differ from each other by modest factors. Factor each one as a shared floating-point number times a small integer:

نعود إلى المثال. المجموعة A أرادت SA=0.03S_A = 0.03 والمجموعة B أرادت SB=0.45S_B = 0.45. لو خُزّنت هذه المقاييس أعدادًا من نوع FP16 لكلّفت 16 بت لكل مجموعة، وهذا يضيف 1 بت كاملًا لكل وزن عندما تكون المجموعات من 16 وزنًا INT4. والأسوأ أن العتاد سيحتاج إلى وحدة ضرب فاصلة عائمة بجانب كل وحدة متجهات صغيرة. يتجنب VS-Quant (Dai et al. من NVIDIA) المشكلتين بملاحظة أن مقاييس المتجهات داخل القناة الواحدة تختلف عن بعضها بعوامل معتدلة. لذلك نحلّل كل واحد منها إلى عدد فاصلة عائمة مشترك مضروبًا في عدد صحيح صغير:

r=S (q−Z)  ⟶  r=γ⋅Sq (q−Z)r = S\,(q - Z) \;\longrightarrow\; r = \gamma \cdot S_q\,(q - Z)
The hierarchical scale of VS-Quant (slide 17)المقياس الهرمي في VS-Quant (الشريحة 17)
  • γ\gamma is a floating-point, coarse-grained scale, one per channel or per tensor.γ\gamma مقياس فاصلة عائمة خشن الحبيبات، واحد لكل قناة أو لكل موتر.
  • SqS_q is an integer scale, one per vector of elements (for example 16), stored with only a few bits such as UINT4.SqS_q مقياس عدد صحيح، واحد لكل متجه من العناصر (مثلًا 16 عنصرًا)، ويُخزَّن ببتات قليلة فقط مثل UINT4.

In the example, pick γ=0.45/15=0.03\gamma = 0.45 / 15 = 0.03 so the largest per-vector scale fits in UINT4. Then Sq,B=15S_{q,B} = 15 and Sq,A=1S_{q,A} = 1: two 4-bit integers and one FP16 number replace two FP16 scales. In a real layer one γ\gamma covers thousands of vectors, so its cost all but vanishes. (Real scales rarely divide this neatly; rounding the scale itself adds a small error, which VS-Quant's calibration algorithm accounts for.)

في المثال، اختر γ=0.45/15=0.03\gamma = 0.45 / 15 = 0.03 حتى يتسع أكبر مقياس متجه في UINT4. عندها Sq,B=15S_{q,B} = 15 وSq,A=1S_{q,A} = 1: عددان صحيحان من 4 بت وعدد FP16 واحد يحلّون محل مقياسين من FP16. في طبقة حقيقية يغطي γ\gamma واحد آلاف المتجهات، فتكاد كلفته تختفي. (نادرًا ما تنقسم المقاييس الحقيقية بهذه السهولة، وتقريب المقياس نفسه يضيف خطأً صغيرًا، وتأخذه خوارزمية المعايرة (calibration) في VS-Quant في الحسبان.)

Why the fine scale is the integer oneلماذا يكون المقياس الناعم هو العدد الصحيح

The design rule on slide 17 is: less expensive integer scales at finer granularity, more expensive floating-point scales at coarser granularity. Count how often each scale is stored and used. There is one SqS_q per vector, so there are many of them, and each one must be both small in memory and cheap to multiply. An integer scale lets the vector MAC unit finish the whole per-vector dot product, scaling included, in integer arithmetic. There is only one γ\gamma per channel, so it can afford to be a precise floating-point number, applied once to the accumulated result. Put the expensive thing where it is rare.

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

The memory billفاتورة الذاكرة

Slide 17 gives the overhead: 4-bit elements with a 4-bit per-vector scale for every 16 elements cost 4+4/16=4.254 + 4/16 = 4.25 bits per element, a storage overhead of 6.25% over plain INT4. The paper writes this as M/(VN)M/(VN) for NN-bit elements, MM-bit scales and vectors of VV elements.

تعطي الشريحة 17 الكلفة الإضافية: عناصر من 4 بت مع مقياس متجه من 4 بت لكل 16 عنصرًا تكلّف 4+4/16=4.254 + 4/16 = 4.25 بت لكل عنصر، أي كلفة تخزين إضافية قدرها 6.25% فوق INT4 العادي. تكتب الورقة ذلك على الصورة M/(VN)M/(VN) لعناصر من NN بت، ومقاييس من MM بت، ومتجهات من VV عنصرًا.

Recall

Write the VS-Quant reconstruction formula and say which factor is integer, which is floating point, and the granularity of each.اكتب صيغة إعادة البناء في VS-Quant، وحدد أي العاملين عدد صحيح وأيهما فاصلة عائمة، ودرجة الحبيبات لكل منهما.

r=γ⋅Sq(q−Z)r = \gamma \cdot S_q (q - Z). SqS_q is an integer scale, one per vector (fine granularity). γ\gamma is a floating-point scale, one per channel or tensor (coarse granularity).

r=γ⋅Sq(q−Z)r = \gamma \cdot S_q (q - Z). SqS_q مقياس عدد صحيح، واحد لكل متجه (حبيبات ناعمة). γ\gamma مقياس فاصلة عائمة، واحد لكل قناة أو موتر (حبيبات خشنة).

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

Why is the fine-level scale in VS-Quant an integer rather than floating point?لماذا يكون مقياس المستوى الناعم في VS-Quant عددًا صحيحًا لا فاصلة عائمة؟

VS-Quant has two scale levels. Nothing stops you from having more, so slides 18 to 20 write the general Multi-level scaling form. Take one weight, say w11w_{11}. It belongs to a small group (level 0), which belongs to a larger group (level 1), and so on. Its real value is its integer times the product of every scale above it:

لدى VS-Quant مستويان من المقاييس. لا شيء يمنعك من أكثر من ذلك، لذلك تكتب الشرائح من 18 إلى 20 الصيغة العامة لـ multi-level scaling (التحجيم متعدد المستويات). خذ وزنًا واحدًا، مثلًا w11w_{11}. إنه ينتمي إلى مجموعة صغيرة (المستوى 0)، وهذه تنتمي إلى مجموعة أكبر (المستوى 1)، وهكذا. قيمته الحقيقية هي عدده الصحيح مضروبًا في حاصل ضرب كل المقاييس التي فوقه:

r=(q−z)⋅s  ⟶  r=(q−z)⋅sl0⋅sl1⋯r = (q - z)\cdot s \;\longrightarrow\; r = (q - z)\cdot s_{l_0}\cdot s_{l_1}\cdots
r real value, q quantized value, z zero point (z = 0 is symmetric), s scale factors of different levelsr القيمة الحقيقية، وq القيمة المكمَّمة، وz نقطة الصفر (z = 0 يعني متماثلًا)، وs معاملات المقياس في المستويات المختلفة

VS-Quant is the case sl0=Sqs_{l_0} = S_q, sl1=γs_{l_1} = \gamma, and plain per-channel quantization is the one-level case. With z=0z = 0 the scheme is Symmetric quantization, which is what every row of the slide table uses.

VS-Quant هو الحالة sl0=Sqs_{l_0} = S_q وsl1=γs_{l_1} = \gamma، والتكميم العادي لكل قناة هو حالة المستوى الواحد. ومع z=0z = 0 يكون المخطط symmetric quantization (تكميمًا متماثلًا)، وهو ما تستخدمه كل صفوف جدول الشريحة.

Nested groups on a weight matrix, as on slides 20 and 21. Hover: pairs form L0 groups with a 1-bit scale, and the whole run of 16 forms an L1 group with an 8-bit scale.مجموعات متداخلة على مصفوفة أوزان، كما في الشريحتين 20 و21. عند التمرير: كل زوج يشكّل مجموعة L0 بمقياس من 1 بت، والسلسلة الكاملة من 16 عنصرًا تشكّل مجموعة L1 بمقياس من 8 بت.

The effective bit widthعرض البت الفعلي (effective bit width)

Every scale is shared by its group, so its bits are spread over the group's elements. Add the element bits to each level's share:

كل مقياس تشترك فيه مجموعته، فتتوزع بتاته على عناصر المجموعة. أضف إلى بتات العنصر حصة كل مستوى:

beff=belement+∑levels lbscale,lglb_{\text{eff}} = b_{\text{element}} + \sum_{\text{levels } l} \frac{b_{\text{scale},l}}{g_l}
g_l is the number of elements that share one level-l scaleg_l عدد العناصر التي تتشارك مقياسًا واحدًا من المستوى l

Worked exampleمثال محلول

The two rows on slide 20الصفان في الشريحة 20

  1. Per-channel INT4, FP16 scale per channelINT4 لكل قناة، مع مقياس FP16 لكل قناة

    One level, g0=Kg_0 = K (the channel length). For K = 4096: 4+16/4096≈4.0044 + 16/4096 \approx 4.004. The slide writes 4.
    مستوى واحد، وg0=Kg_0 = K (طول القناة). عندما K = 4096: 4+16/4096≈4.0044 + 16/4096 \approx 4.004. تكتب الشريحة 4.
  2. VSQ INT4VSQ بصيغة INT4

    L0: UINT4 per 16 elements. L1: FP16 per channel. 4+4/16+16/4096≈4.2544 + 4/16 + 16/4096 \approx 4.254. The slide writes 4+4/16=4.254 + 4/16 = 4.25.
    L0: UINT4 لكل 16 عنصرًا. L1: FP16 لكل قناة. 4+4/16+16/4096≈4.2544 + 4/16 + 16/4096 \approx 4.254. تكتب الشريحة 4+4/16=4.254 + 4/16 = 4.25.
  3. Resultالنتيجة

    Both slide numbers drop the per-channel FP16 term. That is a fair approximation because one scale per thousands of weights is a few thousandths of a bit, but say so explicitly if an exam asks for exact numbers.
    رقما الشريحة كلاهما يُسقطان حد FP16 الخاص بكل قناة. هذا تقريب مقبول لأن مقياسًا واحدًا لكل آلاف الأوزان لا يتجاوز بضعة أجزاء من الألف من البت، لكن صرّح بذلك إذا طلب الاختبار أرقامًا دقيقة.

Use the calculator to rebuild every row of the slide table and to try the exam case. Notice how the L1 share collapses toward 0 as its group grows, and how the L0 share dominates.

استخدم الحاسبة لإعادة بناء كل صف في جدول الشريحة ولتجربة حالة الاختبار. لاحظ كيف تنهار حصة L1 نحو 0 كلما كبرت مجموعتها، وكيف تهيمن حصة L0.

CalculatorحاسبةEffective bit width of a scaled formatعرض البتات الفعلي لصيغة مُحجَّمة
L0 (fine)
L1 (coarse)

4 + 4/16 + 16/4096 = 4.2539

Effective4.2539bits
L0 share0.25bits
L1 share0.0039bits
vs FP163.76xsmalleroverhead 6.35% of element bits

UINT4 scale per 16 weights, FP16 scale per 4096-weight channel. The slide keeps only 4/16. Effective bits = b + s0/g0 + s1/g1.معامل scale بصيغة UINT4 لكل 16 وزنًا، ومعامل scale بصيغة FP16 لكل قناة من 4096 وزنًا. الشريحة تحتفظ بالحد 4/16 فقط. عدد البتات الفعلي (effective bits) يساوي b + s0/g0 + s1/g1.

Recall

A scheme stores INT4 elements, a UINT8 scale per 64 elements, and an FP32 scale per 4096 elements. What is its effective bit width?مخطط يخزّن عناصر INT4، ومقياس UINT8 لكل 64 عنصرًا، ومقياس FP32 لكل 4096 عنصرًا. ما عرض البت الفعلي له؟

4+8/64+32/4096=4+0.125+0.0078≈4.1334 + 8/64 + 32/4096 = 4 + 0.125 + 0.0078 \approx 4.133 bits per element. Dropping the coarse term gives 4.125.

4+8/64+32/4096=4+0.125+0.0078≈4.1334 + 8/64 + 32/4096 = 4 + 0.125 + 0.0078 \approx 4.133 بت لكل عنصر. وإسقاط الحد الخشن يعطي 4.125.

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

INT4 weights use one 8-bit scale per 32 elements. What is the effective bit width?أوزان INT4 تستخدم مقياسًا واحدًا من 8 بت لكل 32 عنصرًا. ما عرض البت الفعلي؟

VS-Quant still multiplies by integer scales. The MX formats of Rouhani et al. (Microsoft and Meta) go one step cheaper: every scale is a pure power of two, stored as an exponent with no mantissa, so applying it is a bit shift. That is the title's joke, "a little shifting goes a long way". Read the MX4 row of slide 21 one field at a time.

ما زال VS-Quant يضرب في مقاييس أعداد صحيحة. صيغ MX التي قدّمها Rouhani et al. (Microsoft وMeta) تخطو خطوة أرخص: كل مقياس قوة خالصة للعدد 2، يُخزَّن أسًّا (exponent) بلا جزء عشري (mantissa)، فيكون تطبيقه إزاحة بتات (shift). وهذه هي الدعابة في عنوان الورقة: "a little shifting goes a long way" (القليل من الإزاحة يوصلك بعيدًا). اقرأ صف MX4 في الشريحة 21 حقلًا حقلًا.

  • Element: S1M2, one sign bit and two mantissa (magnitude) bits, 3 bits in total. There is no per-element exponent at all.العنصر: S1M2، أي بت إشارة واحد وبتان للجزء العشري (المقدار)، بمجموع 3 بت. لا يوجد أسّ خاص بكل عنصر إطلاقًا.
  • L0: each pair of elements shares an E1M0 scale, a single exponent bit that can shift the pair down by one more power of two when both values are small.L0: كل زوج من العناصر يشترك في مقياس E1M0، وهو بت أسّ واحد يمكنه إزاحة الزوج نزولًا بقوة إضافية واحدة للعدد 2 عندما تكون القيمتان صغيرتين.
  • L1: each group of 16 elements shares an E8M0 scale, an 8-bit exponent that sets the overall range like the exponent of a float.L1: كل مجموعة من 16 عنصرًا تشترك في مقياس E8M0، وهو أسّ من 8 بت يحدد المدى العام مثل أسّ العدد العائم (float).
MX4: 3+12+816=4MX6: 5+12+816=6MX9: 8+12+816=9\text{MX4: } 3 + \tfrac{1}{2} + \tfrac{8}{16} = 4 \qquad \text{MX6: } 5 + \tfrac{1}{2} + \tfrac{8}{16} = 6 \qquad \text{MX9: } 8 + \tfrac{1}{2} + \tfrac{8}{16} = 9
Same L0 and L1 scales, only the mantissa width changes (slide 21)مقياسا L0 وL1 نفسهما، ولا يتغير إلا عرض الجزء العشري (mantissa) (الشريحة 21)

The paper writes the same count as (m+1)+d1/k1+d2/k2(m + 1) + d_1/k_1 + d_2/k_2, with mm mantissa bits, the +1+1 for the sign, d1=8d_1 = 8 bits shared by k1=16k_1 = 16 elements and d2=1d_2 = 1 bit shared by k2=2k_2 = 2. The names are the totals: MX4, MX6 and MX9 average exactly 4, 6 and 9 bits per element.

تكتب الورقة العدّ نفسه على الصورة (m+1)+d1/k1+d2/k2(m + 1) + d_1/k_1 + d_2/k_2، حيث mm عدد بتات الجزء العشري، و+1+1 لبت الإشارة، وd1=8d_1 = 8 بتات يشترك فيها k1=16k_1 = 16 عنصرًا، وd2=1d_2 = 1 بت يشترك فيه k2=2k_2 = 2 عنصران. الأسماء هي المجاميع: MX4 وMX6 وMX9 متوسطها بالضبط 4 و6 و9 بت لكل عنصر.

ApproachالطريقةElementالعنصرL0 groupمجموعة L0L0 scaleمقياس L0L1 groupمجموعة L1L1 scaleمقياس L1Effective bitsالبتات الفعلية
Per-channelPer-channelINT4INT4per channelلكل قناةFP16FP16noneلا يوجدnoneلا يوجد44
VSQVSQINT4INT41616UINT4UINT4per channelلكل قناةFP16FP164 + 4/16 = 4.254 + 4/16 = 4.25
MX4MX4S1M2 (3 bits)S1M2 (3 بت)22E1M0E1M01616E8M0E8M03 + 1/2 + 8/16 = 43 + 1/2 + 8/16 = 4
MX6MX6S1M4 (5 bits)S1M4 (5 بت)22E1M0E1M01616E8M0E8M05 + 1/2 + 8/16 = 65 + 1/2 + 8/16 = 6
MX9MX9S1M7 (8 bits)S1M7 (8 بت)22E1M0E1M01616E8M0E8M08 + 1/2 + 8/16 = 98 + 1/2 + 8/16 = 9
Slide 21: multi-level scaling schemes and their effective bit widthsالشريحة 21: مخططات التحجيم متعدد المستويات وعروض البت الفعلية لها
Bits per element, stacked. Element bits sit at rest; hover adds the fine (L0) and coarse (L1) scale shares. MX4 reaches 4 with a 3-bit element; VSQ pays 0.25 on top of 4.البتات لكل عنصر، مكدّسة. بتات العنصر ظاهرة في وضع السكون، والتمرير يضيف حصة المقياس الناعم (L0) والخشن (L1). يصل MX4 إلى 4 بعنصر من 3 بت، ويدفع VSQ قيمة 0.25 فوق 4.

Paper MX versus the MX standard on real chipsMX في الورقة مقابل معيار MX على الرقاقات الحقيقية

The name MX now also refers to the Open Compute Project Microscaling (MX) v1.0 specification, which is what GPUs implement. It is simpler than the paper: a single level, one E8M0 scale per block of 32 elements, with element types such as FP4 (E2M1), FP6, FP8 and INT8. NVIDIA's own NVFP4, also supported on Blackwell, uses an FP8 E4M3 scale per 16 values plus an FP32 scale per tensor. Same counting rule, different numbers:

صار الاسم MX يشير أيضًا إلى مواصفة Open Compute Project Microscaling (MX) v1.0، وهي ما تنفّذه وحدات GPU. وهي أبسط من الورقة: مستوى واحد، ومقياس E8M0 واحد لكل كتلة من 32 عنصرًا، مع أنواع عناصر مثل FP4 (E2M1) وFP6 وFP8 وINT8. أما صيغة NVFP4 الخاصة بـ NVIDIA، المدعومة أيضًا في Blackwell، فتستخدم مقياس FP8 E4M3 لكل 16 قيمة إضافة إلى مقياس FP32 لكل موتر. قاعدة العدّ نفسها، والأرقام مختلفة:

FormatالصيغةDefined byالجهة المعرِّفةScale levelsمستويات المقياسEffective bitsالبتات الفعلية
MX4 / MX6 / MX9 (paper)MX4 / MX6 / MX9 (الورقة البحثية)Rouhani et al. 2023Rouhani et al. 20232 levels: E1M0 per 2, E8M0 per 16مستويان: E1M0 لكل 2، وE8M0 لكل 164 / 6 / 94 / 6 / 9
MXFP4 (standard)MXFP4 (المعيار)OCP MX v1.0OCP MX v1.01 level: E8M0 per 32مستوى واحد: E8M0 لكل 324 + 8/32 = 4.254 + 8/32 = 4.25
NVFP4NVFP4NVIDIA BlackwellNVIDIA BlackwellFP8 E4M3 per 16, FP32 per tensorFP8 E4M3 لكل 16، وFP32 لكل موترabout 4 + 8/16 = 4.5نحو 4 + 8/16 = 4.5
Three formats that are all called MX or micro-scaled FP4ثلاث صيغ تُسمّى كلها MX أو FP4 بالتحجيم الدقيق (micro-scaled)

Recall

Break MX6 into its parts and add them up.فكّك MX6 إلى أجزائه واجمعها.

Element S1M4 = 5 bits. L0: one E1M0 bit per 2 elements = 0.5. L1: one E8M0 (8 bits) per 16 elements = 0.5. Total 5 + 0.5 + 0.5 = 6.

العنصر S1M4 = 5 بت. L0: بت E1M0 واحد لكل 2 عنصر = 0.5. L1: مقياس E8M0 واحد (8 بت) لكل 16 عنصرًا = 0.5. المجموع 5 + 0.5 + 0.5 = 6.

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

In MX4, how many bits does each element itself store?في MX4، كم بتًا يخزّن كل عنصر بنفسه؟

Recapالخلاصة

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

  • Group quantization gives each small group of elements (16 to 64) its own scale, so an outlier only spoils its own group.التكميم بالمجموعات (group quantization) يعطي كل مجموعة صغيرة من العناصر (من 16 إلى 64) مقياسًا خاصًا بها، فلا تُفسد القيمة الشاذة (outlier) إلا مجموعتها.
  • At 4 bits a symmetric INT4 has only 15 levels, so one big weight in a long channel pushes most small weights to 0. That is why 4-bit schemes go finer than per-channel.عند 4 بت لا يملك INT4 المتماثل إلا 15 مستوى، لذلك يكفي وزن كبير واحد في قناة طويلة لدفع معظم الأوزان الصغيرة إلى 0. ولهذا تنزل مخططات 4 بت إلى دقة أنعم من مستوى القناة.
  • Blackwell's FP4 tensor cores give 2x the throughput of FP8/FP6/INT8 (HGX B200: 144 vs 72 PFLOPS, both sparse), and micro-tensor scaling is what keeps FP4 accurate.أنوية الموترات FP4 في Blackwell تعطي ضعف إنتاجية FP8/FP6/INT8 (في HGX B200: 144 مقابل 72 PFLOPS، وكلاهما بالتناثر sparse)، والتحجيم الدقيق للموترات (micro-tensor scaling) هو ما يحافظ على دقة FP4.
  • VS-Quant: r = gamma * S_q (q - Z). Cheap integer S_q per vector at fine granularity, expensive floating-point gamma per channel or tensor at coarse granularity.VS-Quant: r = gamma * S_q (q - Z). مقياس صحيح رخيص S_q لكل متجه بدقة حبيبية ناعمة، ومقياس فاصلة عائمة مكلف gamma لكل قناة أو موتر بدقة حبيبية خشنة.
  • General form: r = (q - z) * s_l0 * s_l1 * ..., z = 0 means symmetric.الصيغة العامة: r = (q - z) * s_l0 * s_l1 * ...، وz = 0 تعني تكميمًا متماثلًا (symmetric).
  • Effective bit width = element bits + sum over levels of (scale bits / group size). INT4 with an 8-bit scale per 32 gives 4.25.عرض البت الفعلي = بتات العنصر + مجموع (بتات المقياس / حجم المجموعة) على كل المستويات. INT4 مع مقياس 8 بت لكل 32 عنصرًا يعطي 4.25.
  • Slide table: per-channel 4, VSQ 4 + 4/16 = 4.25, MX4 3 + 1/2 + 8/16 = 4, MX6 6, MX9 9. The per-channel FP16 terms are ignored because they are spread over thousands of weights.جدول الشريحة: per-channel يساوي 4، وVSQ يساوي 4 + 4/16 = 4.25، وMX4 يساوي 3 + 1/2 + 8/16 = 4، وMX6 يساوي 6، وMX9 يساوي 9. تُهمل حدود FP16 الخاصة بكل قناة لأنها موزعة على آلاف الأوزان.
  • MX scales are powers of two (E1M0, E8M0), so applying them is a shift, not a multiply.مقاييس MX قوى للعدد 2 (E1M0 وE8M0)، لذلك يكون تطبيقها إزاحة بتات (shift) لا عملية ضرب.

Sourcesالمصادر