/**
 * KV-Cache Configuration for Local LLM Inference
 *
 * Manages Key-Value cache settings for llama.cpp and LM Studio:
 * - Cache size estimation
 * - Quantization options (fp16, q8_0, q4_0)
 * - Context length management
 * - Memory offloading configuration
 */
import { EventEmitter } from 'events';
export type KVQuantization = 'f16' | 'f32' | 'q8_0' | 'q4_0' | 'q4_1';
export type OffloadMode = 'none' | 'partial' | 'full';
export interface ModelArchitecture {
    /** Number of layers */
    nLayers: number;
    /** Hidden dimension size */
    nEmbed: number;
    /** Number of attention heads */
    nHead: number;
    /** Number of key-value heads (for GQA) */
    nKVHead?: number;
    /** Head dimension (usually nEmbed / nHead) */
    headDim?: number;
}
export interface KVCacheConfig {
    /** Maximum context length */
    contextLength: number;
    /** KV cache quantization type */
    kvQuantization: KVQuantization;
    /** Memory offload mode */
    offloadMode: OffloadMode;
    /** Number of layers to offload to CPU */
    cpuOffloadLayers: number;
    /** Flash attention enabled */
    flashAttention: boolean;
    /** Batch size for continuous batching */
    batchSize: number;
    /** Ubatch size (micro-batch) */
    ubatchSize: number;
}
export interface KVCacheEstimate {
    /** Total KV cache size in bytes */
    totalBytes: number;
    /** Size per layer in bytes */
    perLayerBytes: number;
    /** GPU memory required (MB) */
    gpuMemoryMB: number;
    /** CPU memory required if offloading (MB) */
    cpuMemoryMB: number;
    /** Recommended configuration */
    recommendation: string;
    /** Whether it fits in available VRAM */
    fitsInVRAM: boolean;
}
export interface InferenceServerConfig {
    /** Base URL for the server */
    baseUrl: string;
    /** Server type */
    serverType: 'llamacpp' | 'lmstudio' | 'ollama' | 'vllm';
    /** KV cache configuration */
    kvCache: KVCacheConfig;
    /** Model architecture (for estimation) */
    architecture?: ModelArchitecture;
}
export declare const DEFAULT_KV_CACHE_CONFIG: KVCacheConfig;
export declare const MODEL_ARCHITECTURES: Record<string, ModelArchitecture>;
export declare class KVCacheManager extends EventEmitter {
    private config;
    private architecture;
    constructor(config?: Partial<KVCacheConfig>);
    /**
     * Set model architecture for accurate estimation
     */
    setArchitecture(arch: ModelArchitecture | string): void;
    /**
     * Estimate KV cache memory requirements
     */
    estimateMemory(contextLength?: number, batchSize?: number): KVCacheEstimate;
    /**
     * Generic estimation without model architecture
     */
    private estimateGeneric;
    /**
     * Generate configuration recommendation
     */
    private generateRecommendation;
    /**
     * Generate llama.cpp server arguments
     */
    generateLlamaCppArgs(): string[];
    /**
     * Generate LM Studio configuration
     */
    generateLMStudioConfig(): Record<string, unknown>;
    /**
     * Optimize configuration for available VRAM
     */
    optimizeForVRAM(availableVRAMMB: number, modelSizeMB: number): KVCacheConfig;
    /**
     * Get current configuration
     */
    getConfig(): KVCacheConfig;
    /**
     * Update configuration
     */
    updateConfig(config: Partial<KVCacheConfig>): void;
    /**
     * Format configuration for display
     */
    formatConfig(): string;
}
export declare function getKVCacheManager(config?: Partial<KVCacheConfig>): KVCacheManager;
export declare function resetKVCacheManager(): void;
