1773235173
2026-03-11 12:27:00
これを介して試してみてください デモ、または自分で構築して実行します CPU または GPU。
bitnet.cpp は、1 ビット LLM (BitNet b1.58 など) の公式推論フレームワークです。最適化されたカーネルのスイートを提供し、 速い そして 無損失 CPU および GPU での 1.58 ビット モデルの推論 (NPU サポートは次に予定されています)。
bitnet.cpp の最初のリリースは、CPU での推論をサポートすることです。 bitnet.cpp は以下の高速化を実現します。 1.37倍 に 5.07倍 ARM CPU では、より大きなモデルほどパフォーマンスが向上します。さらに、エネルギー消費を削減します。 55.4% に 70.0%、全体的な効率がさらに向上します。 x86 CPU では、速度向上の範囲は次のとおりです。 2.37倍 に 6.17倍 間のエネルギー削減により、 71.9% に 82.2%。さらに、bitnet.cpp は単一の CPU 上で 100B BitNet b1.58 モデルを実行でき、人間の読み取りに匹敵する速度 (1 秒あたり 5 ~ 7 トークン) を達成し、ローカル デバイス上で LLM を実行する可能性を大幅に高めます。を参照してください。 テクニカルレポート 詳細については。
最新の最適化 構成可能なタイリングと埋め込み量子化サポートを備えた並列カーネル実装を導入し、 1.15倍から2.1倍 さまざまなハードウェア プラットフォームやワークロードにわたって、元の実装よりもさらに高速化されます。詳細な技術情報については、 最適化ガイド。
Apple M2 上で BitNet b1.58 3B モデルを実行する bitnet.cpp のデモ:
デモ.mp4
このプロジェクトは、 call.cpp フレームワーク。オープンソース コミュニティへの貢献に感謝します。また、bitnet.cpp のカーネルは、 T-MAC。 3 値モデルを超える一般的な低ビット LLM の推論には、T-MAC の使用をお勧めします。
| モデル | パラメータ | CPU | カーネル | ||
|---|---|---|---|---|---|
| I2_S | TL1 | TL2 | |||
| ビットネット-b1.58-2B-4T | 2.4B | x86 | ✅ | ❌ | ✅ |
| アーム | ✅ | ✅ | ❌ | ||
❗️で利用可能な既存の 1 ビット LLM を使用します。 ハグフェイス bitnet.cpp の推論機能をデモンストレーションします。 bitnet.cpp のリリースが、モデル サイズとトレーニング トークンの点で大規模な設定における 1 ビット LLM の開発を刺激することを願っています。
- Python>=3.9
- cmake>=3.22
- カラン>=18
-
Windows ユーザーの場合は、インストールしてください Visual Studio 2022。インストーラーで、少なくとも次のオプションをオンにします (これにより、CMake などの必要な追加ツールも自動的にインストールされます)。
- C++ によるデスクトップ開発
- Windows 用 C++-CMake ツール
- Windows 用の Git
- Windows 用 C++-Clang コンパイラ
- LLVM ツールセット (clang) の MS-Build サポート
-
Debian/Ubuntu ユーザーの場合は、次のようにダウンロードできます。 自動インストールスクリプト
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
-
- conda (強くお勧めします)
重要
Windows を使用している場合は、次のコマンドには必ず VS2022 の開発者コマンド プロンプト/PowerShell を使用してください。問題が発生した場合は、以下の FAQ を参照してください。
- リポジトリのクローンを作成する
git clone --recursive https://github.com/microsoft/BitNet.git
cd BitNet
- 依存関係をインストールする
# (Recommended) Create a new conda environment
conda create -n bitnet-cpp python=3.9
conda activate bitnet-cpp
pip install -r requirements.txt
- プロジェクトをビルドする
# Manually download the model and run with local path
huggingface-cli download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir models/BitNet-b1.58-2B-4T
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s
usage: setup_env.py [-h] [--hf-repo {1bitLLM/bitnet_b1_58-large,1bitLLM/bitnet_b1_58-3B,HF1BitLLM/Llama3-8B-1.58-100B-tokens,tiiuae/Falcon3-1B-Instruct-1.58bit,tiiuae/Falcon3-3B-Instruct-1.58bit,tiiuae/Falcon3-7B-Instruct-1.58bit,tiiuae/Falcon3-10B-Instruct-1.58bit}] [--model-dir MODEL_DIR] [--log-dir LOG_DIR] [--quant-type {i2_s,tl1}] [--quant-embd]
[--use-pretuned]
Setup the environment for running inference
optional arguments:
-h, --help show this help message and exit
--hf-repo {1bitLLM/bitnet_b1_58-large,1bitLLM/bitnet_b1_58-3B,HF1BitLLM/Llama3-8B-1.58-100B-tokens,tiiuae/Falcon3-1B-Instruct-1.58bit,tiiuae/Falcon3-3B-Instruct-1.58bit,tiiuae/Falcon3-7B-Instruct-1.58bit,tiiuae/Falcon3-10B-Instruct-1.58bit}, -hr {1bitLLM/bitnet_b1_58-large,1bitLLM/bitnet_b1_58-3B,HF1BitLLM/Llama3-8B-1.58-100B-tokens,tiiuae/Falcon3-1B-Instruct-1.58bit,tiiuae/Falcon3-3B-Instruct-1.58bit,tiiuae/Falcon3-7B-Instruct-1.58bit,tiiuae/Falcon3-10B-Instruct-1.58bit}
Model used for inference
--model-dir MODEL_DIR, -md MODEL_DIR
Directory to save/load the model
--log-dir LOG_DIR, -ld LOG_DIR
Directory to save the logging info
--quant-type {i2_s,tl1}, -q {i2_s,tl1}
Quantization type
--quant-embd Quantize the embeddings to f16
--use-pretuned, -p Use the pretuned kernel parameters
# Run inference with the quantized model
python run_inference.py -m models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf -p "You are a helpful assistant" -cnv
usage: run_inference.py [-h] [-m MODEL] [-n N_PREDICT] -p PROMPT [-t THREADS] [-c CTX_SIZE] [-temp TEMPERATURE] [-cnv]
Run inference
optional arguments:
-h, --help show this help message and exit
-m MODEL, --model MODEL
Path to model file
-n N_PREDICT, --n-predict N_PREDICT
Number of tokens to predict when generating text
-p PROMPT, --prompt PROMPT
Prompt to generate text from
-t THREADS, --threads THREADS
Number of threads to use
-c CTX_SIZE, --ctx-size CTX_SIZE
Size of the prompt context
-temp TEMPERATURE, --temperature TEMPERATURE
Temperature, a hyperparameter that controls the randomness of the generated text
-cnv, --conversation Whether to enable chat mode or not (for instruct models.)
(When this option is turned on, the prompt specified by -p will be used as the system prompt.)
モデルを提供する推論ベンチマークを実行するためのスクリプトを提供します。
usage: e2e_benchmark.py -m MODEL [-n N_TOKEN] [-p N_PROMPT] [-t THREADS]
Setup the environment for running the inference
required arguments:
-m MODEL, --model MODEL
Path to the model file.
optional arguments:
-h, --help
Show this help message and exit.
-n N_TOKEN, --n-token N_TOKEN
Number of generated tokens.
-p N_PROMPT, --n-prompt N_PROMPT
Prompt to generate text from.
-t THREADS, --threads THREADS
Number of threads to use.
各引数の簡単な説明は次のとおりです。
-m、--model: モデル ファイルへのパス。これは、スクリプトの実行時に指定する必要がある必須の引数です。-n、--n-token: 推論中に生成するトークンの数。これはオプションの引数であり、デフォルト値は 128 です。-p、--n-prompt: テキストの生成に使用するプロンプト トークンの数。これはオプションの引数で、デフォルト値は 512 です。-t、--threads: 推論の実行に使用するスレッドの数。これはオプションの引数であり、デフォルト値は 2 です。-h、--help:ヘルプメッセージを表示して終了します。この引数を使用して、使用法情報を表示します。
例えば:
python utils/e2e_benchmark.py -m /path/to/model -n 200 -p 256 -t 4
このコマンドは、次の場所にあるモデルを使用して推論ベンチマークを実行します。 /path/to/model、4 つのスレッドを利用して、256 トークン プロンプトから 200 トークンを生成します。
パブリック モデルでサポートされていないモデル レイアウトについては、指定されたモデル レイアウトでダミー モデルを生成し、マシン上でベンチマークを実行するためのスクリプトが提供されています。
python utils/generate-dummy-bitnet-model.py models/bitnet_b1_58-large --outfile models/dummy-bitnet-125m.tl1.gguf --outtype tl1 --model-size 125M
# Run benchmark with the generated model, use -m to specify the model path, -p to specify the prompt processed, -n to specify the number of token to generate
python utils/e2e_benchmark.py -m models/dummy-bitnet-125m.tl1.gguf -p 512 -n 128
# Prepare the .safetensors model file
huggingface-cli download microsoft/bitnet-b1.58-2B-4T-bf16 --local-dir ./models/bitnet-b1.58-2B-4T-bf16
# Convert to gguf model
python ./utils/convert-helper-bitnet.py ./models/bitnet-b1.58-2B-4T-bf16
答え:
これは、llama.cpp の最新バージョンで導入された問題です。こちらを参照してください 専念 で 議論 この問題を解決するには。
答え:
プロジェクトをビルドする前に、以下を実行して Clang のインストールと Visual Studio ツールへのアクセスを確認します。
このコマンドは、正しいバージョンの Clang を使用していること、および Visual Studio ツールが利用可能であることを確認します。次のようなエラー メッセージが表示された場合:
'clang' is not recognized as an internal or external command, operable program or batch file.
これは、コマンド ライン ウィンドウが Visual Studio ツール用に適切に初期化されていないことを示します。
• コマンド プロンプトを使用している場合は、次を実行します。
"C:Program FilesMicrosoft Visual Studio2022ProfessionalCommon7ToolsVsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64
• Windows PowerShell を使用している場合は、次のコマンドを実行します。
Import-Module "C:Program FilesMicrosoft Visual Studio2022ProfessionalCommon7ToolsMicrosoft.VisualStudio.DevShell.dll" Enter-VsDevShell 3f0e31ad -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64"
これらの手順により環境が初期化され、正しい Visual Studio ツールを使用できるようになります。
#MicrosoftBitNet #ビット #LLM #用の公式推論フレームワーク #GitHub

