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
12#[cfg(test)]
13extern crate self as ferrum_interfaces;
14
15pub mod engine;
16pub mod kv_cache;
17pub mod kv_dtype;
18pub mod model_executor;
19pub mod recurrent_state;
20pub mod sampler;
21pub mod scheduler;
22pub mod tensor;
23pub mod tokenizer;
24#[allow(
25    dead_code,
26    unused_imports,
27    reason = "reviewed vNext contracts stay isolated and byte-stable until the product runtime migration"
28)]
29pub mod vnext;
30
31// Re-export core traits and important types
32pub use engine::InferenceEngine;
33pub use kv_cache::{
34    AllocationRequest, BlockTable, CacheHandleStats, KvCacheHandle, KvCacheManager,
35};
36pub use kv_dtype::{KvBf16, KvDtypeKind, KvFp16, KvFp8, KvInt8};
37pub use model_executor::{
38    DecodeInput, DecodeOutput, ExecutorAdmissionEpochs, ExecutorPrefillAdmission,
39    ExecutorPrefillAdmissionDecision, ExecutorPrefillAdmissionReceipt,
40    ExecutorPrefillMaintenanceBlocker, ExecutorPrefillMaintenanceDeferral,
41    ExecutorPrefillMaintenanceOutcome, ExecutorPrefillMaintenanceStage, ExecutorSamplingOutput,
42    ModelExecutor, PlanRuntimeBatchDecodeOutcome, PlanRuntimeBatchPrefillOutcome,
43    PlanRuntimeDecodeInput, PlanRuntimeDecodeOutput, PlanRuntimePrefillAuthority,
44    PlanRuntimePrefillCompletion, PlanRuntimePrefillInput, PlanRuntimePrefillOutcome,
45    PlanRuntimePrefillOutput, PlanRuntimePrefillProduct, PrefillInput, PrefillOutput,
46};
47pub use recurrent_state::{
48    RecurrentStateHandle, RecurrentStateHandleStats, RecurrentStateManager,
49    RecurrentStateManagerStats, RecurrentStateResumePolicy, RecurrentStateSpec,
50    RecurrentStateTensorSpec,
51};
52pub use sampler::{
53    LogitsProcessor, Sampler, SamplingConfig, SamplingContext, SamplingRng,
54    SAMPLING_RNG_ALGORITHM_ID,
55};
56pub use scheduler::{BatchHint, BatchPlan, Scheduler as SchedulerInterface};
57pub use tensor::{TensorFactory, TensorLike, TensorOps, TensorRef};
58pub use tokenizer::{IncrementalTokenizer, Tokenizer, TokenizerFactory, TokenizerInfo};
59
60// Re-export types from ferrum-types, avoiding conflicts
61pub use ferrum_types::{
62    config::BackendConfig,
63    // Config types - use fully qualified names to avoid conflicts
64    config::EngineConfig,
65    config::SchedulerConfig,
66    config::TokenizerConfig,
67    BatchId,
68    BlockId,
69    ClientId,
70    ComponentHealth,
71    ComponentStatus,
72    DataType,
73    // Device types
74    Device,
75    EngineMetrics,
76    EngineStatus,
77    FerrumError,
78    FinishReason,
79    HealthStatus,
80    // Requests and responses
81    InferenceRequest,
82    InferenceResponse,
83    // Metrics
84    MemoryUsage,
85    ModelId,
86    // Model types
87    ModelInfo,
88    ModelSource,
89    ModelType,
90    Priority,
91    // IDs
92    RequestId,
93    Result,
94    // Sampling
95    SamplingParams,
96    SchedulerStats,
97    SessionId,
98    SpecialTokens,
99    StreamChunk,
100    TaskId,
101    // Basic types
102    TokenId,
103};