trustformers_optim/lib.rs
1// Allow certain clippy warnings at crate level for numeric algorithms
2// These patterns are common and intentional in optimization code
3#![allow(
4 clippy::needless_range_loop,
5 clippy::manual_memcpy,
6 clippy::vec_init_then_push,
7 clippy::borrowed_box
8)]
9
10//! # TrustformeRS Optimization
11//!
12//! This crate provides state-of-the-art optimization algorithms for training transformer models,
13//! including distributed training support and memory-efficient techniques.
14//!
15//! ## Overview
16//!
17//! TrustformeRS Optim includes:
18//! - **Core Optimizers**: Adam, AdamW, SGD, LAMB, AdaFactor
19//! - **Cutting-Edge 2024-2025 Optimizers**: HN-Adam, AdEMAMix, Muon, CAME, MicroAdam for state-of-the-art performance
20//! - **Schedule-Free Optimizers**: Schedule-Free SGD and Adam (no LR scheduling needed)
21//! - **Advanced Quantization**: 4-bit optimizers with NF4 and block-wise quantization
22//! - **Memory-Efficient Optimization**: MicroAdam with compressed gradients and low space overhead
23//! - **Learning Rate Schedulers**: Linear, Cosine, Polynomial, Step, Exponential
24//! - **Distributed Training**: ZeRO optimization stages, multi-node support
25//! - **Memory Optimization**: Gradient accumulation, mixed precision, CPU offloading
26//!
27//! ## Optimizers
28//!
29//! ### Adam and AdamW
30//!
31//! Adaptive Moment Estimation with optional weight decay:
32//! ```rust,no_run
33//! use trustformers_optim::{AdamW, OptimizerState};
34//! use trustformers_core::traits::Optimizer;
35//!
36//! let mut optimizer = AdamW::new(
37//! 1e-3, // learning_rate
38//! (0.9, 0.999), // (beta1, beta2)
39//! 1e-8, // epsilon
40//! 0.01, // weight_decay
41//! );
42//!
43//! // Ready to use in training loop with .zero_grad(), .update(), and .step()
44//! ```
45//!
46//! ### SGD
47//!
48//! Stochastic Gradient Descent with momentum and Nesterov acceleration:
49//! ```rust,no_run
50//! use trustformers_optim::SGD;
51//!
52//! let optimizer = SGD::new(
53//! 0.1, // learning_rate
54//! 0.9, // momentum
55//! 1e-4, // weight_decay
56//! true, // nesterov
57//! );
58//! ```
59//!
60//! ### Schedule-Free Optimizers
61//!
62//! Revolutionary optimizers that eliminate the need for learning rate scheduling:
63//! ```rust,no_run
64//! use trustformers_optim::{ScheduleFreeAdam, ScheduleFreeSGD};
65//! use trustformers_core::traits::Optimizer;
66//!
67//! // Schedule-Free Adam - no learning rate scheduling needed!
68//! let optimizer = ScheduleFreeAdam::for_language_models();
69//!
70//! // Higher learning rates work better (e.g., 0.25-1.0 instead of 0.001)
71//! let optimizer = ScheduleFreeAdam::new(0.5, 0.9, 0.95, 1e-8, 0.1);
72//!
73//! // Schedule-Free SGD for simpler models
74//! let optimizer = ScheduleFreeSGD::for_large_models();
75//!
76//! // No learning rate scheduler needed! Just use .zero_grad(), .update(), .step()
77//! // eval_mode() can be used to switch to average weights
78//! ```
79//!
80//! ### Cutting-Edge 2024-2025 Optimizers
81//!
82//! The latest state-of-the-art optimizers for superior performance:
83//!
84//! #### 🌟 **NEW: Latest 2025 Research Algorithms** 🚀
85//!
86//! **Self-Scaled BFGS (SSBFGS)** - Revolutionary quasi-Newton method:
87//! ```rust,no_run
88//! use trustformers_optim::{SSBFGS, SSBFGSConfig};
89//!
90//! // For Physics-Informed Neural Networks (PINNs)
91//! let optimizer = SSBFGS::for_physics_informed();
92//!
93//! // For challenging non-convex problems
94//! let optimizer = SSBFGS::for_non_convex();
95//!
96//! // Custom configuration
97//! let optimizer = SSBFGS::from_config(SSBFGSConfig {
98//! learning_rate: 0.8,
99//! history_size: 15,
100//! scaling_factor: 1.2,
101//! momentum: 0.95,
102//! });
103//!
104//! // Get optimization statistics
105//! let stats = optimizer.get_stats();
106//! println!("Current scaling factor: {:.3}", stats.current_scaling_factor);
107//! ```
108//!
109//! **Self-Scaled Broyden (SSBroyden)** - Efficient rank-1 updates:
110//! ```rust,no_run
111//! use trustformers_optim::{SSBroyden, SSBroydenConfig};
112//!
113//! // Optimized for PINNs with rank-1 efficiency
114//! let optimizer = SSBroyden::for_physics_informed();
115//!
116//! // More computationally efficient than BFGS
117//! let optimizer = SSBroyden::new(); // Default configuration
118//! ```
119//!
120//! **PDE-aware Optimizer** - Specialized for Physics-Informed Neural Networks:
121//! ```rust,no_run
122//! use trustformers_optim::{PDEAwareOptimizer, PDEAwareConfig};
123//!
124//! // Specialized configurations for different PDEs
125//! let burgers_opt = PDEAwareOptimizer::for_burgers_equation(); // Burgers' equation
126//! let allen_cahn_opt = PDEAwareOptimizer::for_allen_cahn(); // Allen-Cahn equation
127//! let kdv_opt = PDEAwareOptimizer::for_kdv_equation(); // Korteweg-de Vries
128//! let sharp_grad_opt = PDEAwareOptimizer::for_sharp_gradients(); // Sharp gradient regions
129//!
130//! // Get PDE-specific optimization statistics
131//! let stats = sharp_grad_opt.get_pde_stats();
132//! println!("Average residual variance: {:.6}", stats.average_residual_variance);
133//! ```
134//!
135//! **🔬 Research Breakthrough Features:**
136//! - **Orders-of-magnitude improvements** in PINN training accuracy
137//! - **Dynamic rescaling** based on gradient history and PDE residual variance
138//! - **Sharp gradient handling** for challenging PDE optimization landscapes
139//! - **Lower computational cost** than second-order methods like SOAP
140//! - **Specialized presets** for different equation types (Burgers, Allen-Cahn, KdV)
141//!
142//! #### BGE-Adam (2024) - Revolutionary Performance Optimization! 🚀
143//! Enhanced Adam with entropy weighting and adaptive gradient strategy, now featuring **OptimizedBGEAdam** with **3-5x speedup**:
144//! ```rust,no_run
145//! use trustformers_optim::{BGEAdam, OptimizedBGEAdam, BGEAdamConfig, OptimizedBGEAdamConfig};
146//!
147//! // 🚀 RECOMMENDED: Use the optimized version for 3-5x better performance!
148//! let optimizer = OptimizedBGEAdam::new(); // 3-5x faster than original!
149//!
150//! // Performance-optimized presets for different use cases
151//! let llm_optimizer = OptimizedBGEAdam::for_large_models(); // For LLMs (optimized settings)
152//! let vision_optimizer = OptimizedBGEAdam::for_vision(); // For computer vision
153//! let perf_optimizer = OptimizedBGEAdam::for_high_performance(); // Maximum speed
154//!
155//! // Built-in performance monitoring and entropy statistics
156//! println!("{}", optimizer.performance_stats());
157//! let (min_entropy, max_entropy, avg_entropy) = optimizer.get_entropy_stats();
158//!
159//! // Original BGE-Adam still available (but much slower)
160//! let original_optimizer = BGEAdam::new(
161//! 1e-3, // learning rate
162//! (0.9, 0.999), // (β1, β2)
163//! 1e-8, // epsilon
164//! 0.01, // weight decay
165//! 0.1, // entropy scaling factor
166//! 0.05, // β1 adaptation factor
167//! 0.05, // β2 adaptation factor
168//! );
169//! ```
170//!
171//! **🔥 Performance Improvements in OptimizedBGEAdam:**
172//! - ⚡ **3.4-4.9x faster execution** (16.3ms → 4.7ms per iteration for 50k params)
173//! - 💾 **85-87x memory reduction** through optimized buffer management
174//! - 🔥 **Single-pass processing** eliminates redundant calculations
175//! - 🚀 **Vectorized operations** with SIMD-friendly processing patterns
176//!
177//! #### HN-Adam (2024)
178//! Hybrid Norm Adam with adaptive step size:
179//! ```rust,no_run
180//! use trustformers_optim::{HNAdam, HNAdamConfig};
181//!
182//! // Automatically adjusts step size based on update norms
183//! let optimizer = HNAdam::new(1e-3, (0.9, 0.999), 1e-8, 0.01, 0.1);
184//!
185//! // Or use presets for specific tasks
186//! let transformer_opt = HNAdam::for_transformers(); // Optimized for transformers
187//! let vision_opt = HNAdam::for_vision(); // Optimized for computer vision
188//!
189//! // Better convergence speed and accuracy than standard Adam
190//! ```
191//!
192//! #### AdEMAMix (2024)
193//! Dual EMA system for better gradient utilization:
194//! ```rust,no_run
195//! use trustformers_optim::AdEMAMix;
196//!
197//! // Revolutionary dual EMA optimizer from Apple/EPFL
198//! let optimizer = AdEMAMix::for_llm_training(); // Optimized for LLMs
199//!
200//! // Or for vision tasks
201//! let optimizer = AdEMAMix::for_vision_training();
202//!
203//! // 95% data efficiency improvement demonstrated in research
204//! ```
205//!
206//! #### Muon (2024)
207//! Orthogonalized-momentum optimizer for 2-D hidden-layer weights. It is a
208//! *first-order* method — the Newton-Schulz iteration orthogonalizes the momentum
209//! matrix, it does not estimate curvature:
210//! ```rust,no_run
211//! use trustformers_optim::Muon;
212//!
213//! // Used in NanoGPT and CIFAR-10 speed records
214//! let optimizer = Muon::for_nanogpt(); // <1% FLOP overhead
215//!
216//! // For large language models
217//! let optimizer = Muon::for_large_lm();
218//!
219//! // Automatically chooses 2D optimization for matrices, 1D fallback for vectors
220//! ```
221//!
222//! #### CAME (2023)
223//! Confidence-guided memory efficient optimization:
224//! ```rust,no_run
225//! use trustformers_optim::CAME;
226//!
227//! // Memory efficient with fast convergence
228//! let optimizer = CAME::for_bert_training();
229//!
230//! // For memory-constrained environments
231//! let optimizer = CAME::for_memory_constrained();
232//!
233//! // Check memory savings
234//! println!("Memory savings: {:.1}%", optimizer.memory_savings_ratio() * 100.0);
235//! ```
236//!
237//! #### MicroAdam (NeurIPS 2024)
238//! Memory-efficient Adam with compressed gradients:
239//! ```rust,no_run
240//! use trustformers_optim::MicroAdam;
241//!
242//! // Standard configuration with adaptive compression
243//! let optimizer = MicroAdam::new();
244//!
245//! // For large language models (higher compression)
246//! let optimizer = MicroAdam::for_large_models();
247//!
248//! // Memory-constrained environments (aggressive compression)
249//! let optimizer = MicroAdam::for_memory_constrained();
250//!
251//! // Check compression statistics
252//! println!("{}", optimizer.compression_statistics());
253//! println!("Memory savings: {:.1}%", optimizer.memory_savings_ratio() * 100.0);
254//! ```
255//!
256//! ### Advanced Quantization
257//!
258//! Ultra-low memory usage with 4-bit quantization:
259//! ```rust,no_run
260//! use trustformers_optim::{Adam4bit, AdvancedQuantizationConfig, QuantizationMethod};
261//!
262//! // 4-bit Adam with NF4 quantization (75% memory savings)
263//! let optimizer = Adam4bit::new(0.001, 0.9, 0.999, 1e-8, 0.01);
264//!
265//! // Custom quantization configuration
266//! let quant_config = AdvancedQuantizationConfig {
267//! method: QuantizationMethod::NF4,
268//! block_size: 64,
269//! adaptation_rate: 0.01,
270//! double_quantization: true,
271//! ..Default::default()
272//! };
273//!
274//! let optimizer = Adam4bit::with_quantization_config(
275//! Default::default(),
276//! quant_config,
277//! );
278//!
279//! // Massive memory savings for large models
280//! println!("Memory savings: {:.1}%", optimizer.memory_savings() * 100.0);
281//! ```
282//!
283//! ## Learning Rate Schedules
284//!
285//! Control learning rate during training:
286//! ```rust,no_run
287//! use trustformers_optim::{AdamW, CosineScheduler, LRScheduler};
288//!
289//! let base_lr = 1e-3;
290//! let optimizer = AdamW::new(base_lr, (0.9, 0.999), 1e-8, 0.01);
291//!
292//! // Cosine annealing with warmup
293//! let scheduler = CosineScheduler::new(
294//! base_lr,
295//! 1000, // num_warmup_steps
296//! 10000, // num_training_steps
297//! 1e-5, // min_lr
298//! );
299//!
300//! // Update learning rate each step
301//! for step in 0..10000 {
302//! let current_lr = scheduler.get_lr(step);
303//! // Use current_lr with optimizer.set_lr(current_lr)
304//! }
305//! ```
306//!
307//! ## ZeRO Optimization
308//!
309//! Memory-efficient distributed training:
310//! ```rust,ignore
311//! // ZeRO distributed training (requires distributed environment)
312//! use trustformers_optim::{AdamW};
313//!
314//! let optimizer = AdamW::new(1e-4, (0.9, 0.999), 1e-8, 0.01);
315//! // ZeRO configuration and distributed setup would go here
316//! ```
317//!
318//! ### ZeRO Stages
319//!
320//! - **Stage 1**: Optimizer state partitioning (4x memory reduction)
321//! - **Stage 2**: Optimizer + gradient partitioning (8x memory reduction)
322//! - **Stage 3**: Full parameter partitioning (Nx memory reduction)
323//!
324//! ## Multi-Node Training
325//!
326//! Scale training across multiple machines:
327//! ```text
328//! Multi-node distributed training setup
329//! Configuration and training would require distributed environment
330//! Example: MultiNodeTrainer::new(config)
331//! ```
332//!
333//! ## Advanced Features
334//!
335//! ### Gradient Accumulation
336//! ```text
337//! Example: Accumulate gradients over multiple batches before stepping
338//! if (step + 1) % accumulation_steps == 0 {
339//! optimizer.step(&mut model.parameters())?;
340//! optimizer.zero_grad();
341//! }
342//! ```
343//!
344//! ### Mixed Precision Training
345//! ```text
346//! Mixed precision optimizers can provide memory savings and speed improvements
347//! Configuration example:
348//! MixedPrecisionOptimizer::new(base_optimizer, scale_config)
349//! ```
350//!
351//! ## Performance Tips
352//!
353//! 1. **Choose the Right Optimizer**:
354//! - AdamW for most transformer training
355//! - SGD for fine-tuning with small learning rates
356//! - LAMB for large batch training
357//!
358//! 2. **Learning Rate Scheduling**:
359//! - Use warmup for stable training start
360//! - Cosine schedule for most cases
361//! - Linear decay for fine-tuning
362//!
363//! 3. **Memory Optimization**:
364//! - Enable ZeRO Stage 2 for models > 1B parameters
365//! - Use gradient accumulation for larger effective batch sizes
366//! - Consider CPU offloading for very large models
367//!
368//! 4. **Distributed Training**:
369//! - Use data parallelism for models < 10B parameters
370//! - Add model parallelism for larger models
371//! - Enable communication overlap for better throughput
372
373// Allow large error types in Result (TrustformersError is large by design)
374#![allow(clippy::result_large_err)]
375// Allow common patterns in optimizer implementations
376#![allow(clippy::too_many_arguments)]
377#![allow(clippy::type_complexity)]
378#![allow(clippy::excessive_nesting)]
379
380pub mod adafactor_new;
381pub mod adafisher_simple;
382pub mod adam;
383pub mod adam_v2;
384pub mod adamax_plus;
385pub mod adan;
386pub mod adaptive;
387pub mod ademamix;
388pub mod advanced_2025_research;
389pub mod advanced_distributed_features;
390pub mod advanced_features;
391pub mod amacp;
392pub mod async_optim;
393pub mod averaged_adam;
394pub mod bge_adam;
395pub mod bge_adam_optimized;
396pub mod cache_friendly;
397pub mod came;
398pub mod common;
399pub mod compression;
400pub mod continual_learning;
401pub mod convergence;
402pub mod cpu_offload;
403pub mod cross_framework;
404pub mod cyclic_decay;
405pub mod deep_distributed_qp;
406pub mod enhanced_distributed_training;
407pub mod eva;
408pub mod federated;
409pub mod fsdp;
410pub mod fusion;
411pub mod genie;
412pub mod gradient_processing;
413pub mod hardware_aware;
414pub mod hierarchical_aggregation;
415pub mod hn_adam;
416pub mod hyperparameter_tuning;
417pub mod jax_compat;
418pub mod kernel_fusion;
419pub mod lamb;
420pub mod lancbio;
421pub mod lazy_state;
422pub mod linalg;
423pub mod lion;
424pub mod lookahead;
425pub mod lora;
426pub mod lora_rite;
427pub mod lr_finder;
428pub mod memory_layout;
429pub mod microadam;
430pub mod monitoring;
431pub mod multinode;
432pub mod muon;
433pub mod novograd;
434pub mod onnx_export;
435pub mod optimizer;
436pub mod optimizer_surgery;
437pub mod parallel;
438pub mod param_id;
439pub mod pde_aware;
440pub mod per_layer_quant;
441pub mod performance_validation;
442pub mod prodigy;
443pub mod pytorch_compat;
444pub mod quantized;
445pub mod quantized_advanced;
446pub mod quantum_inspired;
447pub mod schedule_free;
448pub mod scheduler;
449pub mod second_order;
450pub mod sgd;
451pub mod simd_optimizations;
452pub mod sofo;
453pub mod sophia;
454pub mod sparse;
455pub mod task_specific;
456pub mod tensorflow_compat;
457pub mod traits;
458pub mod zero;
459
460#[cfg(test)]
461pub mod tests;
462
463pub use adafactor_new::{AdaFactor, AdaFactorConfig};
464pub use adafisher_simple::{AdaFisher, AdaFisherConfig};
465pub use adam::{AdaBelief, Adam, AdamW, NAdam, RAdam};
466pub use adam_v2::{AdamConfig, StandardizedAdam, StandardizedAdamW};
467pub use adamax_plus::{AdaMaxPlus, AdaMaxPlusConfig};
468pub use adan::{Adan, AdanConfig};
469pub use adaptive::{create_ranger, create_ranger_with_config, AMSBound, AdaBound, Ranger};
470pub use ademamix::{AdEMAMix, AdEMAMixConfig};
471pub use advanced_2025_research::{AdaWin, AdaWinConfig, DiWo, DiWoConfig, MeZOV2, MeZOV2Config};
472pub use advanced_distributed_features::{
473 AutoScaler, AutoScalerConfig, CheckpointConfig as AdvancedCheckpointConfig, CheckpointInfo,
474 CostOptimizer, MLOptimizerConfig, OptimizationResult, OptimizationType, PerformanceMLOptimizer,
475 ScalingDecision, ScalingStrategy, SmartCheckpointManager, WorkloadPredictor,
476};
477pub use advanced_features::{
478 CheckpointConfig, FusedOptimizer, MemoryBandwidthOptimizer, MultiOptimizerStats,
479 MultiOptimizerTrainer, ResourceUtilization, WarmupOptimizer, WarmupStrategy,
480};
481pub use amacp::{AMacP, AMacPConfig, AMacPStats};
482pub use async_optim::{
483 AsyncSGD, AsyncSGDConfig, DelayCompensationMethod, DelayedGradient, DelayedGradientConfig,
484 ElasticAveraging, ElasticAveragingConfig, Hogwild, HogwildConfig, ParameterServer,
485};
486pub use averaged_adam::{AveragedAdam, AveragedAdamConfig};
487pub use bge_adam::{BGEAdam, BGEAdamConfig};
488pub use bge_adam_optimized::{OptimizedBGEAdam, OptimizedBGEAdamConfig};
489pub use cache_friendly::{
490 CacheConfig, CacheFriendlyAdam, CacheFriendlyState, CacheStats, ParameterMetadata,
491};
492pub use came::{
493 came_update,
494 CAMEConfig,
495 // Advanced CAME (Wave 15 Workstream BB)
496 CameConfig,
497 CameOptimizer,
498 CameParamState,
499 OptimError as CameOptimError,
500 CAME,
501};
502pub use common::{
503 BiasCorrection, GradientProcessor, OptimizerState, ParameterIds, ParameterUpdate,
504 StateMemoryStats, WeightDecayMode,
505};
506pub use compression::{
507 CompressedAllReduce, CompressedGradient, CompressionMethod, GradientCompressor,
508};
509pub use continual_learning::{
510 AllocationStrategy, EWCConfig, FisherMethod, L2Regularization, L2RegularizationConfig,
511 MemoryReplay, MemoryReplayConfig, MemorySelectionStrategy, PackNet, PackNetConfig,
512 UpdateStrategy, EWC,
513};
514pub use convergence::{
515 AggMo, AggMoConfig, FISTAConfig, HeavyBall, HeavyBallConfig, NesterovAcceleratedGradient,
516 NesterovAcceleratedGradientConfig, QHMConfig, VarianceReduction, VarianceReductionConfig,
517 VarianceReductionMethod, FISTA, QHM,
518};
519pub use cpu_offload::{
520 create_cpu_offloaded_adam, create_cpu_offloaded_adamw, create_cpu_offloaded_sgd,
521 CPUOffloadConfig, CPUOffloadStats, CPUOffloadedOptimizer,
522};
523pub use cross_framework::{
524 ConfigSource, ConfigTarget, CrossFrameworkConverter, Framework, JAXOptimizerConfig,
525 PyTorchOptimizerConfig, TrustformeRSOptimizerConfig, UniversalOptimizerConfig,
526 UniversalOptimizerState,
527};
528pub use deep_distributed_qp::{DeepDistributedQP, DeepDistributedQPConfig};
529pub use enhanced_distributed_training::{
530 Bottleneck, CompressionConfig, CompressionType, DistributedConfig, DistributedTrainingStats,
531 DynamicBatchingConfig, EnhancedDistributedTrainer, FaultToleranceConfig, GpuTelemetrySample,
532 MemoryOptimizationConfig, MonitoringConfig as DistributedMonitoringConfig,
533 PerformanceMetrics as DistributedPerformanceMetrics, PerformanceTrend, TrainingStepResult,
534};
535pub use eva::{EVAConfig, EVA};
536pub use federated::{
537 ClientInfo, ClientSelectionStrategy, DifferentialPrivacy, DifferentialPrivacyConfig, FedAvg,
538 FedAvgConfig, FedProx, FedProxConfig, NoiseMechanism, SecureAggregation,
539};
540pub use fsdp::{
541 FsdpConfig, FsdpError, FsdpMemoryAnalyzer, FsdpState, FsdpUnit, ShardingStrategy,
542 WrappingPolicy,
543};
544#[cfg(target_arch = "x86_64")]
545pub use fusion::simd;
546pub use fusion::{FusedOperation, FusedOptimizerState, FusionConfig, FusionStats};
547pub use genie::{DomainStats, GENIEConfig, GENIEStats, GENIE};
548pub use gradient_processing::{
549 AdaptiveClippingConfig, GradientProcessedOptimizer, GradientProcessingConfig,
550 HessianApproximationType, HessianPreconditioningConfig, NoiseInjectionConfig, NoiseType,
551 SmoothingConfig,
552};
553pub use hardware_aware::{
554 create_edge_optimizer, create_gpu_adam, create_mobile_optimizer, create_tpu_optimizer,
555 CompressionRatio, EdgeOptimizer, GPUAdam, HardwareAwareConfig, HardwareTarget, MobileOptimizer,
556 TPUOptimizer, TPUVersion,
557};
558/// Real collective communication algorithms (ring all-reduce, ring all-gather,
559/// ring reduce-scatter, binomial broadcast/reduce, barrier) over a pluggable
560/// point-to-point transport.
561pub use hierarchical_aggregation::collective;
562pub use hierarchical_aggregation::collective::{Collective, CollectiveError, ReduceOp};
563/// Pure-Rust point-to-point transports: shared-memory (multi-threaded ranks)
564/// and TCP (multi-process / multi-host ranks).
565pub use hierarchical_aggregation::transport;
566pub use hierarchical_aggregation::transport::{
567 InProcessSession, InProcessTransport, TcpTransport, Transport, TransportError,
568};
569pub use hierarchical_aggregation::{
570 AggregationError, AggregationStats, AggregationStrategy, ButterflyStructure,
571 CommunicationGroups, FaultDetector, HierarchicalAggregator, HierarchicalConfig, NodeTopology,
572 RecoveryStrategy, RingStructure, TreeStructure,
573};
574pub use hn_adam::{HNAdam, HNAdamConfig};
575pub use hyperparameter_tuning::{
576 BayesianOptimizer, HyperparameterSample, HyperparameterSpace, HyperparameterTuner,
577 MultiObjectiveOptimizer, OptimizationTask, OptimizerType,
578 PerformanceMetrics as HyperparameterPerformanceMetrics, TaskType as HyperparameterTaskType,
579};
580pub use jax_compat::{
581 JAXAdam, JAXAdamW, JAXChain, JAXCosineDecay, JAXCosineDecaySchedule, JAXExponentialDecay,
582 JAXGradientTransformation, JAXLearningRateSchedule, JAXOptState, JAXOptimizerFactory,
583 JAXOptimizerState, JAXWarmupCosineDecay, JAXSGD,
584};
585pub use kernel_fusion::{
586 CoalescingLevel, FusedAdamState, FusedLayoutStats, KernelFusedAdam, KernelFusionConfig,
587};
588pub use lamb::LAMB;
589pub use lancbio::{LancBiO, LancBiOConfig};
590pub use lion::{Lion, LionConfig};
591pub use lookahead::{
592 Lookahead, LookaheadAdam, LookaheadAdamW, LookaheadNAdam, LookaheadRAdam, LookaheadSGD,
593};
594pub use lora::{
595 create_lora_adam, create_lora_adamw, create_lora_sgd, LoRAAdapter, LoRAConfig, LoRAOptimizer,
596};
597pub use lora_rite::{LoRARITE, LoRARITEConfig, LoRARITEStats, TransformationStats};
598pub use memory_layout::{
599 AlignedAllocator, AlignmentConfig, LayoutOptimizedAdam, LayoutStats, SoAOptimizerState,
600};
601pub use microadam::{MicroAdam, MicroAdamConfig};
602pub use monitoring::{
603 ConvergenceIndicators, ConvergenceSpeed, HyperparameterSensitivity,
604 HyperparameterSensitivityConfig, HyperparameterSensitivityMetrics, MemoryStats, MemoryUsage,
605 MetricStats, MonitoringConfig, OptimizerMetrics, OptimizerMonitor, OptimizerRecommendation,
606 OptimizerSelector, PerformanceStats, PerformanceTier,
607};
608pub use muon::{Muon, MuonConfig};
609pub use optimizer_surgery::{
610 MigrationReport, OptimizerKind, OptimizerSurgeon, ParamStateSnapshot, SurgeryConfig,
611 SurgeryError,
612};
613pub use pde_aware::{PDEAwareConfig, PDEAwareOptimizer, PDEAwareStats};
614pub use per_layer_quant::{
615 BitWidth, BitWidthStrategy, LayerBitWidthAssignment, LayerSensitivity, PerLayerQuantSelector,
616 QuantSelectionError, QuantizationPolicy, QuantizationSummary,
617};
618pub use prodigy::{Prodigy, ProdigyConfig};
619// pub use optimizer::OptimizerState; // Already imported from common
620pub use performance_validation::{
621 BenchmarkScenario, ConvergenceAnalysisResults, CorrectnessResults,
622 DistributedValidationResults, MathematicalProperty, MathematicalTestCase,
623 MemoryValidationResults, PerformanceBenchmarkResults, PerformanceValidator,
624 RegressionAnalysisResults, StatisticalMetrics, ValidationConfig, ValidationResults,
625};
626pub use pytorch_compat::{
627 PyTorchAdam, PyTorchAdamW, PyTorchLRScheduler, PyTorchOptimizer, PyTorchOptimizerFactory,
628 PyTorchOptimizerState, PyTorchParamGroup, PyTorchSGD,
629};
630pub use quantized::{Adam8bit, AdamW8bit, QuantizationConfig, QuantizedState};
631pub use quantized_advanced::{
632 Adam4bit, Adam4bitOptimizerConfig, AdamW4bit, AdvancedQuantizationConfig, GradientStatistics,
633 QuantizationMethod, QuantizationUtils, QuantizedTensor,
634};
635pub use quantum_inspired::{
636 QuantumAnnealingConfig, QuantumAnnealingOptimizer, QuantumAnnealingStats,
637};
638pub use schedule_free::{
639 ScheduleFreeAdam, ScheduleFreeAdamConfig, ScheduleFreeSGD, ScheduleFreeSGDConfig,
640};
641pub use scheduler::{
642 AdaptiveScheduler, CompositeScheduler, ConstantWithWarmupScheduler, CosineScheduler,
643 CosineWithRestartsScheduler, CyclicalMode, CyclicalScheduler, DynamicScheduler,
644 ExponentialScheduler, LRScheduler, LinearScheduler, OneCycleScheduler, Phase,
645 PhaseBasedScheduler, PolynomialScheduler, StepScheduler, SwitchCondition,
646 TaskSpecificScheduler, TaskType as SchedulerTaskType,
647};
648pub use second_order::{
649 LineSearchMethod, NewtonCG, SSBFGSConfig, SSBFGSStats, SSBroyden, SSBroydenConfig, LBFGS,
650 SSBFGS,
651};
652pub use sgd::SGD;
653pub use simd_optimizations::{SIMDConfig, SIMDOptimizer, SIMDPerformanceInfo};
654pub use sofo::{
655 CurvatureSource, ForwardModeStats, MemoryStats as SOFOMemoryStats, SOFOConfig, SOFOStats, SOFO,
656};
657pub use sophia::{
658 gauss_newton_diagonal,
659 sophia_update,
660 Sophia,
661 // Advanced Sophia (Wave 15 Workstream BB)
662 SophiaConfig,
663 SophiaError,
664 SophiaLegacyConfig,
665 SophiaOptimizer,
666 SophiaParamState,
667};
668pub use sparse::{SparseAdam, SparseConfig, SparseMomentumState, SparseSGD};
669pub use task_specific::{
670 create_bert_optimizer, create_gan_optimizer, create_maml_optimizer, create_ppo_optimizer,
671 BERTOptimizer, GANOptimizer, MetaOptimizer as TaskMetaOptimizer, RLOptimizer,
672};
673pub use tensorflow_compat::{
674 TensorFlowAdam, TensorFlowAdamW, TensorFlowCosineDecay, TensorFlowExponentialDecay,
675 TensorFlowLearningRateSchedule, TensorFlowOptimizer, TensorFlowOptimizerConfig,
676 TensorFlowOptimizerFactory,
677};
678pub use traits::{
679 AdaptiveMomentumOptimizer, AsyncOptimizer, ClassicalMomentumOptimizer, CompositeOptimizer,
680 DistributedOptimizer, FederatedOptimizer, GPUOptimizer, GradientCompressionOptimizer,
681 HardwareOptimizer, HardwareStats, LookaheadOptimizer, MetaOptimizer, MomentumOptimizer,
682 OptimizerFactory, ScheduledOptimizer, SecondOrderOptimizer, SerializableOptimizer,
683 StalenessCompensation, StatefulOptimizer,
684};
685pub use zero::{
686 all_gather_gradients, gather_parameters, partition_gradients, partition_parameters,
687 reduce_scatter_gradients, GradientBuffer, ParameterGroup, ParameterPartition, ZeROConfig,
688 ZeROImplementationStage, ZeROMemoryStats, ZeROOptimizer, ZeROStage, ZeROStage1, ZeROStage2,
689 ZeROStage3, ZeROState,
690};
691
692pub use multinode::{MultiNodeConfig, MultiNodeStats, MultiNodeTrainer};
693pub use novograd::{MemoryEfficiencyStats, NovoGrad, NovoGradConfig, NovoGradStats};
694pub use onnx_export::{
695 ONNXExportConfig, ONNXGraph, ONNXModel, ONNXNode, ONNXOptimizerExporter, ONNXOptimizerMetadata,
696 OptimizerConfig,
697};
698pub use parallel::{BatchUpdate, ParallelAdam, ParallelConfig, ParallelStats};
699
700pub use cyclic_decay::{
701 AnnealStrategy, CyclicLrConfig, CyclicLrMode, CyclicLrScheduler, OneCycleLrScheduler,
702};
703pub use lazy_state::{LazyAdam, LazyOptimizerStats, LazyParamState};
704pub use lr_finder::{
705 find_optimal_lr, LrFinder, LrFinderAction, LrFinderConfig, LrFinderResult, LrStopReason,
706};