-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_host.ps1
More file actions
122 lines (102 loc) · 3.16 KB
/
build_host.ps1
File metadata and controls
122 lines (102 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Geodessical - Host-Mode Build Script
# Builds the Geodessical inference runtime for Windows x86_64
#
# Requirements: zig (0.15+)
# Usage: .\build_host.ps1 [-Run] [-Clean]
param(
[switch]$Run,
[switch]$Clean,
[switch]$Cuda,
[switch]$NoCuda,
[string]$Model
)
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
$BUILD = "build_host"
$OUT = "$BUILD\geodessical.exe"
$CFLAGS = @(
"-target", "x86_64-windows-gnu",
"-O2",
"-msse2", "-mavx2", "-mfma",
"-DGEODESSICAL_HOSTED=1",
"-Ihost/shims",
"-I.",
"-Ihost",
"-Wno-unused-function", "-Wno-unused-variable", "-Wno-format",
"-Wno-incompatible-pointer-types", "-Wno-int-conversion",
"-Wno-sign-compare", "-Wno-missing-field-initializers",
"-Wno-unused-parameter"
)
$SOURCES = @(
"host/hal.c",
"host/main.c",
"host/api_server.c",
"host/gd_daemon.c",
"host/mcp_server.c",
"runtime/nn/llm.c",
"runtime/nn/gguf.c",
"runtime/nn/backend.c",
"runtime/nn/model_meta.c",
"runtime/nn/tensor_bridge.c",
"runtime/nn/mod_package.c",
"runtime/nn/token_comm.c",
"runtime/nn/hf_download.c",
"runtime/nn/axiom_linalg.c",
"runtime/nn/axiom_geo.c",
"runtime/nn/axiom_beta.c",
"runtime/nn/axiom_vis.c",
"runtime/jit/x86_jit.c",
"runtime/jit/llm_jit.c"
)
$LDFLAGS = @(
"-ladvapi32",
"-lws2_32",
"-lwinhttp"
)
# Default to CUDA backend unless explicitly disabled.
# Keep -Cuda for backward compatibility with existing scripts.
$EnableCuda = $Cuda -or (-not $NoCuda)
if ($EnableCuda) {
$CFLAGS += "-DENABLE_CUDA"
$SOURCES += "runtime/nn/backend_cuda.c"
Write-Host ' CUDA backend enabled (default)' -ForegroundColor Yellow
} else {
Write-Host ' CUDA backend disabled via -NoCuda' -ForegroundColor Yellow
}
# Clean
if ($Clean) {
Write-Host 'Cleaning build_host...' -ForegroundColor Yellow
if (Test-Path $BUILD) { Remove-Item -Recurse -Force $BUILD }
}
# Build
if (!(Test-Path $BUILD)) { New-Item -ItemType Directory -Path $BUILD | Out-Null }
Write-Host ''
Write-Host ' Geodessical Build System' -ForegroundColor Cyan
Write-Host ' Host-mode inference runtime (x86_64)' -ForegroundColor Cyan
Write-Host ''
$sw = [System.Diagnostics.Stopwatch]::StartNew()
Write-Host ('Compiling {0} sources...' -f $SOURCES.Length) -ForegroundColor Green
$args_list = @('cc') + $CFLAGS + $SOURCES + @('-o', $OUT) + $LDFLAGS
Write-Host ('zig ' + ($args_list -join ' ')) -ForegroundColor DarkGray
& zig @args_list 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host ('BUILD FAILED (exit code {0})' -f $LASTEXITCODE) -ForegroundColor Red
exit 1
}
$sw.Stop()
$size = (Get-Item $OUT).Length
$sizeKB = [math]::Round($size / 1024, 1)
Write-Host ''
Write-Host 'BUILD SUCCESS' -ForegroundColor Green
Write-Host ('Output: {0} ({1} KB)' -f $OUT, $sizeKB) -ForegroundColor Green
Write-Host ('Time: {0:F1}s' -f $sw.Elapsed.TotalSeconds) -ForegroundColor Green
Write-Host ''
# Run
if ($Run) {
if (!$Model) {
Write-Host 'No model specified. Usage: .\build_host.ps1 -Run -Model path\to\model.gguf' -ForegroundColor Yellow
exit 0
}
Write-Host ('Running: {0} {1}' -f $OUT, $Model) -ForegroundColor Cyan
& $OUT $Model
}