| |
| |
| |
| |
| |
| |
| |
|
|
| param( |
| |
| [ValidateSet("BitNetLarge", "Falcon1B", "BitNet2B")] |
| [string]$Model = "BitNetLarge", |
| [switch]$SkipBuild, |
| [switch]$SkipDownload, |
| [string]$BitNetRoot = "F:\Kinetic\BitNet" |
| ) |
|
|
| $ErrorActionPreference = "Stop" |
|
|
| if (-not (Test-Path $BitNetRoot)) { |
| Write-Error "BitNet not found at $BitNetRoot" |
| } |
|
|
| Set-Location $BitNetRoot |
| Write-Host "==> BitNet root: $BitNetRoot" -ForegroundColor Cyan |
|
|
| |
| $hfMap = @{ |
| "Falcon1B" = "tiiuae/Falcon-E-1B-Instruct" |
| "BitNetLarge" = "1bitLLM/bitnet_b1_58-large" |
| "BitNet2B" = "microsoft/BitNet-b1.58-2B-4T" |
| } |
| $hf = $hfMap[$Model] |
| Write-Host "==> Lightweight model choice: $Model ($hf)" -ForegroundColor Cyan |
|
|
| |
| Write-Host "==> git submodule update --init --recursive" -ForegroundColor Cyan |
| git submodule update --init --recursive |
| if ($LASTEXITCODE -ne 0) { Write-Error "submodule update failed" } |
|
|
| |
| Write-Host "==> pip install huggingface_hub gguf deps" -ForegroundColor Cyan |
| python -m pip install -q huggingface_hub |
| if (Test-Path "3rdparty\llama.cpp\gguf-py") { |
| python -m pip install -q "3rdparty\llama.cpp\gguf-py" |
| } |
|
|
| |
| if (-not $SkipBuild) { |
| Write-Host "==> MinGW/clang build (build_bitnet_mingw.ps1)" -ForegroundColor Cyan |
| & "$PSScriptRoot\build_bitnet_mingw.ps1" -BitNetRoot $BitNetRoot |
| if ($LASTEXITCODE -ne 0) { Write-Error "build failed" } |
| } |
|
|
| if (-not $SkipDownload) { |
| Write-Host "==> Download + convert light model: $hf" -ForegroundColor Cyan |
| $name = switch ($Model) { |
| "Falcon1B" { "Falcon-E-1B-Instruct" } |
| "BitNetLarge" { "bitnet_b1_58-large" } |
| "BitNet2B" { "BitNet-b1.58-2B-4T" } |
| } |
| $dest = Join-Path "models" $name |
| New-Item -ItemType Directory -Force -Path $dest | Out-Null |
| python -c "from huggingface_hub import snapshot_download; snapshot_download('$hf', local_dir=r'$dest'); print('ok')" |
| $i2s = Join-Path $dest "ggml-model-i2_s.gguf" |
| if (-not (Test-Path $i2s)) { |
| python -m pip install -q safetensors |
| python utils/convert-hf-to-gguf-bitnet.py $dest --outtype f32 |
| $f32 = Join-Path $dest "ggml-model-f32.gguf" |
| $quant = Join-Path $BitNetRoot "build\bin\llama-quantize.exe" |
| if (-not (Test-Path $quant)) { $quant = Join-Path $BitNetRoot "build\bin\Release\llama-quantize.exe" } |
| & $quant $f32 $i2s I2_S 1 |
| } |
| } |
|
|
| |
| $ggufs = Get-ChildItem -Path models -Recurse -Filter "*.gguf" -ErrorAction SilentlyContinue | |
| Sort-Object Length |
| if ($ggufs) { |
| $best = $ggufs | Select-Object -First 1 |
| |
| $i2 = $ggufs | Where-Object { $_.Name -like "*i2_s*" } | Select-Object -First 1 |
| if ($i2) { $best = $i2 } |
| Write-Host "==> GGUF: $($best.FullName) ($([math]::Round($best.Length/1MB,1)) MB)" -ForegroundColor Green |
| $env:KINETIC_BITNET_REPO = $BitNetRoot |
| $env:KINETIC_BITNET_MODEL = $best.FullName |
| Write-Host "Set for this session:" -ForegroundColor Green |
| Write-Host " `$env:KINETIC_BITNET_REPO = '$BitNetRoot'" |
| Write-Host " `$env:KINETIC_BITNET_MODEL = '$($best.FullName)'" |
| } else { |
| Write-Host "==> No GGUF found yet under models/" -ForegroundColor Yellow |
| } |
|
|
| |
| $cfg = "F:\Kinetic\configs\bitnet.yaml" |
| if ((Test-Path $cfg) -and $ggufs) { |
| Write-Host "==> Update configs/bitnet.yaml model_path" -ForegroundColor Cyan |
| $posix = ($best.FullName -replace "\\", "/") |
| $text = Get-Content $cfg -Raw |
| $text = $text -replace "model_path:.*", "model_path: $posix" |
| Set-Content -Path $cfg -Value $text -NoNewline |
| } |
|
|
| Write-Host "" |
| Write-Host "Next:" -ForegroundColor Cyan |
| Write-Host " cd F:\Kinetic" |
| Write-Host " python -m kinetic.cli bitnet-info --config configs/bitnet.yaml" |
| Write-Host " python -m kinetic.cli reason -i `"Pick up the bottle`" --config configs/bitnet.yaml --json" |
| Write-Host " python -m kinetic.demos.pick_bottle --config configs/bitnet.yaml" |
|
|