# longhornsilicon/lambda architecture

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

- Interactive diagram: https://gitdiagram.com/longhornsilicon/lambda
- Repository: https://github.com/longhornsilicon/lambda

## Overview

Lambda is a monorepo for LonghornSilicon’s LLM decode-attention accelerator. Its documented decode path computes Q·Kᵀ, applies online softmax, then computes P·V; KV compression, token-importance management, and ACU precision selection support that datapath. The tree also contains software reference models and a separate APA precision-policy research project. The graph uses README-documented relationships for the chip-level flow and excerpted source relationships for research code; many RTL, integration, and peripheral implementations were not sampled, so their internal wiring is not inferred.

Main entry points: [`src/blocks/acu/mate`](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/mate) (MatE), [`research/apa-precision-policy/common/reference.py`](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/reference.py) (Attention Reference), [`research/apa-precision-policy/phase1_policy/evaluator.py`](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/phase1_policy/evaluator.py) (Policy Evaluator), [`src/blocks/acu/vecu`](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/vecu) (VecU)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_attention["Attention Compute"]
  node_mate["MatE"]
  node_vecu["VecU"]
  node_attention_result["Attention Output"]
  node_precision_gate["Precision Gate"]
end

subgraph group_state["Decode State"]
  node_kve[("KV Cache Engine")]
  node_tiu["Token Importance"]
end

subgraph group_models["Reference Models"]
  node_mate_model["MatE Reference<br/>[mac_array_ref.cpp]"]
  node_sparsity_model["Sparsity Model"]
  node_precision_model["Precision Reference"]
  node_vecu_model["VecU Softmax Model"]
  node_kve_model["KV Engine Reference"]
  node_tiu_model["TIU Reference<br/>[tiu_ref.py]"]
end

subgraph group_research["Precision Research"]
  node_apa_evaluator["Policy Evaluator<br/>[evaluator.py]"]
  node_attention_reference["Attention Reference<br/>[reference.py]"]
  node_block_stats["Block Statistics<br/>[block_stats.py]"]
  node_quantization["Quantization<br/>[quantization.py]"]
  node_workloads["Workload Sets<br/>[workloads.py]"]
end

node_request(("Decode Request"))

node_request -->|"initiates decode"| node_mate
node_mate -->|"scores to softmax"| node_vecu
node_vecu -->|"probabilities for PV"| node_mate
node_mate -->|"produces output"| node_attention_result
node_kve -.->|"supplies KV state"| node_mate
node_tiu -.->|"manages token importance"| node_mate
node_precision_gate -.->|"selects precision"| node_mate
node_apa_evaluator -->|"evaluates against"| node_attention_reference
node_apa_evaluator -->|"loads workloads"| node_workloads
node_attention_reference -->|"computes statistics"| node_block_stats
node_attention_reference -->|"quantizes blocks"| node_quantization

click node_mate "https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/mate"
click node_vecu "https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/vecu"
click node_kve "https://github.com/longhornsilicon/lambda/tree/main/src/blocks/kve"
click node_tiu "https://github.com/longhornsilicon/lambda/tree/main/src/blocks/tiu"
click node_precision_gate "https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/precision_controller"
click node_mate_model "https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/mate/sw/reference_model/mac_array_ref.cpp"
click node_sparsity_model "https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/mate/sw/reference_model/sparsity_controller_ref.py"
click node_precision_model "https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/precision_controller/sw/reference_model/precision_controller_ref.py"
click node_vecu_model "https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/vecu/sw/reference_model/vecu_softmax_ref.py"
click node_kve_model "https://github.com/longhornsilicon/lambda/blob/main/src/blocks/kve/sw/reference_model/kv_cache_engine_ref.py"
click node_tiu_model "https://github.com/longhornsilicon/lambda/blob/main/src/blocks/tiu/sw/reference_model/tiu_ref.py"
click node_apa_evaluator "https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/phase1_policy/evaluator.py"
click node_attention_reference "https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/reference.py"
click node_block_stats "https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/block_stats.py"
click node_quantization "https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/quantization.py"
click node_workloads "https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/workloads.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_mate,node_vecu,node_attention_result,node_precision_gate toneBlue
class node_kve,node_tiu toneAmber
class node_mate_model,node_sparsity_model,node_precision_model,node_vecu_model,node_kve_model,node_tiu_model,node_request toneMint
class node_apa_evaluator,node_attention_reference,node_block_stats,node_quantization,node_workloads toneRose
```

## Components

### Attention Compute

- [MatE](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/mate): `src/blocks/acu/mate`
- [VecU](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/vecu): `src/blocks/acu/vecu`
- **Attention Output**
- [Precision Gate](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/acu/precision_controller): `src/blocks/acu/precision_controller`

### Decode State

- [KV Cache Engine](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/kve): `src/blocks/kve`
- [Token Importance](https://github.com/longhornsilicon/lambda/tree/main/src/blocks/tiu): `src/blocks/tiu`

### Reference Models

- [MatE Reference](https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/mate/sw/reference_model/mac_array_ref.cpp): `src/blocks/acu/mate/sw/reference_model/mac_array_ref.cpp`
- [Sparsity Model](https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/mate/sw/reference_model/sparsity_controller_ref.py): `src/blocks/acu/mate/sw/reference_model/sparsity_controller_ref.py`
- [Precision Reference](https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/precision_controller/sw/reference_model/precision_controller_ref.py): `src/blocks/acu/precision_controller/sw/reference_model/precision_controller_ref.py`
- [VecU Softmax Model](https://github.com/longhornsilicon/lambda/blob/main/src/blocks/acu/vecu/sw/reference_model/vecu_softmax_ref.py): `src/blocks/acu/vecu/sw/reference_model/vecu_softmax_ref.py`
- [KV Engine Reference](https://github.com/longhornsilicon/lambda/blob/main/src/blocks/kve/sw/reference_model/kv_cache_engine_ref.py): `src/blocks/kve/sw/reference_model/kv_cache_engine_ref.py`
- [TIU Reference](https://github.com/longhornsilicon/lambda/blob/main/src/blocks/tiu/sw/reference_model/tiu_ref.py): `src/blocks/tiu/sw/reference_model/tiu_ref.py`

### Precision Research

- [Policy Evaluator](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/phase1_policy/evaluator.py): `research/apa-precision-policy/phase1_policy/evaluator.py`
- [Attention Reference](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/reference.py): `research/apa-precision-policy/common/reference.py`
- [Block Statistics](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/block_stats.py): `research/apa-precision-policy/common/block_stats.py`
- [Quantization](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/quantization.py): `research/apa-precision-policy/common/quantization.py`
- [Workload Sets](https://github.com/longhornsilicon/lambda/blob/main/research/apa-precision-policy/common/workloads.py): `research/apa-precision-policy/common/workloads.py`

### Other components

- **Decode Request**

## Connections

- Decode Request → MatE: initiates decode (evidence: `README.md`)
- MatE → VecU: scores to softmax (evidence: `README.md`)
- VecU → MatE: probabilities for PV (evidence: `README.md`)
- MatE → Attention Output: produces output (evidence: `README.md`)
- KV Cache Engine → MatE: supplies KV state (evidence: `README.md`)
- Token Importance → MatE: manages token importance (evidence: `README.md`)
- Precision Gate → MatE: selects precision (evidence: `README.md`)
- Policy Evaluator → Attention Reference: evaluates against (evidence: `research/apa-precision-policy/phase1_policy/evaluator.py`)
- Policy Evaluator → Workload Sets: loads workloads (evidence: `research/apa-precision-policy/phase1_policy/evaluator.py`)
- Attention Reference → Block Statistics: computes statistics (evidence: `research/apa-precision-policy/common/reference.py`)
- Attention Reference → Quantization: quantizes blocks (evidence: `research/apa-precision-policy/common/reference.py`)
