ExternalDraftConfig accepts tvd_ce weights that produce zero or infinite loss

オープン 初心者向け
#3,524 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@adimalkar がすでに取り組んでいます。

2026年11月23日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

検証は modelopt/torch/speculative/config.py の ExternalDraftConfig にあり、external_tvd_alpha と external_ce_alpha には現在 ge=0.0 しか設定されていません。_mix_ce を読んで2つの重みがどのように組み合わされるかを確認し、その後 issue の再現スニペットを実行して、0/0 と無限大のケースが受け入れられていることを確認してください。tvd_ce が有限でない重みを拒否し、両方の重みがゼロの組み合わせも拒否するようになり、各ケースをテストがカバーし、片方の項だけを無効化する機能が引き続き動作していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Hullo folks,

I’m doing some research for Tessl Code Review and ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:

ExternalDraftConfig(external_loss="tvd_ce", ...) accepts both a zero/zero weight pair and an infinite weight. The current _mix_ce then produces a zero objective or a non-finite loss.

Reproduction

ExternalDraftConfig(
    external_loss="tvd_ce",
    external_tvd_alpha=0.0,
    external_ce_alpha=0.0,
)  # accepted

ExternalDraftConfig(
    external_loss="tvd_ce",
    external_tvd_alpha=float("inf"),
    external_ce_alpha=0.1,
)  # also accepted

Both fields have ge=0.0, but neither a finiteness constraint nor a combined-positive-weight check.

Validation

I executed the current ExternalDraftConfig class using the actual current ModeloptBaseConfig and ModeloptField, with Pydantic 2.14.4 and PyTorch 2.15.0 on CPU. The two configurations above were accepted; a negative weight was rejected.

I also executed the current _mix_ce method with a small logits/target fixture and a controlled TVD scalar:

  • Weights 0/0: loss 0, zero logits gradient and zero TVD gradient.
  • Weights infinity/0.1: infinite loss and infinite TVD gradient.
  • Weights 0.9/0.1: finite loss and gradients.

No GPU or full training run was involved.

Expected behavior

For tvd_ce, reject non-finite weights and require at least one positive contribution. That would catch a configuration that silently disables the objective before starting training, while still allowing either individual term to be disabled.

Current source: implementation. The lead came from this earlier review finding, and I checked it against the current source.

Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.

We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.

Bap

主要言語
Python
スター
5.6k
フォーク
819
平均マージ
2日 21時間
マージ済み PR(30日)
191

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/Model-Optimizer のほかの issue

NVIDIA/Model-Optimizer の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。