Skip to main content

Crate optirs_nas

Crate optirs_nas 

Source
Expand description

Version: 0.3.2 Status: Research-grade implementations; APIs may still change between releases

⚠️ Warning: Architecture search is compute-heavy and the search-space / objective APIs are still evolving. Validate a discovered architecture against your own baselines before relying on it in production.

optirs-nas provides neural architecture search and automated optimizer discovery built on SciRS2.

§Dependencies

  • scirs2-core 0.6.5 - required foundation (arrays, RNG, numeric traits)

This crate has no intra-workspace dependencies: optirs-core and optirs-learned were declared once but never referenced, and were removed so optirs-nas builds and tests standalone. The benchmark harness in evaluation::BenchmarkSuite implements its optimizer update rules directly, which also makes NAS scores reproducible independently of sibling-crate changes.

§Implementation Status (v0.3.2)

  • ✅ Bayesian optimization (search_strategies::bayesian - Gaussian-process surrogate search)
  • ✅ Hyperparameter search (hyperparameter - grid enumeration, TPE, a GP-free kernel-regression surrogate, and evolutionary search)
  • ✅ Evolutionary algorithms (search_strategies::evolutionary - population-based search)
  • ✅ RL-based search (search_strategies::rl_search - neural-controller sampling)
  • ✅ Differentiable search (search_strategies::differentiable - DARTS-style gradient search)
  • ✅ Multi-objective optimization (multi_objective - NSGA-II, NSGA-III, MOEA/D, weighted-sum, Pareto frontier, exact hypervolume)
  • ✅ Hardware-aware cost modeling (hardware_cost - latency/memory/energy estimation)
  • ✅ AutoML pipeline coordination (automl_pipeline), cross-domain transfer, few-shot and progressive search
  • 📝 Real, tested algorithms throughout - still labeled research-grade because search-space and objective APIs may change across releases

§Features

§Search Strategies

  • Bayesian Optimization - Gaussian processes for efficient search
  • Evolutionary Algorithms - Population-based architecture evolution
  • Reinforcement Learning - Neural controller for architecture sampling
  • Gradient-Based - DARTS and differentiable NAS

§Multi-Objective Optimization

  • Pareto Frontier - Balance accuracy, speed, memory
  • Weighted Sum - Customizable objective functions
  • NSGA-II - Non-dominated sorting genetic algorithm
  • NSGA-III - Reference-point-based many-objective sorting
  • MOEA/D - Decomposition-based optimization (Tchebycheff/PBI/ASF/weighted-sum)
  • Interactive preference articulation and Pareto-level constraint handling (MultiObjectiveConfig::user_preferences/constraint_handling) are declared but not yet consulted by any optimizer; hard resource limits are enforced separately by nas_engine::resources::ResourceMonitor, not by the multi-objective layer.
  • Start Simple - Begin with small architectures
  • Gradual Complexity - Incrementally increase depth/width
  • Early Stopping - Prune unpromising architectures
  • Transfer Learning - Reuse knowledge from previous searches

§Hardware-Aware NAS

  • Latency Prediction - Model inference time on target hardware
  • Memory Estimation - Predict GPU/TPU memory usage
  • Energy Consumption - Optimize for mobile/edge devices
  • Cost Optimization - Minimize cloud compute costs

§Example Usage

The engine type is nas_engine::NeuralArchitectureSearch, configured with a nas_engine::NASConfig. This example compiles and runs as a doctest, so it cannot drift away from the real API.

use optirs_nas::nas_engine::resources::SystemResourceTracker;
use optirs_nas::nas_engine::telemetry::{FixedTelemetry, TelemetrySample};
use optirs_nas::nas_engine::{
    create_minimal_nas_config, NeuralArchitectureSearch, SearchStrategyType,
};
use std::time::Duration;

// A small, ready-made configuration: a populated search space, a Random
// strategy and a tiny budget.
let mut config = create_minimal_nas_config::<f64>();
config.search_strategy = SearchStrategyType::Evolutionary;
config.search_budget = 2;
config.population_size = 4;

let mut engine = NeuralArchitectureSearch::new(config)?;
// The engine reports which strategy is *actually* running, not just what was
// requested.
assert_eq!(engine.search_strategy_name(), "EvolutionaryStrategy");

// Pin the telemetry so this example's outcome does not depend on how much
// memory the host happens to have free. `resource_monitor_mut` is the supported
// injection point for real telemetry too.
engine.resource_monitor_mut().set_trackers(vec![Box::new(
    SystemResourceTracker::with_telemetry(
        "example".to_string(),
        Duration::from_secs(5),
        Box::new(FixedTelemetry::new("example", TelemetrySample::unknown())),
    ),
)]);

// A short search: two generations against the built-in evaluator.
let results = engine.run_search()?;
assert!(!results.search_history.is_empty());

Hyperparameter search is independent of the engine and can be driven directly:

use optirs_nas::hyperparameter::{
    DistributionType, HyperparameterOptimizer, HyperparameterSpace,
    OptimizationStrategy, ParameterRange,
};

let mut space: HyperparameterSpace<f64> = HyperparameterSpace::new();
space.add_parameter(
    "learning_rate".to_string(),
    ParameterRange {
        name: "learning_rate".to_string(),
        min_value: 1e-5,
        max_value: 1e-1,
        distribution: DistributionType::Uniform,
        log_scale: true,
        discrete_values: None,
    },
);

// Grid search enumerates the grid; it does not sample at random.
let mut optimizer =
    HyperparameterOptimizer::with_seed(space, OptimizationStrategy::Grid, 7);
optimizer.set_grid_resolution(4);
assert_eq!(optimizer.grid_size(), Some(4));

let suggestion = optimizer.suggest_configuration()?;
let learning_rate = suggestion.parameters["learning_rate"];
assert!((1e-5..=1e-1).contains(&learning_rate));

§Supported Search Spaces

  • Optimizer Selection - Choose between SGD, Adam, RMSprop, etc.
  • Hyperparameters - Learning rates, momentum, weight decay
  • Learning Rate Schedules - Warmup, decay, cosine annealing
  • Regularization - L1/L2, dropout rates, gradient clipping
  • Architecture Components - Optimizer composition and ensembles

§Architecture

Every algorithm in this crate is implemented here; scirs2-core supplies the numeric substrate only:

The search machinery itself lives in this crate:

(Earlier revisions of this document referenced scirs2_core::neural_architecture_search and scirs2_core::quantum_optimization; neither module exists.)

§References

  • DARTS: Differentiable Architecture Search (Liu et al., 2019)
  • EfficientNet: Rethinking Model Scaling for CNNs (Tan & Le, 2019)
  • Once-for-All: Train One Network and Specialize it for Efficient Deployment (Cai et al., 2020)

§Contributing

Research contributions welcome! Follow SciRS2 integration guidelines.

Re-exports§

pub use architecture::ArchitectureSpace;
pub use architecture_embedding::AggregationMethod;
pub use architecture_embedding::ArchitectureEmbedder;
pub use architecture_knowledge_graph::ArchKnowledgeEdge;
pub use architecture_knowledge_graph::ArchKnowledgeNode;
pub use architecture_knowledge_graph::ArchitectureKnowledgeGraph;
pub use architecture_knowledge_graph::NodeId;
pub use architecture_knowledge_graph::PerformanceRecord;
pub use architecture_knowledge_graph::RelationType;
pub use automl_pipeline::AutomlPipelineConfig;
pub use automl_pipeline::AutomlPipelineCoordinator;
pub use automl_pipeline::CandidateModel;
pub use automl_pipeline::EnsembleStrategy;
pub use automl_pipeline::FeatureEngineeringStep;
pub use automl_pipeline::PipelineEvaluation;
pub use automl_pipeline::PreprocessingStep;
pub use automl_pipeline::ScoredPipeline;
pub use automl_pipeline::SvmKernel;
pub use automl_pipeline::TrainValSplit;
pub use cross_domain_transfer::CrossDomainTransferEngine;
pub use cross_domain_transfer::DomainProfile;
pub use cross_domain_transfer::DomainSimilarityMetric;
pub use cross_domain_transfer::DomainSimilarityReport;
pub use cross_domain_transfer::TransferRecommendation;
pub use cross_domain_transfer::TransferabilityWeights;
pub use domain_specific_nas::DomainNASEngine;
pub use domain_specific_nas::DomainSearchSpace;
pub use domain_specific_nas::DomainType as NASDomainType;
pub use domain_specific_nas::NASConstraint;
pub use error::OptimError;
pub use error::Result;
pub use few_shot_architecture::ArchitectureExample;
pub use few_shot_architecture::DistanceMetric;
pub use few_shot_architecture::FewShotAlgorithm;
pub use few_shot_architecture::FewShotArchitectureOptimizer;
pub use few_shot_architecture::FewShotConfig;
pub use few_shot_architecture::FewShotPrediction;
pub use hardware_cost::ActivationKind;
pub use hardware_cost::Bottleneck;
pub use hardware_cost::CostReport;
pub use hardware_cost::HardwareCostModel;
pub use hardware_cost::HardwareProfile;
pub use hardware_cost::LatencyLookupTable;
pub use hardware_cost::LatencyPrediction;
pub use hardware_cost::LatencySource;
pub use hardware_cost::LayerKind;
pub use hardware_cost::LayerSignature;
pub use hardware_cost::LayerSpec;
pub use hardware_cost::PerLayerCost;
pub use hardware_cost::PoolKind;
pub use hardware_cost::RooflineResult;
pub use multimodal_nas::FusionOp;
pub use multimodal_nas::Modality;
pub use multimodal_nas::ModalityEncoder;
pub use multimodal_nas::MultimodalArchitecture;
pub use multimodal_nas::MultimodalEvaluation;
pub use multimodal_nas::MultimodalLayer;
pub use multimodal_nas::MultimodalNasEngine;
pub use multimodal_nas::MultimodalSearchSpace;
pub use multimodal_nas::MultimodalValidationError;
pub use search_strategies::SearchStrategy;
pub use speech_nas::layer_position_constraint;
pub use speech_nas::LayerPositionConstraint;
pub use speech_nas::SpeechLayerType;
pub use speech_nas::SpeechModelConfig;
pub use speech_nas::SpeechModelEvaluation;
pub use speech_nas::SpeechNasEngine;
pub use speech_nas::SpeechSearchSpace;
pub use nas_engine::config::NASConfig;
pub use nas_engine::results::BenchmarkResult;
pub use nas_engine::results::CrossValidationResults;
pub use nas_engine::results::EvaluationResults;
pub use nas_engine::results::OptimizerArchitecture;
pub use nas_engine::results::ResourceUsage;
pub use nas_engine::results::TrainingSnapshot;

Modules§

architecture
Architecture representation and search space definition for Neural Architecture Search.
architecture_embedding
Architecture embedding for similarity search and performance prediction.
architecture_knowledge_graph
Architecture Knowledge Graph for transfer learning across NAS searches.
automl_pipeline
End-to-end automated machine learning (AutoML) pipeline coordinator.
cross_domain_transfer
Cross-domain knowledge transfer for Neural Architecture Search.
domain_specific_nas
Domain-specific Neural Architecture Search for optimizer discovery.
error
Error types for OptiRS NAS module
evaluation
Performance evaluation system for neural architecture search
few_shot_architecture
Few-shot architecture optimization for Neural Architecture Search.
hardware_cost
Analytical hardware-aware cost models for Neural Architecture Search.
hyperparameter
Hyperparameter optimization for Neural Architecture Search.
multi_objective
multimodal_nas
Multimodal Neural Architecture Search.
nas_engine
progressive
search_strategies
speech_nas
Speech recognition Neural Architecture Search.

Structs§

EvaluationConfig
Evaluation configuration for architecture search

Enums§

EvaluationMetric
Evaluation metrics for architectures