perf(moe): run the shared expert beside the routed-expert miss copy in offloaded decode

オープン
#678 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, pytorch

調査の方向性

Start from the offloaded decode path behind --moe-strategy offload, where the routed-expert miss copy and the shared expert run on the compute stream. The issue links fork commits e0c4109 and 4679672 as a reference, but names no file in this repo. Creating the side stream with cudaStreamCreateWithFlags and wrapping it in torch.cuda.ExternalStream is the key constraint, and CUDA-graph capture must stay safe. Done means greedy outputs stay token-identical and decode throughput is measured against the LRU baseline.

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

説明

In offloaded decode (--moe-strategy offload, GPU decode), a layer's routed-expert miss copy and its shared expert run back to back on the compute stream. The shared expert does not depend on the routed experts. It can run while the miss copy is in flight.

Proposal: keep the miss copy on the compute stream right after its ensure, and run the shared expert on a dedicated side stream that joins before the routed outputs are combined.

The stream must be created with cudaStreamCreateWithFlags and wrapped in torch.cuda.ExternalStream. A torch.cuda.Stream() comes from a small pool and can alias the stream CUDA-graph capture runs on.

Measured on an RTX 5080 (16 GB) with Qwen3.8-Flash-Next-NVFP4, together with a scored eviction policy (cf. #174), at 32K/128K context:

decode
LRU ~40.2 / ~39.6 tok/s
scored eviction +5.5%
scored eviction + shared-expert overlap 43.4 / 42.7 tok/s (+7.8%)

Greedy outputs are token-identical. Peak VRAM is +24 MiB.

Implementation (on my fork, against an older main):

主要言語
Python
スター
14.2k
フォーク
1.4k
平均マージ
18時間 46分
マージ済み PR(30日)
98

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

FlashML-org/FreeToken のほかの issue

FlashML-org/FreeToken の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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