Appleの「LLM in a Flash」を活用してQwen 397Bをローカルで実行する自動研究
研究者のDan Woodsは、Appleの「LLM in a Flash」技術を応用し、通常209GBのQwen3.5-397B-A17Bモデルを48GB MacBook Pro M3 Max上で5.5+トークン/秒で動作させることに成功した。
キーポイント
大規模LLMのローカル実行の実現
通常209GB(量子化後120GB)の大規模MoEモデルQwen3.5-397B-A17Bを、48GBメモリのMacBook Pro M3 Max上で5.5+トークン/秒で動作させることに成功した。
Appleの「LLM in a Flash」技術の応用
Appleの2023年論文で提案された、フラッシュメモリからDRAMへのオンデマンドなパラメータ読み込み技術を活用し、メモリ容量を超えるモデルの効率的な推論を実現した。
オートリサーチと高度な量子化の組み合わせ
Claude Codeとオートリサーチパターンを用いて90回の実験を実施し、エキスパート部分を2ビットに量子化、非エキスパート部分は元の精度を維持する最適化を行った。
MoEアーキテクチャの特性を活かした最適化
Mixture-of-Expertsモデルの特性を利用し、各トークンで必要なエキスパートの数を10から4に削減しつつ、品質の大幅な低下は回避したと主張している。
影響分析・編集コメントを表示
影響分析
この研究は、高価な専門ハードウェアなしで大規模言語モデルをローカル実行する道筋を示し、AIの民主化とエッジコンピューティングの進展に寄与する可能性がある。特に、MoEアーキテクチャと効率的なメモリ管理技術の組み合わせは、今後のローカルAI実装の参考事例となる。
編集コメント
大規模モデルのローカル実行における実用的なブレークスルーを示す事例。ただし、出力品質への影響評価が不十分な点は今後の検証課題として残っている。
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
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み