Files
oqyude a182905829
nixos flake checks / invariant-checks (push) Successful in 1m21s
test-runner / smoke (push) Successful in 1s
engipy: дефолт bge-m3 в юните, флаг AB-моделей, настоящая проверка venv
После мержа feat/model-select-default (02ed6aa) юнит отдавал устаревший env:
ENGIPY_MODEL указывал на legacy-чекпойнт rubert-tiny2, которого в каталоге без
ENGIPY_ENABLE_AB_MODELS=1 нет — сервис падал на старте с ValueError. Вдобавок
ENGIPY_EMBEDDINGS_PATH указывал на 312-мерную матрицу при 1024-мерной модели.

- model = "BAAI/bge-m3" (каталожный id), embeddingsStem = "gesn_baai_bge_m3"
- новый option enableAbModels -> ENGIPY_ENABLE_AB_MODELS=1 (селектор в UI;
  e5-large остаётся available=false — чекпойнта нет)
- engipy-install проверяет сам venv, а не только маркер: python из pyvenv.cfg
  уехал в GC, после ребута 19.11 exec падал с 203/EXEC
2026-11-19 13:05:40 +03:00

189 lines
9.2 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Host: "rydiwo" (device: secondary)
#
# The host record lives in configurations/default.nix; this file is only the
# module body. `xlib` (identity, dirs, helpers) arrives as a module argument.
{
lib,
pkgs,
xlib,
inputs,
...
}:
{
imports = with inputs; [
nixos-hardware.nixosModules.chuwi-minibook-x
./hardware/mini-laptop.nix
self.nixosModules.default
../modules/pxe-infra
../modules/server/engipy-backend.nix
];
boot = {
# Measured 2026-11-12: with the nixpkgs revision the flake now points at,
# `linuxPackages_xanmod_stable` does not build at all —
# linux-config-7.3.3: applying tools-add-128-bit-integer-types-for-aarch64.patch
# patching file tools/include/linux/types.h
# Reversed (or previously applied) patch detected! Assume -R? [n]
# 1 out of 1 hunk ignored -- saving rejects to file tools/include/linux/types.h.rej
# error: builder failed with exit code 1
# — and the failure cascades the whole way up:
# linux-xanmod-7.3.3 -> linux-xanmod-7.3.3-modules -> initrd ->
# boot.json -> activate -> toplevel,
# so NO `nixos-rebuild` can succeed while this host is on xanmod. Mainline
# kernel instead, by the owner's decision (2026-11-12).
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
loader = {
systemd-boot.enable = lib.mkDefault true;
efi.canTouchEfiVariables = lib.mkDefault true;
};
};
fileSystems = xlib.helpers.mkNtfsMount {
path = xlib.dirs.lamet-drive;
uuid = "DC76BD3576BD116E";
mask = "0000";
};
host.ssh.enable = true;
hardware.intel-gpu-tools.enable = true;
# engipy webapp backend на rydiwo: uvicorn + FastAPI + ONNX-SBERT.
# Python-окружение через pip-venv на rydiwo (см. modules/server/engipy-backend.nix).
# Sapphira проксирует engipy.zeroq.su/api/* на 192.168.1.102:8000.
#
# model = путь к локальной ONNX-папке (экспорт `cointegrated/rubert-tiny2`
# сделан в WSL nixos и разложен на rydiwo). HF Hub id
# `cointegrated/rubert-tiny2` НЕ должен здесь стоять — это
# триггерит optimum через from_pretrained() скачивать с HF и
# конвертировать через torch, что падает в
# `RuntimeError: could not create a primitive` в GELU activation.
#
# T-MULTI-MODEL-REGISTRY (commit cd64a8e, 2026-10-18): 3 модели
# (rubert-tiny2 default + BAAI/bge-m3 + intfloat/multilingual-e5-large)
# лежат на /mnt/lamet/engipy-models/. `model` указывает на default
# (rubert-tiny2), `ENGIPY_MODELS_DIR` (`modelsDir`) — корень для всех
# трёх (см. modules/server/engipy-backend.nix). Старая папка
# /var/lib/engipy/model/cointegrated__rubert-tiny2/ больше не
# используется и может быть удалена вручную после успешного deploy.
host.engipy-backend = {
enable = true;
bindAddress = "0.0.0.0";
# 2026-11-19: прод-модель — `BAAI/bge-m3` (решение владельца, ветка
# feat/model-select-default, 02ed6aa). `model` — КАТАЛОЖНЫЙ id, а не путь:
# `app/services/models.py:build_default_registry` знает id каталога и сам
# выводит путь к чекпойнту как `<modelsDir>/bge-m3`. Прежнее значение
# (`/mnt/lamet/engipy-models/rubert-tiny2`) после мержа падало на старте:
# legacy-спека без флага AB в каталог не попадает.
model = "BAAI/bge-m3";
# Матрица дефолтной модели в dataDir (1024-dim, GPU fp32, batch sweep).
embeddingsStem = "gesn_baai_bge_m3";
# Селектор моделей во фронте: rubert-tiny2 и e5-large попадают в реестр
# только с ENGIPY_ENABLE_AB_MODELS=1. e5 останется `available = false` —
# чекпойнта нет, и это честный ответ, а не тихий матчинг по чужой матрице.
enableAbModels = true;
# `modelsDir` остаётся дефолтным (/mnt/lamet/engipy-models).
};
# Не засыпать при закрытии крышки: rydiwo используется как
# headless-сервер для engipy (sapphira проксирует /api/* на него).
# Если пользователь берёт ноутбук в руки — пусть остаётся правило
# по умолчанию (suspend); но для unattended-режима нужно ignore.
#
# 2026-11-01: `services.logind.lidSwitch` / `lidSwitchDocked` переименованы
# в nixpkgs (`services.logind.settings.Login.HandleLidSwitch{,Docked}`) —
# старое имя работает, но печатает предупреждение при каждой оценке.
# Значения те же, что и у systemd в logind.conf.
services.logind.settings.Login = {
HandleLidSwitch = "ignore";
HandleLidSwitchDocked = "ignore";
};
system.stateVersion = "26.05";
# Measured 2026-11-11: swap has to be declared here at all — the 6 GiB
# /swapfile existed and was active, but only because somebody ran `swapon`
# by hand: there was no swapDevices in the config and no swap line in the
# generated /etc/fstab, so a reboot lost swap. On this 11 GiB box (it runs
# qemu VMs) that turned a build into an OOM kill.
#
# 2026-11-12: size = 2048 REPLACES the 6144 value. The pending switch needs
# ~22 GiB unpacked on a 62 GiB root that already carries a 20 GiB store, so
# the swap file is 2 GiB — and that is the value it stays at, not a one-off
# shrink: `nixos-prebuild` is now capped at MemoryMax=6G (below), and
# 11 GiB of RAM plus 2 GiB of swap absorbs a build spike.
swapDevices = [
{
device = "/swapfile";
size = 2048;
}
];
# Measured 2026-11-11: nixos-prebuild.service (daily 04:00 nix build of the
# whole toplevel, Nice 10, CPUQuota 20% — defined in
# modules/essentials/systemd-routines.nix, shared by every host, so no cap
# there) had no memory bound and was what got killed when memory ran out.
# Host-scoped bound: 6 GiB of the 11 GiB box stays for engipy/the VMs.
systemd.services.nixos-prebuild.serviceConfig.MemoryMax = "6G";
# --------------------------------------------------------------------------
# PXE infrastructure rig (L2 of docs/ARCHITECTURE.md).
# The rig gives rydiwo an isolated Linux bridge
# (`pxe-infra.bridge.name`, default `pxe0`) plus a MAC-filtered
# dnsmasq DHCP server bound only to that bridge — the real LAN is
# not touched. The QEMU guest (L4) is configured but NOT
# autostarted: start it by hand with
# systemctl start pxe-infra-vm
# when a test session needs it, and stop it the same way. Set
# `vm.autostart = true` here to bring the VM up on every boot
# (e.g. for a long unattended test run). See `modules/options.nix`
# (options.pxe-infra.*) for the full option surface and
# `modules/pxe-infra/` for the implementation.
pxe-infra = {
enable = true;
bridge = {
address = "10.66.0.1";
prefixLength = 24;
};
# ipxe.efi (universal, ~600K) instead of snp.efi (SNP-only, 310K).
# snp.efi worked on linux-virt 6.18.56 but breaks on 6.18.57
# (delivered via aports 2b1f5137, 2026-10-16, kernel commit
# c967b365 — `PCI: Make pci_match_one_device() match on ID
# instead of device`). The new drivers/pci/search.c
# `match_pci_dev_by_id()` (uses pci_match_one_id()+pci_id_from_device())
# fails to match the virtio-blk PCI device that snp.efi
# presents through its SAN hook (the IDs reported by the SAN
# path are not full device IDs). The kernel boots, but rootfs
# fails to mount: `UUID=...: Can't lookup blockdev` →
# `Mounting root: failed.` The universal `ipxe.efi` presents
# the SAN device through a different code path that
# successfully matches against the new pci_match machinery.
# Verified end-to-end on rydiwo 2026-10-17 with explicit
# `bootMode=pxe`: two independent verdict=PASS reports
# (20261017T180654Z, 20261017T180730Z). See pxe-infra-automation
# T14 in .agent/tasks/manifest.json for full RCA. The ~290K
# extra TFTP volume vs snp.efi is negligible.
bootloader.ipxeBinary = "ipxe.efi";
vm = {
enable = true;
autostart = false; # start manually when testing
memory = "4G"; # iPXE needs 2G+ heap to sanboot a 2G raw image
# bootMode=pxe: the guest boots over the network (TFTP → iPXE →
# HTTP → kernel+initrd) instead of from the attached raw image.
# This is the production path for the READ-ONLY payload (T24):
# the initramfs carries the squashfs rootfs inside itself, so
# the guest needs no disk at all and the chain does not depend on
# iPXE's SAN-boot extensions (T14/R1). `direct` remains the
# legacy disk profile (the attached alpine-worker.raw).
bootMode = "pxe";
};
dhcp.guests = [
{
mac = "52:54:00:12:34:56";
ip = "10.66.0.10";
hostname = "pxe-vm-01"; # optional
}
];
};
# --------------------------------------------------------------------------
}