$ErrorActionPreference='Continue' $B='C:\AGI\agi-research\build'; $log="$B\e21x_chain.log" function L($m){ "$(Get-Date -Format o) $m" | Out-File -FilePath $log -Append -Encoding utf8 } L "=== e21x start: does KV quantization error grow with context length? KLD vs f16 KV at c65536 and c131072, 4B, WikiText test ===" $out='C:\AGI\agi-research\e21_budget\e21x'; 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 foreach($cc in @(@(65536,2),@(131072,1))){ $ctx=$cc[0]; $ch=$cc[1] $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 @(@('q8_0','q8_0'),@('q4_0','q4_0'),@('q8_0','q4_0'),@('f16','f16'))){ $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 "=== E21xDONE ==="