Files
leleka/engine/strata/tools/windows/enable_large_pages.ps1
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree
(570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base =
the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main).

Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR
experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details,
conflict table and left-out files are in docs/upstream.md.

Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61),
docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out.

scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run").
Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR
macros on. No GPU run, no quality gate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:49:15 +01:00

90 lines
4.4 KiB
PowerShell

<#
.SYNOPSIS
Enables the 'Lock pages in memory' privilege (SeLockMemoryPrivilege) on Windows.
.DESCRIPTION
Strata keeps the experts the GPU does not hold in a host memory arena. With SeLockMemoryPrivilege
granted, Windows lets it allocate that arena in 2 MB large pages (MEM_LARGE_PAGES); without it the
engine says at start that the large pages were refused and uses 4 KB pages (docs/DETAILS.md, #1412).
The same can be done by hand with secpol.msc (User Rights Assignment, "Lock pages in memory").
NOTE: Windows applies security token privilege changes ONLY after sign-out/sign-in or reboot.
#>
[CmdletBinding()]
param (
[string]$AccountName = $env:USERNAME
)
function Test-IsAdmin {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (-not (Test-IsAdmin)) {
Write-Host "[!] This script must be run as Administrator." -ForegroundColor Yellow
Write-Host " Right-click PowerShell -> 'Run as Administrator', then run:"
Write-Host " .\tools\windows\enable_large_pages.ps1"
Write-Host ""
Write-Host " GUI Alternative:"
Write-Host " 1. Press Win + R, type 'secpol.msc' and press Enter."
Write-Host " 2. Navigate to: Security Settings -> Local Policies -> User Rights Assignment"
Write-Host " 3. Double-click 'Lock pages in memory'."
Write-Host " 4. Click 'Add User or Group...', add '$AccountName', and click OK."
Write-Host " 5. Sign out of Windows and sign back in."
exit 1
}
Write-Host "=== Configuring 'Lock pages in memory' (SeLockMemoryPrivilege) for $AccountName ===" -ForegroundColor Cyan
$tempInf = [System.IO.Path]::GetTempFileName()
$tempSdb = [System.IO.Path]::ChangeExtension($tempInf, ".sdb")
try {
Write-Host "1. Exporting current security policy..."
secedit /export /cfg $tempInf | Out-Null
$content = Get-Content $tempInf -Raw
$userSid = (New-Object System.Security.Principal.NTAccount($AccountName)).Translate([System.Security.Principal.SecurityIdentifier]).Value
if ($content -match "SeLockMemoryPrivilege\s*=\s*(.*)") {
$currentList = $matches[1].Trim()
if ($currentList -match [regex]::Escape($userSid) -or $currentList -match [regex]::Escape($AccountName)) {
Write-Host "[OK] $AccountName already possesses SeLockMemoryPrivilege." -ForegroundColor Green
Write-Host " If 'whoami /priv' still shows it as missing, please SIGN OUT and sign back in to refresh your token."
return
}
$newList = "$currentList,*$userSid"
$content = $content -replace "SeLockMemoryPrivilege\s*=.*", "SeLockMemoryPrivilege = $newList"
} else {
# Section [Privilege Rights]
if ($content -match "\[Privilege Rights\]") {
$content = $content -replace "\[Privilege Rights\]", "[Privilege Rights]`r`nSeLockMemoryPrivilege = *$userSid"
} else {
$content += "`r`n[Privilege Rights]`r`nSeLockMemoryPrivilege = *$userSid`r`n"
}
}
Set-Content -Path $tempInf -Value $content -Encoding ASCII
Write-Host "2. Importing updated policy database..."
secedit /import /db $tempSdb /cfg $tempInf | Out-Null
Write-Host "3. Applying updated policy to Windows system..."
secedit /configure /db $tempSdb /cfg $tempInf /areas USER_RIGHTS | Out-Null # only the user rights, nothing else of the exported policy
Write-Host ""
Write-Host "[SUCCESS] SeLockMemoryPrivilege has been granted to $AccountName ($userSid)!" -ForegroundColor Green
Write-Host "==========================================================================" -ForegroundColor Cyan
Write-Host "IMPORTANT: You MUST sign out of Windows and sign back in (or restart)" -ForegroundColor Yellow
Write-Host " for the new privilege to take effect on your user session." -ForegroundColor Yellow
Write-Host "==========================================================================" -ForegroundColor Cyan
}
catch {
Write-Host "[ERROR] Failed to configure privilege automatically: $_" -ForegroundColor Red
Write-Host "Please use the GUI steps via secpol.msc outlined above."
}
finally {
if (Test-Path $tempInf) { Remove-Item $tempInf -Force -ErrorAction SilentlyContinue }
if (Test-Path $tempSdb) { Remove-Item $tempSdb -Force -ErrorAction SilentlyContinue }
}