# E21z: is the lower perplexity with quantized KV at 64K caused by the f16 KV reference? # Paths below are placeholders; point them at your llama.cpp build, model and WikiText-2 raw test file. $ErrorActionPreference='Continue' $log='.\e21z_chain.log' function L($m){ "$(Get-Date -Format o) $m" | Out-File -FilePath $log -Append -Encoding utf8 } $out='.\e21z'; New-Item -ItemType Directory -Force $out | Out-Null $bin='.\llama.cpp\build-cuda\bin\llama-perplexity.exe' # llama.cpp built with upstream PR 29827 $m4='.\models\Qwen3.5-4B-Q4_K_M.gguf'; $txt='.\wiki_test.txt' $ctx=65536; $ch=2; $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_fa_base.log" $p=(Select-String -Path "$out\f16_fa_base.log" -Pattern 'Final estimate' | % { $_.Line.Trim() }) -join ' ' L "f16 FA-on base c$ctx exit $LASTEXITCODE :: $p" $runs=@(@('q8_0','q8_0','on','q8_rep'),@('f16','f16','off','f16_faoff'),@('bf16','bf16','on','bf16_faon'),@('f32','f32','on','f32_faon')) foreach($r in $runs){ $tag=$r[3]; $lf="$out\$tag.log" $args2=@('-m',$m4,'-f',$txt,'-c',$ctx,'--chunks',$ch,'-ngl',99,'-fa',$r[2],'-ctk',$r[0],'-ctv',$r[1],'-b',2048,'-ub',512,'--kl-divergence-base',$base,'--kl-divergence') $t0=Get-Date $pr=Start-Process -FilePath $bin -ArgumentList $args2 -RedirectStandardOutput "$lf.out" -RedirectStandardError $lf -NoNewWindow -PassThru if(-not $pr.WaitForExit(45*60*1000)){ $pr.Kill(); L "result $tag TIMEOUT"; continue } $sum=(Select-String -Path $lf,"$lf.out" -Pattern 'Mean PPL|Mean KLD|Same top|RMS' | % { $_.Line.Trim() }) -join ' | ' L "result $tag exit $($pr.ExitCode) wall $([int]((Get-Date)-$t0).TotalSeconds)s :: $sum" } Remove-Item $base -Force -ErrorAction SilentlyContinue L "=== E21zDONE ==="