Amari v0.9.10
Multi-GPU Mathematical Computing Platform with Intelligent Load Balancing
A comprehensive mathematical computing library featuring geometric algebra, relativistic physics, tropical algebra, automatic differentiation, and information geometry. The library provides complete multi-GPU infrastructure with intelligent workload distribution, advanced profiling systems, and optimization algorithms across all mathematical domains.
Features
Core Mathematical Systems
- Geometric Algebra (Clifford Algebra): Multivectors, rotors, and geometric products for 3D rotations and spatial transformations
- Relativistic Physics: Complete spacetime algebra (Cl(1,3)) with Minkowski signature for relativistic calculations
- Tropical Algebra: Max-plus semiring operations for optimization and neural network applications
- Automatic Differentiation: Forward-mode AD with dual numbers for exact derivatives
- Fusion Systems: Tropical-dual-Clifford fusion combining three algebraic systems
- Information Geometry: Statistical manifolds, KL/JS divergences, and Fisher information
- Optimization: Gradient-based optimization with geometric constraints
- Network Analysis: Geometric network analysis and graph neural networks
- Cellular Automata: Geometric automata with configurable rules
- Enumerative Geometry: Algebraic curves and enumerative computations
Multi-GPU Infrastructure
- Multi-GPU Architecture: Infrastructure supporting up to 8 GPUs with intelligent workload distribution
- Advanced Load Balancing: Five strategies including Balanced, CapabilityAware, MemoryAware, LatencyOptimized, and Adaptive
- Performance Profiling: Timeline analysis with microsecond precision and automatic bottleneck detection
- Comprehensive Benchmarking: Production-ready validation across all mathematical domains
- Scaling Efficiency: Realistic performance modeling with 90%/80%/70% efficiency for 2/4/8 GPUs
- Graceful Degradation: Automatic fallback to single GPU or CPU when multi-GPU unavailable
High-Precision Arithmetic
- Spacecraft Orbital Mechanics: High-precision arithmetic for critical trajectory calculations with configurable tolerance
- Geodesic Integration: Velocity Verlet method for curved spacetime particle trajectories
- Schwarzschild Metric: Spherically symmetric gravitational fields for astrophysics applications
- Phantom Types: Compile-time verification of relativistic invariants and spacetime signatures
Platform Support
- Native Rust: High-performance execution with rug (GMP/MPFR) backend for high-precision arithmetic
- WebAssembly: Full-featured WASM bindings with dashu backend for browser compatibility
- Universal Precision: Consistent API and mathematical accuracy across all platforms
- GPU Acceleration: WebGPU support for large-scale parallel computations
- TypeScript Support: Complete TypeScript definitions included
- Deployment Freedom: Pure Rust WASM builds deploy anywhere without system dependencies
- Cross-Platform: Linux, macOS, Windows, browsers, Node.js, and edge computing environments
Installation
Rust Crates
Add to your Cargo.toml:
[]
# Core geometric algebra and mathematical foundations
= "0.9.10"
# High-precision relativistic physics with multi-backend support
= { = "0.9.10", = ["high-precision"] }
# For native applications (uses rug/GMP backend)
= { = "0.9.10", = ["native-precision"] }
# For WebAssembly targets (uses dashu backend)
= { = "0.9.10", = ["wasm-precision"] }
# Multi-GPU acceleration and intelligent load balancing
= "0.9.10"
# Optimization algorithms
= "0.9.10"
# Additional mathematical systems
= "0.9.10"
= "0.9.10"
= "0.9.10"
= "0.9.10"
= "0.9.10"
= "0.9.10"
= "0.9.10"
JavaScript/TypeScript (WebAssembly)
Or with yarn:
Quick Start
Rust: Spacecraft Orbital Mechanics
use *;
Rust: Multi-GPU Load Balancing
use ;
async
Rust: Geometric Algebra
use ;
// 3D Euclidean Clifford algebra
type Cl3 = ;
// Create basis vectors
let e1: Cl3 = e1;
let e2: Cl3 = e2;
// Geometric product: e1 * e2 = e1 ∧ e2 (bivector)
let e12 = e1.geometric_product;
// Create rotor for 90° rotation in xy-plane
let rotor = from_bivector;
// Apply rotation: e1 → e2
let rotated = rotor.apply;
Rust: Tropical-Dual-Clifford System
use TropicalDualClifford;
use DualNumber;
use TropicalNumber;
// Create from logits (common in ML applications)
let logits = vec!;
let tdc = from_logits;
// Evaluate using all three algebras simultaneously
let other = from_logits;
let evaluation = tdc.evaluate;
// Extract features from each algebra
let tropical_features = tdc.extract_tropical_features; // Fast path-finding
let dual_features = tdc.extract_dual_features; // Automatic gradients
let clifford_geom = tdc.clifford; // Geometric relationships
// Perform sensitivity analysis
let sensitivity = tdc.sensitivity_analysis;
let most_sensitive = sensitivity.most_sensitive;
println!;
println!;
JavaScript/TypeScript: Mathematical Computing
import init, { WasmMultivector, WasmTropicalNumber, WasmDualNumber } from '@justinelliottcobb/amari-wasm';
async function main() {
// Initialize the WASM module
await init();
// Geometric Algebra: Create and rotate vectors
const e1 = WasmMultivector.basisVector(0);
const e2 = WasmMultivector.basisVector(1);
const bivector = e1.geometricProduct(e2);
console.log('Geometric product:', bivector.toString());
// Tropical Algebra: Neural network operations
const trop1 = new WasmTropicalNumber(3.0);
const trop2 = new WasmTropicalNumber(5.0);
const sum = trop1.tropicalAdd(trop2); // max(3, 5) = 5
const product = trop1.tropicalMul(trop2); // 3 + 5 = 8
console.log('Tropical operations:', sum.getValue(), product.getValue());
// Automatic Differentiation: Compute derivatives
const x = new WasmDualNumber(2.0, 1.0);
const xSquared = x.mul(x); // f(x) = x², f'(x) = 2x
console.log('f(2) =', xSquared.getReal(), "f'(2) =", xSquared.getDual());
// Clean up WASM memory
e1.free(); e2.free(); bivector.free();
trop1.free(); trop2.free(); sum.free(); product.free();
x.free(); xSquared.free();
}
main();
Architecture
Crates
amari-core: Core Clifford algebra types and CPU implementationsamari-tropical: Tropical (max-plus) algebra for neural networksamari-dual: Dual numbers for automatic differentiationamari-fusion: Unified Tropical-Dual-Clifford systemamari-info-geom: Information geometry and statistical manifoldsamari-wasm: WASM bindings for TypeScript/JavaScriptamari-gpu: Multi-GPU acceleration with intelligent load balancingamari-automata: Cellular automata with geometric algebraamari-network: Graph neural networks and network analysisamari-relativistic: Spacetime algebra and relativistic physicsamari-enumerative: Enumerative geometry and algebraic curvesamari-optimization: Gradient-based optimization algorithms
Key Types
// Multivector in Clifford algebra Cl(P,Q,R)
// Tropical-Dual-Clifford unified system
// Dual numbers for automatic differentiation
// Tropical numbers for max-plus algebra
// Common algebras
type Cl3 = ; // 3D Euclidean
type Spacetime = ; // Minkowski spacetime
Multi-Backend Precision Architecture
Automatic Backend Selection
Amari provides intelligent backend selection for high-precision arithmetic:
// Same API, different backends automatically selected:
// For native builds (optimal performance)
cargo build --features native-precision // Uses rug (GMP/MPFR)
// For WASM builds (maximum compatibility)
cargo build --target wasm32-unknown-unknown --features wasm-precision // Uses dashu
// Auto-selection (recommended)
cargo build --features high-precision // Chooses best backend for target
Backend Characteristics
| Backend | Platform | Performance | Dependencies | Use Case |
|---|---|---|---|---|
| rug | Native | Ultimate | GMP/MPFR (C libraries) | High-performance computing, research |
| dashu | WASM | Excellent | Pure Rust | Web apps, edge computing, universality |
Mathematical Consistency
Both backends provide:
- Identical API: Same function signatures across platforms
- Numerical Accuracy: Configurable precision with orbital-grade tolerance
- Mathematical Correctness: All relativistic calculations preserve physical invariants
- Feature Parity: Full support for spacecraft orbital mechanics in both environments
WebAssembly Deployment Example
// Compile for WASM with high-precision arithmetic
use StandardFloat; // Uses dashu backend
// Native compilation automatically uses rug
use StandardFloat; // Uses rug backend
// Same code works everywhere!
let spacecraft_trajectory = propagate_orbital_mechanics?;
Mathematical Foundation
Tropical-Dual-Clifford System
The fusion of three algebraic systems:
Tropical Algebra (Max-Plus)
a ⊕ b = max(a, b) // Tropical addition
a ⊙ b = a + b // Tropical multiplication
- Applications: Path optimization, sequence decoding, dynamic programming
- Benefits: Converts exponential operations to linear max operations
Dual Numbers
a + εb where ε² = 0
(a + εb) + (c + εd) = (a + c) + ε(b + d)
(a + εb) × (c + εd) = ac + ε(ad + bc)
- Applications: Automatic differentiation, gradient computation
- Benefits: Exact derivatives without finite differences or computational graphs
Clifford Algebra
ab = a·b + a∧b // Geometric product
- Applications: Rotations, reflections, geometric transformations
- Benefits: Unified treatment of scalars, vectors, bivectors, trivectors
Unified TDC Operations
The fusion system enables simultaneous computation across all three algebras:
- Tropical Phase: Fast approximation using max-plus operations
- Dual Phase: Exact computation with automatic gradients
- Clifford Phase: Geometric refinement and spatial reasoning
Clifford Algebra Cl(P,Q,R)
- P: Basis vectors with e²ᵢ = +1
- Q: Basis vectors with e²ᵢ = -1
- R: Basis vectors with e²ᵢ = 0
Information Geometry
- Fisher Information Metric: Riemannian metric on statistical manifolds
- α-Connections: Generalized connections parameterized by α ∈ [-1,1]
- Dually Flat Manifolds: Manifolds with e-connection (α=+1) and m-connection (α=-1)
- Bregman Divergences: Information-geometric divergences
- Amari-Chentsov Tensor: Fundamental tensor structure
Use Cases
Scientific Computing
- Computer Graphics: 3D rotations and transformations using rotors
- Physics Simulations: Geometric algebra for electromagnetic fields
- Relativistic Physics: Spacetime calculations and orbital mechanics
- Astrophysics: Schwarzschild metric and geodesic integration
Machine Learning
- Neural Networks: Tropical algebra for efficient network operations
- Automatic Differentiation: Forward-mode AD with dual numbers
- Statistical Manifolds: Information geometry and natural gradients
- Geometric Deep Learning: Operations on non-Euclidean data
Optimization
- Path Optimization: Tropical algebra for shortest path problems
- Gradient-Based Optimization: Hybrid tropical-dual-Clifford optimization
- Sequence Analysis: Efficient decoding using tropical Viterbi
- Mathematical Optimization: Multi-algebraic system integration
Research Applications
- Information Geometry: Statistical manifold computations
- Quantum Computing: Clifford group operations
- Crystallography: Symmetry group calculations
- Tropical Geometry: Max-plus linear algebra and optimization
- Computational Algebra: Multi-algebraic system integration
- Neural Architecture Search: Gradient-based optimization with geometric constraints
Examples
Tropical Sequence Decoding
use ViterbiDecoder;
// Efficient Viterbi algorithm using tropical algebra
let transitions = create_transition_matrix;
let emissions = create_emission_matrix;
let observations = vec!;
let decoder = new;
let best_path = decoder.decode;
Automatic Differentiation
use ;
// Forward-mode autodiff
let inputs: = vec!;
let output = softmax;
// output[i].real contains the value
// output[i].dual contains the gradient
Information Geometry
use ;
// Bregman divergence with quadratic potential
let phi = ;
let divergence = bregman_divergence?;
Optimization
use ;
// Optimization using all three algebras
let initial_params = vec!;
let tdc = from_logits;
let optimizer = new
.with_tropical_warmup // Fast tropical approximation
.with_dual_refinement // Exact dual gradients
.with_clifford_projection; // Geometric constraints
let result = optimizer.optimize?;
Building
Prerequisites
- Rust 1.75+ with
cargo - Node.js 16+ (for TypeScript bindings)
wasm-pack(installed automatically by build script)
Build All Tests
Documentation
API documentation will be available at target/doc/amari_core/index.html
Performance
The library is optimized for high-performance applications:
- SIMD: Vectorized operations where supported
- Cache Alignment: 64-byte aligned data structures
- Const Generics: Zero-cost abstractions for dimensions
- GPU Fallback: Automatic CPU/GPU dispatch based on workload size
- Batch Operations: Efficient batch processing for large datasets
Integration Status
Amari provides three deployment targets with varying levels of integration across crates:
| Target | Description | Coverage |
|---|---|---|
| Rust | Native library | All crates fully integrated |
| WASM | Web browsers/Node.js | Complete coverage for all domain crates |
| GPU | Hardware acceleration | Core + network + info-geom + relativistic modules |
For detailed architecture documentation, see docs/architecture/v0.9.6-multi-gpu-design.md.
Documentation
Comprehensive documentation is available in the docs/ directory:
- Release Process: Current release procedures
- Multi-GPU Design: Multi-GPU architecture details
- Publishing Guide: Publishing to npm and crates.io
- Technical Documentation: Mathematical rigor, phantom types, formal verification
See docs/README.md for the complete documentation index.
Contributing
Contributions are welcome. For development setup:
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Acknowledgments
- Inspired by the geometric algebra community and research in Information Geometry
- Built with modern Rust performance idioms and WebAssembly best practices
- Named after Shun-ichi Amari's contributions to Information Geometry
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: API Docs
"Geometry is the art of correct reasoning from incorrectly drawn figures." - Henri Poincaré