Whole-workspace rustfmt pass picked up while iterating on Mamba GPU backward work. Verified formatting-only via diff sampling; no logic changed. Co-Authored-By: Claude Sonnet 5 <[email protected]>
224 lines
6.9 KiB
Rust
224 lines
6.9 KiB
Rust
//! # RTX Transformers: Complete Transformer Training Infrastructure
|
|
//!
|
|
//! Revolutionary transformer training framework with production-ready core functionality.
|
|
//! Advanced features are being progressively integrated.
|
|
//!
|
|
//! ## Core Features
|
|
//!
|
|
//! - **Core Training Infrastructure**: Basic training loop, optimizer integration
|
|
//! - **Foundation Architectures**: GPT, BERT foundations
|
|
//! - **Essential Layers**: Layer normalization, attention mechanisms
|
|
//! - **Tensor Bridge**: Compatibility layer for tensor operations
|
|
//!
|
|
//! ## Example
|
|
//!
|
|
//! ```rust
|
|
//! use rtx_transformers::prelude::*;
|
|
//!
|
|
//! // Basic transformer functionality
|
|
//! let result = rtx_transformers::test_complete_pipeline();
|
|
//! assert!(result.is_ok());
|
|
//! ```
|
|
|
|
#![deny(missing_docs)]
|
|
#![allow(missing_docs)]
|
|
|
|
// ============================================================================
|
|
// PHASE 1: CORE MODULES (Essential functionality)
|
|
// ============================================================================
|
|
|
|
pub mod error;
|
|
pub mod tensor_bridge;
|
|
|
|
// Core training components
|
|
pub mod optimizers;
|
|
pub mod schedulers; // Re-enabled for rtx-multimodal
|
|
pub mod training; // Re-enabled for rtx-multimodal
|
|
|
|
// Essential architectural components
|
|
pub mod architectures;
|
|
pub mod layers; // Core layer implementations // Re-enabled for BERT implementation
|
|
|
|
// ============================================================================
|
|
// PHASE 2: ADVANCED MODULES (Temporarily disabled for compilation)
|
|
// ============================================================================
|
|
|
|
// Advanced training features
|
|
pub mod regression_tests;
|
|
pub mod validation_framework;
|
|
|
|
// Test modules
|
|
#[cfg(test)]
|
|
pub mod comprehensive_tests;
|
|
|
|
// Advanced architectures and features
|
|
pub mod revolutionary; // Re-enabled for rtx-multimodal
|
|
pub mod tensor_core_kernels;
|
|
pub mod tensor_core_optimizations;
|
|
pub mod tensor_core_scheduling;
|
|
pub mod tokenization;
|
|
|
|
// RAG and modern features
|
|
pub mod continual;
|
|
pub mod curriculum;
|
|
pub mod distributed;
|
|
pub mod graph;
|
|
pub mod kan;
|
|
pub mod losses;
|
|
pub mod meta;
|
|
pub mod modular;
|
|
pub mod neural_ode;
|
|
pub mod perceiver;
|
|
pub mod rag;
|
|
pub mod regularization;
|
|
pub mod ssl; // Re-enabled for rtx-multimodal
|
|
|
|
// Re-export key types for convenience
|
|
pub use error::{Result, TransformerError};
|
|
|
|
/// Current version of rtx-transformers
|
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
|
|
/// Prelude module for common imports
|
|
pub mod prelude {
|
|
//! Common imports for RTX Transformers (Phase 1: Core functionality)
|
|
|
|
// Core types
|
|
pub use crate::{Result, TransformerError};
|
|
|
|
// Real tensor operations
|
|
pub use rtx_autograd::{NodeId, TensorAutograd, backward, clear_tape};
|
|
pub use rtx_tensor::{DType, Device, Tensor, TensorError};
|
|
|
|
// Tensor bridge for API compatibility
|
|
pub use crate::tensor_bridge::{TensorBridge, TensorBridgeStatic, TensorCompat};
|
|
|
|
// Core Optimizers (Phase 1)
|
|
pub use crate::optimizers::{
|
|
AdamConfig,
|
|
AdamWConfig,
|
|
Optimizer,
|
|
OptimizerConfig,
|
|
OptimizerType,
|
|
// Advanced optimizers will be re-enabled in Phase 2
|
|
// ShampooOptimizer, ShampooConfig, KFacOptimizer, KFacConfig, LayerType,
|
|
};
|
|
|
|
// Core Layer types (Phase 1)
|
|
pub use crate::layers::{
|
|
Layer,
|
|
LayerNorm,
|
|
PositionalEncoding,
|
|
RMSNorm,
|
|
// Advanced layer types will be re-enabled progressively
|
|
// MultiQueryAttention, MQAConfig, MoEConfig, etc.
|
|
};
|
|
|
|
// ========================================================================
|
|
// PHASE 2: ADVANCED FEATURES (Will be re-enabled progressively)
|
|
// ========================================================================
|
|
|
|
// Schedulers (Phase 2)
|
|
// pub use crate::schedulers::{
|
|
// LearningRateScheduler, SchedulerConfig, WarmupSchedulerConfig, CosineAnnealingConfig, SchedulerType,
|
|
// };
|
|
|
|
// Training (Phase 2)
|
|
// pub use crate::training::{
|
|
// TransformerTrainer, TrainingConfig, TrainingMetrics,
|
|
// GradientAccumulator, MixedPrecisionTrainer, LossScalingStrategy, TrainingState, TrainingStats,
|
|
// };
|
|
|
|
// Architecture types (Re-enabled for BERT implementation)
|
|
pub use crate::architectures::{
|
|
BertConfig, BertEmbeddings, BertModel, ModelOutput, MultiHeadAttention,
|
|
TransformerArchitecture, TransformerBlock, TransformerConfig,
|
|
};
|
|
|
|
// Advanced features will be re-exported in phases 2 and 3...
|
|
// - Tokenization, Revolutionary features, RAG, SSL, Regularization
|
|
// - Meta-learning, Continual learning, Curriculum learning
|
|
// - Graph transformers, Neural ODEs, KAN networks, Perceiver IO
|
|
// - Modular networks, Distributed training, Advanced losses
|
|
}
|
|
|
|
/// Initialize RTX Transformers with logging
|
|
pub fn init() -> Result<()> {
|
|
tracing_subscriber::fmt::init();
|
|
tracing::info!("RTX Transformers v{} initialized", VERSION);
|
|
Ok(())
|
|
}
|
|
|
|
/// Test complete transformer training pipeline (minimal version)
|
|
pub fn test_complete_pipeline() -> Result<()> {
|
|
tracing::info!(
|
|
"Testing RTX Transformers pipeline v{} (minimal version)",
|
|
VERSION
|
|
);
|
|
|
|
// Test basic functionality
|
|
let capabilities = vec![
|
|
"Core Infrastructure",
|
|
"Autograd Integration",
|
|
"Optimizer Framework",
|
|
];
|
|
|
|
tracing::info!("Current capabilities: {:?}", capabilities);
|
|
tracing::info!("RTX Transformers pipeline test completed successfully");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
/// Get RTX Transformers capabilities and performance metrics
|
|
#[must_use]
|
|
pub fn get_capabilities() -> std::collections::HashMap<String, String> {
|
|
let mut capabilities = std::collections::HashMap::new();
|
|
|
|
capabilities.insert("version".to_string(), VERSION.to_string());
|
|
capabilities.insert("architectures".to_string(), "In Development".to_string());
|
|
capabilities.insert(
|
|
"training_features".to_string(),
|
|
"Autograd Integration, Optimizer Framework".to_string(),
|
|
);
|
|
capabilities.insert("tokenization".to_string(), "In Development".to_string());
|
|
capabilities.insert(
|
|
"revolutionary_features".to_string(),
|
|
"Planned: Quantum, Neuromorphic, Edge-Aware".to_string(),
|
|
);
|
|
capabilities.insert(
|
|
"performance_advantage".to_string(),
|
|
"5-10x faster than PyTorch".to_string(),
|
|
);
|
|
capabilities.insert("memory_efficiency".to_string(), "50% reduction".to_string());
|
|
capabilities.insert(
|
|
"safety_guarantee".to_string(),
|
|
"Zero runtime crashes".to_string(),
|
|
);
|
|
|
|
capabilities
|
|
}
|
|
|
|
#[cfg(all(test, feature = "disabled_tests"))]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_version() {
|
|
assert!(!VERSION.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn test_capabilities() {
|
|
let caps = get_capabilities();
|
|
assert!(caps.contains_key("version"));
|
|
assert!(caps.contains_key("revolutionary_features"));
|
|
assert!(caps.contains_key("performance_advantage"));
|
|
}
|
|
|
|
#[test]
|
|
fn test_complete_pipeline() {
|
|
let result = test_complete_pipeline();
|
|
assert!(result.is_ok());
|
|
}
|
|
}
|