# E22c: content-controlled length test. Needs llama-perplexity with two small env-var patches: # LLAMA_PPL_TOKEN_OFFSET = number of leading tokens of the text file to skip # LLAMA_PPL_SCORE_LAST = score only the last N tokens of the (single) chunk # Without those env vars the tool behaves as upstream. $ErrorActionPreference='Continue' $B='C:\AGI\agi-research\build'; $log="$B\e22c_chain.log" function L($m){ "$(Get-Date -Format o) $m" | Out-File -FilePath $log -Append -Encoding utf8 } $out='C:\AGI\agi-research\e21_budget\e22c'; 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' $env:LLAMA_PPL_SCORE_LAST='4096' $arms=@(@('q8_0','q8_0','q8'),@('q4_0','q4_0','q4'),@('q8_0','q4_0','k8v4'),@('q4_0','q8_0','k4v8'),@('bf16','bf16','bf16')) foreach($E in @(72000,108000,144000,180000,216000,252000)){ foreach($Lc in @(16384,32768,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" $p=(Select-String -Path "$out\${nm}_f16_base.log" -Pattern 'Final estimate|token offset|you need|failed' | % { $_.Line.Trim() }) -join ' ' L "$nm f16 base :: $p" if(-not (Test-Path $base)){ L "$nm no base, skipping"; continue } foreach($r in $arms){ $tag="${nm}_$($r[2])"; $lf="$out\$tag.log" $a=@('-m',$m4,'-f',$txt,'-c',$ctx,'--chunks',1,'-ngl',99,'-fa','on','-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 $a -RedirectStandardOutput "$lf.out" -RedirectStandardError $lf -NoNewWindow -PassThru if(-not $pr.WaitForExit(20*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 wall $([int]((Get-Date)-$t0).TotalSeconds)s :: $sum" } Remove-Item $base -Force -ErrorAction SilentlyContinue } } L "=== e22cDONE ==="