interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tools / localrouter / README.md

157 lines · 9213 bytes Raw Blame History Rendered
1# LocalRouter with an Omega text server
2
3This is a text-only candidate setup, tracked by [CUDApp #27](https://github.com/aien-dev/CUDApp/issues/27).
4It generates configuration and checks HTTP behavior. It installs no service, downloads no weights,
5and changes no GPU driver. It does not port LocalRouter's image/video kernels to CUDA++.
6
7## What connects
8
9An OpenAI client or LocalRouter's MCP `chat` tool reaches LocalRouter on loopback port 8192.
10LocalRouter's existing `openai_server` worker launches a separate `aien-serve-http` candidate
11on loopback port 18092. That server selects the Omega engine. Its actual linked GPU backend
12must be qualified through the canonical CUDApp consumption work in #5.
13
14Inspected sources:
15
16| Repository | Revision | Contract |
17| --- | --- | --- |
18| [LocalRouter](https://github.com/jayleaton/localrouter/tree/70ad4fa198dfc0c8175d02fff746e95759c42d59) | `70ad4fa198dfc0c8175d02fff746e95759c42d59` | `src/engines/openai_server.zig`, `src/config.zig`, `src/tool/process.zig` |
19| [sovereign-core](https://github.com/aien-dev/aien-sovereign-core-mv/tree/754c07b118f41ad899607b60329bd851b1ccb13e) | `754c07b118f41ad899607b60329bd851b1ccb13e` | `crates/aien-serve-http/src/{main,server,omega_engine}.rs` |
20| CUDA++ | `232332422bfdc31c8918085b50f13c1e18ab702e` | baseline before this integration |
21
22Recheck these contracts if consuming different revisions. Do not overwrite the live motor's binary,
23configuration or CUDApp pin to make this example run.
24
25## Two integration limits
26
27**Process ownership:** `openai_server` starts a child and terminates it on unload or daemon exit.
28It cannot attach to the existing motor. Use a separate immutable candidate binary, candidate
29model ID, data directory and ports. The generator reserves port 18091 for the live motor.
30Other live-service ports must also be excluded by the operator. `check` refuses occupied ports,
31but checking a free port does not reserve it against another process.
32
33**GPU locking:** LocalRouter normally holds its configured host lock shared while any model
34is loaded. The inspected Omega engine takes `/tmp/aien-gb10.lock` exclusively during load and
35generation. Using that file for both would block Omega. This profile therefore leaves
36LocalRouter's `gpu_lock` empty, keeps Omega's lock unchanged, and permits exactly one text tool.
37Do not add LocalRouter image/video/speech GPU workers to this profile. Their execution would
38need an explicitly qualified lock/admission handoff. The memory budget is admission accounting,
39not a global reservation against other processes. Coordinate candidate loading with the GPU
40owner and keep the live motor's memory in the budget.
41
42## Before starting
43
44You need Python 3.10+, a LocalRouter binary and a separately qualified `aien-serve-http` candidate.
45The inspected LocalRouter build requires **exactly Zig 0.17.0** and pins TensorFold in
46`build.zig.zon`. Its documented host build is `zig build -Doptimize=ReleaseSafe`; omit `-Dnvcc`
47for this text-only experiment. That avoids embedding its own CUDA kernels. It does not prove
48that every LocalRouter process is free of CUDA library mappings. Record and inspect the actual
49binaries/processes before making that claim. Run upstream's `zig build test` on the build host.
50
51Reuse the server build and complete source/dependency closure from the #5 integration owner.
52The inspected server accepts `--engine omega`, `--model-dir`, `--bind`, `--port`, `--model-id`
53and `--max-context`. This profile limits context to 4096 and uses the server's existing default
54FP8 weights. Use its supported Qwen checkpoint and tokenizer, not an image/video checkpoint.
55The candidate needs enough free memory for its own load even when the live motor is resident.
56
57Measure and record `resident_bytes` and incremental per-request `working_bytes` for the
58chosen engine, checkpoint and context. Do not copy another model's memory numbers or enter
59zero for an unmeasured Omega resident size. Zero incremental working memory is valid only
60when measured. The generator requires these values explicitly.
61
62## Generate and check a candidate config
63
64Run from the CUDA++ checkout on the target host. Supply real absolute paths and measured byte
65counts. These shell parameters deliberately refuse missing values:
66
67```sh
68python3 tools/localrouter/setup.py config \
69 --server "${OMEGA_CANDIDATE_BIN:?absolute path to a separate aien-serve-http}" \
70 --model-dir "${OMEGA_MODEL_DIR:?absolute path to the supported checkpoint}" \
71 --data-dir "${LOCALROUTER_CANDIDATE_DATA:?absolute path to a separate data directory}" \
72 --resident-bytes "${OMEGA_RESIDENT_BYTES:?measured resident bytes}" \
73 --working-bytes "${OMEGA_WORKING_BYTES:?measured incremental working bytes}" \
74 --router-port 8192 --backend-port 18092 \
75 > localrouter-omega.candidate.json
76
77python3 tools/localrouter/setup.py check --config localrouter-omega.candidate.json
78```
79
80Keep generated host-specific config outside version control. Generation only inspects paths.
81`check` additionally tests whether the ports are available. Neither starts a server or opens a GPU.
82The 8 GiB OS reserve is a starting configuration, not a measured model budget or an OOM guarantee.
83Increase it to account for the other resident workloads as needed with `--reserve-bytes`.
84
85Use a foreground daemon first, on the same host as the candidate binary and model files:
86
87```sh
88/absolute/path/to/localrouter serve --config localrouter-omega.candidate.json
89```
90
91There is no boot service, container, tailnet exposure or full Jarvis installation in this setup.
92The generated `keep_loaded: false` prevents eager model loading at daemon startup. A generation
93request loads the candidate. It can then remain warm until its 300-second idle timeout or an
94explicit unload. Logs are under the configured data directory.
95
96## Read-only inspection, then opt-in generation
97
98In a second terminal:
99
100```sh
101# Lists the candidate without asking it to load or generate.
102python3 tools/localrouter/setup.py probe --config localrouter-omega.candidate.json
103
104# Coordinated GPU window only: this sends several short requests and loads the model.
105python3 tools/localrouter/setup.py probe --config localrouter-omega.candidate.json \
106 --exercise --timeout 180 > localrouter-omega.http-receipt.json
107```
108
109The exercised probe checks router model listing, a whole completion, backend health/model/engine,
110a second turn, a complete SSE response, rejected tool calling and an unknown-model error.
111SSE errors, empty replies, wrong models and missing finish/[DONE] events fail. A local mock test
112of the client is not a test of the real Zig daemon or Rust model server.
113
114The HTTP receipt always leaves GPU correctness, process lifecycle and CUDA-free provenance
115`NOT_RUN`. It establishes only protocol behavior. Qualify the actual model with golden/numerical
116checks, cancellation, unload/reload, process cleanup, memory measurements, source/binary hashes,
117and `/proc/<pid>/maps` observations in a separate receipt before promoting this configuration.
118Confirm the live motor is still healthy before and after the window. Do not run deliberate
119faults against the live service.
120
121At the inspected sovereign-core revision, nonempty `tools` and `tool` message roles are rejected.
122The generated voice settings disable tools, model management, speculative chat and priming.
123LocalRouter MCP can still expose a plain-text `chat` tool to an external agent, but this does
124not give Omega native tool calling. Validate MCP separately if enabling it in a client.
125
126## Stop and rollback
127
128Stop only the foreground candidate daemon with Ctrl-C. LocalRouter is expected to stop its
129worker and owned server. Verify port 18092 is closed and its child PID has exited; record a
130lifecycle failure if either survives. Keep the live 18091 motor untouched. Keep model files and
131qualified binaries; remove only the candidate configuration/data when no longer needed.
132Do not use a broad `pkill`, restart the production service, unload GPU modules, or install the
133full upstream Jarvis profile as a shortcut for this experiment.
134
135## Host smoke test without a model
136
137Use the server's explicit `--engine stub` mode with an empty temporary model directory and
138`--resident-bytes 0 --working-bytes 0`. Follow the same generate/check/start/probe sequence.
139Label every result `stub`, not GPU-qualified. The setup script itself has no compiler or model
140dependency:
141
142```sh
143python3 -m unittest discover -s tests/localrouter -v
144```
145
146## After text routing works
147
1481. Qualify shared-lock ownership and capability reporting before adding other GPU workers.
1492. Benchmark one matched RMSNorm/SwiGLU operation with identical shape, datatype and numerical
150 contract. Compare full outputs, warm latency, submission cost and memory on the same GB10.
1513. Extend to a short native chain using #18 and #19. Reusable graph replay additionally needs
152 persistent resources, safe parameter updates and lifecycle tests; command lists alone do
153 not establish CUDA Graph equivalence.
1544. Treat NVFP4/image/video parity as separate numerical and kernel-coverage work. Existing CUDA
155 fatbins cannot simply be passed to CUDA++'s native kernel builder.
156
157No speedup or full Jarvis capability is claimed by this integration.