Repository navigation
GLM CUDA のコピー窓を 16 行(15 トークン)まで広げる - #21
Merged
Merged
Conversation
TF_GLM_COPY_MAX defaults to 15, and 7 restores the 8-row window. Reply copies need a 16-token match. Shared rounds use the same ramp. TF_GLM_COPY_EXTEND=1 opts into context copies, root copies, and a long copy after a 16-token match. Co-authored-by: GarupanOjisan <GarupanOjisan@users.noreply.github.com>
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変更内容
GLM CUDA レーンのコピー(prompt lookup)を、最大 16 行(ドラフト 15 トークン)まで取れるようにした。DFlash の窓は 8 行のまま(ドラフト 7)、MTP ヘッドの吸収も 8 行チャンクのまま。最初のコピー幅は 3 のまま。
ランク 0 だけが環境変数を読む。バッファ自体は全ランクで常に 16 行分を確保する。両ランクには同じ値を渡す。
デフォルト
TF_GLM_COPY_MAX7で従来の 8 行窓に戻る。1..15 にクランプ。整数でない文字列は 15。TF_GLM_COPY_REPLY_MATCHTF_GLM_COPY_EXTEND1のときだけ有効。context copies と root copies をオンにし、一致が 16 トークン以上ならそのラウンドでTF_GLM_COPY_MAXまで一気に伸ばす。COPY_REPLY_MATCHやWIDE_GRAPHSは読まない。ネイティブ側の名前はTF_GLM_COPY_REPLY_MATCH。返信一致のデフォルト 16 はレシピの測定による。レシピのコメントでは、16 トークン一致の reply-copy で code が 55.4→56.2 tok/s、edit が 120→125 tok/s。
COPY_MAX=15の 16 行窓では edit が 84→119 tok/s で、prose と code は変わらなかった、とある。いずれもレシピ側の数字であり、このツリーでの測定ではない。TF_GLM_COPY_EXTEND=1では既存の優先順位のまま、root copies が context-copy の追記を止める(!root_copies)。弱い一致はランプ(3 → 7 → 15)に切り詰め、返信の一致が 16 未満ならそのコピーは捨てる。単独ストリームでは context copies が有効なため、一致が足りていれば 1 トークンのコピーも残せる。共有ラウンドでも幅を伸ばす
共有ラウンドと複数ストリームでも、コピーが全部採用されたら幅を
2 * width + 1(上限TF_GLM_COPY_MAX)まで伸ばす。以前止めていたのは、KDA の保存が 8 行しかなく、伸ばしたコピーを置けなかったため。今は次が 16 行に揃っている。allocateがバッチに合わせて切るTF_GLM_SHARED=0でストリームごとにフォワードしても、ライブが 2 本以上ならaloneは false だった。その場合も同じランプで伸びる。CUDA graph は増やしていない
GLM CUDA はカーネルをその場で起動する。キャプチャしたグラフはなく、16 行用のグラフも足していない。KDA の wide step は行数を 16 行タイルで回すので、16 行窓は 1 タイルに収まる。
cuda_q4は 16 行までを受け付ける。TF_GLM_COPY_MAX=7でもバッファ・サンプラ・KDA 保存は 16 行のまま確保する(使わない行がある)。KDA 保存は 8 行のときの約 2 倍。共有のチェーンも 16 行分。検証
c740ba65。nvcc 12.0.140。token_sha256は未測定。ホストの fake バックエンドで、ドラフトありの出力が"draft": falseとトークン列で一致することを、greedy と sampled、1 ストリームと 2 ストリームで確認した。zig test zig/src/core/lanes/lanes.zigのコピー窓・ランプ・共有ラウンド: 17 件成功cuda_copyのクランプを含む): 76 件成功zig build install: 成功(tensorfoldとtf-cuda-testを生成。fatbin は空イメージ)zig build test: 2451/2457 成功、6 skip。失敗 1 件はローカルのwindow_fallback_shim.c(GCC 13 と 14 が同居し、-Werrorの gcc-install-dir 警告)。GitHub の ubuntu では再現しない既知の環境差zig fmt --check build.zig zig: 成功.cuは変更なし。glm_kda.cuとglm_glue.cuを nvcc 12.0 で sm_80 の fatbin にコンパイルし、成功した。全カーネルの-Dnvccと GB10(sm_121)では回していない。2x DGX Spark での A/B
両方のランクに同じ環境変数を置く。プロンプトは毎回新しいものにする(キャッシュに当たると edit の数字が読まない)。
token_sha256は同じプロンプトの"draft": falseと比較する。TF_GLM_COPY_MAX=7(従来の 8 行、返信ゲートも実質オフにしたいときはTF_GLM_COPY_REPLY_MATCH=8)。echo / edit / code / prose。ストリーム数 1 と 4。TF_GLM_COPY_EXTEND=1。同じ組。見るもの:
ttft_s)が落ちていないことtoken_sha256が"draft": falseと一致すること(greedy と、温度を付けた sampled)echo は一致の確認用。edit はコピーが伸びる本命。code と prose は退行がないことの確認。