Implementation:Ggml org Llama cpp Arch Registry
| Knowledge Sources | |
|---|---|
| Domains | Model_Architecture |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Defines the static mapping tables that associate model architectures with their string names, GGUF key-value metadata keys, and tensor name schemas.
Description
Contains large `std::map` constants (`LLM_ARCH_NAMES`, `LLM_KV_NAMES`, and per-architecture tensor maps) that map enum values to their corresponding GGUF string identifiers. Supports 100+ model architectures (LLaMA, Falcon, GPT-2, Qwen, Gemma, DeepSeek, RWKV, Mamba, and many more) and provides lookup functions like `llm_arch_from_string` and `llm_arch_name`. Also defines which architectures are recurrent, hybrid, or diffusion-based.
Usage
This is a core registry component used internally by llama.cpp. All GGUF model file parsing depends on these mappings to identify architectures, read hyperparameters, and locate tensor data by name.
Code Reference
Source Location
- Repository: Ggml_org_Llama_cpp
- File: src/llama-arch.cpp
- Lines: 1-2809
Signature
// Architecture name mappings
static const std::map<llm_arch, const char *> LLM_ARCH_NAMES;
// Metadata key name mappings
static const std::map<llm_kv, const char *> LLM_KV_NAMES;
// Per-architecture tensor name mappings
static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_NAMES;
// Lookup functions
llm_arch llm_arch_from_string(const std::string & name);
const char * llm_arch_name(llm_arch arch);
// Architecture classification
bool llm_arch_is_recurrent(llm_arch arch);
bool llm_arch_is_hybrid(llm_arch arch);
bool llm_arch_is_diffusion(llm_arch arch);
Import
#include "llama-arch.h"
#include "llama-impl.h"
#include <map>
#include <set>
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | std::string | Yes | Architecture string name from GGUF metadata (for llm_arch_from_string) |
| arch | llm_arch | Yes | Architecture enum value (for llm_arch_name and classification functions) |
Outputs
| Name | Type | Description |
|---|---|---|
| arch | llm_arch | Architecture enum value resolved from string name |
| name | const char* | String name for a given architecture enum value |
| is_recurrent | bool | Whether the architecture uses recurrent layers (e.g., Mamba, RWKV) |
| is_hybrid | bool | Whether the architecture mixes attention and recurrent layers |
| is_diffusion | bool | Whether the architecture is diffusion-based |
Usage Examples
// Look up architecture from GGUF metadata string
llm_arch arch = llm_arch_from_string("llama");
// Returns LLM_ARCH_LLAMA
// Get the string name for an architecture
const char * name = llm_arch_name(LLM_ARCH_QWEN2);
// Returns "qwen2"
// Check architecture type
if (llm_arch_is_recurrent(arch)) {
// Use recurrent-specific code path (e.g., for Mamba, RWKV)
}
// Construct a GGUF key for a specific architecture
LLM_KV kv(LLM_ARCH_LLAMA);
std::string key = kv(LLM_KV_CONTEXT_LENGTH);
// Returns "llama.context_length"