How avarok-cybersecurity/atlas works
Purpose and entry points
Atlas is a Rust LLM inference monorepo: it serves local, hardware-tuned model inference through OpenAI-, Anthropic-, and Responses-compatible HTTP APIs. The primary executable is spark-server, entered at crates/spark-server/src/main.rs; CLI serve configuration is defined under crates/spark-server/src/cli/serve_args.rs. A separate translation-oriented CLI exists at crates/spark-nllb/src/bin/nllb-translate.rs.
Server API and request normalization
spark-server owns HTTP lifecycle, authentication, rate limiting, request/session state, streaming, and protocol translation. OpenAI and Anthropic wire formats are lowered into a shared internal request/response representation, isolating inference from external API compatibility.
• crates/spark-server/src/api/mod.rs
• crates/spark-server/src/openai/to_ir.rs
• crates/spark-server/src/anthropic/to_ir.rs
• crates/spark-server/src/ir/request.rs
Startup, model resolution, and construction
The server’s staged startup builds app state, resolves a model, initializes tokenizer/runtime/KV cache/topology, loads weights, and constructs the executable model. Model-family configuration parsing and factory dispatch are separate from per-family weight loaders, allowing new model support without changing serving or scheduling.
• crates/spark-server/src/main_modules/serve_phases/mod.rs
• crates/spark-server/src/model_resolver.rs
• crates/spark-model/src/factory.rs
• crates/spark-model/src/weight_loader/mod.rs
• crates/atlas-core/src/config/parsers/mod.rs
Scheduling and generation control
The scheduler is the central control plane after admission: it manages sequence lifecycle, batched prefill and decode, token emission, sampling/logprobs, speculative/MTP verification, rollback, and per-request grammar/logit constraints. Requests flow API → tokenizer/preparation → scheduler → model forward steps → streamed or blocking API responses.
• crates/spark-server/src/scheduler/mod.rs
• crates/spark-server/src/scheduler/phase_start_prefills.rs
• crates/spark-server/src/scheduler/decode_step.rs
• crates/spark-server/src/scheduler/spec_step.rs
Model execution and architectural variants
spark-model implements the generic model engine and composes transformer layers from attention, SSM/GDN or Mamba paths, dense FFNs, routed/shared MoE, vision encoders, and MTP heads. It separates prefill from decode and keeps model-specific loading/mapping at the weight boundary. Tensor-parallel sharding and expert-parallel dispatch are model-level concerns.
• crates/spark-model/src/engine.rs
• crates/spark-model/src/layer/transformer_layer.rs
• crates/spark-model/src/layers/qwen3_attention/mod.rs
• crates/spark-model/src/layers/moe/mod.rs
• crates/spark-model/src/tp_shard.rs
Runtime, kernels, and hardware boundary
The runtime provides GPU buffers, launches, paged KV cache, sampling, and backend-specific CUDA or Metal implementations. Build-time kernel discovery/compilation bridges Rust dispatch to hardware/model/quant-specific CUDA or Metal sources. Current kernel inventory covers GB10, Strix/Strix HIP, and Metal targets; CUDA integrations include cuBLASLt, CUTLASS, and FlashInfer.
• crates/spark-runtime/src/gpu.rs
• crates/spark-runtime/src/cuda_backend.rs
• crates/spark-runtime/src/metal_backend.rs
• crates/atlas-kernels/build.rs
• kernels/gb10/common/KERNEL.toml
Stateful memory, distributed execution, and constrained output
KV state is paged and prefix-cached in runtime; storage extends this to NVMe/io_uring, mmap, and RDMA-backed paging/swap for long contexts. NCCL communication supports multi-GPU collectives/expert parallelism, while xgrammar compiles schemas/grammars into token masks consumed by server grammar and scheduler logit-processing paths.
• crates/spark-runtime/src/kv_cache/paged_impl.rs
• crates/spark-runtime/src/prefix_cache.rs
• crates/spark-storage/src/kv_paging/backend.rs
• crates/spark-storage/src/high_speed_swap.rs
• crates/spark-comm/src/nccl_backend.rs
• crates/xgrammar/src/api/compiler.rs
Main entry points: scheduler/mod.rs Scheduler · engine.rs Model engine · api/mod.rs HTTP API · main.rs spark-server
Components 23
Serving
HTTP serving, normalization, startup, and generation control.
- spark-server · Primary inference server entry point.
crates/spark-server/src/main.rs - Serve CLI
crates/spark-server/src/cli/serve_args.rs - Serve phases · Builds state and initializes executable inference.
crates/spark-server/src/main_modules/serve_phases/mod.rs - HTTP API · Owns authentication, admission, sessions, and response streaming.
crates/spark-server/src/api/mod.rs - OpenAI lowering
crates/spark-server/src/openai/to_ir.rs - Anthropic lowering
crates/spark-server/src/anthropic/to_ir.rs - Request IR · Shared inference request and response representation.
crates/spark-server/src/ir/request.rs - Scheduler · Runs sequence lifecycle, batching, decode, sampling, and token emission.
crates/spark-server/src/scheduler/mod.rs - Prefill phase
crates/spark-server/src/scheduler/phase_start_prefills.rs - Decode and spec · Per-token decode, speculative verification, and rollback.
crates/spark-server/src/scheduler/decode_step.rs
Model execution
Model construction and transformer execution.
- Model resolver
crates/spark-server/src/model_resolver.rs - Model config parsers
crates/atlas-core/src/config/parsers/mod.rs - Model factory · Dispatches model-family construction and loading.
crates/spark-model/src/factory.rs - Weight loaders · Per-family loading and tensor mapping.
crates/spark-model/src/weight_loader/mod.rs - Model engine · Separates prefill and decode model execution.
crates/spark-model/src/engine.rs - Transformer layers · Composes attention, FFN, SSM, MoE, vision, and MTP variants.
crates/spark-model/src/layer/transformer_layer.rs - MoE layers · Routed and shared expert execution.
crates/spark-model/src/layers/moe/mod.rs
Runtime platform
Hardware execution, state, storage, and distributed support.
- GPU runtime · Provides buffers, launches, sampling, and backend dispatch.
crates/spark-runtime/src/gpu.rs - Paged KV cache · Paged attention state for active sequences.
crates/spark-runtime/src/kv_cache/paged_impl.rs - KV storage paging · Extends KV paging to persistent and remote storage.
crates/spark-storage/src/kv_paging/backend.rs - NCCL backend · Multi-GPU and expert-parallel communication.
crates/spark-comm/src/nccl_backend.rs - Grammar compiler · Compiles schemas and grammars into token masks.
crates/xgrammar/src/api/compiler.rs - Kernel build · Discovers and compiles target-specific CUDA and Metal kernels.
crates/atlas-kernels/build.rs
Connections 26
- Serve CLI → spark-server: configures
- spark-server → Serve phases: starts
- spark-server → HTTP API: serves
- Serve phases → Model resolver: resolves model
- Model resolver → Model config parsers: parses family config
- Model resolver → Model factory: selects
- Model factory → Weight loaders: loads weights
- Model factory → Model engine: constructs
- OpenAI lowering → Request IR: normalizes
- Anthropic lowering → Request IR: normalizes
- HTTP API → OpenAI lowering: OpenAI requests
- HTTP API → Anthropic lowering: Anthropic requests
- Request IR → Scheduler: admitted requests
- Scheduler → Prefill phase: batches prompts
- Scheduler → Decode and spec: generates tokens
- Prefill phase → Model engine: prefill forward
- Decode and spec → Model engine: decode forward
- Model engine → Transformer layers: executes layers
- Transformer layers → MoE layers: routes experts
- Model engine → GPU runtime: launches tensors
- Scheduler → Paged KV cache: manages sequence state
- Paged KV cache → KV storage paging: pages and swaps
- Model engine → NCCL backend: parallel collectives
- Scheduler → Grammar compiler: applies token masks
- GPU runtime → Kernel build: uses compiled kernels
- Scheduler → HTTP API: streamed or blocking response