docs/delivery-gap-audit.md: host test counts, Python audit, Codex-direct and deployment gaps with file:line, recommended tasks with acceptance criteria. docs/rust-runtime-run.md: leleka-seal-exec + leleka-inference (--backend-mode original) behind leleka-daemon, what was executed without a model or GPU context. desktop-core/examples/daemon.original.json and deploy/rust-runtime/*: configuration and user-unit templates (systemd-analyze --user verify only; not run with the model). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1152 lines
63 KiB
Markdown
1152 lines
63 KiB
Markdown
# Deployment
|
||
|
||
Linux CI builds a statically linked musl CLI/control-plane preview and publishes it as a prerelease artifact on version tags. This is not yet a complete GPU runtime: the C++/CUDA engine is not linked into that executable. The host must have a compatible NVIDIA driver already installed (CUDA 13.0 GA baseline: 580.65.06 or newer). The `strata-next doctor` command checks the installed version. Model weights belong on an external volume. A complete GPU deployment image has not been built yet.
|
||
|
||
For a local static CLI image smoke test, build `deploy/Dockerfile.static-cli` with a Linux/musl target. The final image is `scratch` plus the CLI binary. It is a packaging test, not the deployment image for inference.
|
||
|
||
The Rust engine pair (`leleka-inference` behind `leleka-daemon`) is a separate runtime from `strata-next` plus the C++ engine described below: its run recipe, example configuration and systemd templates are in [`docs/rust-runtime-run.md`](../docs/rust-runtime-run.md) and [`deploy/rust-runtime/`](rust-runtime/), and the open delivery items are in [`docs/delivery-gap-audit.md`](../docs/delivery-gap-audit.md). It needs CUDA 12 `libcublas.so.12` (not the `.so.13` named below) and a driver of 595 or newer.
|
||
|
||
## Worker recovery
|
||
|
||
Configure top-level JSON `max_in_flight_requests` or environment
|
||
`STRATA_MAX_IN_FLIGHT_REQUESTS` to bound admitted HTTP inference requests
|
||
(1–256; default 17). Environment overrides the file. At capacity, new Responses
|
||
POSTs receive 429 `runtime_overloaded` and `Retry-After: 1` before parsing;
|
||
drain still returns 503. This covers queued requests and streaming bodies,
|
||
not GPU concurrency. `/admin/lifecycle` exposes the limit and available request
|
||
slots; `check-config` validates and reports the limit. See
|
||
[admission lifecycle](../docs/api-contract.md#admission-lifecycle) for scope.
|
||
|
||
The Rust supervisor defaults to three lifetime restarts after a post-READY
|
||
worker failure, with 2/4/8-second backoff. Configure `engine.max_restarts` or
|
||
`STRATA_MAX_WORKER_RESTARTS` from 0 to 3; zero disables recovery. Failed and
|
||
queued generations are not replayed. Readiness stays false until the new
|
||
worker handshake completes. A startup failure or an exhausted budget leaves
|
||
the service unhealthy for inference until an operator restarts it; `/health`
|
||
remains available. See [the API contract](../docs/api-contract.md).
|
||
|
||
Top-level `queue_timeout_s` (or `STRATA_QUEUE_TIMEOUT_S`, 1–86400 seconds) optionally
|
||
bounds waiting for a worker to claim an inference command. It is disabled by
|
||
default; environment overrides the config file. The clock starts after request
|
||
validation, prompt rendering and tokenization, and includes command-channel
|
||
admission and waiting behind active work. `check-config` reports seconds or null.
|
||
Responses, Chat and Messages use the same queue. An expired unclaimed request
|
||
returns HTTP 504 with a JSON error before any SSE headers; Responses/Chat use
|
||
`queue_timeout`, while Messages retains its own error envelope.
|
||
|
||
Worker claim and expiry have one atomic winner. Expired commands are skipped
|
||
without sending `GEN`; there is no retry or replay. Once claimed, only the
|
||
existing active-generation deadline applies, so a long prefill is not cut short
|
||
by the queue setting. A canceled queued command retains its generation activity
|
||
guard until the worker dequeues it or the queue closes, allowing drain to account
|
||
for outstanding cleanup. Queue time does not include upload or tokenization and
|
||
is not a total request deadline. Default behavior is unchanged. Tests cover an
|
||
isolated CPU worker and exact output A, not real-model performance.
|
||
|
||
An optional `engine.generation_timeout_s` (or `STRATA_GENERATION_TIMEOUT_S`)
|
||
sets an absolute active-command deadline, 1–86400 seconds. It is **disabled
|
||
when omitted**. Select a budget that accommodates the model's longest prefill
|
||
and output. The clock starts when the worker takes the command; HTTP parsing,
|
||
tokenization and queue wait are excluded. Engine stdin writes, reading tokens
|
||
and waiting on the streaming channel are included. Native `check-config`
|
||
reports this value, or null when disabled/unconfigured.
|
||
|
||
On expiry the supervisor revokes readiness and kills/reaps that worker rather
|
||
than attempting to reuse its unfinished protocol stream. The failed command
|
||
and queued work are never replayed. The existing finite restart budget applies;
|
||
model loading and caches must be rebuilt after restart. With zero restarts the
|
||
worker remains failed. Connected clients receive the terminal failure described
|
||
in [the API contract](../docs/api-contract.md#active-generation-deadline).
|
||
|
||
## Native Linux service lifecycle
|
||
|
||
For an authenticated deployment, initialize its credential using the executable:
|
||
|
||
```sh
|
||
mkdir -m 700 /absolute/private/config
|
||
/absolute/path/strata-next api-key init --file /absolute/private/config/api.key
|
||
```
|
||
|
||
Set `api_key_file` in the serving config (or `STRATA_API_KEY_FILE`) to this path;
|
||
pass it to `wait-ready --key-file` and configure the client to use its contents.
|
||
`api-key init` uses the Linux OS random source and atomically publishes a 0600
|
||
file in an existing owned private directory. It returns only `created`/`reused`.
|
||
Repeated or concurrent initialization preserves the existing valid private key.
|
||
Invalid, permissive, symlink or nonregular targets are refused without replacement
|
||
or permission changes. This command does not rotate credentials or alter a running
|
||
service; retain the key outside Git and container images.
|
||
|
||
The native executable can install and operate its per-user service directly:
|
||
|
||
```sh
|
||
/absolute/path/strata-next service-install \
|
||
--config /absolute/path/config.json --working-dir /absolute/path/workdir \
|
||
--unit strata-next-prod.service --start
|
||
/absolute/path/strata-next service-control status \
|
||
--config /absolute/path/config.json --working-dir /absolute/path/workdir \
|
||
--unit strata-next-prod.service
|
||
```
|
||
|
||
`service-control` accepts `status`, `start`, `stop`, `restart`, `enable`, `disable`,
|
||
`start-ready`, `restart-ready`, `drain-stop` or `resume`. Supply the same
|
||
executable, config, working directory, optional `--env-file` and unit name used
|
||
at installation. The CLI verifies the existing private unit's exact generated
|
||
content and the user manager's fragment path/no drop-ins before operating on it.
|
||
A stale manager definition (`NeedDaemonReload`) is refused until explicitly reconciled.
|
||
Missing or conflicting units are refused. `status` only queries the manager;
|
||
control never installs or replaces a unit. Activation actions reload user-manager
|
||
unit definitions; status/start/stop/restart do not. Start/stop are
|
||
idempotent manager requests; restart explicitly stops and starts the service.
|
||
The JSON result includes `manager.active_state`, `manager.sub_state`,
|
||
`manager.main_pid`, `manager.unit_file_state` and `model_readiness: "not_checked"`. Use native `wait-ready`
|
||
for actual model readiness. No journal or environment contents are returned.
|
||
|
||
For a managed start that also verifies model readiness, use:
|
||
|
||
```sh
|
||
/absolute/path/strata-next service-control start-ready \
|
||
--config /absolute/path/config.json --working-dir /absolute/path/workdir \
|
||
--unit strata-next-prod.service \
|
||
--ready-url http://127.0.0.1:18082 --ready-model MODEL_ID \
|
||
--ready-key-file /absolute/path/api.key --ready-timeout-s 120
|
||
```
|
||
|
||
`restart-ready` explicitly restarts first; `start-ready` reuses an already running
|
||
service. Both require a literal loopback HTTP origin and model ID. The key file is
|
||
optional for an unauthenticated profile. Options and private key validity are
|
||
checked before any manager command. After the manager action, the bounded HTTP
|
||
wait checks service/model/worker readiness and `server_pid` against the managed
|
||
MainPID. Before returning `model_readiness: "ready"`, it rechecks the exact unit,
|
||
loaded definition, active state and unchanged MainPID. `/status` and `/ready`
|
||
include `server_pid`; standalone `wait-ready` still accepts endpoints without it.
|
||
|
||
This process correlation requires the same local PID namespace. A PID is neither
|
||
authentication nor a durable process epoch, and readiness is a point-in-time
|
||
observation. The readiness timeout (1–3600 seconds, default 300) starts after the
|
||
manager action; manager query/action limits still apply separately. On a wait or
|
||
identity failure, the CLI returns an error and leaves the service for explicit
|
||
reconciliation. It does not repeat the action, stop an unrelated endpoint or
|
||
perform automatic rollback. Hosted checks use an isolated synthetic worker,
|
||
including cold/repeated start, restart, exact output A, mismatched PID and timeout.
|
||
|
||
To stop after current work finishes, use `service-control drain-stop` with the
|
||
same unit identity and `--ready-*` arguments. It validates the managed process,
|
||
closes new inference admission, and waits for its admitted HTTP requests and
|
||
queued/active worker jobs to finish. Only a same-process `drained: true` snapshot
|
||
with zero activity, followed by fresh unit/manager checks, permits one systemd
|
||
stop request. Plain `stop` and `restart` retain their existing bounded shutdown
|
||
behavior; draining is explicit.
|
||
|
||
If the admission deadline expires or the HTTP outcome is unknown, no manager
|
||
stop is requested. The runtime may remain draining. Inspect its state, then use
|
||
`service-control resume` with the same arguments to reopen that process without
|
||
restarting it, or explicitly retry `drain-stop` to wait longer. These commands
|
||
never automatically replay an HTTP mutation or force stop after drain failure.
|
||
The HTTP budget includes the initial identity read, single mutation and polls;
|
||
manager timeouts are separate. Serialize administrative operations: an external
|
||
operator can change admission or systemd state after the final observation.
|
||
|
||
`/admin/lifecycle`, `/admin/drain` and `/admin/resume` return service/model/PID
|
||
identity. Drain and resume accept optional `x-strata-expected-pid`; an invalid or
|
||
duplicate header returns 400 and a different PID returns 409 before changing
|
||
admission. Native managed controls send this precondition. Existing authenticated
|
||
HTTP clients without it remain compatible. As with readiness, PID correlation
|
||
requires the same local namespace and does not replace authentication or an epoch.
|
||
|
||
### Switch between installed native profiles
|
||
|
||
`service-switch` composes target preparation, graceful drain and verified startup
|
||
with rollback when target startup fails. Both profiles must already be installed
|
||
using this exact executable and `service-install`; the previous service must be
|
||
running and ready, and the target inactive. Use distinct units and immutable,
|
||
versioned config/model paths. This initial path supports native Strata service
|
||
profiles without environment-file overlays, sharing one literal loopback origin.
|
||
It does not import the qwen-codex-ctl catalog or add other inference backends.
|
||
|
||
Save a private (mode 600), owned catalog, for example:
|
||
|
||
```json
|
||
{
|
||
"schema_version": 1,
|
||
"provision_timeout_s": 3600,
|
||
"profiles": {
|
||
"alpha": {
|
||
"unit": "strata-next-alpha.service",
|
||
"config": "/home/operator/strata/alpha/config.json",
|
||
"working_dir": "/home/operator/strata/alpha",
|
||
"url": "http://127.0.0.1:18082",
|
||
"model": "alpha",
|
||
"key_file": "/home/operator/strata/api.key",
|
||
"timeout_s": 300
|
||
},
|
||
"beta": {
|
||
"unit": "strata-next-beta.service",
|
||
"config": "/home/operator/strata/beta/config.json",
|
||
"working_dir": "/home/operator/strata/beta",
|
||
"url": "http://127.0.0.1:18082",
|
||
"model": "beta",
|
||
"key_file": "/home/operator/strata/api.key",
|
||
"timeout_s": 300
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
```sh
|
||
strata-next service-switch --catalog /home/operator/strata/catalog.json \
|
||
--from alpha --to beta --state-dir /home/operator/strata/switch-state
|
||
```
|
||
|
||
The catalog is bounded to 64 KiB/16 profiles; readiness budgets are 1–3600 seconds
|
||
and the preparation budget is 1–86400 seconds. Target preparation invokes this
|
||
same executable's `provision --config`, with inherited `STRATA_*` overrides
|
||
removed, before draining the previous service. Service-manager environment
|
||
should likewise contain no conflicting overrides. Config digests are checked
|
||
around preparation and before startup. Successful preparation is not proof of
|
||
GPU/model readiness; startup still has to pass the managed readiness check.
|
||
|
||
The state directory is created privately (parent must exist), with an OS lock
|
||
and durable `transaction.json` phase record. Use one state directory for all
|
||
switches of this deployment and serialize external administrative changes. A
|
||
preparation failure preserves the running profile. A failed target startup is
|
||
followed by verified target stop and previous-profile startup/readiness; this
|
||
returns a nonzero exit with `rolled_back` and retains the result in the journal.
|
||
If target stop or previous restoration cannot be confirmed, the command stops
|
||
with reconciliation required. No unknown lifecycle action is silently replayed.
|
||
|
||
An unfinished/unknown journal prevents another switch. After interruption,
|
||
inspect both units with `service-control status` and their native lifecycle
|
||
endpoints. Explicitly keep the selected service, or stop the target and restore
|
||
the previous one using the existing native controls; resume admission if needed.
|
||
For known interrupted phases, use the SHA-bound `service-switch reconcile` command
|
||
below to verify and record that state before a new explicit selection. Unknown
|
||
or corrupt records remain blocked for manual investigation.
|
||
This version does not automatically recover across command/process crashes.
|
||
PID checks require the same namespace; all artifact paths must remain immutable
|
||
through the transaction. Tests qualify actual isolated Linux services with CPU
|
||
fixtures, not live GPU rollback or full model/backend catalog parity.
|
||
|
||
To opt in to startup in future user-manager sessions, add `--enable` to
|
||
`service-install`. It is independent of `--start`: enabling alone does not start
|
||
or restart the runtime. For an installed unit use `service-control enable` or
|
||
`service-control disable` with the same identity arguments as `status` above.
|
||
These actions use `systemctl --user enable/disable` with its normal user-manager
|
||
configuration reload, without `--now` or `--force`. Reload is needed to reconcile
|
||
activation state; it does not restart the process. The exact loaded unit identity
|
||
is checked again after activation. Repeated enable/disable is supported.
|
||
The default-target activation directory must be owned and not group/other
|
||
writable, and any existing activation link must point to this exact unit.
|
||
Conflicts are refused for explicit reconciliation. No activation option is
|
||
enabled by default, and disabling does not delete the unit or model artifacts.
|
||
|
||
Enabling a user service means startup when that user's systemd manager starts,
|
||
usually at login. Startup without login requires host-admin configured lingering
|
||
or an equivalent manager lifecycle. The CLI never invokes `loginctl`, changes
|
||
lingering, installs a system-wide unit or requests privileges. An enabled unit
|
||
does not establish model readiness; use `wait-ready` after startup. Hosted tests
|
||
verify actual isolated manager activation links and PID preservation, not a
|
||
physical reboot or clean-node GPU inference.
|
||
|
||
Each manager query is limited to 30 seconds/16 KiB, and lifecycle actions to
|
||
60 seconds (the generated unit has a 45-second stop deadline). If a client times
|
||
out, its process is killed/reaped; the manager job may still be pending. Inspect
|
||
status before retrying. A moved executable or changed unit/config identity
|
||
requires explicit reconciliation; control does not guess which service to use.
|
||
|
||
For manual installation or unit inspection, `strata-next service-unit` renders a **systemd user unit** to stdout. It does
|
||
not install, start, enable or replace a service. Provision the native executable,
|
||
engine, tokenizer and private JSON configuration first; all supplied paths must
|
||
be absolute and exist. Systemd disallows quotes and backslashes in the executable
|
||
path; the renderer rejects these with a relocation instruction. For example,
|
||
on the Linux host:
|
||
|
||
```sh
|
||
umask 077
|
||
mkdir -p "$HOME/.config/systemd/user"
|
||
/absolute/path/strata-next service-unit \
|
||
--config /absolute/path/config.json \
|
||
--working-dir /absolute/path/engine-workdir \
|
||
--env-file /absolute/path/runtime.env > "$HOME/strata-next.service"
|
||
systemd-analyze --user verify "$HOME/strata-next.service"
|
||
# Review the generated unit before installing. Do not overwrite a live unit.
|
||
systemctl --user link "$HOME/strata-next.service"
|
||
systemctl --user start strata-next.service
|
||
systemctl --user status strata-next.service
|
||
journalctl --user -u strata-next.service -n 100
|
||
```
|
||
|
||
Omit `--env-file` if unnecessary. The file uses systemd EnvironmentFile syntax,
|
||
not shell commands; it can set `LD_LIBRARY_PATH` and engine tuning variables.
|
||
Its path cannot contain glob characters (`*`, `?`, `[`), backslashes or trailing
|
||
whitespace, because systemd interprets that directive as a filename pattern.
|
||
`serve --config FILE` selects the explicit config even if `STRATA_CONFIG` is
|
||
also set; other documented environment overrides still apply. Keep the API
|
||
bound to loopback and use SSH forwarding; optional bearer authentication does
|
||
not provide transport encryption. Set `STRATA_API_KEY_FILE` to a private key
|
||
file to enable the [native auth gate](../docs/api-contract.md#optional-bearer-authentication).
|
||
|
||
Systemd process startup is not model readiness: check the configured `/ready`
|
||
endpoint before connecting the console harness. `Restart=no` preserves the
|
||
supervisor's finite worker restart policy. SIGTERM goes to the supervisor;
|
||
remaining processes in its cgroup are killed after the 45-second stop deadline.
|
||
No model or logs are copied into a release by rendering the unit. Journald
|
||
retention is managed by the host; model and capture paths should remain private.
|
||
|
||
To stop and remove an explicitly installed service:
|
||
|
||
```sh
|
||
systemctl --user stop strata-next.service
|
||
systemctl --user disable strata-next.service
|
||
systemctl --user daemon-reload
|
||
```
|
||
|
||
Without the explicit `--enable`/`enable` option, the service is not enabled at
|
||
login/boot by these instructions. A running user
|
||
manager is required. The existing trial endpoint remains externally launched;
|
||
these instructions do not migrate it. Use the existing `connect strata-native`
|
||
command once a provisioned service is ready.
|
||
|
||
### Console controller
|
||
|
||
Install the opt-in controller commands on the laptop after the native Responses
|
||
launcher integration (the installer preserves the selected connection):
|
||
|
||
```sh
|
||
python3 scripts/install-qwen-native.py
|
||
python3 scripts/install-qwen-native-service.py
|
||
qwen-codex-ctl native-service status --host rnr5090 --unit strata-next.service
|
||
qwen-codex-ctl native-service start --host rnr5090 --unit strata-next.service
|
||
qwen-codex-ctl native-service logs --host rnr5090 --unit strata-next.service
|
||
qwen-codex-ctl native-service stop --host rnr5090 --unit strata-next.service
|
||
```
|
||
|
||
These operate on an **already provisioned** systemd user unit through SSH;
|
||
they never install, enable, migrate or switch a model. The host defaults to the
|
||
launcher's configured SSH alias, and the unit to `strata-next.service`. Optional
|
||
unit names must follow `strata-next-NAME.service`. Start/stop are idempotent;
|
||
SSH calls time out after 90 seconds. Logs show the selected unit's last 100
|
||
entries. No service credentials are copied or stored by this helper.
|
||
|
||
The JSON status describes the **process**; `model_readiness: not_checked` is
|
||
explicit. Model initialization can continue after process startup. The separate
|
||
`qwen-codex-ctl connect strata-native --url http://127.0.0.1:18084 --no-auth`
|
||
|
||
### Select an existing native deployment in the launcher menu
|
||
|
||
After native Responses integration, run `python3 scripts/install-qwen-native-menu.py`
|
||
on the client to install or upgrade the native picker. This preserves the selected
|
||
connection and backs up the launcher. To make `qwen-codex-ctl start strata-native`
|
||
attach to a specific ready deployment, create a private `native-picker.json` in
|
||
the launcher profile directory (normally `~/.codex-qwen-interactive`, or the
|
||
explicit `QWEN_CODEX_PROFILE` directory):
|
||
|
||
```json
|
||
{
|
||
"schema_version": 1,
|
||
"mode": "attach",
|
||
"url": "http://127.0.0.1:18084",
|
||
"model": "my-native-model",
|
||
"key_file": "/absolute/private/path/api.key"
|
||
}
|
||
```
|
||
|
||
Set permissions to `0600`; the file must be owned by the current user and cannot
|
||
be a symlink. `key_file` may be `null` for a deliberately unauthenticated loopback
|
||
endpoint. The endpoint/tunnel must already exist. Attachment checks readiness,
|
||
the exact model ID, and the supported one-slot 256K layout before updating the
|
||
connection. It does not start or switch remote services, create tunnels, or change
|
||
the model's compression mode. Errors fail without invoking the legacy controller.
|
||
If the file is absent, the prior managed native menu behavior remains in effect.
|
||
checks inference readiness through the existing SSH tunnel before switching
|
||
the console connection. Tunnel setup remains separate. The existing plain
|
||
`start/stop` commands retain their previous behavior; use `native-service`
|
||
explicitly for a managed native unit. The currently running external trial
|
||
has no such unit, so these commands safely report it as not provisioned.
|
||
|
||
### Native API commands in the console controller
|
||
|
||
Install the API helper after the native launcher integration:
|
||
|
||
```sh
|
||
python3 scripts/install-qwen-native-api.py
|
||
qwen-codex-ctl native-api status
|
||
qwen-codex-ctl native-api wait-ready --wait 60
|
||
qwen-codex-ctl native-api metrics
|
||
qwen-codex-ctl native-api lifecycle
|
||
qwen-codex-ctl native-api drain --wait 60
|
||
# Explicitly reopen admission when maintenance is abandoned or complete:
|
||
qwen-codex-ctl native-api resume
|
||
```
|
||
|
||
These use the selected `strata-native` connection and its private key file.
|
||
An explicit URL requires an explicit authentication choice and does not change
|
||
the selected connection:
|
||
|
||
```sh
|
||
qwen-codex-ctl native-api status --url http://127.0.0.1:18084 --no-auth
|
||
qwen-codex-ctl native-api metrics --url http://127.0.0.1:18084 --key-file /private/path/api.key
|
||
```
|
||
|
||
The helper verifies native `/status` identity before any admission mutation.
|
||
It uses direct loopback HTTP, ignoring proxy environment variables, refuses
|
||
redirects, and bounds each JSON response to 64 KiB. Socket operations time out
|
||
after eight seconds; this is not a hard total deadline for a server that keeps
|
||
sending partial bytes. Credentials are never command-line token arguments.
|
||
|
||
`drain --wait SECONDS` polls lifecycle for up to the requested interval (0–3600
|
||
seconds, subject to in-flight HTTP I/O). Without a positive wait it returns the
|
||
initial snapshot. Timeout, interruption or a concurrent resume produces an
|
||
error; the client never automatically stops or resumes the runtime. Inspect
|
||
lifecycle after any uncertain mutation result. Serialize operator actions.
|
||
No service, SSH tunnel or model is created or switched by these commands.
|
||
|
||
`wait-ready --wait SECONDS` waits for native model readiness using read-only
|
||
`GET /status` calls, including when the process is still loading its model or
|
||
recovering its worker. It retries connection failures and polls every 250 ms.
|
||
The positive wait budget (up to 3600 seconds) starts before the first request;
|
||
each socket timeout is capped by the remaining budget and eight seconds.
|
||
As with the other commands, this is not a hard total deadline against a server
|
||
that keeps sending partial bytes. A response arriving after the budget does not
|
||
count as success. With no positive wait, it performs one check and fails if
|
||
the model is not ready.
|
||
|
||
Authentication/HTTP/JSON errors, wrong endpoint identity, inconsistent status,
|
||
and failed/stopping/unconfigured workers fail immediately. The command never
|
||
starts a service, sends inference, restarts a failed worker or changes the
|
||
selected connection. Ready means available at that instant; it does not mean
|
||
idle, model quality verified, or sustained stability.
|
||
|
||
The retained GPU trial supports `native-api status` and `native-api wait-ready`; metrics and admission
|
||
controls require the newer feature preview and return HTTP 404 on that older
|
||
trial. The helper does not upgrade a runtime automatically. Client Python is
|
||
part of the existing laptop harness; native production serving remains Rust.
|
||
|
||
Verification without GPU inference:
|
||
|
||
```sh
|
||
python3 scripts/smoke-service-unit.py /absolute/path/strata-next --lifecycle
|
||
```
|
||
|
||
This creates and removes an isolated CPU-only service on an unused loopback
|
||
port. It checks real systemd path parsing (spaces, quotes, backslashes, `$` and
|
||
`%`), config precedence, environment loading, health, false readiness without a
|
||
worker and process removal. Without `--lifecycle`, only unit syntax and rejected
|
||
path checks run, as wired into Linux CI. Hosted CI execution remains pending.
|
||
|
||
## Drain before maintenance
|
||
|
||
The feature preview exposes process-local admission controls (protected by the
|
||
configured API key, if enabled):
|
||
|
||
```sh
|
||
curl -fsS -X POST http://127.0.0.1:18082/admin/drain
|
||
curl -fsS http://127.0.0.1:18082/admin/lifecycle
|
||
# Wait for drained: true, then perform an intentional stop using your service manager.
|
||
# To abandon maintenance and accept new work again:
|
||
curl -fsS -X POST http://127.0.0.1:18082/admin/resume
|
||
```
|
||
|
||
Use the configured endpoint port and bearer header when enabled. These calls
|
||
only change admission; they do not stop, restart, migrate or switch the engine.
|
||
They are not installed on the preserved GPU user trial yet.
|
||
|
||
Drain is idempotent. It rejects new Responses admissions with HTTP 503
|
||
`runtime_draining` and makes `/ready` return 503 (`/status.ready` is false).
|
||
Previously admitted JSON/SSE requests, including requests waiting for the
|
||
command queue, continue normally. Health, metrics and admin endpoints remain
|
||
available. Resume is idempotent and restores admission, subject to ordinary
|
||
worker readiness.
|
||
|
||
`GET /admin/lifecycle` reports `draining`, `requests_in_flight`,
|
||
`generation_jobs`, `worker` and `drained`. Request tracking starts before body
|
||
parsing and lasts until the response body is consumed or dropped. Generation
|
||
tracking includes queue waits, queued commands, execution and worker protocol
|
||
cleanup. Client disconnect does not declare a generation drained while STOP
|
||
is still being processed. Frames and trailers pass through unchanged.
|
||
|
||
`drained: true` requires drain mode, zero tracked requests and commands, no
|
||
active generation, and a ready or unconfigured worker. Startup, restart,
|
||
stopping or failed worker states report false. A stalled client or worker can
|
||
hold drain indefinitely; the existing STOP timeout and finite restart policy
|
||
still apply. No deadline triggers a forced stop. Investigate a stuck drain or
|
||
explicitly choose to stop, accepting interruption, using the service manager.
|
||
|
||
Optional signal grace: set top-level `shutdown_grace_s` in the native JSON config
|
||
or `STRATA_SHUTDOWN_GRACE_S` in its environment (integer 0–20 seconds, default 0).
|
||
`strata-next check-config` reports the effective setting. A positive value lets
|
||
admitted requests finish after SIGTERM/SIGINT, until the grace expires. During
|
||
that interval lifecycle reports `shutting_down: true`, readiness is false, new
|
||
inference is rejected, and resume cannot reopen admission. Worker shutdown
|
||
starts when admitted HTTP/worker activity clears or the grace expires.
|
||
|
||
The rendered unit's 45-second stop budget still applies. Grace is only the
|
||
initial drain phase; worker and HTTP cleanup follow it. Use the explicit drain
|
||
procedure above for longer maintenance windows. Existing deployments keep
|
||
immediate interruption until this setting and a supporting binary are installed.
|
||
|
||
Serialize maintenance operations: another operator can resume admission after
|
||
a status snapshot. The state is not a deployment lock or evidence that a client
|
||
received/processed all bytes. It resets to accepting after a control-plane
|
||
restart. CPU protocol tests cover the controls; managed GPU maintenance and
|
||
long-running user workloads require separate qualification.
|
||
|
||
## Optional embedded engine preview
|
||
|
||
A private build can carry a pinned Linux engine executable inside `strata-next`:
|
||
|
||
```sh
|
||
export STRATA_EMBED_ENGINE_PATH=/absolute/path/to/verified/strata
|
||
export STRATA_EMBED_ENGINE_SHA256=THE_64_HEX_DIGIT_ENGINE_SHA256
|
||
export STRATA_EMBED_ENGINE_REVISION=THE_FULL_40_HEX_DIGIT_SOURCE_COMMIT
|
||
cargo build --manifest-path control-plane/Cargo.toml --locked --release \
|
||
--target x86_64-unknown-linux-musl
|
||
```
|
||
|
||
Use an actual engine digest and its declared source revision. The build requires
|
||
all three variables together, verifies the digest, limits the payload to 1 GiB with a 64 KiB copy/hash buffer
|
||
and checks an ELF64 little-endian executable header matching the target CPU.
|
||
This is not a complete ELF dependency audit or proof that the declared revision
|
||
produced that binary; retain the build/provenance record alongside the digest.
|
||
Normal builds without these variables remain control-plane-only builds. The
|
||
copy/hash stage uses a fixed buffer; Rust compilation/linking still process the
|
||
full payload and require memory and disk space proportional to its size.
|
||
|
||
`strata-next engine-info` reports payload identity without executing it.
|
||
`strata-next engine-help` materializes the embedded worker and runs its `--help`
|
||
with no GPU visible; this checks loading and help output, not model readiness.
|
||
`strata-next --engine-license` prints the imported Strata MIT license. The
|
||
upstream record in `docs/upstream.md` remains authoritative and unchanged.
|
||
Select the embedded worker explicitly in the usual configuration:
|
||
|
||
```json
|
||
{
|
||
"bind": "127.0.0.1:18082",
|
||
"model": "your-model-id",
|
||
"engine": {
|
||
"executable": "@embedded",
|
||
"args": ["--pack", "/absolute/path/to/pack"],
|
||
"tokenizer_dir": "/absolute/path/to/tokenizer"
|
||
}
|
||
}
|
||
```
|
||
|
||
Keep the actual engine arguments from the qualified model profile. An external
|
||
executable path continues to work even in a payload build. Missing payload or
|
||
unsupported platforms fail before the HTTP listener opens when `@embedded` is
|
||
selected. The Linux supervisor copies the embedded bytes into an anonymous
|
||
executable `memfd`, seals content and size changes, and retains its descriptor
|
||
through worker restarts. The descriptor is released after worker shutdown;
|
||
there is no persistent extraction directory. This consumes RAM proportional to
|
||
engine size in addition to the executable's mapped pages. `/proc` access and
|
||
an OS policy allowing executable memfds are required; the runtime does not
|
||
change kernel policy. See the [Linux memfd documentation](https://man7.org/linux/man-pages/man2/memfd_create.2.html)
|
||
and [executable memfd policy](https://docs.kernel.org/userspace-api/mfd_noexec.html).
|
||
|
||
**One packaged executable does not yet mean a fully static GPU runtime.** The
|
||
current qualified engine still needs host `libcudart.so.13`, `libcublas.so.13`,
|
||
C++/C runtime libraries and the NVIDIA driver. These are not embedded, and the
|
||
engine's existing library search paths remain unchanged. Model/tokenizer assets
|
||
also remain external. Do not deploy this preview to a clean host assuming a
|
||
driver alone suffices, or replace a running user trial to test packaging.
|
||
The synthetic CPU packaging check exercises supervisor behavior without GPU
|
||
qualification. A production single-file package still needs library/linking,
|
||
clean-node, real-model and license/distribution gates.
|
||
|
||
## Validate configuration before switching a service
|
||
|
||
```sh
|
||
strata-next check-config --config /absolute/path/to/native.json
|
||
```
|
||
|
||
This native command reads the same configuration, environment overrides, key file
|
||
and tokenizer assets as `serve`. It checks that an external engine resolves to
|
||
an accessible executable file (including `PATH` lookup), or that the selected
|
||
embedded engine is present in a Linux build. Bare executable names require `PATH`;
|
||
an explicit executable path avoids lookup ambiguity. Run it with the same user,
|
||
working directory and environment as the intended service.
|
||
|
||
The existing laptop controller can run this check over SSH after installing its
|
||
updated helper:
|
||
|
||
```sh
|
||
python3 scripts/install-qwen-native-service.py
|
||
qwen-codex-ctl native-service check-config --host rnr5090 \
|
||
--binary /absolute/path/to/candidate/strata-next \
|
||
--config /absolute/path/to/native.json \
|
||
--working-dir /absolute/path/to/engine-workdir
|
||
```
|
||
|
||
All three paths refer to the remote host. This uses the SSH login environment;
|
||
it does not source a systemd environment file, upload files, install a unit or
|
||
change the selected connection. The candidate must already support `check-config`.
|
||
The client filters the returned JSON and suppresses raw remote errors. SSH stdout
|
||
is capped at 64 KiB with a 30-second local deadline; on failure the local SSH
|
||
process is terminated, which is not a guarantee that a remote process has exited.
|
||
Only invoke an explicitly chosen, trusted candidate executable.
|
||
|
||
Success prints JSON with `configuration_valid`, `engine`, `tokenizer_validated`,
|
||
`authentication_enabled` and `inference_configured`. The last field means both
|
||
engine and tokenizer are configured. A control-plane-only config can also pass.
|
||
Keys, engine arguments and raw file contents are not printed; failures identify
|
||
the config/key, executable or tokenizer stage and return nonzero.
|
||
|
||
The check does not execute the worker, extract the embedded payload, bind the
|
||
configured port, contact a running server or inspect model weights. Files and
|
||
permissions may change after it runs. `readiness_checked` is always false:
|
||
shared libraries, driver compatibility, model loading, available ports and real
|
||
generation still require deployment qualification. An already occupied port is
|
||
allowed so the candidate can be checked while the current service keeps running.
|
||
|
||
## Linux engine with static CUDA toolkit libraries
|
||
|
||
`STRATA_CUDA_STATIC=ON` is an optional Linux/GNU C++ build profile. It selects
|
||
CMake's static CUDA runtime and cuBLAS targets and statically links the engine's
|
||
GNU C++ runtime. The default CUDA profile continues to use shared toolkit
|
||
libraries. HIP and non-Linux/GNU configurations reject this option.
|
||
|
||
On a Linux builder with the toolkit and CMake already installed:
|
||
|
||
```sh
|
||
export CUDACXX=/absolute/path/to/cuda/bin/nvcc
|
||
export CUDAToolkit_ROOT=/absolute/path/to/cuda
|
||
# Optional existing pinned llama.cpp checkout; otherwise CMake fetches its pinned source:
|
||
export STRATA_GGML_DIR=/absolute/path/to/llama.cpp
|
||
BUILD_JOBS=2 scripts/build-static-cuda.sh
|
||
```
|
||
|
||
The script builds only `strata`, using SM 120 and portable AVX2 GGML defaults;
|
||
`CUDA_ARCHITECTURES` and `STRATA_BUILD_DIR` can override the build target/path.
|
||
It audits ELF dependencies and runs only `--help` with no GPU visible. It does
|
||
not install anything, serve a model, change a service, or run a speed test.
|
||
CMake's imported targets provide the static dependency closure; see the
|
||
[FindCUDAToolkit reference](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html).
|
||
|
||
The measured CUDA 13.2 build has only `libm.so.6`, `libc.so.6` and the host loader
|
||
in DT_NEEDED, with no RPATH/RUNPATH. It is **593,942,184 bytes**. This host's GNU
|
||
build requires **glibc 2.43**; build against an older supported glibc baseline
|
||
before targeting older distributions. The audit reports this symbol-version
|
||
minimum. NVIDIA's installed driver remains required. ELF direct dependencies
|
||
do not establish whether runtime-selected CUDA paths use additional `dlopen`
|
||
components; real-model and clean-host qualification are still necessary.
|
||
|
||
This private candidate has not replaced the user's running engine. The bounded
|
||
large-payload path can now include it in one executable under the 1 GiB cap.
|
||
The combined static-CUDA preview is **611,277,088 bytes**. On Linux it passed
|
||
embedded identity verification and `engine-help` with `LD_LIBRARY_PATH` unset
|
||
and no GPU visible. The outer musl executable has no ELF interpreter or
|
||
DT_NEEDED entries; the embedded engine retains the glibc/driver requirements
|
||
above. The earlier 63 MB combined preview remains a separate fallback containing
|
||
the dynamic engine. See the [packaging report](../docs/experiments/2026-10-04-large-embedded-package.md).
|
||
No quality, numerical parity, speedup or production-ready claim follows from
|
||
linking successfully. Keep the default profile until the model gates pass.
|
||
|
||
The optional `static_cuda_package` workflow-dispatch job performs the build and
|
||
ELF audit on the private CUDA runner without inference. It publishes no package
|
||
and cleans its private build directory. The runner must have the required
|
||
compiler/toolkit in its environment; hosted execution has not yet occurred.
|
||
|
||
## Fetch pinned assets as part of native startup
|
||
|
||
`serve --config /absolute/runtime.json` can now acquire prebuilt model-pack and
|
||
Qwen tokenizer files before it opens its HTTP listener or starts the worker.
|
||
Declare an optional `assets` array alongside the existing engine configuration:
|
||
|
||
```json
|
||
{
|
||
"assets": [
|
||
{
|
||
"manifest": "/home/user/strata/pack-v1.manifest.json",
|
||
"directory": "/home/user/strata/assets/pack-v1"
|
||
},
|
||
{
|
||
"manifest": "/home/user/strata/tokenizer-v1.manifest.json",
|
||
"directory": "/home/user/strata/assets/tokenizer-v1"
|
||
}
|
||
],
|
||
"engine": {
|
||
"executable": "@embedded",
|
||
"args": ["--pack", "/home/user/strata/assets/pack-v1"],
|
||
"tokenizer_dir": "/home/user/strata/assets/tokenizer-v1"
|
||
}
|
||
}
|
||
```
|
||
|
||
Each local manifest uses the same schema as `model fetch`: `schema_version: 1`
|
||
and a nonempty `files` array with `name`, HTTPS `url`, positive `size` and
|
||
`sha256` for each file. Names are flat, unique filenames. Use manifests for
|
||
artifacts already prepared for the chosen worker; fetching GGUF shards alone
|
||
is not a Strata pack conversion. Models and private manifests stay outside Git.
|
||
The example requires a Linux executable built with an embedded engine.
|
||
|
||
To acquire/verify the assets separately without starting the service:
|
||
|
||
```sh
|
||
strata-next provision --config /absolute/runtime.json
|
||
```
|
||
|
||
Paths must be absolute, without `..`; bundle destinations cannot overlap.
|
||
All manifests are parsed before acquisition. Each bundle is downloaded into a
|
||
private sibling `.NAME.strata-stage`, verified in full, and then published by
|
||
a directory rename. Existing bundles are verified even when offline; a digest
|
||
mismatch fails without overwriting them. Use a new versioned destination for
|
||
upgrades, and retain the previous config/destination for rollback. No global
|
||
current-model pointer or running service is changed by provisioning.
|
||
|
||
A per-destination `.NAME.strata-lock` coordinates native preparers. A competing
|
||
preparer fails promptly; process death releases the OS lock. The small lock
|
||
file remains to avoid an inode race. Failed/interrupted stages remain for
|
||
resume; after stopping all preparers they may be removed to discard incomplete
|
||
downloads. Extra files from a different manifest fail verification. Atomicity
|
||
is per bundle: if a later bundle fails, earlier verified bundles remain, but
|
||
`serve` never launches the worker. Use user-owned local storage for locks and
|
||
staging. This is not a defense against another process with the same user's
|
||
write access altering files after verification.
|
||
|
||
`check-config` stays read-only and reports the bundle count and
|
||
`assets_verified: false`; it does not download or hash model files. It still
|
||
requires configured tokenizer assets to exist. Run `provision` first when
|
||
using that preflight on a fresh installation.
|
||
|
||
This implements acquisition of prepared assets, not automatic GGUF-to-pack
|
||
conversion or full KAR model preparation. The complete-package Linux/GPU
|
||
clean-node acceptance gate remains separate. The CPU smoke uses synthetic
|
||
pack bytes and tokenizer files; it proves publication and startup ordering,
|
||
not model inference or performance.
|
||
|
||
## Prepare a native serving pack from GGUF
|
||
|
||
The native CLI can now build a Qwen `qwen4exp` serving pack from locally present,
|
||
manifest-pinned GGUF shards:
|
||
|
||
```sh
|
||
strata-next model prepare-native-pack /absolute/shards.json \
|
||
--source-dir /absolute/models --output /absolute/packs/model-v1
|
||
```
|
||
|
||
The command verifies source sizes and SHA-256, split shard identity/counts,
|
||
unique tensors, expert router counts and gate/up/down geometry. It emits
|
||
`dense.bin`, `index.txt`, `native_experts.txt`, `conversions.json`,
|
||
`source.json` and `tokenizer/` through a private staging directory, then renames
|
||
the completed directory into place. Existing output is refused; retain the
|
||
old version and configuration for rollback. Failed ordinary preparation
|
||
removes its own stage; after a killed process an unused
|
||
`.NAME.native-pack-PID.tmp` may be removed before retrying. No existing pack is
|
||
replaced and no worker is started.
|
||
|
||
Use the result with the existing engine's `--native FIRST_SHARD.gguf` option
|
||
and `--pack` output directory, plus the pack's `tokenizer/` for native Responses.
|
||
The quantized expert weights, native dense projections and large PLE table
|
||
remain in the original GGUF shards: **retain those shards**. This command does
|
||
not create `experts.bin` unless `--experts-bin` is given, add KAR compression or
|
||
reduce the model's quantization.
|
||
Source shard filenames must form the engine's usual split-file family.
|
||
|
||
Preparation accepts matching float types, F16/BF16-to-F32 widening, and the
|
||
conversions the unmodified `tools/iq_pack.py` performs: F32-to-BF16 and
|
||
F32-to-F16 round to nearest even. A rounding that overflows to infinity is
|
||
refused (Python records an infinite error for BF16 and writes the infinity; the
|
||
stricter refusal is deliberate). `conversions.json` records every change with `method`, `exact`,
|
||
`max_abs_err` and `source_shards`; an inexact conversion (for example the
|
||
PLE `ple_conv1d` weights, F32 to F16) is accepted and recorded with
|
||
`exact: false`, as Python does. Optional switches mirror `iq_pack.py`:
|
||
|
||
- `--compat-bf16` rounds F16 tensors to BF16 (writes `compat-bf16.json`);
|
||
- `--experts-bin` additionally writes `experts.bin` and its
|
||
`experts.bin.src.json` source sidecar (the optional on-disk expert copy);
|
||
- `--base DIR` reuses another pack's index and dense file and appends only the
|
||
tensors the base lacks to `extra.bin`.
|
||
|
||
Unsupported architectures, missing expert roles, incompatible shapes,
|
||
quantized projections requiring conversion, and non-finite converted values
|
||
fail without publishing a pack. `conversions.json` records the changes
|
||
and source tensor hashes; `source.json` records the verified shard identities;
|
||
the receipt lists the optional files that are present.
|
||
|
||
`scripts/smoke-native-pack.py` compares dense bytes, index rows and the complete
|
||
v3/v4 expert table against the unmodified pinned `tools/iq_pack.py` oracle on
|
||
small single/split GGUF fixtures, including per-role shard offsets. Numerical
|
||
and byte tolerance is zero. `scripts/offline/diff_native_pack.py` extends this to
|
||
thousands of generated cases plus the full CLI with `--compat-bf16`, `--base` and
|
||
`--experts-bin` (see `docs/offline-port.md`). Python/numpy are test-only dependencies. This does
|
||
not establish full-model GPU readiness: real-model pack parity and clean-node
|
||
GPU startup still require their separate gates. Automatic fetch/prepare/start
|
||
orchestration remains a subsequent integration step.
|
||
|
||
## Fetch, prepare and serve a native GGUF model
|
||
|
||
An optional `native_model` section connects source acquisition and exact pack
|
||
preparation to `provision --config` and `serve --config`:
|
||
|
||
```json
|
||
{
|
||
"bind": "127.0.0.1:8081",
|
||
"model": "qwen-flash-native",
|
||
"gpu_requirement": "cuda-13.0-linux",
|
||
"engine_probe": true,
|
||
"native_model": {
|
||
"manifest": "/srv/strata/manifests/source-v1.json",
|
||
"source_dir": "/srv/strata/models/source-v1",
|
||
"output": "/srv/strata/models/pack-v1"
|
||
},
|
||
"engine": {
|
||
"executable": "@embedded",
|
||
"args": ["--max-context", "262144"]
|
||
}
|
||
}
|
||
```
|
||
|
||
Use a binary that actually embeds the Linux engine, or an explicit engine path.
|
||
The existing engine still needs a compatible GPU/driver and appropriate memory
|
||
settings. This configuration does not select new hardware or compression policy.
|
||
|
||
Startup obtains and verifies source shards, builds the exact native pack, then
|
||
adds `--pack OUTPUT --native FIRST_SHARD` and selects `OUTPUT/tokenizer` before
|
||
opening HTTP or launching the worker. Do not also supply those engine arguments
|
||
or a tokenizer override. `check-config` remains read-only and reports an absent
|
||
managed tokenizer as pending; it does not claim model integrity or readiness.
|
||
|
||
The pack now includes `receipt.json`, with source identities and SHA-256/size for
|
||
all generated files. Offline reuse verifies both source shards and the complete
|
||
pack, rejecting damaged files, symlinks and unexpected entries. The receipt is an
|
||
integrity record in user-owned storage, not a publisher signature or protection
|
||
against a local actor who can replace both receipt and files. Earlier packs
|
||
without a receipt must be regenerated into a new versioned directory.
|
||
|
||
Use distinct versioned source/output directories when changing models. A failed
|
||
new preparation leaves earlier versions intact; reverting to the earlier config
|
||
reuses that version after verification. This does not hot-switch an already
|
||
running service or automatically restart a previous service after a worker
|
||
startup failure. A per-output OS lock prevents concurrent managed preparation.
|
||
Source GGUF files remain required for native quantized weights and PLE lookup.
|
||
|
||
Asset bundles, native packs and extracted tokenizers use an atomic no-replace
|
||
directory rename on Linux and macOS. Any destination created during preparation,
|
||
including an empty directory, is preserved and causes publication to fail. A
|
||
filesystem without the exclusive rename primitive returns an error; there is no
|
||
fallback that can replace a destination. Existing resumable asset stages and
|
||
temporary pack cleanup retain their respective behavior.
|
||
|
||
MTP is a separate pack selected by the engine's `--mtp PATH` option. The native
|
||
preparer does not produce MTP, vision or calibration assets. Acquire any required
|
||
auxiliary pack with a separate pinned `assets` bundle and pass its explicit path;
|
||
keep its directory disjoint from managed sources/output. The baseline can run
|
||
without optional MTP. Full-model and clean-node GPU qualification remain open.
|
||
|
||
For the current specialised engine, add
|
||
`"runtime_profile": "qwen4exp-flash-next"` inside `native_model`. After source
|
||
SHA verification and shard discovery, `provision`/`serve` check the first GGUF
|
||
shard **before pack preparation or output mutation**, including offline reuse.
|
||
The profile requires `qwen4exp` metadata with 48 blocks, hidden width 2560,
|
||
24 attention heads and 2 KV heads. Expert counts must be positive 32-bit signed
|
||
values and selected experts cannot exceed total experts; pruned counts remain
|
||
allowed with or without MTP. The engine uses an independent canonical draft
|
||
geometry for MTP, so its 512 experts need not match a pruned target. Missing, mistyped or incompatible fields identify the failing key.
|
||
Unknown profile names fail config validation; `check-config` reports the selected
|
||
`native_runtime_profile` and `native_runtime_profile_checked: false` without
|
||
reading model files or downloading anything.
|
||
|
||
Omitting the profile preserves generic exact preparation. The profile checks
|
||
metadata compatibility only: tensor layout/values, checkpoint pairing, memory
|
||
fit and actual GPU/model/MTP qualification remain separate checks. It does not
|
||
change generated bytes or enable compression. Rejected versioned sources remain
|
||
available for diagnosis, and existing prepared versions remain unchanged.
|
||
|
||
For the current Qwen3.8 Flash Next **Q2 MTP runtime layout**, set `mtp_pack` to
|
||
exactly one directory listed in `assets`:
|
||
|
||
```json
|
||
{
|
||
"assets": [{"manifest": "/models/mtp-assets.json", "directory": "/models/mtp-v1"}],
|
||
"mtp_pack": "/models/mtp-v1"
|
||
}
|
||
```
|
||
|
||
Merge these fields into an engine configuration. The pinned bundle must contain
|
||
`dense.txt`, `dense.bin`, and `experts.bin`. Existing bundle SHA/size verification
|
||
runs first. Then a bounded native structural check runs before `native_model`
|
||
source acquisition or preparation, listener creation and worker startup. The
|
||
control plane appends `--mtp /models/mtp-v1`; remove any manual `--mtp` or
|
||
`--mtp=...` from engine arguments when using this option. Existing configurations
|
||
without `mtp_pack` retain their behavior.
|
||
|
||
The check validates an ASCII index of at most 64 KiB / 128 tensors, required
|
||
current-engine tensor names/dtypes and exact rows/columns, exact dtype byte counts,
|
||
256-byte alignment, non-overlapping in-file ranges and exact dense file extent.
|
||
The Q2 expert blob must have exactly 707788800 bytes (512 × 1382400). Files must
|
||
be readable regular files, not symlinks; read-only host volumes can use another
|
||
owner UID, as with existing pinned assets. Keep paths immutable during serving.
|
||
`check-config` reports `pinned_structural_check_pending` without fetching or
|
||
reading the pack; `provision` reports `mtp_pack_structurally_validated: true`
|
||
only after verification. Missing or malformed packs fail before fetching the
|
||
base model, preserving existing versioned directories.
|
||
|
||
Required tensor geometry is pinned to the current Flash Next MTP consumer
|
||
(2560 hidden width, four hyper-connection streams, 24 query heads of width 256,
|
||
two KV heads, 640 expert width). The optional three indexer tensors must also
|
||
match their pinned geometry when present. Dimensions are checked independently
|
||
of byte count: a rectangular matrix with swapped dimensions is rejected even
|
||
when its byte length and offsets remain consistent. Sparse CPU fixtures take
|
||
their shapes from the upstream checkpoint manifest and compare against this
|
||
preflight; a transposed Q projection is rejected before base acquisition.
|
||
|
||
This is a structural and MTP geometry check, **not proof of compatible base-model geometry, weight values,
|
||
source-model pairing, Gemma norm conversion, quality, VRAM capacity or GPU
|
||
readiness**. It neither converts a raw MTP GGUF nor quantizes new weights. The
|
||
existing offline `mtp_rt.py` conversion remains separate; its dense Q8 conversion
|
||
must not be described as lossless. MTP activation stays explicit and real-model
|
||
qualification is still required. CPU verification:
|
||
`python3 scripts/smoke-mtp-pack.py /path/to/strata-next` (synthetic sparse layout).
|
||
|
||
|
||
`scripts/smoke-native-bootstrap.py` verifies real HTTP acquisition, exact pack
|
||
preparation and offline reuse with a synthetic worker, including corruption,
|
||
locking, conflicting config and previous-version preservation. It is a CPU
|
||
startup-order test, not an inference or model-quality result.
|
||
|
||
### Explicit GPU profile requirement
|
||
|
||
Set top-level `"gpu_requirement": "cuda-13.0-linux"` on CUDA 13.0 Linux
|
||
profiles. `provision` and `serve` check the host before fetching assets,
|
||
preparing a model, materializing an embedded engine, starting a worker, or
|
||
opening the HTTP listener. Unsupported OS, missing/unreadable driver, and a
|
||
version below this profile's conservative **580.65.06** floor fail with an
|
||
actionable error. The floor follows the Linux CUDA 13.0 GA toolkit driver in
|
||
[NVIDIA's release table](https://docs.nvidia.com/cuda/archive/13.0.0/cuda-toolkit-release-notes/index.html).
|
||
This is an explicit deployment policy, not a universal CUDA compatibility limit.
|
||
|
||
The check reads the kernel driver version, falling back to `nvidia-smi` when
|
||
unavailable. That subprocess has a five-second timeout and 8 KiB output limit;
|
||
it is killed and reaped on failure. Versions are compared numerically. No CUDA
|
||
context or inference request is created. `check-config` only reports the
|
||
requirement with `gpu_requirement_checked: false`; it never runs this probe.
|
||
Omitting the requirement preserves CPU/manual worker behavior. A requirement
|
||
without a worker, or an unknown requirement, is rejected.
|
||
|
||
A successful check does **not** qualify GPU architecture, free VRAM, model
|
||
quality, engine shared-library dependencies, MTP support, or a clean-node
|
||
real-model launch. Those remain separate release gates. Keep model/auxiliary
|
||
bundles pinned and use distinct versioned output directories as described above.
|
||
|
||
### Optional declared VRAM budget
|
||
|
||
For a previously sized single-GPU profile, add top-level
|
||
`"cuda_memory": {"required_mib": 24000, "reserve_mib": 1024}` together with
|
||
`"gpu_requirement": "cuda-13.0-linux"`. These example numbers are placeholders;
|
||
use a budget qualified for the model, context, KV and optional MTP configuration.
|
||
The control plane queries GPU UUID, total/free MiB and MIG mode through a bounded
|
||
5-second, 8-KiB `nvidia-smi` call before model acquisition. It selects the eligible
|
||
GPU with the most free memory covering the declared budget plus reserve; UUID
|
||
breaks ties deterministically. MIG-enabled physical GPUs are excluded.
|
||
|
||
The worker receives only the selected full UUID in `CUDA_VISIBLE_DEVICES`; the
|
||
parent environment is unchanged. Existing visibility is respected: use an unset
|
||
variable or a comma-separated list of full GPU UUIDs; empty means no GPU.
|
||
Ordinal, abbreviated and MIG identifiers fail explicitly instead of being
|
||
reinterpreted. See NVIDIA's [UUID visibility contract](https://docs.nvidia.com/cuda/cuda-programming-guide/05-appendices/environment-variables.html)
|
||
and [inventory query documentation](https://docs.nvidia.com/deploy/nvidia-smi/index.html).
|
||
Inventory is limited to devices exposed by the host/container runtime.
|
||
|
||
The same selected GPU is checked again before each worker spawn (including
|
||
restarts). If capacity is lost or the device disappears, the worker fails before
|
||
spawn and readiness stays false. It does not silently migrate to another device.
|
||
`check-config` only validates and reports `cuda_memory_checked: false`.
|
||
Omitting this policy preserves the manual/CPU launch behavior.
|
||
|
||
This is point-in-time admission against a **declared** budget, not automatic model
|
||
memory sizing, an allocation reservation, CUDA kernel compatibility or an OOM
|
||
guarantee. Other processes can consume memory after the check. Query time is
|
||
bounded separately from the worker's READY timeout. No context, cache, sampling
|
||
or quantization setting is changed. Isolated CPU tests verify selection, child
|
||
environment, failed recheck, restart and timeout; actual GPU/model qualification
|
||
remains a separate gate.
|
||
|
||
### Early engine loader probe
|
||
|
||
Set top-level `"engine_probe": true` to run the selected engine's `--help`
|
||
before model/auxiliary downloads and preparation. It works with an explicit
|
||
external executable or `@embedded`. `provision` can perform this check without
|
||
starting a serving worker; `serve` performs it before opening its listener.
|
||
Missing executables, wrong executable format, a missing loader/eager shared
|
||
library, nonzero exit, or a ten-second timeout fail before acquisition. The
|
||
timeout kills and reaps the direct child. Existing profiles default to no probe.
|
||
|
||
The probe passes **only** `--help`, with `CUDA_VISIBLE_DEVICES` empty and stdin,
|
||
stdout and stderr discarded. Configured model arguments are not passed. It
|
||
executes an operator-trusted binary: only enable it for an engine whose help is
|
||
side-effect-free. The pinned Strata entry point exits from help before model or
|
||
CUDA initialization. This is not a sandbox for arbitrary executables.
|
||
|
||
`check-config` never executes help; it reports `engine_probe_configured` and
|
||
`engine_probe_checked: false`. A successful help exit checks only that loader
|
||
path, not lazy-loaded libraries, CUDA kernels, VRAM, MTP or real-model quality.
|
||
A loader failure reports the stage and exit status without echoing child output;
|
||
use the engine's explicit `--help` (`strata-next engine-help` for embedded payloads)
|
||
for detailed local loader diagnostics. Full clean-node inference remains a
|
||
separate qualification step.
|
||
|
||
### Assemble a complete private Linux package
|
||
|
||
On a Linux x86_64 build host with the CUDA toolkit, GNU toolchain, `musl-gcc`,
|
||
Python 3.11+, `readelf`, and the pinned Rust toolchain/target installed:
|
||
|
||
```sh
|
||
scripts/build-static-cuda.sh
|
||
engine="$PWD/artifacts/build-static-cuda/strata"
|
||
python3 scripts/build-linux-package.py \
|
||
--engine "$engine" --sha256 "$(sha256sum "$engine" | cut -d ' ' -f 1)" \
|
||
--revision "$(git rev-parse HEAD)" \
|
||
--build-features "$PWD/artifacts/build-static-cuda/BUILD-FEATURES.json" \
|
||
--cargo-target-dir "$PWD/artifacts/combined-build" \
|
||
--output "$PWD/artifacts/combined-v1"
|
||
```
|
||
|
||
Commit source changes before packaging. The revision must match the clean
|
||
checkout; the engine digest must match the exact frozen bytes embedded by the
|
||
existing Rust build. Use a dedicated Cargo directory without concurrent external
|
||
Cargo commands. The builder serializes its own calls and never replaces an
|
||
existing output directory. Failed assembly removes its private stage and leaves
|
||
older packages intact. Linux `renameat2(RENAME_NOREPLACE)` atomically publishes the
|
||
new directory; unsupported hosts fail instead of using an overwrite fallback.
|
||
|
||
The result contains the combined executable, `PROVENANCE.json`, and `SHA256SUMS`.
|
||
It verifies static outer ELF, embedded identity and bounded GPU-hidden engine
|
||
help before publication. The provenance records the inner engine's direct
|
||
shared-library and minimum glibc requirements. The engine source revision is
|
||
operator/CI-declared provenance, not a binary-to-source attestation, and this
|
||
pipeline does not promise bit-identical compiler output. Python is used only on
|
||
the build host; the resulting runtime does not require it.
|
||
|
||
The manual `static_cuda_package` workflow builds the engine then assembles and
|
||
uploads the combined preview to the **private repository**, with seven-day
|
||
artifact retention. It cleans owned build directories after the upload attempt; the final package
|
||
copy is removed only after a successful upload. A failed upload leaves that
|
||
private final package available for recovery.
|
||
The normal hosted job uses `--cpu-fixture` to exercise the same assembly path and
|
||
then tests exact serving output/restart against the external fixture. CPU
|
||
artifacts are explicitly marked and are not CUDA releases. No model weights,
|
||
requests or credentials enter either package.
|
||
|
||
A successful package build does not pass the clean-node real-model gate: the
|
||
inner engine still requires the recorded host glibc and NVIDIA driver, and lazy
|
||
CUDA dependencies, kernels, model/MTP compatibility and quality need separate
|
||
qualification. Existing active endpoints are not modified by this build tool.
|
||
|
||
## Combined runtime OCI preview (STRA-67)
|
||
|
||
Build a private image from a trusted STRA-65 combined package (exactly the
|
||
executable, `PROVENANCE.json`, and `SHA256SUMS`):
|
||
|
||
```sh
|
||
python3 scripts/build-runtime-image.py --package /private/package \
|
||
--receipt-sha256 <trusted-SHA256-of-SHA256SUMS> > /private/image.json
|
||
```
|
||
|
||
The builder freezes and verifies the three files before Docker receives a minimal
|
||
context. An official Ubuntu 26.04 **linux/amd64 manifest digest** is the default
|
||
base; its actual `getconf GNU_LIBC_VERSION` reports 2.43 in the isolated validation.
|
||
`--base repository@sha256:DIGEST` permits another explicitly pinned glibc image.
|
||
A base below the engine's recorded minimum glibc is rejected before image build.
|
||
Embedded identity and GPU-hidden `engine-help` are checked inside the resulting
|
||
non-root, read-only image. The image ID is returned only after these checks;
|
||
failed probes remove the uniquely labelled build image. No public registry push
|
||
occurs. Python and Docker are build tools, not serving dependencies.
|
||
|
||
Run the image ID with NVIDIA Container Toolkit and a compatible installed host
|
||
driver. The caller supplies private configuration, source/model data, and a
|
||
writable state directory owned by UID 65532. Example paths inside the configuration
|
||
must match these mount destinations:
|
||
|
||
```sh
|
||
docker run --rm --gpus all --read-only --cap-drop ALL \
|
||
--security-opt no-new-privileges --tmpfs /tmp:rw,nosuid,nodev,size=256m \
|
||
-e NVIDIA_VISIBLE_DEVICES=all -p 127.0.0.1:8081:8081 \
|
||
--mount type=bind,src=/private/config,dst=/config,readonly \
|
||
--mount type=bind,src=/private/models,dst=/models,readonly \
|
||
--mount type=bind,src=/private/state,dst=/state \
|
||
sha256:IMAGE_ID serve --config /config/runtime.json
|
||
```
|
||
|
||
The runtime uses its native `@embedded` engine and existing asset/native-model
|
||
configuration. Set the profile's explicit GPU requirement and `engine_probe`;
|
||
keep the key file private and readable by the container UID. Network access is
|
||
needed for configured acquisition; use verified offline assets to avoid it.
|
||
Do not mount the Docker socket or include models, keys, logs or configuration in
|
||
the build context. The default image exposes no GPU unless requested explicitly.
|
||
|
||
The hosted CPU path uses `--cpu-fixture` and verifies actual Responses output `A`,
|
||
worker crash/restart and graceful shutdown in the image, with zero tolerance.
|
||
The manual private CUDA job now saves the image and provenance alongside the
|
||
combined package. Neither CPU success nor hidden-GPU help qualifies CUDA kernels,
|
||
lazy driver dependencies, real model/MTP compatibility, quality or clean-node GPU
|
||
serving. That full gate remains pending; the active user trial is not migrated.
|
||
|
||
Switch preparation uses `provision --config FILE --defer-memory-check`: it verifies
|
||
assets and the declared driver requirement while the previous runtime occupies
|
||
VRAM. Its JSON explicitly reports `memory_admission: deferred_until_serve`.
|
||
This command never starts a worker. Ordinary `provision` and every `serve` still
|
||
perform the full declared memory admission; a target rejected at startup triggers
|
||
the switch rollback procedure.
|
||
|
||
### Select a native profile without knowing the current one
|
||
|
||
Omit `--from` to select the target from the same installed native catalog:
|
||
|
||
```sh
|
||
strata-next service-switch --catalog /home/operator/strata/catalog.json \
|
||
--to next --state-dir /home/operator/strata/switch-state
|
||
```
|
||
|
||
Under the shared transaction lock, the command checks every catalog unit. With
|
||
none running it prepares and starts the target; with the target already running
|
||
it verifies readiness and reuses the same process; with one other running it
|
||
uses the existing drain/switch/rollback path. Multiple active, failed,
|
||
transitional or unknown units cause an error before lifecycle changes. Every
|
||
catalog entry must be installed, have distinct unit/config paths and share the
|
||
same loopback origin. External service administration must remain serialized.
|
||
|
||
A failed cold start stops only the verified target and records `cold_failed`,
|
||
allowing a later explicit selection. An interrupted or unconfirmed operation
|
||
still requires reconciliation. This does not discover unmanaged runtimes or
|
||
import other inference backends.
|
||
|
||
### Install and wait for model readiness in one command
|
||
|
||
```sh
|
||
strata-next service-install --config /home/operator/strata/runtime.json \
|
||
--working-dir /home/operator/strata --unit strata-next-main.service \
|
||
--start-ready --ready-url http://127.0.0.1:8080 --ready-model MODEL_ID \
|
||
--ready-key-file /home/operator/strata/api.key --ready-timeout-s 600
|
||
```
|
||
|
||
`--start-ready` verifies credentials before publishing the unit, installs or
|
||
reuses the exact unit, and waits for authenticated model readiness tied to its
|
||
systemd PID. Repeating it reuses a running service without restarting it.
|
||
`--enable` remains independently opt-in. The existing `--start` checks only the
|
||
manager operation; it cannot be combined with `--start-ready`.
|
||
|
||
A readiness timeout or identity error returns failure and retains the unit and
|
||
service for explicit inspection through `service-control status`. It does not
|
||
silently stop, restart or replay the action. Readiness options require
|
||
`--start-ready`. Actual model loading still uses the configured serving pipeline;
|
||
this CLI option does not qualify a GPU/model combination by itself.
|
||
|
||
### Reconcile an interrupted profile selection
|
||
|
||
After inspecting `service-control status` for the catalog units, acknowledge the
|
||
exact private transaction record and verify the current state without replaying
|
||
any lifecycle command:
|
||
|
||
```sh
|
||
sha256sum /home/operator/strata/switch-state/transaction.json
|
||
strata-next service-switch reconcile --catalog /home/operator/strata/catalog.json \
|
||
--state-dir /home/operator/strata/switch-state --expected-journal-sha SHA256_FROM_ABOVE
|
||
```
|
||
|
||
Reconciliation requires the original catalog and recorded config digests, a
|
||
known interrupted phase, and either all units inactive or exactly one ready
|
||
native process. It rejects ambiguous, failed or transitional states. The result
|
||
records the prior journal digest/phase and current profile/PID; it does not
|
||
start, stop, drain, resume or prepare a model. A later explicit selection can
|
||
then proceed. Wrong acknowledgments or changed configurations leave the journal
|
||
unchanged. Keep external administration serialized with these operations.
|