Expand description
GPU acceleration for geometric algebra operations using WebGPU/wgpu
This crate provides GPU-accelerated implementations of core Amari operations using WebGPU/wgpu for cross-platform compatibility (native + WASM).
§Overview
The crate currently offers GPU acceleration for:
- Clifford Algebra: Batch geometric products with Cayley table upload
- GF(2) Algebra: Batch binary Clifford products, matrix-vector multiply, Hamming distance (with
gf2feature) - Information Geometry: Batch Amari-Chentsov tensor computation
- Holographic Memory: Batch bind, unbind, bundle, similarity (with
holographicfeature) - Measure Theory: GPU-accelerated Monte Carlo integration (with
measurefeature) - Relativistic Physics: Batch Lorentz transformations
- Topology: Distance matrices, Morse critical points, Rips filtrations (with
topologyfeature)
Some source modules are still undergoing redesign before full public exposure.
In particular, tropical exposes a narrow crate-root v1 surface, while fusion
has only a reduced first public surface intended for restoration so far.
§Quick Start
use amari_gpu::{GpuCliffordAlgebra, AdaptiveCompute};
// Create GPU context for Cl(3,0,0)
let gpu = GpuCliffordAlgebra::new::<3, 0, 0>().await?;
// Batch geometric product
let results = gpu.batch_geometric_product(&a_batch, &b_batch).await?;
// Or use adaptive dispatch (auto CPU/GPU)
let adaptive = AdaptiveCompute::new::<3, 0, 0>().await;
let results = adaptive.batch_geometric_product(&a_batch, &b_batch).await?;§Holographic Memory (with holographic feature)
GPU-accelerated batch operations for vector symbolic architectures:
use amari_gpu::GpuHolographic;
// Create GPU holographic processor
let gpu = GpuHolographic::new(256).await?; // 256-dimensional vectors
// Batch bind thousands of key-value pairs
let bound_flat = gpu.batch_bind(&keys_flat, &values_flat).await?;
// Batch similarity computation
let similarities = gpu.batch_similarity(&a_flat, &b_flat).await?;
// Batch bundle operation
let bundled_flat = gpu.batch_bundle(&a_flat, &b_flat).await?;§Information Geometry
use amari_gpu::GpuInfoGeometry;
let gpu = GpuInfoGeometry::new().await?;
// Batch Amari-Chentsov tensor computation
let tensors = gpu.amari_chentsov_tensor_batch(&x_batch, &y_batch, &z_batch).await?;
// Fisher information matrix
let fisher = gpu.fisher_information_matrix(¶ms).await?;§Adaptive CPU/GPU Dispatch
All GPU operations automatically fall back to CPU when:
- GPU is unavailable
- Batch size is too small to benefit from GPU parallelism
- Operating in CI/test environments
The threshold is typically ~100 operations for GPU to be beneficial.
§Feature Flags
| Feature | Description |
|---|---|
std | Standard library support |
holographic | GPU-accelerated holographic memory |
measure | GPU-accelerated Monte Carlo integration |
calculus | GPU-accelerated differential geometry |
dual | Narrow GPU-backed dual-number v1 surface; broader gradient/training scaffolding private |
probabilistic | GPU-accelerated probability sampling |
automata | GPU-backed automata rule/energy kernels with documented CPU neighborhood fallback |
enumerative | Broad GPU-backed enumerative kernels; high-use surface with representative baseline tests |
functional | Mixed GPU-backed functional analysis and documented CPU spectral/fallback paths |
topology | Mixed GPU-backed topology and documented CPU Rips/Betti fallback paths |
gf2 | GPU-accelerated GF(2) algebra (binary Clifford products, matrix ops, Hamming distance) |
fusion | Reduced first public surface restored; broader fusion GPU API still redesign-pending |
tropical | Narrow crate-root public v1 surface for tropical matrix multiply/adaptive dispatch |
webgpu | Enable WebGPU backend |
high-precision | Enable 128-bit float support |
§Tropical GPU v1 (with tropical feature)
A narrow public tropical GPU surface is available at the crate root:
use amari_gpu::{TropicalExecutionPath, TropicalGpuOps};
use amari_tropical::{TropicalMatrix, TropicalNumber};
let mut gpu = TropicalGpuOps::new().await?;
let mut a = TropicalMatrix::new(64, 64);
let mut b = TropicalMatrix::new(64, 64);
for i in 0..64 {
for j in 0..64 {
a.data[i][j] = TropicalNumber::new((i as f32 - j as f32) * 0.25);
b.data[i][j] = TropicalNumber::new((i as f32 + j as f32) * 0.125);
}
}
match gpu.matrix_multiply_execution_path(a.rows, a.cols, b.cols) {
TropicalExecutionPath::Cpu => println!("CPU path"),
TropicalExecutionPath::Gpu => println!("GPU path"),
}
let gpu_result = gpu.matrix_multiply(&a, &b).await?;
let adaptive_result = gpu.matrix_multiply_adaptive(&a, &b).await?;
let attention_scores = gpu.attention_scores(&a).await?;This is intentionally narrower than a full amari_gpu::tropical module. It currently
includes dense tropical matrix multiply and winner-takes-all attention scores. Broader
tropical GPU APIs remain redesign-pending.
§Performance
GPU acceleration provides significant speedups for batch operations:
| Operation | Batch Size | Speedup |
|---|---|---|
| Geometric Product | 1000 | ~10-50x |
| Holographic Bind | 10000 | ~20-100x |
| Similarity Batch | 10000 | ~50-200x |
| Monte Carlo | 100000 | ~100-500x |
| Distance Matrix | 1000 pts | ~50x |
| Morse Critical Points | 100x100 | ~100x |
Actual speedups depend on GPU hardware and driver support.
Re-exports§
pub use adaptive::AdaptiveVerificationError;pub use adaptive::AdaptiveVerificationLevel;pub use adaptive::AdaptiveVerifier;pub use adaptive::CpuFeatures;pub use adaptive::GpuBackend;pub use adaptive::PlatformCapabilities;pub use adaptive::PlatformPerformanceProfile;pub use adaptive::VerificationPlatform;pub use adaptive::WasmEnvironment;pub use benchmarks::AmariMultiGpuBenchmarks;pub use benchmarks::BenchmarkConfig;pub use benchmarks::BenchmarkResult;pub use benchmarks::BenchmarkRunner;pub use benchmarks::BenchmarkSuiteResults;pub use benchmarks::BenchmarkSummary;pub use benchmarks::ScalingAnalysis;pub use multi_gpu::ComputeIntensity;pub use multi_gpu::DeviceCapabilities;pub use multi_gpu::DeviceId;pub use multi_gpu::DeviceWorkload;pub use multi_gpu::GpuArchitecture;pub use multi_gpu::GpuDevice;pub use multi_gpu::IntelligentLoadBalancer;pub use multi_gpu::LoadBalancingStrategy;pub use multi_gpu::MultiGpuBarrier;pub use multi_gpu::PerformanceRecord;pub use multi_gpu::PerformanceStats;pub use multi_gpu::SynchronizationManager;pub use multi_gpu::Workload;pub use multi_gpu::WorkloadCoordinator;pub use network::AdaptiveNetworkCompute;pub use network::GpuGeometricNetwork;pub use network::GpuNetworkError;pub use network::GpuNetworkResult;pub use performance::AdaptiveDispatchPolicy;pub use performance::CalibrationResult;pub use performance::GpuProfile;pub use performance::GpuProfiler;pub use performance::WorkgroupConfig;pub use performance::WorkgroupOptimizer;pub use relativistic::GpuRelativisticParticle;pub use relativistic::GpuRelativisticPhysics;pub use relativistic::GpuSpacetimeVector;pub use relativistic::GpuTrajectoryParams;pub use shaders::ShaderLibrary;pub use shaders::DUAL_SHADERS;pub use shaders::FUSION_SHADERS;pub use shaders::TOPOLOGY_SHADERS;pub use shaders::TROPICAL_SHADERS;pub use timeline::BottleneckAnalysis;pub use timeline::DeviceUtilizationStats;pub use timeline::GpuTimelineAnalyzer;pub use timeline::MultiGpuPerformanceMonitor;pub use timeline::OptimizationRecommendation;pub use timeline::PerformanceAnalysisReport;pub use timeline::PerformanceBottleneck;pub use timeline::PerformanceSummary;pub use timeline::RecommendationPriority;pub use timeline::SynchronizationAnalysis;pub use timeline::TimelineEvent;pub use timeline::UtilizationAnalysis;pub use unified::BufferPoolStats;pub use unified::EnhancedGpuBufferPool;pub use unified::GpuAccelerated;pub use unified::GpuContext;pub use unified::GpuDispatcher;pub use unified::GpuOperationParams;pub use unified::GpuParam;pub use unified::MultiGpuStats;pub use unified::PoolEntryStats;pub use unified::UnifiedGpuError;pub use unified::UnifiedGpuResult;pub use verification::GpuBoundaryVerifier;pub use verification::GpuVerificationError;pub use verification::RelativisticVerifier;pub use verification::StatisticalGpuVerifier;pub use verification::VerificationConfig;pub use verification::VerificationStrategy;pub use verification::VerifiedMultivector;
Modules§
- adaptive
- Adaptive Verification Framework for Cross-Platform GPU Operations
- benchmarks
- Comprehensive Benchmarking Suite for Multi-GPU Performance Validation
- multi_
gpu - Multi-GPU workload distribution and coordination infrastructure
- network
- GPU-accelerated geometric network analysis
- performance
- GPU performance optimization and profiling infrastructure
- relativistic
- GPU acceleration for relativistic physics computations
- shaders
- WebGPU compute shader library for mathematical operations
- timeline
- GPU Timeline Analysis and Performance Profiling Infrastructure
- unified
- Unified GPU acceleration infrastructure for all mathematical domains
- verification
- GPU Verification Framework for Phase 4B
Structs§
- Adaptive
Compute - Adaptive GPU/CPU dispatcher for the legacy Cl(3,0,0) flat-batch helper.
- GpuClifford
Algebra - GPU-accelerated Clifford algebra operations.
- GpuDevice
Info - GPU device information for edge computing
- GpuFisher
Matrix - Fisher Information Matrix returned by
GpuInfoGeometry. - GpuInfo
Geometry - Information-geometry operations with GPU-ready infrastructure.