$ErrorActionPreference='Continue' $B='C:\AGI\agi-research\build'; $log="$B\e21y_chain.log" function L($m){ "$(Get-Date -Format o) $m" | Out-File -FilePath $log -Append -Encoding utf8 } L "=== e21y start: fill KLD-vs-context curve at c32768 (4 chunks) and add K/V splits + q5_0 at c65536, 4B, WikiText test ===" $out='C:\AGI\agi-research\e21_budget\e21y'; New-Item -ItemType Directory -Force $out | Out-Null $bin='C:\AGI\llama.cpp\fork-29827\build-cuda\bin\llama-perplexity.exe' $m4='C:\AGI\gguf\q35\Qwen3.5-4B-Q4_K_M.gguf'; $txt='C:\AGI\agi-research\bench\wiki_test.txt' Get-Process llama-server -ErrorAction SilentlyContinue | Stop-Process -Force $plan=@{ 32768=@(4,@(@('q8_0','q8_0'),@('q5_0','q5_0'),@('q4_0','q4_0'),@('q8_0','q4_0'),@('q4_0','q8_0'),@('f16','f16'))); 65536=@(2,@(@('q4_0','q8_0'),@('q5_0','q5_0'))) } foreach($ctx in @(32768,65536)){ $ch=$plan[$ctx][0]; $base="$out\kld_base_c$ctx.bin" & $bin -m $m4 -f $txt -c $ctx --chunks $ch -ngl 99 -fa on -ctk f16 -ctv f16 -b 2048 -ub 512 --kl-divergence-base $base *> "$out\f16_c$ctx.log" $p=(Select-String -Path "$out\f16_c$ctx.log" -Pattern 'Final estimate' | % { $_.Line.Trim() }) -join ' ' L "f16 base c$ctx exit $LASTEXITCODE :: $p" foreach($kv in $plan[$ctx][1]){ $tag="$($kv[0])_$($kv[1])_c$ctx" & $bin -m $m4 -f $txt -c $ctx --chunks $ch -ngl 99 -fa on -ctk $kv[0] -ctv $kv[1] -b 2048 -ub 512 --kl-divergence-base $base --kl-divergence *> "$out\$tag.log" $sum=(Select-String -Path "$out\$tag.log" -Pattern 'Mean PPL|Mean KLD|Mean KLD|Same top|RMS' | % { $_.Line.Trim() }) -join ' | ' L "result $tag exit $LASTEXITCODE :: $sum" } Remove-Item $base -Force -ErrorAction SilentlyContinue; L "deleted scratch base c$ctx" } L "=== E21yDONE ==="