Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tools/localrouter/README.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 3 This is a text-only candidate setup, tracked by [CUDApp #27](https://github.com/aien-dev/CUDApp/issues/27). 4 It generates configuration and checks HTTP behavior. It installs no service, downloads no weights, 5 and changes no GPU driver. It does not port LocalRouter's image/video kernels to CUDA++. 6 7 ## What connects 8 9 An OpenAI client or LocalRouter's MCP `chat` tool reaches LocalRouter on loopback port 8192. 10 LocalRouter's existing `openai_server` worker launches a separate `aien-serve-http` candidate 11 on loopback port 18092. That server selects the Omega engine. Its actual linked GPU backend 12 must be qualified through the canonical CUDApp consumption work in #5. 13 14 Inspected 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 22 Recheck these contracts if consuming different revisions. Do not overwrite the live motor's binary, 23 configuration 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. 28 It cannot attach to the existing motor. Use a separate immutable candidate binary, candidate 29 model ID, data directory and ports. The generator reserves port 18091 for the live motor. 30 Other live-service ports must also be excluded by the operator. `check` refuses occupied ports, 31 but 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 34 is loaded. The inspected Omega engine takes `/tmp/aien-gb10.lock` exclusively during load and 35 generation. Using that file for both would block Omega. This profile therefore leaves 36 LocalRouter's `gpu_lock` empty, keeps Omega's lock unchanged, and permits exactly one text tool. 37 Do not add LocalRouter image/video/speech GPU workers to this profile. Their execution would 38 need an explicitly qualified lock/admission handoff. The memory budget is admission accounting, 39 not a global reservation against other processes. Coordinate candidate loading with the GPU 40 owner and keep the live motor's memory in the budget. 41 42 ## Before starting 43 44 You need Python 3.10+, a LocalRouter binary and a separately qualified `aien-serve-http` candidate. 45 The 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` 47 for this text-only experiment. That avoids embedding its own CUDA kernels. It does not prove 48 that every LocalRouter process is free of CUDA library mappings. Record and inspect the actual 49 binaries/processes before making that claim. Run upstream's `zig build test` on the build host. 50 51 Reuse the server build and complete source/dependency closure from the #5 integration owner. 52 The inspected server accepts `--engine omega`, `--model-dir`, `--bind`, `--port`, `--model-id` 53 and `--max-context`. This profile limits context to 4096 and uses the server's existing default 54 FP8 weights. Use its supported Qwen checkpoint and tokenizer, not an image/video checkpoint. 55 The candidate needs enough free memory for its own load even when the live motor is resident. 56 57 Measure and record `resident_bytes` and incremental per-request `working_bytes` for the 58 chosen engine, checkpoint and context. Do not copy another model's memory numbers or enter 59 zero for an unmeasured Omega resident size. Zero incremental working memory is valid only 60 when measured. The generator requires these values explicitly. 61 62 ## Generate and check a candidate config 63 64 Run from the CUDA++ checkout on the target host. Supply real absolute paths and measured byte 65 counts. These shell parameters deliberately refuse missing values: 66 67 ```sh 68 python3 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 77 python3 tools/localrouter/setup.py check --config localrouter-omega.candidate.json 78 ``` 79 80 Keep 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. 82 The 8 GiB OS reserve is a starting configuration, not a measured model budget or an OOM guarantee. 83 Increase it to account for the other resident workloads as needed with `--reserve-bytes`. 84 85 Use 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 91 There is no boot service, container, tailnet exposure or full Jarvis installation in this setup. 92 The generated `keep_loaded: false` prevents eager model loading at daemon startup. A generation 93 request loads the candidate. It can then remain warm until its 300-second idle timeout or an 94 explicit unload. Logs are under the configured data directory. 95 96 ## Read-only inspection, then opt-in generation 97 98 In a second terminal: 99 100 ```sh 101 # Lists the candidate without asking it to load or generate. 102 python3 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. 105 python3 tools/localrouter/setup.py probe --config localrouter-omega.candidate.json \ 106 --exercise --timeout 180 > localrouter-omega.http-receipt.json 107 ``` 108 109 The exercised probe checks router model listing, a whole completion, backend health/model/engine, 110 a second turn, a complete SSE response, rejected tool calling and an unknown-model error. 111 SSE errors, empty replies, wrong models and missing finish/[DONE] events fail. A local mock test 112 of the client is not a test of the real Zig daemon or Rust model server. 113 114 The 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 116 checks, cancellation, unload/reload, process cleanup, memory measurements, source/binary hashes, 117 and `/proc//maps` observations in a separate receipt before promoting this configuration. 118 Confirm the live motor is still healthy before and after the window. Do not run deliberate 119 faults against the live service. 120 121 At the inspected sovereign-core revision, nonempty `tools` and `tool` message roles are rejected. 122 The generated voice settings disable tools, model management, speculative chat and priming. 123 LocalRouter MCP can still expose a plain-text `chat` tool to an external agent, but this does 124 not give Omega native tool calling. Validate MCP separately if enabling it in a client. 125 126 ## Stop and rollback 127 128 Stop only the foreground candidate daemon with Ctrl-C. LocalRouter is expected to stop its 129 worker and owned server. Verify port 18092 is closed and its child PID has exited; record a 130 lifecycle failure if either survives. Keep the live 18091 motor untouched. Keep model files and 131 qualified binaries; remove only the candidate configuration/data when no longer needed. 132 Do not use a broad `pkill`, restart the production service, unload GPU modules, or install the 133 full upstream Jarvis profile as a shortcut for this experiment. 134 135 ## Host smoke test without a model 136 137 Use 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. 139 Label every result `stub`, not GPU-qualified. The setup script itself has no compiler or model 140 dependency: 141 142 ```sh 143 python3 -m unittest discover -s tests/localrouter -v 144 ``` 145 146 ## After text routing works 147 148 1. Qualify shared-lock ownership and capability reporting before adding other GPU workers. 149 2. 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. 151 3. 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. 154 4. 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 157 No speedup or full Jarvis capability is claimed by this integration.