int8_quantize_kernel truncates toward zero instead of rounding (the ±0.5 offset is cast to int8 before being added)
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
バグは wan/triton_kernels.py の int8_quantize_kernel、30行目付近(29〜31行目)にあります。±0.5 の丸めオフセットが加算される前に int8 にキャストされているため、0 になっています。周囲のカーネルを読んで x_scale とストアマスクの使われ方を確認し、出力が [-127, 127] にクランプされているかを確認してください。完了の条件は、int8 へのキャストの前に float でオフセットを加算すること、そして、カーネルの出力を「0から遠ざかる方向への半分切り上げ(round-half-away-from-zero)」と比較する小さなテストがサンプル入力で一致することです。
索引モデルが issue の本文から書いたものです。
説明
x_scaled = x * x_scale
x_scaled += (0.5 * tl.where(x_scaled >= 0, 1, -1)).to(tl.int8)
tl.store(out_ptr + h_offset, x_scaled, mask=h_offset < HDIM)
What happens: (0.5 * sign).to(tl.int8) evaluates to 0, so nothing is added. The float x_scaled is then stored into the int8 output, which truncates toward zero. The intended rounding (half away from zero) is lost and every activation is biased toward zero.
Suggested fix: add the offset in float before the cast:
x_scaled = x_scaled + 0.5 * tl.where(x_scaled >= 0, 1.0, -1.0)
tl.store(out_ptr + h_offset, x_scaled.to(tl.int8), mask=h_offset < HDIM)
(or use a round-to-nearest intrinsic). Since x_scale = 127 / max|x|, the rounded value stays within [-127, 127].
Measured impact (our replication, Matrix-Game-3.0 distilled, --use_int8 path on the 240 attention q/k/v/o layers, real activations from one rollout):
- Mean relative output MSE vs BF16: 3.68e-3 with the current kernel vs 6.44e-4 with round-to-nearest (about 5.7x lower).
- The current kernel's error is a systematic magnitude shrinkage (cosine between error and output between -0.62 and -0.85; about 0 with rounding).
- Other factors (int32 accumulation, bf16 weight scales, per-token / per-channel granularity) change the error by less than 2%.
- In our closed-loop rollouts (352x640 and 704x1280) we did not detect visible degradation from the current kernel with our metrics, so this is a precision issue rather than an obvious quality break; fixing it should still reduce error at no cost.
Happy to share the per-layer measurements if useful.
- 主要言語
- Python
- スター
- 2.4k
- フォーク
- 257
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SkyworkAI/Matrix-Game のほかの issue
-
Replace deprecated v2.ToTensor() in Matrix-Game-2/inference.py with v2.ToImage() + v2.ToDtype(scale=True)対応中かも @xyf5432 が 54 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
SkyworkAI/Matrix-Game#82 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
SkyworkAI/Matrix-Game#80 ·
-
run logic error when finish対応中かも @Arison591 が 91 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
SkyworkAI/Matrix-Game#77 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 12/100
SkyworkAI/Matrix-Game#88 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
SkyworkAI/Matrix-Game#87 · コメント 1 件 ·
SkyworkAI/Matrix-Game の issue をすべて見る
似ている issue
-
bot-triaged module: LrScheduler module: optimizer triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
documentation glm5 llm-model
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vllm-project/vllm-ascend#19062 ·
メンテナーはふだん 1 日以内に返信
-
author-page correction
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
acl-org/acl-anthology#10496 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Issue Type: Bug Report
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
celery/celery#10875 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SasanLabs/VulnerableApp#836 ·
メンテナーはふだん 1 日以内に返信