Skip to content

feat(ai): serve Laya through upstream laya-serve, on the GPU when VRAM allows - #90

Merged
fts-forge[bot] merged 2 commits into
mainfrom
feat/sta-630-laya-serve-gpu
Nov 2, 2026
Merged

fts-forge[bot] merged 2 commits into
mainfrom
feat/sta-630-laya-serve-gpu

Conversation

@fts-forge

@fts-forge fts-forge Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

What

Replaces fleet.ai/ollaya with fleet.ai/laya (modules/ai/laya.nix): upstream laya-serve (NandhaKishorM/laya v0.4.21, its own NixOS module) on the same 127.0.0.1:11435 /v1/systemone, so the Paperclip router (STA-631) keeps working.

  • Why laya-serve: it loads laya-train fine-tunes directly (settings.ai.laya.extraModels). Ollaya only runs ONNX graphs, and training on our own decisions is where Laya's accuracy comes from.
  • GPU when there's room: a start wrapper reads free VRAM and starts on cuda with at least 4 GiB free, else cpu. A 2-minute timer restarts the service onto the other device when that changes: under 1 GiB free on the GPU moves it to the CPU, and 4 GiB free moves it back.
  • fp32 on both devices, so a move never shifts the probabilities that thresholds get fitted on. Weights are pinned to laya's reviewed revision, and a checkpoint unloads after 10 idle minutes.

Verified

  • nix build .#nixosConfigurations.THEBATTLESHIP.config.system.build.toplevel exits 0.
  • A scratch instance of the same laya-serve, run as cody on port 11439: it started on cuda with 12.7 GiB free, answered HTTP 200 with a 2-question choice, and warm requests took 19–44 ms (Ollaya on the CPU takes about 93 ms). It used 2.0 GiB VRAM and 3.0 GB RSS.
  • flake.lock: only the new laya input. systems_8 and systems_9 swapped numbering; no revision changed.

Notes

  • The router config uses laya:en (Ollaya's name). laya-serve answers to laya/english, so the router should switch to laya.
  • Not deployed. Switching THEBATTLESHIP stops ollaya.service and starts laya-serve. Its first start downloads about 800 MB of weights.
  • Rollback: sudo nixos-rebuild switch --rollback.

fts-forge Bot added 2 commits November 1, 2026 23:28
…M allows

Replaces the Ollaya aspect with fleet.ai/laya: upstream laya-serve
(NandhaKishorM/laya v0.4.21, its own NixOS module) on the same
127.0.0.1:11435 /v1/systemone, so the Paperclip router keeps working.

- laya-serve loads laya-train fine-tunes directly (settings.ai.laya.extraModels);
  Ollaya only runs ONNX graphs.
- A start wrapper reads free VRAM: >= 4 GiB starts on cuda, else cpu. A
  2-minute timer restarts it onto the other device when that changes
  (below 1 GiB free on the GPU -> CPU).
- fp32 on both devices, so a move never shifts the probabilities thresholds
  are fitted on. Weights pinned to laya's reviewed revision.
- 10 minutes idle unloads the checkpoint.

Smoke test (scratch instance, port 11439): started on cuda, HTTP 200,
warm 19-44 ms (Ollaya on the CPU: ~93 ms), 2.0 GiB VRAM, 3.0 GB RSS.
…cuda

On CUDA, ModernBERT's Triton kernels build a C helper on first use. The
service had no HOME (cache in read-only /.triton), no cc and no libcuda
path, so every request was HTTP 500. The cache goes in the private /tmp:
systemd mounts the DynamicUser state dir noexec, so a helper built there
fails to load ("failed to map segment").
@fts-forge

fts-forge Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Deployed to THEBATTLESHIP (generation 1078) and fixed what the first switch exposed:

  • HTTP 500 on every request at first. On CUDA, ModernBERT's Triton kernels compile a C helper on first use. The sandboxed service had no writable cache, no cc and no libcuda path. Then the helper built but wouldn't load, because systemd mounts the DynamicUser state dir noexec. Fix: TRITON_CACHE_DIR=/tmp/triton (the private /tmp allows exec), stdenv.cc on the path, and TRITON_LIBCUDA_PATH.
  • Live now: started on cuda (12.3 GiB free). HTTP 200, warm requests 11–13 ms, 2.0 GiB VRAM, 1.2 GB unit memory. laya:en is accepted too, so the STA-631 router works unchanged. laya-serve-rebalance runs cleanly, and systemctl --failed is empty.
  • CPU fallback: the same package with LAYA_DEVICE=cpu gives HTTP 200 at about 250 ms warm, with the same choices and probabilities as the GPU (max difference 0 at the returned precision).

@fts-forge
fts-forge Bot merged commit 9c5c267 into main Nov 2, 2026
4 checks passed
@fts-forge
fts-forge Bot deleted the feat/sta-630-laya-serve-gpu branch November 2, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants