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