# jessesme/granite-llm-test architecture

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

- Interactive diagram: https://gitdiagram.com/jessesme/granite-llm-test
- Repository: https://github.com/jessesme/granite-llm-test

## Overview

tinyllm is a register-based SystemVerilog implementation of Granite 4.0-H-350M decoder layers, with model weights baked into the design. Its documented end-to-end path starts with token embeddings, processes a hybrid stack of Mamba2 and attention decoder layers, then applies the tied embedding/LM head to produce logits. A single-layer wrapper combines normalization, a Mamba2 mixer, residual addition and MLP; the documented hybrid check runs one RTL layer and the remaining layers in software. The supplied tree omits RTL files, so paths below use the exact unit directories present in the tree; edges follow README-described behavior.

Main entry points: [`src/granite_layer`](https://github.com/jessesme/granite-llm-test/tree/main/src/granite_layer) (32-layer decoder), [`src/mamba2_unit`](https://github.com/jessesme/granite-llm-test/tree/main/src/mamba2_unit) (Mamba2 layer), [`src/embedding_lookup_unit`](https://github.com/jessesme/granite-llm-test/tree/main/src/embedding_lookup_unit) (Token embedding), [`src/output_projection_unit`](https://github.com/jessesme/granite-llm-test/tree/main/src/output_projection_unit) (LM projection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input_output["Input and output"]
  node_embedding["Token embedding"]
  node_output_projection["LM projection"]
end

subgraph group_mamba_stack["Mamba processing"]
  node_mamba_layer["Mamba2 layer"]
  node_conv1d["Causal Conv1D"]
  node_ssm["State-space scan"]
end

subgraph group_attention_stack["Attention processing"]
  node_attention["Attention layer"]
  node_softmax["Softmax"]
end

subgraph group_layer_support["Layer support"]
  node_decoder_stack["32-layer decoder"]
  node_matrix["Matrix operations"]
  node_rmsnorm["RMS normalization"]
  node_residual["Residual addition"]
  node_mlp["MLP"]
  node_silu["SiLU activation"]
  node_sigmoid["Sigmoid activation"]
end

node_user(("Token input"))
node_logits["Token logits"]

node_user -->|"provides token"| node_embedding
node_embedding -->|"feeds embeddings"| node_decoder_stack
node_decoder_stack -->|"uses 28 layers"| node_mamba_layer
node_decoder_stack -->|"uses 4 layers"| node_attention
node_mamba_layer -->|"includes convolution"| node_conv1d
node_mamba_layer -->|"includes scan"| node_ssm
node_decoder_stack -->|"normalizes"| node_rmsnorm
node_decoder_stack -->|"adds residuals"| node_residual
node_decoder_stack -->|"applies MLP"| node_mlp
node_decoder_stack -.->|"uses projections"| node_matrix
node_mlp -.->|"uses activation"| node_silu
node_attention -.->|"normalizes scores"| node_softmax
node_decoder_stack -->|"projects hidden state"| node_output_projection
node_embedding -->|"shares tied weights"| node_output_projection
node_output_projection -->|"produces logits"| node_logits
node_mamba_layer -.->|"activation support"| node_sigmoid

click node_embedding "https://github.com/jessesme/granite-llm-test/tree/main/src/embedding_lookup_unit"
click node_decoder_stack "https://github.com/jessesme/granite-llm-test/tree/main/src/granite_layer"
click node_mamba_layer "https://github.com/jessesme/granite-llm-test/tree/main/src/mamba2_unit"
click node_conv1d "https://github.com/jessesme/granite-llm-test/tree/main/src/conv1d_unit"
click node_ssm "https://github.com/jessesme/granite-llm-test/tree/main/src/SSM_unit"
click node_attention "https://github.com/jessesme/granite-llm-test/tree/main/src/attention_unit"
click node_matrix "https://github.com/jessesme/granite-llm-test/tree/main/src/matrix_unit"
click node_rmsnorm "https://github.com/jessesme/granite-llm-test/tree/main/src/RMSNorm_unit"
click node_residual "https://github.com/jessesme/granite-llm-test/tree/main/src/residual_adder_unit"
click node_mlp "https://github.com/jessesme/granite-llm-test/tree/main/src/mlp_unit"
click node_silu "https://github.com/jessesme/granite-llm-test/tree/main/src/SiLU_unit"
click node_sigmoid "https://github.com/jessesme/granite-llm-test/tree/main/src/sigmoid_unit"
click node_softmax "https://github.com/jessesme/granite-llm-test/tree/main/src/softmax_unit"
click node_output_projection "https://github.com/jessesme/granite-llm-test/tree/main/src/output_projection_unit"

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_embedding,node_output_projection toneBlue
class node_mamba_layer,node_conv1d,node_ssm toneAmber
class node_attention,node_softmax toneMint
class node_decoder_stack,node_matrix,node_rmsnorm,node_residual,node_mlp,node_silu,node_sigmoid toneRose
class node_user,node_logits toneIndigo
```

## Components

### Input and output

- [Token embedding](https://github.com/jessesme/granite-llm-test/tree/main/src/embedding_lookup_unit): `src/embedding_lookup_unit`
- [LM projection](https://github.com/jessesme/granite-llm-test/tree/main/src/output_projection_unit): `src/output_projection_unit`

### Mamba processing

- [Mamba2 layer](https://github.com/jessesme/granite-llm-test/tree/main/src/mamba2_unit): `src/mamba2_unit`
- [Causal Conv1D](https://github.com/jessesme/granite-llm-test/tree/main/src/conv1d_unit): `src/conv1d_unit`
- [State-space scan](https://github.com/jessesme/granite-llm-test/tree/main/src/SSM_unit): `src/SSM_unit`

### Attention processing

- [Attention layer](https://github.com/jessesme/granite-llm-test/tree/main/src/attention_unit): `src/attention_unit`
- [Softmax](https://github.com/jessesme/granite-llm-test/tree/main/src/softmax_unit): `src/softmax_unit`

### Layer support

- [32-layer decoder](https://github.com/jessesme/granite-llm-test/tree/main/src/granite_layer): `src/granite_layer`
- [Matrix operations](https://github.com/jessesme/granite-llm-test/tree/main/src/matrix_unit): `src/matrix_unit`
- [RMS normalization](https://github.com/jessesme/granite-llm-test/tree/main/src/RMSNorm_unit): `src/RMSNorm_unit`
- [Residual addition](https://github.com/jessesme/granite-llm-test/tree/main/src/residual_adder_unit): `src/residual_adder_unit`
- [MLP](https://github.com/jessesme/granite-llm-test/tree/main/src/mlp_unit): `src/mlp_unit`
- [SiLU activation](https://github.com/jessesme/granite-llm-test/tree/main/src/SiLU_unit): `src/SiLU_unit`
- [Sigmoid activation](https://github.com/jessesme/granite-llm-test/tree/main/src/sigmoid_unit): `src/sigmoid_unit`

### Other components

- **Token input**
- **Token logits**

## Connections

- Token input → Token embedding: provides token (evidence: `README.md`)
- Token embedding → 32-layer decoder: feeds embeddings (evidence: `README.md`)
- 32-layer decoder → Mamba2 layer: uses 28 layers (evidence: `README.md`)
- 32-layer decoder → Attention layer: uses 4 layers (evidence: `README.md`)
- Mamba2 layer → Causal Conv1D: includes convolution (evidence: `README.md`)
- Mamba2 layer → State-space scan: includes scan (evidence: `README.md`)
- 32-layer decoder → RMS normalization: normalizes (evidence: `README.md`)
- 32-layer decoder → Residual addition: adds residuals (evidence: `README.md`)
- 32-layer decoder → MLP: applies MLP (evidence: `README.md`)
- 32-layer decoder → Matrix operations: uses projections
- MLP → SiLU activation: uses activation
- Attention layer → Softmax: normalizes scores
- 32-layer decoder → LM projection: projects hidden state (evidence: `README.md`)
- Token embedding → LM projection: shares tied weights (evidence: `README.md`)
- LM projection → Token logits: produces logits (evidence: `README.md`)
- Mamba2 layer → Sigmoid activation: activation support
