Skip to main content

ferrum_interfaces/
lib.rs

1//! Core interface definitions for the Ferrum inference framework
2//!
3//! This crate carries the stable, GPU-free trait contracts shared across
4//! the workspace: model execution, scheduling, KV cache management,
5//! tokenization, sampling, and the lifecycle/modality engine traits.
6//! Hardware backends live in `ferrum-kernels` (the `Backend<B>` trait
7//! and its supertraits); only types that compile without GPU features
8//! belong here.
9
10#![allow(async_fn_in_trait)]
11
12pub mod engine;
13pub mod kv_cache;
14pub mod kv_dtype;
15pub mod model_executor;
16pub mod recurrent_state;
17pub mod sampler;
18pub mod scheduler;
19pub mod tensor;
20pub mod tokenizer;
21#[allow(
22    dead_code,
23    unused_imports,
24    reason = "reviewed vNext contracts stay isolated and byte-stable until the product runtime migration"
25)]
26pub mod vnext;
27
28// Re-export core traits and important types
29pub use engine::InferenceEngine;
30pub use kv_cache::{
31    AllocationRequest, BlockTable, CacheHandleStats, KvCacheHandle, KvCacheManager,
32};
33pub use kv_dtype::{KvBf16, KvDtypeKind, KvFp16, KvFp8, KvInt8};
34pub use model_executor::{
35    DecodeInput, DecodeOutput, ExecutorAdmissionEpochs, ExecutorPrefillAdmission,
36    ExecutorPrefillAdmissionDecision, ExecutorPrefillAdmissionReceipt,
37    ExecutorPrefillMaintenanceBlocker, ExecutorPrefillMaintenanceDeferral,
38    ExecutorPrefillMaintenanceOutcome, ExecutorPrefillMaintenanceStage, ExecutorSamplingOutput,
39    ModelExecutor, PlanRuntimeBatchDecodeOutcome, PlanRuntimeBatchPrefillOutcome,
40    PlanRuntimeDecodeInput, PlanRuntimeDecodeOutput, PlanRuntimePrefillAuthority,
41    PlanRuntimePrefillCompletion, PlanRuntimePrefillInput, PlanRuntimePrefillOutcome,
42    PlanRuntimePrefillOutput, PlanRuntimePrefillProduct, PrefillInput, PrefillOutput,
43};
44pub use recurrent_state::{
45    RecurrentStateHandle, RecurrentStateHandleStats, RecurrentStateManager,
46    RecurrentStateManagerStats, RecurrentStateResumePolicy, RecurrentStateSpec,
47    RecurrentStateTensorSpec,
48};
49pub use sampler::{
50    LogitsProcessor, Sampler, SamplingConfig, SamplingContext, SamplingRng,
51    SAMPLING_RNG_ALGORITHM_ID,
52};
53pub use scheduler::{BatchHint, BatchPlan, Scheduler as SchedulerInterface};
54pub use tensor::{TensorFactory, TensorLike, TensorOps, TensorRef};
55pub use tokenizer::{IncrementalTokenizer, Tokenizer, TokenizerFactory, TokenizerInfo};
56
57// Re-export types from ferrum-types, avoiding conflicts
58pub use ferrum_types::{
59    config::BackendConfig,
60    // Config types - use fully qualified names to avoid conflicts
61    config::EngineConfig,
62    config::SchedulerConfig,
63    config::TokenizerConfig,
64    BatchId,
65    BlockId,
66    ClientId,
67    ComponentHealth,
68    ComponentStatus,
69    DataType,
70    // Device types
71    Device,
72    EngineMetrics,
73    EngineStatus,
74    FerrumError,
75    FinishReason,
76    HealthStatus,
77    // Requests and responses
78    InferenceRequest,
79    InferenceResponse,
80    // Metrics
81    MemoryUsage,
82    ModelId,
83    // Model types
84    ModelInfo,
85    ModelSource,
86    ModelType,
87    Priority,
88    // IDs
89    RequestId,
90    Result,
91    // Sampling
92    SamplingParams,
93    SchedulerStats,
94    SessionId,
95    SpecialTokens,
96    StreamChunk,
97    TaskId,
98    // Basic types
99    TokenId,
100};