# E22e: kernel path vs quantization for the 64K quantized-KV perplexity drop (Qwen3.5-4B Q4_K_M). # llama-perplexity built with upstream PR 29827 plus two small patches: # LLAMA_PPL_TOKEN_OFFSET skips the first N tokens of the file, LLAMA_PPL_SCORE_LAST scores only the last N tokens. $ErrorActionPreference='Continue' $log='e22e_chain.log' function L($m){ "$(Get-Date -Format o) $m" | Out-File -FilePath $log -Append -Encoding utf8 } $out='e22e'; New-Item -ItemType Directory -Force $out | Out-Null $bin='llama.cpp\build-cuda\bin\llama-perplexity.exe' $m4='models\Qwen3.5-4B-Q4_K_M.gguf' $txt='bench\wiki_test.txt' # WikiText-2 test set $env:LLAMA_PPL_SCORE_LAST='4096' $arms=@(@('f16','f16','f16faoff','off'),@('q8_0','f16','k8vf_faoff','off'),@('q8_0','f16','k8vf_faon','on'),@('f32','f32','f32faon','on')) foreach($E in @(72000,108000,144000,180000,216000,252000)){ $Lc=65536; $ctx=$Lc+4097; $off=$E-$ctx; $env:LLAMA_PPL_TOKEN_OFFSET="$off"; $nm="E${E}_L$Lc"; $base="$out\kld_base_$nm.bin" & $bin -m $m4 -f $txt -c $ctx --chunks 1 -ngl 99 -fa on -ctk f16 -ctv f16 -b 2048 -ub 512 --kl-divergence-base $base *> "$out\${nm}_f16_base.log" foreach($r in $arms){ $tag="${nm}_$($r[2])"; $lf="$out\$tag.log" $a=@('-m',$m4,'-f',$txt,'-c',$ctx,'--chunks',1,'-ngl',99,'-fa',$r[3],'-ctk',$r[0],'-ctv',$r[1],'-b',2048,'-ub',512,'--kl-divergence-base',$base,'--kl-divergence') $pr=Start-Process -FilePath $bin -ArgumentList $a -RedirectStandardOutput "$lf.out" -RedirectStandardError $lf -NoNewWindow -PassThru if(-not $pr.WaitForExit(8*60*1000)){ $pr.Kill(); L "result $tag TIMEOUT"; continue } $sum=(Select-String -Path $lf,"$lf.out" -Pattern 'Mean PPL\(Q\) |Mean PPL\(base\)|Mean KLD|Same top' | % { $_.Line.Trim() }) -join ' | ' L "result $tag :: $sum" } Remove-Item $base -Force -ErrorAction SilentlyContinue } L "=== e22eDONE ==="