How ian-cowley/glacier.inference works
Glacier.Inference is a pure C# LLM inference engine and server runtime. The principal workflow is: a CLI user starts inference, the server creates a session, model files are parsed and loaded, hardware is selected, and tokens are generated and sampled. The repository also includes speculative decoding, staged multi-device execution, and embedding and media-input capabilities. The graph uses source-index references and excerpts for implementation links; broader runtime capabilities documented in the README are identified as such. Unsampled implementation details are not inferred.
Main entry points: InferenceSession.cs Inference session · GgufFile.cs GGUF loader · Pipeline Pipeline stages · DeviceManager.cs Device discovery
Components 19
Model ingestion
- GGUF loader
src/Glacier.Inference/Gguf/GgufFile.cs - GGUF types
src/Glacier.Inference/Gguf/GgufTypes.cs - Model weights
src/Glacier.Inference/Model/ModelWeights.cs
Inference runtime
- Inference session
src/Glacier.Inference/Engine/InferenceSession.cs - Model execution
src/Glacier.Inference/Model - Pipeline coordinator
src/Glacier.Inference/Pipeline/PipelineSession.cs - Pipeline stages
src/Glacier.Inference/Pipeline - KV cache
src/Glacier.Inference/Memory/KVCache.cs
Hardware execution
- Device discovery
src/Glacier.Inference/Hardware/DeviceManager.cs - Device capabilities
src/Glacier.Inference/Hardware/DeviceInfo.cs - GPU backends
src/Glacier.Inference/Gpu
Generation features
- BPE tokenizer
src/Glacier.Inference/Tokenizer/BpeTokenizer.cs - Token sampler
src/Glacier.Inference/Sampling/Sampler.cs - Speculative decoding
src/Glacier.Inference/Engine/SpeculativeEngine.cs - Embedding and media
src/Glacier.Inference/Embedding/EmbeddingGemma2Model.cs
User interfaces
- CLI commands
src/Glacier.Inference.Cli/Program.Commands.cs - Inference server
src/Glacier.Inference.Cli/Program.Serve.cs
Other components
- CLI user
- Model file
Connections 22
- CLI user → CLI commands: runs commands
src/Glacier.Inference.Cli/Program.Commands.cs - CLI user → Inference server: requests inference
src/Glacier.Inference.Cli/Program.Serve.cs - Inference server → Inference session: creates session
src/Glacier.Inference.Cli/Program.Serve.cs - Model file → GGUF loader: provides data
README.md - GGUF loader → GGUF types: uses definitions
src/Glacier.Inference/Gguf/GgufFile.cs - GGUF loader → Model weights: supplies tensors
src/Glacier.Inference/Model/ModelWeights.cs - Inference session → GGUF loader: loads model
src/Glacier.Inference/Engine/InferenceSession.cs - Inference session → Model weights: uses weights
src/Glacier.Inference/Engine/InferenceSession.cs - Inference session → Device discovery: selects device
src/Glacier.Inference/Engine/InferenceSession.cs - Device discovery → Device capabilities: enumerates capabilities
src/Glacier.Inference/Hardware/DeviceManager.cs - Device discovery → GPU backends: checks availability
src/Glacier.Inference/Hardware/DeviceManager.cs - Inference session → Model execution: executes inference
src/Glacier.Inference/Engine/InferenceSession.cs - Inference session → Pipeline coordinator: runs split model
src/Glacier.Inference/Engine/InferenceSession.cs - Pipeline coordinator → Pipeline stages: dispatches layers
src/Glacier.Inference/Pipeline/PipelineSession.cs - Pipeline stages → Model execution: executes stage
src/Glacier.Inference/Pipeline/CpuPipelineStage.cs - Pipeline stages → GPU backends: uses accelerator
src/Glacier.Inference/Pipeline/D3D12PipelineStage.cs - Inference session → KV cache: uses cache
src/Glacier.Inference/Engine/InferenceSession.cs - Inference session → BPE tokenizer: encodes prompt
src/Glacier.Inference/Engine/InferenceSession.cs - Inference session → Token sampler: samples tokens
README.md - Speculative decoding → Token sampler: uses sampling
src/Glacier.Inference/Engine/SpeculativeEngine.cs - Speculative decoding → Inference session: verifies candidates
- CLI user → Embedding and media: requests embeddings