pub fn require_gpu_preflight() -> Result<(), String>Expand description
Require-GPU preflight, independent of backend routing.
When KEYHOG_REQUIRE_GPU=1 is NOT set this is a no-op and returns
Ok(()). When it IS set, the contract (docs/src/reference/env.md,
install.md, the require-gpu-fails-closed docker scenario) is to
“refuse to run when no usable GPU adapter is detected”. This check
fires on the no-GPU path the flag exists for - it does not depend on
select_backend having chosen GPU first (finding C0): the hard-fail
that used to live only inside the GPU-selected dispatch paths was
unreachable when there was no GPU, so a CPU scan completed and exited 0.
Returns Err(diagnostic) when a GPU is required but the host has no
non-software adapter, or the GPU self-test (adapter init + one real MoE
compute dispatch) fails. The caller (CLI run loop) maps that to the
documented exit code 2. Returning an Err here - rather than calling
std::process::exit from the library - keeps embedders alive (finding
M12).