# tencent/angelslim architecture

> Architecture diagram of the GitHub repository tencent/angelslim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tencent/angelslim
- Repository: https://github.com/tencent/angelslim

## Overview

AngelSlim is a broad large-model compression toolkit. A typical workflow configures a model and compression strategy, prepares calibration or training data, runs compression, and exports a deployable model; the README also documents sparse attention, token compression, diffusion optimization, and speculative decoding. The graph preserves these product branches. Several internal paths are represented at subsystem-directory level because their implementations were not excerpted; those relationships are therefore omitted or marked unverified rather than inferred from names alone.

Main entry points: [`angelslim/engine.py`](https://github.com/tencent/angelslim/blob/main/angelslim/engine.py) (Compression engine), [`angelslim/compressor/quant/core`](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/core) (Quantization core), [`angelslim/compressor/compressor_factory.py`](https://github.com/tencent/angelslim/blob/main/angelslim/compressor/compressor_factory.py) (Compressor factory), [`angelslim/compressor/quant/ptq.py`](https://github.com/tencent/angelslim/blob/main/angelslim/compressor/quant/ptq.py) (Post-training quantization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Workflow and models"]
  node_engine["Compression engine<br/>[engine.py]"]
  node_configs["Config parsing<br/>[config_parser.py]"]
  node_modelzoo["Model adapters"]
  node_compressors["Compressor factory"]
end

subgraph group_quant["Quantization and transforms"]
  node_ptq["Post-training quantization<br/>[ptq.py]"]
  node_quantcore["Quantization core"]
  node_quantmethods["Quantization methods"]
  node_transform["Model transforms"]
  node_export["Quantized model export<br/>[save.py]"]
end

subgraph group_runtime["Inference optimization"]
  node_sparsity["Sparse attention"]
  node_tokcomp["Token compression"]
  node_diffusion["Diffusion optimization"]
  node_specdecode["Speculative decoding"]
end

subgraph group_learning["Training and distillation"]
  node_mcoreqad["Megatron QAD"]
  node_qat["Quant-aware training<br/>[qat.py]"]
  node_distill["Distillation"]
end

subgraph group_data["Data and calibration"]
  node_datasets["Data loaders<br/>[dataloader.py]"]
  node_calibration["vLLM calibration"]
end

node_user(("Engineer"))

node_user -->|"configures and runs"| node_engine
node_engine -->|"loads configuration"| node_configs
node_engine -->|"loads model"| node_modelzoo
node_engine -->|"creates data loader"| node_datasets
node_engine -->|"creates compressor"| node_compressors
node_compressors -.->|"offers quantization"| node_ptq
node_ptq -.->|"uses quantization core"| node_quantcore
node_quantcore -.->|"provides method modules"| node_quantmethods
node_quantcore -.->|"saves quantized models"| node_export
node_user -->|"runs distributed QAD"| node_mcoreqad
node_user -->|"trains quant-aware models"| node_qat
node_user -->|"distills models"| node_distill
node_user -->|"applies model transforms"| node_transform
node_user -->|"uses sparse attention"| node_sparsity
node_user -.->|"compresses tokens"| node_tokcomp
node_user -->|"optimizes diffusion"| node_diffusion
node_user -->|"trains speculative decoding"| node_specdecode
node_user -->|"calibrates activations"| node_calibration

click node_engine "https://github.com/tencent/angelslim/blob/main/angelslim/engine.py"
click node_configs "https://github.com/tencent/angelslim/blob/main/angelslim/utils/config_parser.py"
click node_modelzoo "https://github.com/tencent/angelslim/tree/main/angelslim/models"
click node_compressors "https://github.com/tencent/angelslim/blob/main/angelslim/compressor/compressor_factory.py"
click node_datasets "https://github.com/tencent/angelslim/blob/main/angelslim/data/dataloader.py"
click node_ptq "https://github.com/tencent/angelslim/blob/main/angelslim/compressor/quant/ptq.py"
click node_quantcore "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/core"
click node_quantmethods "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/modules"
click node_mcoreqad "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/mcore_qad"
click node_qat "https://github.com/tencent/angelslim/blob/main/angelslim/compressor/qat/qat.py"
click node_distill "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/distill"
click node_transform "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/transform"
click node_sparsity "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/sparsity"
click node_tokcomp "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/token_compressor"
click node_diffusion "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/diffusion"
click node_specdecode "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/speculative"
click node_calibration "https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/core/vllm_calibrate_utils"
click node_export "https://github.com/tencent/angelslim/blob/main/angelslim/compressor/quant/core/save.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_engine,node_configs,node_modelzoo,node_compressors toneBlue
class node_ptq,node_quantcore,node_quantmethods,node_transform,node_export toneAmber
class node_sparsity,node_tokcomp,node_diffusion,node_specdecode toneMint
class node_mcoreqad,node_qat,node_distill toneRose
class node_datasets,node_calibration,node_user toneIndigo
```

## Components

### Workflow and models

- [Compression engine](https://github.com/tencent/angelslim/blob/main/angelslim/engine.py): `angelslim/engine.py`
- [Config parsing](https://github.com/tencent/angelslim/blob/main/angelslim/utils/config_parser.py): `angelslim/utils/config_parser.py`
- [Model adapters](https://github.com/tencent/angelslim/tree/main/angelslim/models): `angelslim/models`
- [Compressor factory](https://github.com/tencent/angelslim/blob/main/angelslim/compressor/compressor_factory.py): `angelslim/compressor/compressor_factory.py`

### Quantization and transforms

- [Post-training quantization](https://github.com/tencent/angelslim/blob/main/angelslim/compressor/quant/ptq.py): `angelslim/compressor/quant/ptq.py`
- [Quantization core](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/core): `angelslim/compressor/quant/core`
- [Quantization methods](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/modules): `angelslim/compressor/quant/modules`
- [Model transforms](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/transform): `angelslim/compressor/transform`
- [Quantized model export](https://github.com/tencent/angelslim/blob/main/angelslim/compressor/quant/core/save.py): `angelslim/compressor/quant/core/save.py`

### Inference optimization

- [Sparse attention](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/sparsity): `angelslim/compressor/sparsity`
- [Token compression](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/token_compressor): `angelslim/compressor/token_compressor`
- [Diffusion optimization](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/diffusion): `angelslim/compressor/diffusion`
- [Speculative decoding](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/speculative): `angelslim/compressor/speculative`

### Training and distillation

- [Megatron QAD](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/mcore_qad): `angelslim/compressor/mcore_qad`
- [Quant-aware training](https://github.com/tencent/angelslim/blob/main/angelslim/compressor/qat/qat.py): `angelslim/compressor/qat/qat.py`
- [Distillation](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/distill): `angelslim/compressor/distill`

### Data and calibration

- [Data loaders](https://github.com/tencent/angelslim/blob/main/angelslim/data/dataloader.py): `angelslim/data/dataloader.py`
- [vLLM calibration](https://github.com/tencent/angelslim/tree/main/angelslim/compressor/quant/core/vllm_calibrate_utils): `angelslim/compressor/quant/core/vllm_calibrate_utils`

### Other components

- **Engineer**

## Connections

- Engineer → Compression engine: configures and runs (evidence: `README.md`)
- Compression engine → Config parsing: loads configuration (evidence: `angelslim/engine.py`)
- Compression engine → Model adapters: loads model (evidence: `angelslim/engine.py`)
- Compression engine → Data loaders: creates data loader (evidence: `angelslim/engine.py`)
- Compression engine → Compressor factory: creates compressor (evidence: `angelslim/engine.py`)
- Compressor factory → Post-training quantization: offers quantization
- Post-training quantization → Quantization core: uses quantization core
- Quantization core → Quantization methods: provides method modules (evidence: `angelslim/compressor/quant/modules/daq/scale_search.py`)
- Quantization core → Quantized model export: saves quantized models (evidence: `angelslim/compressor/quant/core/__init__.py`)
- Engineer → Megatron QAD: runs distributed QAD (evidence: `README.md`)
- Engineer → Quant-aware training: trains quant-aware models (evidence: `README.md`)
- Engineer → Distillation: distills models (evidence: `README.md`)
- Engineer → Model transforms: applies model transforms (evidence: `README.md`)
- Engineer → Sparse attention: uses sparse attention (evidence: `README.md`)
- Engineer → Token compression: compresses tokens
- Engineer → Diffusion optimization: optimizes diffusion (evidence: `README.md`)
- Engineer → Speculative decoding: trains speculative decoding (evidence: `README.md`)
- Engineer → vLLM calibration: calibrates activations
