Skip to main content

aisimulate_core/
lib.rs

1// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Engine-neutral inference simulation, deterministic replay, and performance
5//! modeling.
6//!
7//! [`engine`] owns scheduling, native GPU KV accounting, preemption, timing,
8//! and attention-DP composition. [`replay`] owns virtual time, logical-worker
9//! lifecycle, placement/scaling composition, and report collection.
10//! [`perfmodel`] is the imported AIConfigurator latency and memory model. It is
11//! deliberately namespaced so its `EngineConfig` and compiled engine do not
12//! collide with the replay engine's public API.
13//!
14//! The crate root exposes the stable, commonly used configuration and replay
15//! surface. Advanced engine and adapter contracts remain available through
16//! their explicit module paths.
17
18pub mod engine;
19// The mirror contains compatibility and diagnostics helpers that are reached
20// only from the optional Python surface or parity harnesses.
21#[allow(dead_code)]
22pub mod perfmodel;
23#[cfg(feature = "python")]
24mod python;
25pub mod replay;
26
27pub use engine::{EngineConfig as ReplayEngineConfig, TimingModel, TimingModelConfig};
28pub use replay::{ReplayReport, ReplaySpec, Replayer};
29
30// Preserve the former published AIC crate-root surface. Replay's conflicting
31// engine configuration remains available as `engine::EngineConfig` and under
32// the explicit `ReplayEngineConfig` alias above.
33pub use perfmodel::EngineConfig;
34pub use perfmodel::{
35    AicError, BackendKind, DataType, ENGINE_CONFIG_SCHEMA_VERSION, ENGINE_SPEC_SCHEMA_VERSION,
36    EstimateSource, FPM_VERSION, ForwardPassMetrics, ForwardPassPerfDiagnostics,
37    ForwardPassPerfModel, ForwardPassPerfOptions, ForwardPassPerfReadiness, ForwardPassPerfSource,
38    KvCacheEstimate, KvCacheEstimateAdjusted, KvCacheEstimateError, KvCacheEstimateOptions,
39    KvCacheEstimateRequest, KvCacheMemoryFraction, MemoryBreakdown, ParallelMapping,
40    QuantizationConfig, QueuedRequestMetrics, ScheduledRequestMetrics, SpeculativeConfig,
41};
42
43#[cfg(feature = "python")]
44pub use perfmodel::{AicEngine, AicEngineBuilder, estimate_kv_cache};
45
46// The imported perf-model sources historically used additional crate-root
47// module paths. Keep these module aliases crate-private so the mirror subtree
48// can stay mechanically syncable while external users use `perfmodel::*` for
49// advanced APIs.
50#[allow(unused_imports)]
51pub(crate) use perfmodel::{
52    common, config, fpm, memory, operators, perf_database, repo_relative, session,
53    validate_forward_pass_metrics,
54};
55
56#[cfg(feature = "python")]
57#[allow(unused_imports)]
58pub(crate) use perfmodel::{py, py_ops};