Skip to main content

Module compute

Module compute 

Source
Expand description

Compute infrastructure integration (trueno 0.8.7+) Compute Infrastructure Integration (trueno 0.8.8+)

This module provides ML-specific wrappers around trueno’s compute primitives and simulation testing infrastructure.

§Features

  • Backend Selection: Automatic CPU/GPU dispatch based on data size
  • Jidoka Guards: NaN/Inf detection for training stability
  • Reproducibility: Deterministic RNG for reproducible experiments
  • Stress Testing: Performance validation infrastructure

§Toyota Way Principles

  • Jidoka: Built-in quality - stop on defect (NaN/Inf detection)
  • Poka-Yoke: Mistake-proofing via type-safe backend selection
  • Heijunka: Leveled testing across compute backends

§Example

use aprender::compute::{TrainingGuard, select_backend, BackendCategory};

// Auto-select backend based on data size (100k+ → GPU, 1k+ → SimdParallel)
let data_size = 50_000;
let gpu_available = false;
let backend = select_backend(data_size, gpu_available);
assert_eq!(backend, BackendCategory::SimdParallel);

// Create training guard for NaN/Inf detection
let guard = TrainingGuard::new("gradient_update");

// Check weights after update (detects NaN/Inf)
let weights = vec![1.0f32, 2.0, 3.0];
assert!(guard.check_weights(&weights).is_ok());

Structs§

BackendSelector
Poka-Yoke: Type-safe backend selection
BackendTolerance
Backend-specific tolerance configuration
DivergenceGuard
Guard for detecting cross-backend numerical divergence
ExperimentSeed
Seed management for reproducible ML experiments
JidokaGuard
Jidoka guard for simulation tests
Matrix
A 2D matrix with row-major storage
StressTestConfig
Stress test configuration for trueno operations
StressThresholds
Performance thresholds for stress testing
TrainingGuard
ML-specific training guard for numerical stability
Vector
High-performance vector with multi-backend support

Enums§

Backend
Backend execution target
BackendCategory
Backend category for selection result
JidokaAction
Jidoka action on condition trigger
JidokaCondition
Jidoka condition that triggers stop
JidokaError
Jidoka error types

Functions§

select_backend
Select optimal backend for ML operation based on data size
should_use_gpu
Check if GPU would be beneficial for this operation size
should_use_parallel
Check if parallel execution would be beneficial