# sgl-project/sgl-amd-mono architecture

> Architecture diagram of the GitHub repository sgl-project/sgl-amd-mono, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sgl-project/sgl-amd-mono
- Repository: https://github.com/sgl-project/sgl-amd-mono

## Overview

SGLang-AMD-Mono is an AMD GPU monokernel plugin for SGLang inference. SGLang routes supported decode and speculative-verification steps to model specs, which invoke persistent GPU kernels; unsupported steps remain on SGLang’s standard path. The model implementations cover distinct decoder stages such as attention, indexing, MoE/FFN, tensor-parallel reductions, and speculative-draft glue. Shared device utilities provide planning, synchronization, epoch tracking, and fail-stop guards. Model-specific paths and capabilities are grounded in the README and source index; unsampled implementation details are not expanded.

Main entry points: [`sgl_amd_mono`](https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono) (Model Specs), [`sgl_amd_mono/common/sync.py`](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/sync.py) (Tagged Mailboxes), [`sgl_amd_mono/glm53/gfx950/kernel.py`](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53/gfx950/kernel.py) (GLM-5.3 Kernels), [`sgl_amd_mono/common/guard.py`](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/guard.py) (Fail-stop Guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["SGLang Integration"]
  node_plugin["AMD Plugin<br/>[__init__.py]"]
  node_model_specs["Model Specs"]
end

subgraph group_runtime["Shared Runtime"]
  node_common_plan["Execution Planning<br/>[plan.py]"]
  node_common_ops["Device Operations<br/>[ops.py]"]
  node_common_sync["Tagged Mailboxes<br/>[sync.py]"]
  node_common_guard["Fail-stop Guard<br/>[guard.py]"]
  node_common_epoch["Launch Epochs<br/>[epoch.py]"]
  node_common_peer["Peer Coordination<br/>[peer.py]"]
  node_common_mx["MX Formats<br/>[mx.py]"]
end

subgraph group_deepseek["DeepSeek Kernels"]
  node_v41_spec["DeepSeek V4.1 Spec<br/>[spec.py]"]
  node_v41_index["Indexer Query<br/>[index_query.py]"]
  node_v41_stages["V4.1 Layer Stages"]
  node_v41_glue["Speculative Glue"]
  node_v4_spec["DeepSeek V4 Spec<br/>[spec.py]"]
end

subgraph group_models["Other Model Kernels"]
  node_glm53["GLM-5.3 Kernels<br/>[kernel.py]"]
  node_glm53_layout["GLM-5.3 Layout<br/>[layout.py]"]
  node_glm_flash["GLM Flash Kernels<br/>[kernel.py]"]
  node_kimi["Kimi K3 Stages<br/>[moe.py]"]
  node_kimi31["Kimi K3.1 Chain<br/>[chain.py]"]
  node_minimax["MiniMax M3 Layer<br/>[post_attn.py]"]
  node_minimax31["MiniMax M3.1 FFN<br/>[ffn.py]"]
  node_muse_draft["Muse Spark Draft<br/>[draft.py]"]
  node_qwen35["Qwen 3.5 FP8<br/>[verify.py]"]
  node_qwen38["Qwen 3.8 Layer<br/>[layer.py]"]
  node_qwen_flash["Qwen Flash Kernel<br/>[kernel.py]"]
end

node_sglang(("SGLang Serving"))

node_sglang -->|"loads plugin"| node_plugin
node_plugin -->|"registers specs"| node_model_specs
node_sglang -->|"routes decode"| node_model_specs
node_model_specs -->|"selects spec"| node_v41_spec
node_model_specs -->|"selects spec"| node_v4_spec
node_model_specs -.->|"dispatches supported steps"| node_glm53
node_model_specs -.->|"dispatches supported steps"| node_glm_flash
node_model_specs -.->|"dispatches supported steps"| node_kimi
node_model_specs -.->|"dispatches supported steps"| node_kimi31
node_model_specs -.->|"dispatches supported steps"| node_minimax
node_model_specs -.->|"dispatches supported steps"| node_minimax31
node_model_specs -.->|"dispatches draft steps"| node_muse_draft
node_model_specs -.->|"dispatches supported steps"| node_qwen35
node_model_specs -.->|"dispatches supported steps"| node_qwen38
node_model_specs -.->|"routes verify steps"| node_qwen_flash
node_v41_spec -->|"uses index query"| node_v41_index
node_v41_spec -.->|"runs layer stages"| node_v41_stages
node_v41_spec -->|"applies step glue"| node_v41_glue
node_v4_spec -->|"uses planning"| node_common_plan
node_v4_spec -->|"configures execution"| node_common_plan
node_glm53 -->|"uses layout"| node_glm53_layout
node_glm53 -->|"checks waits"| node_common_guard
node_glm53 -->|"tracks launches"| node_common_epoch
node_glm53 -->|"uses MX helpers"| node_common_mx
node_glm_flash -->|"checks waits"| node_common_guard
node_glm_flash -->|"tracks launches"| node_common_epoch
node_kimi -->|"uses mailboxes"| node_common_sync
node_kimi -->|"uses MX helpers"| node_common_mx
node_kimi31 -->|"uses KDA stage"| node_kimi
node_kimi31 -->|"coordinates peers"| node_common_peer
node_minimax -->|"uses mailboxes"| node_common_sync
node_minimax -->|"uses MX helpers"| node_common_mx
node_minimax31 -->|"uses mailboxes"| node_common_sync
node_qwen38 -->|"uses mailboxes"| node_common_sync
node_qwen38 -.->|"coordinates peers"| node_common_peer
node_qwen_flash -->|"checks waits"| node_common_guard
node_common_epoch -->|"uses guard layout"| node_common_guard
node_common_epoch -->|"spins via sync"| node_common_sync
node_common_sync -->|"guards polling"| node_common_guard
node_common_ops -->|"uses planning"| node_common_plan

click node_plugin "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/__init__.py"
click node_model_specs "https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono"
click node_common_plan "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/plan.py"
click node_common_ops "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/ops.py"
click node_common_sync "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/sync.py"
click node_common_guard "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/guard.py"
click node_common_epoch "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/epoch.py"
click node_common_peer "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/peer.py"
click node_common_mx "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/mx.py"
click node_v41_spec "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/deepseek_v41/spec.py"
click node_v41_index "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/deepseek_v41/gfx950/attention/index_query.py"
click node_v41_stages "https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono/deepseek_v41/gfx950/stages"
click node_v41_glue "https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono/deepseek_v41/glue"
click node_v4_spec "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/deepseek_v4/spec.py"
click node_glm53 "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53/gfx950/kernel.py"
click node_glm53_layout "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53/gfx950/layout.py"
click node_glm_flash "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53_flash/gfx950/kernel.py"
click node_kimi "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/kimi_k3/gfx950/stages/moe.py"
click node_kimi31 "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/kimi_k31/gfx950/chain.py"
click node_minimax "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/minimax_m3/gfx950/post_attn.py"
click node_minimax31 "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/minimax_m31/ffn.py"
click node_muse_draft "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/muse_spark/draft.py"
click node_qwen35 "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/qwen35_a17b/fp8/gfx950/verify.py"
click node_qwen38 "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/qwen38_a95b_mxfp4/gfx950/layer.py"
click node_qwen_flash "https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/qwen38_flash_next/gfx950/kernel.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_plugin,node_model_specs toneBlue
class node_common_plan,node_common_ops,node_common_sync,node_common_guard,node_common_epoch,node_common_peer,node_common_mx toneAmber
class node_v41_spec,node_v41_index,node_v41_stages,node_v41_glue,node_v4_spec toneMint
class node_glm53,node_glm53_layout,node_glm_flash,node_kimi,node_kimi31,node_minimax,node_minimax31,node_muse_draft,node_qwen35,node_qwen38,node_qwen_flash toneRose
class node_sglang toneIndigo
```

## Components

### SGLang Integration

- [AMD Plugin](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/__init__.py): `sgl_amd_mono/__init__.py`
- [Model Specs](https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono): `sgl_amd_mono`

### Shared Runtime

- [Execution Planning](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/plan.py): `sgl_amd_mono/common/plan.py`
- [Device Operations](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/ops.py): `sgl_amd_mono/common/ops.py`
- [Tagged Mailboxes](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/sync.py): `sgl_amd_mono/common/sync.py`
- [Fail-stop Guard](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/guard.py): `sgl_amd_mono/common/guard.py`
- [Launch Epochs](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/epoch.py): `sgl_amd_mono/common/epoch.py`
- [Peer Coordination](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/peer.py): `sgl_amd_mono/common/peer.py`
- [MX Formats](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/common/mx.py): `sgl_amd_mono/common/mx.py`

### DeepSeek Kernels

- [DeepSeek V4.1 Spec](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/deepseek_v41/spec.py): `sgl_amd_mono/deepseek_v41/spec.py`
- [Indexer Query](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/deepseek_v41/gfx950/attention/index_query.py): `sgl_amd_mono/deepseek_v41/gfx950/attention/index_query.py`
- [V4.1 Layer Stages](https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono/deepseek_v41/gfx950/stages): `sgl_amd_mono/deepseek_v41/gfx950/stages`
- [Speculative Glue](https://github.com/sgl-project/sgl-amd-mono/tree/main/sgl_amd_mono/deepseek_v41/glue): `sgl_amd_mono/deepseek_v41/glue`
- [DeepSeek V4 Spec](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/deepseek_v4/spec.py): `sgl_amd_mono/deepseek_v4/spec.py`

### Other Model Kernels

- [GLM-5.3 Kernels](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53/gfx950/kernel.py): `sgl_amd_mono/glm53/gfx950/kernel.py`
- [GLM-5.3 Layout](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53/gfx950/layout.py): `sgl_amd_mono/glm53/gfx950/layout.py`
- [GLM Flash Kernels](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/glm53_flash/gfx950/kernel.py): `sgl_amd_mono/glm53_flash/gfx950/kernel.py`
- [Kimi K3 Stages](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/kimi_k3/gfx950/stages/moe.py): `sgl_amd_mono/kimi_k3/gfx950/stages/moe.py`
- [Kimi K3.1 Chain](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/kimi_k31/gfx950/chain.py): `sgl_amd_mono/kimi_k31/gfx950/chain.py`
- [MiniMax M3 Layer](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/minimax_m3/gfx950/post_attn.py): `sgl_amd_mono/minimax_m3/gfx950/post_attn.py`
- [MiniMax M3.1 FFN](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/minimax_m31/ffn.py): `sgl_amd_mono/minimax_m31/ffn.py`
- [Muse Spark Draft](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/muse_spark/draft.py): `sgl_amd_mono/muse_spark/draft.py`
- [Qwen 3.5 FP8](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/qwen35_a17b/fp8/gfx950/verify.py): `sgl_amd_mono/qwen35_a17b/fp8/gfx950/verify.py`
- [Qwen 3.8 Layer](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/qwen38_a95b_mxfp4/gfx950/layer.py): `sgl_amd_mono/qwen38_a95b_mxfp4/gfx950/layer.py`
- [Qwen Flash Kernel](https://github.com/sgl-project/sgl-amd-mono/blob/main/sgl_amd_mono/qwen38_flash_next/gfx950/kernel.py): `sgl_amd_mono/qwen38_flash_next/gfx950/kernel.py`

### Other components

- **SGLang Serving**

## Connections

- SGLang Serving → AMD Plugin: loads plugin
- AMD Plugin → Model Specs: registers specs (evidence: `sgl_amd_mono/__init__.py`)
- SGLang Serving → Model Specs: routes decode
- Model Specs → DeepSeek V4.1 Spec: selects spec
- Model Specs → DeepSeek V4 Spec: selects spec (evidence: `sgl_amd_mono/deepseek_v4/spec.py`)
- Model Specs → GLM-5.3 Kernels: dispatches supported steps (evidence: `sgl_amd_mono/glm53/gfx950/kernel.py`)
- Model Specs → GLM Flash Kernels: dispatches supported steps (evidence: `sgl_amd_mono/glm53_flash/spec.py`)
- Model Specs → Kimi K3 Stages: dispatches supported steps (evidence: `sgl_amd_mono/kimi_k3/spec.py`)
- Model Specs → Kimi K3.1 Chain: dispatches supported steps (evidence: `sgl_amd_mono/kimi_k31/wide.py`)
- Model Specs → MiniMax M3 Layer: dispatches supported steps (evidence: `sgl_amd_mono/minimax_m3/gfx950/post_attn.py`)
- Model Specs → MiniMax M3.1 FFN: dispatches supported steps (evidence: `sgl_amd_mono/minimax_m31/ffn.py`)
- Model Specs → Muse Spark Draft: dispatches draft steps (evidence: `sgl_amd_mono/muse_spark/draft.py`)
- Model Specs → Qwen 3.5 FP8: dispatches supported steps (evidence: `sgl_amd_mono/qwen35_a17b/fp8/spec.py`)
- Model Specs → Qwen 3.8 Layer: dispatches supported steps (evidence: `sgl_amd_mono/qwen38_a95b_mxfp4/spec.py`)
- Model Specs → Qwen Flash Kernel: routes verify steps (evidence: `sgl_amd_mono/qwen38_flash_next/gfx950/kernel.py`)
- DeepSeek V4.1 Spec → Indexer Query: uses index query (evidence: `sgl_amd_mono/deepseek_v41/gfx950/attention/index_query.py`)
- DeepSeek V4.1 Spec → V4.1 Layer Stages: runs layer stages
- DeepSeek V4.1 Spec → Speculative Glue: applies step glue
- DeepSeek V4 Spec → Execution Planning: uses planning (evidence: `sgl_amd_mono/deepseek_v4/spec.py`)
- DeepSeek V4 Spec → Execution Planning: configures execution (evidence: `sgl_amd_mono/deepseek_v4/spec.py`)
- GLM-5.3 Kernels → GLM-5.3 Layout: uses layout (evidence: `sgl_amd_mono/glm53/gfx950/kernel.py`)
- GLM-5.3 Kernels → Fail-stop Guard: checks waits (evidence: `sgl_amd_mono/glm53/gfx950/kernel.py`)
- GLM-5.3 Kernels → Launch Epochs: tracks launches (evidence: `sgl_amd_mono/glm53/gfx950/kernel.py`)
- GLM-5.3 Kernels → MX Formats: uses MX helpers (evidence: `sgl_amd_mono/glm53/gfx950/kernel.py`)
- GLM Flash Kernels → Fail-stop Guard: checks waits (evidence: `sgl_amd_mono/glm53_flash/gfx950/kernel.py`)
- GLM Flash Kernels → Launch Epochs: tracks launches (evidence: `sgl_amd_mono/glm53_flash/gfx950/kernel.py`)
- Kimi K3 Stages → Tagged Mailboxes: uses mailboxes (evidence: `sgl_amd_mono/kimi_k3/gfx950/stages/moe.py`)
- Kimi K3 Stages → MX Formats: uses MX helpers (evidence: `sgl_amd_mono/kimi_k3/gfx950/stages/moe.py`)
- Kimi K3.1 Chain → Kimi K3 Stages: uses KDA stage
- Kimi K3.1 Chain → Peer Coordination: coordinates peers (evidence: `sgl_amd_mono/kimi_k31/wide.py`)
- MiniMax M3 Layer → Tagged Mailboxes: uses mailboxes (evidence: `sgl_amd_mono/minimax_m3/gfx950/post_attn.py`)
- MiniMax M3 Layer → MX Formats: uses MX helpers (evidence: `sgl_amd_mono/minimax_m3/gfx950/post_attn.py`)
- MiniMax M3.1 FFN → Tagged Mailboxes: uses mailboxes (evidence: `sgl_amd_mono/minimax_m31/ffn.py`)
- Qwen 3.8 Layer → Tagged Mailboxes: uses mailboxes (evidence: `sgl_amd_mono/qwen38_a95b_mxfp4/gfx950/layer.py`)
- Qwen 3.8 Layer → Peer Coordination: coordinates peers
- Qwen Flash Kernel → Fail-stop Guard: checks waits (evidence: `sgl_amd_mono/qwen38_flash_next/gfx950/kernel.py`)
- Launch Epochs → Fail-stop Guard: uses guard layout (evidence: `sgl_amd_mono/common/epoch.py`)
- Launch Epochs → Tagged Mailboxes: spins via sync (evidence: `sgl_amd_mono/common/epoch.py`)
- Tagged Mailboxes → Fail-stop Guard: guards polling (evidence: `sgl_amd_mono/common/sync.py`)
- Device Operations → Execution Planning: uses planning (evidence: `sgl_amd_mono/common/ops.py`)
