[Perf] Reuse single-element media tensors in qwen3_vl_sft_collator and SequenceContext.cat (follow-up of #2239)
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 62/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- data, machine-learning
調査の方向性
Start with the _reuse_single_or_cat helper in xtuner/v1/datasets/collator.py and the qwen3_vl_sft_collator lines around 280-287, then read SequenceContext.cat in xtuner/v1/data_proto/sequence_context.py at about lines 393-418. Apply the single-element reuse pattern at both sites and add a comment about the read-only sharing invariant from #2239. Done means single-media packs skip torch.cat and a test asserts the media tensors are bitwise unchanged after use.
索引モデルが issue の本文から書いたものです。
説明
Background
#2239 removed full torch.cat copies for single-media packs on the GLM-5.3 SFT
path (collator helper _reuse_single_or_cat, tokenize fn, and the compose model
entry). The same "single-element list still pays a full copy" pattern remains at
two sites outside that PR's scope:
-
qwen3_vl_sft_collator—xtuner/v1/datasets/collator.py:280,287:
pixel_values/image_grid_thware unconditionallytorch.cat-ed even when
the pack contains a single media item. The_reuse_single_or_cathelper added
in #2239 sits in the same file and can be applied directly. -
SequenceContext.cat—xtuner/v1/data_proto/sequence_context.py:393-403
(pixel_values/pixel_values_videos) and:415,418(image_grid_thw/
video_grid_thw): single-element lists are unconditionally copied. This is on
the RL path — the RL controller merges seq_ctx lists viaSequenceContext.cat
(xtuner/v1/rl/trainer/controller.py:236).
Impact
No correctness issue today. GLM-5.3 SFT does not go through either site, so this
is pure follow-up: qwen3_vl SFT benefits for single-media packs; the RL path
benefits if rollout packing of media seq_ctx becomes hot.
Suggested fix
- Apply the same
len == 1 → reuse, else catpattern at both sites. - Mind the invariant pinned in #2239: a reused tensor shares storage with its
source, so the downstream path must stay read-only — add the same kind of
comment + a "media tensor bitwise unchanged after use" test assertion.
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 466
- 平均マージ
- 5日 8時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
InternLM/xtuner のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 4 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
InternLM/xtuner#2134 · リアクション 1 件 ·
メンテナーはふだん 4 日以内に返信
-
[NPU] reduce_sum_across_dp_group builds the all_reduce tensor on CPU when CUDA is unavailable対応中かも @li-lizhe が 69 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
メンテナーはふだん 4 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
InternLM/xtuner#2118 · コメント 6 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
メンテナーはふだん 4 日以内に返信
InternLM/xtuner の issue をすべて見る
似ている issue
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
future-agi/future-agi#5908 ·
メンテナーはふだん 1 日以内に返信
-
Placeholder export disables HTML image input for picture description対応中かも @cloudiful が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
docling-project/docling-serve#817 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
Techiebutler/freeframe#687 ·
メンテナーはふだん 1 日以内に返信
-
Parse truncated verbose GC logs up to the first XML error対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug verbose GC
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
IBM/javacore-analyser#677 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信