Skip to main content

Module gpu

Module gpu 

Source
Expand description

GPU-accelerated matching via wgpu. GPU-accelerated batch inference for the MoE classifier via wgpu compute shaders.

Processes N feature vectors in a single GPU dispatch, achieving ~10-100x throughput over CPU for large batches. Falls back to CPU when no GPU is available or for batches smaller than the crossover threshold.

Architecture mirrors ml_scorer.rs exactly:

  • Gate: Linear(41→6) + softmax
  • 6 experts: Linear(41→32)+ReLU → Linear(32→16)+ReLU → Linear(16→1)
  • Output: sigmoid(weighted sum of expert logits)

§Feature-gating in the lean build

Every entry point that would touch wgpu / vyre-driver-wgpu directly is wrapped in #[cfg(feature = "gpu")]. With the gpu feature off (the cargo install keyhog --no-default-features --features ci path), the GPU drivers aren’t linked at all, the probe functions report “no GPU available” without ever calling into wgpu, and the self-test functions return a “not available in this build” Err instead of panicking. The CPU MoE path in ml_scorer.rs is the entire scoring story under that profile.

Structs§

GpuSelfTest
Result from an explicit GPU adapter and dispatch self-test.
VyreAcKernelSelfTest
Status report from the AC-kernel GPU self-test. Returned by vyre_ac_kernel_self_test so the diagnostic CLI can display the active backend and match count rather than just PASS/FAIL.
VyreGpuSelfTest
Result from an explicit vyre GPU scanner self-test.

Functions§

batch_ml_inference
Score multiple (credential, context) pairs in a single batch.
env_no_gpu
env_require_gpu
True when KEYHOG_REQUIRE_GPU=1 is set: the operator demands a usable GPU and a silent CPU fallback is forbidden. Read uncached so embedders / tests that toggle the var between scans see the change (it is process- global at runtime, so this is only a few extra syscalls on the cold path).
gpu_available
Check if GPU acceleration is available. Return true when GPU scoring support is available in this build/runtime.
gpu_probe
Probe GPU availability and adapter metadata without panicking.
gpu_self_test
Force a GPU compute dispatch and validate the returned scores.
is_ci_environment
True when we are running inside a CI system. Used by the GPU init paths to auto-skip the wgpu adapter probe (which always fails on hosted CI runners and costs ~250ms of pointless cold- start time + emits a confusing warning).
require_gpu_preflight
Require-GPU preflight, independent of backend routing.
vyre_ac_kernel_self_test
vyre_gpu_self_test