vllm.model_executor.models.moondream3
¶
Inference-only Moondream3 model implementation.
Classes:
-
Moondream3Attention–Decoder attention with RoPE and tau scaling.
-
Moondream3DecoderLayer–Decoder layer with attention + MLP/MoE.
-
Moondream3DummyInputsBuilder–Dummy inputs builder for profiling.
-
Moondream3ForCausalLM–Moondream3 multimodal model for causal language modeling.
-
Moondream3ImageInput–Container holding per-image inputs for embedding.
-
Moondream3MultiModalProcessor–Multimodal processor for Moondream3.
-
Moondream3ProcessingInfo–Processing info for Moondream3.
-
Moondream3TextMLP–Standard MLP for non-MoE layers (layers 0-3).
-
Moondream3TextMoE–Mixture of Experts layer for layers 4+ with expert parallelism.
-
Moondream3TextModel–Text decoder model.
-
Moondream3VisionAttention–Self-attention for vision encoder (bidirectional).
-
Moondream3VisionBlock–Transformer block for vision encoder.
-
Moondream3VisionEncoder–Vision encoder (SigLIP-style ViT).
-
Moondream3VisionMLP–MLP for vision encoder blocks.
-
Moondream3VisionProjection–Projects vision features to text embedding dimension.
Functions:
-
reconstruct_from_crops–Reconstruct features from overlapping crops.
Moondream3Attention
¶
Bases: Module
Decoder attention with RoPE and tau scaling.
Moondream3 uses a tau attention mechanism that scales Q and V based on both token content and position.
Moondream3DummyInputsBuilder
¶
Moondream3ForCausalLM
¶
Bases: Module, SupportsMultiModal, SupportsPP
Moondream3 multimodal model for causal language modeling.
vLLM supports the standard autoregressive Moondream3 query and caption prompt formats. The region-module point/detect skills require custom coordinate decoding and are intentionally not exposed here.
Methods:
-
embed_multimodal–Generate the HF image prefix: BOS embedding + 729 image embeddings.
-
load_weights–Load weights with remapping from HuggingFace format.
Moondream3ImageInput
dataclass
¶
Container holding per-image inputs for embedding.
Moondream3MultiModalProcessor
¶
Moondream3ProcessingInfo
¶
Moondream3TextMoE
¶
Bases: Module
Mixture of Experts layer for layers 4+ with expert parallelism.
Moondream3 uses a custom GeGLU activation: gelu(h) * (g + 1) where fc1 outputs [gate, up] and the activation is gelu(gate) * (up + 1).
Uses expert parallelism where each GPU stores num_experts/tp_size experts. Routing and communication handled via all-to-all or replicated computation.
Checkpoint format: - fc1.weight: [num_experts, expert_inner_dim * 2, hidden_size] (gate+up) - fc2.weight: [num_experts, hidden_size, expert_inner_dim] (down) - router.weight: [num_experts, hidden_size] - router.bias: [num_experts]
Methods:
-
forward–Forward pass with expert parallelism and custom GeGLU activation.
Moondream3VisionEncoder
¶
Bases: Module
Vision encoder (SigLIP-style ViT).
Methods:
-
create_patches–Convert images to patch embeddings.
-
forward–Encode images.
create_patches(images)
¶
reconstruct_from_crops(crops, tiling, overlap_margin, patch_size=14)
¶
Reconstruct features from overlapping crops.