$ErrorActionPreference='Continue' $B='C:\AGI\agi-research\build'; $log="$B\e22b_chain.log" function L($m){ "$(Get-Date -Format o) $m" | Out-File -FilePath $log -Append -Encoding utf8 } L "=== e22b start: does the lower PPL with quantized KV replicate on non-WikiText? code (llama.cpp C++ source, ~900K chars) 2 chunks at c65536, and calib_v3 at c16384; f16 FA-on base, q8_0, q4_0, bf16, f16 repeat; 4B ===" $out='C:\AGI\agi-research\e21_budget\e22b'; 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' $sb=New-Object Text.StringBuilder; foreach($f in (Get-ChildItem C:\AGI\llama.cpp\fork-29827\src -Recurse -Include *.cpp,*.h | sort FullName)){ [void]$sb.Append([IO.File]::ReadAllText($f.FullName)); if($sb.Length -gt 900000){break} }; [IO.File]::WriteAllText("$out\code.txt",$sb.ToString()) $texts=@(@("$out\code.txt",2,'code',65536),@('C:\AGI\agi-research\bench\calib_v3.txt',2,'calib',16384)) Get-Process llama-server -ErrorAction SilentlyContinue | Stop-Process -Force foreach($t in $texts){ $txt=$t[0]; $ch=$t[1]; $nm=$t[2]; $ctx=$t[3]; $base="$out\kld_base_$nm.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\${nm}_f16_base.log" $p=(Select-String -Path "$out\${nm}_f16_base.log" -Pattern 'Final estimate|failed|error' | % { $_.Line.Trim() }) -join ' ' L "$nm f16 base exit $LASTEXITCODE :: $p" if(-not (Test-Path $base)){ L "$nm no base, skipping"; continue } foreach($r in @(@('q8_0','q8'),@('q4_0','q4'),@('bf16','bf16'),@('f16','f16rep'))){ $tag="${nm}_$($r[1])"; $lf="$out\$tag.log" $a=@('-m',$m4,'-f',$txt,'-c',$ctx,'--chunks',$ch,'-ngl',99,'-fa','on','-ctk',$r[0],'-ctv',$r[0],'-b',2048,'-ub',512,'--kl-divergence-base',$base,'--kl-divergence') $t0=Get-Date $pr=Start-Process -FilePath $bin -ArgumentList $a -RedirectStandardOutput "$lf.out" -RedirectStandardError $lf -NoNewWindow -PassThru if(-not $pr.WaitForExit(30*60*1000)){ $pr.Kill(); L "result $tag TIMEOUT"; continue } $sum=(Select-String -Path $lf,"$lf.out" -Pattern 'Mean PPL|Mean KLD|Same top' | % { $_.Line.Trim() }) -join ' | ' L "result $tag exit $($pr.ExitCode) wall $([int]((Get-Date)-$t0).TotalSeconds)s :: $sum" } Remove-Item $base -Force -ErrorAction SilentlyContinue } L "=== e22bDONE ==="