Appleの「LLM in a Flash」を活用してQwen 397Bをローカルで実行する自動研究
本文の状態
日本語全文を表示中
詳細モードで約3分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
Simon Willison Blog
研究者のDan Woodsが、Appleの「LLM in a Flash」技術を応用し、通常209GB(量子化後120GB)のQwen3.5-397B-A17Bモデルを48GB MacBook Pro M3 Maxで5.5+トークン/秒で動作させることに成功した。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
Apple の「LLM in a Flash」を自動調査し、Qwen 397B をローカルで実行する
Dan Woods 氏による興味深い研究をご紹介します。同氏は、ディスク上で 209GB(量子化済みで 120GB)を必要とするモデルにもかかわらず、48GB の MacBook Pro M3 Max で Qwen3.5-397B-A17B のカスタムバージョンを秒間 5.5 トークン以上の速度で実行することに成功しました。
Qwen3.5-397B-A17B は、Mixture-of-Experts (MoE: エキスパートの混合) モデルです。これは、各トークンの生成において、モデル全体の重みの一部のみを処理すればよいことを意味します。これらのエキスパート用重みは SSD からメモリにストリーミングされるため、すべての重みを同時に RAM に保持する必要がありません。
Dan 氏は、Apple が 2023 年に発表した論文 LLM in a flash: Efficient Large Language Model Inference with Limited Memory で記述された技術を活用しました。
この論文は、利用可能な DRAM(ダイナミックランダムアクセスメモリ)容量を超える大規模言語モデル (LLM) を効率的に実行する課題に取り組んでいます。その手法は、モデルパラメータをフラッシュメモリに保存しつつ、必要な時にのみ DRAM に読み込むというものです。私たちの方法は、フラッシュメモリの特性を考慮した推論コストモデルを構築し、2 つの重要な領域で最適化を行うことを目指しています。すなわち、フラッシュからのデータ転送量を削減することと、より大きく連続的なチャンク単位でデータを読み込むことです。
彼は論文を Claude Code に読み込ませ、Andrej Karpathy の autoresearch パターンの派生形を用いて、Claude に 90 回の実験を実行させ、MLX Objective-C および Metal コードを生成させました。このコードは、モデルを可能な限り効率的に実行するものです。
danveloper/flash-moe には、その結果得られたコードと、PDF 論文が含まれています。この論文は主に Claude Opus 4.6 によって執筆され、実験の詳細を記述しています。
最終的なモデルでは、エキスパート部分は 2 ビットに量子化されていますが、埋め込みテーブルやルーティング行列といったモデルの非エキスパート部分は元の精度のまま維持されており、これらを合わせると 5.5GB になります。これはモデル実行中にメモリ上に常駐します。
通常、Qwen 3.5 はトークンあたり 10 のエキスパートを実行しますが、この設定ではそれを 4 に減らしました。ただし、品質の低下が最も顕著に現れるのは 3 の場合であると主張しています。
モデル結果の品質がどの程度影響を受けるかは私には不明です。Claude は「これらの評価において、2 ビットでの出力品質は 4 ビットと区別できない」と主張しましたが、彼が実行した評価の詳細な記述は非常に薄いです。
Tags: ai, generative-ai, local-llms, llms, qwen, mlx
原文を表示
Autoresearching Apple's "LLM in a Flash" to run Qwen 397B locally
Here's a fascinating piece of research by Dan Woods, who managed to get a custom version of Qwen3.5-397B-A17B running at 5.5+ tokens/second on a 48GB MacBook Pro M3 Max despite that model taking up 209GB (120GB quantized) on disk.
Qwen3.5-397B-A17B is a Mixture-of-Experts (MoE) model, which means that each token only needs to run against a subset of the overall model weights. These expert weights can be streamed into memory from SSD, saving them from all needing to be held in RAM at the same time.
Dan used techniques described in Apple's 2023 paper LLM in a flash: Efficient Large Language Model Inference with Limited Memory:
This paper tackles the challenge of efficiently running LLMs that exceed the available DRAM capacity by storing the model parameters in flash memory, but bringing them on demand to DRAM. Our method involves constructing an inference cost model that takes into account the characteristics of flash memory, guiding us to optimize in two critical areas: reducing the volume of data transferred from flash and reading data in larger, more contiguous chunks.
He fed the paper to Claude Code and used a variant of Andrej Karpathy's autoresearch pattern to have Claude run 90 experiments and produce MLX Objective-C and Metal code that ran the model as efficiently as possible.
danveloper/flash-moe has the resulting code plus a PDF paper mostly written by Claude Opus 4.6 describing the experiment in full.
The final model has the experts quantized to 2-bit, but the non-expert parts of the model such as the embedding table and routing matrices are kept at their original precision, adding up to 5.5GB which stays resident in memory while the model is running.
Qwen 3.5 usually runs 10 experts per token, but this setup dropped that to 4 while claiming that the biggest quality drop-off occurred at 3.
It's not clear to me how much the quality of the model results are affected. Claude claimed that "Output quality at 2-bit is indistinguishable from 4-bit for these evaluations", but the description of the evaluations it ran is quite thin.
Tags: ai, generative-ai, local-llms, llms, qwen, mlx
関連記事
News to Guide
ニュースの次に確認する
発表内容を、現在の料金や仕様と照らし合わせられる関連ガイドです。
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み