# maymhappy/meshripple architecture

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

- Interactive diagram: https://gitdiagram.com/maymhappy/meshripple
- Repository: https://github.com/maymhappy/meshripple

## Overview

MeshRipple is a mesh-generation inference application. The documented workflow loads a configured mesh dataset, prepares point-cloud conditioning and frontier-ordered face tokens, generates faces autoregressively with either full attention or NSA, then detokenizes and exports mesh files. The README documents the two inference variants and the topology-aware generation design. Some orchestration calls are omitted from the excerpts, so edges rely on indexed imports or README statements; unsampled subsystems are not expanded beyond supported paths.

Main entry points: [`main.py`](https://github.com/maymhappy/meshripple/blob/main/main.py) (Inference runner), [`model_nsa_compile/transformer_nsa.py`](https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/transformer_nsa.py) (NSA model), [`model_compile/transformer.py`](https://github.com/maymhappy/meshripple/blob/main/model_compile/transformer.py) (Full-attention model), [`nsa/module/nsa.py`](https://github.com/maymhappy/meshripple/blob/main/nsa/module/nsa.py) (Sparse attention core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Inference runtime"]
  node_config["Config loader<br/>[load_config.py]"]
  node_runner["Inference runner<br/>[main.py]"]
  node_dataset["Mesh dataset"]
end

subgraph group_representation["Mesh representation"]
  node_tokenizer["BFS face tokenizer<br/>[tokenizer.py]"]
  node_postprocess["Mesh postprocessor<br/>[data_process.py]"]
end

subgraph group_generation["Autoregressive models"]
  node_dense["Full-attention model<br/>[transformer.py]"]
  node_dense_attention["Dense attention layers"]
  node_dense_norm["Dense RMSNorm<br/>[rms_norm.py]"]
  node_nsa_model["NSA model<br/>[transformer_nsa.py]"]
  node_nsa_attention["NSA attention layers"]
  node_nsa_norm["NSA RMSNorm<br/>[rms_norm.py]"]
end

subgraph group_attention["Sparse attention"]
  node_nsa_core["Sparse attention core<br/>[nsa.py]"]
  node_compressed["Compressed attention"]
  node_linear_compress["Linear compression<br/>[linear_compress.py]"]
  node_topk["Top-k attention"]
end

subgraph group_conditioning["Shape conditioning"]
  node_conditioner["Point-cloud conditioner"]
  node_nsa_conditioner["NSA point-cloud conditioner"]
  node_miche_encode["Michelangelo encoder<br/>[encode.py]"]
end

node_user(("Inference user"))
node_output["Generated mesh files"]

node_user -->|"starts inference"| node_runner
node_runner -->|"loads config"| node_config
node_runner -->|"builds dataset"| node_dataset
node_dataset -->|"uses tokenization"| node_tokenizer
node_runner -->|"selects model"| node_dense
node_runner -->|"selects model"| node_nsa_model
node_dense -->|"uses attention"| node_dense_attention
node_dense -->|"uses normalization"| node_dense_norm
node_nsa_model -->|"uses attention"| node_nsa_attention
node_nsa_model -->|"uses normalization"| node_nsa_norm
node_nsa_model -->|"dispatches sparse attention"| node_nsa_core
node_nsa_core -->|"calls compressed attention"| node_compressed
node_nsa_core -->|"calls linear compression"| node_linear_compress
node_nsa_core -->|"calls top-k attention"| node_topk
node_dense -->|"uses conditioning"| node_conditioner
node_nsa_model -->|"uses conditioning"| node_nsa_conditioner
node_conditioner -->|"loads encoder"| node_miche_encode
node_nsa_conditioner -->|"loads encoder"| node_miche_encode
node_runner -->|"processes predictions"| node_postprocess
node_postprocess -->|"undiscretizes tokens"| node_tokenizer
node_postprocess -->|"exports meshes"| node_output

click node_config "https://github.com/maymhappy/meshripple/blob/main/config_loader/load_config.py"
click node_runner "https://github.com/maymhappy/meshripple/blob/main/main.py"
click node_dataset "https://github.com/maymhappy/meshripple/blob/main/data_load/mesh_dataset_more_aug.py"
click node_tokenizer "https://github.com/maymhappy/meshripple/blob/main/ripple_tokenizer/tokenizer.py"
click node_postprocess "https://github.com/maymhappy/meshripple/blob/main/utils/data_process.py"
click node_dense "https://github.com/maymhappy/meshripple/blob/main/model_compile/transformer.py"
click node_dense_attention "https://github.com/maymhappy/meshripple/blob/main/model_compile/multihead_flashdiff_2.py"
click node_dense_norm "https://github.com/maymhappy/meshripple/blob/main/model_compile/rms_norm.py"
click node_nsa_model "https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/transformer_nsa.py"
click node_nsa_attention "https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/multihead_flashdiff_2.py"
click node_nsa_norm "https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/rms_norm.py"
click node_nsa_core "https://github.com/maymhappy/meshripple/blob/main/nsa/module/nsa.py"
click node_compressed "https://github.com/maymhappy/meshripple/blob/main/nsa/ops/compressed_attention.py"
click node_linear_compress "https://github.com/maymhappy/meshripple/blob/main/nsa/ops/linear_compress.py"
click node_topk "https://github.com/maymhappy/meshripple/blob/main/nsa/ops/topk_sparse_attention.py"
click node_conditioner "https://github.com/maymhappy/meshripple/blob/main/model_compile/miche_conditioner.py"
click node_nsa_conditioner "https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/miche_conditioner.py"
click node_miche_encode "https://github.com/maymhappy/meshripple/blob/main/miche/encode.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_config,node_runner,node_dataset,node_user toneBlue
class node_tokenizer,node_postprocess toneAmber
class node_dense,node_dense_attention,node_dense_norm,node_nsa_model,node_nsa_attention,node_nsa_norm toneMint
class node_nsa_core,node_compressed,node_linear_compress,node_topk toneRose
class node_conditioner,node_nsa_conditioner,node_miche_encode,node_output toneIndigo
```

## Components

### Inference runtime

- [Config loader](https://github.com/maymhappy/meshripple/blob/main/config_loader/load_config.py): `config_loader/load_config.py`
- [Inference runner](https://github.com/maymhappy/meshripple/blob/main/main.py): `main.py`
- [Mesh dataset](https://github.com/maymhappy/meshripple/blob/main/data_load/mesh_dataset_more_aug.py): `data_load/mesh_dataset_more_aug.py`

### Mesh representation

- [BFS face tokenizer](https://github.com/maymhappy/meshripple/blob/main/ripple_tokenizer/tokenizer.py): `ripple_tokenizer/tokenizer.py`
- [Mesh postprocessor](https://github.com/maymhappy/meshripple/blob/main/utils/data_process.py): `utils/data_process.py`

### Autoregressive models

- [Full-attention model](https://github.com/maymhappy/meshripple/blob/main/model_compile/transformer.py): `model_compile/transformer.py`
- [Dense attention layers](https://github.com/maymhappy/meshripple/blob/main/model_compile/multihead_flashdiff_2.py): `model_compile/multihead_flashdiff_2.py`
- [Dense RMSNorm](https://github.com/maymhappy/meshripple/blob/main/model_compile/rms_norm.py): `model_compile/rms_norm.py`
- [NSA model](https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/transformer_nsa.py): `model_nsa_compile/transformer_nsa.py`
- [NSA attention layers](https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/multihead_flashdiff_2.py): `model_nsa_compile/multihead_flashdiff_2.py`
- [NSA RMSNorm](https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/rms_norm.py): `model_nsa_compile/rms_norm.py`

### Sparse attention

- [Sparse attention core](https://github.com/maymhappy/meshripple/blob/main/nsa/module/nsa.py): `nsa/module/nsa.py`
- [Compressed attention](https://github.com/maymhappy/meshripple/blob/main/nsa/ops/compressed_attention.py): `nsa/ops/compressed_attention.py`
- [Linear compression](https://github.com/maymhappy/meshripple/blob/main/nsa/ops/linear_compress.py): `nsa/ops/linear_compress.py`
- [Top-k attention](https://github.com/maymhappy/meshripple/blob/main/nsa/ops/topk_sparse_attention.py): `nsa/ops/topk_sparse_attention.py`

### Shape conditioning

- [Point-cloud conditioner](https://github.com/maymhappy/meshripple/blob/main/model_compile/miche_conditioner.py): `model_compile/miche_conditioner.py`
- [NSA point-cloud conditioner](https://github.com/maymhappy/meshripple/blob/main/model_nsa_compile/miche_conditioner.py): `model_nsa_compile/miche_conditioner.py`
- [Michelangelo encoder](https://github.com/maymhappy/meshripple/blob/main/miche/encode.py): `miche/encode.py`

### Other components

- **Inference user**
- **Generated mesh files**

## Connections

- Inference user → Inference runner: starts inference (evidence: `README.md`)
- Inference runner → Config loader: loads config (evidence: `main.py`)
- Inference runner → Mesh dataset: builds dataset (evidence: `main.py`)
- Mesh dataset → BFS face tokenizer: uses tokenization (evidence: `data_load/mesh_dataset_more_aug.py`)
- Inference runner → Full-attention model: selects model (evidence: `main.py`)
- Inference runner → NSA model: selects model (evidence: `main.py`)
- Full-attention model → Dense attention layers: uses attention (evidence: `model_compile/transformer.py`)
- Full-attention model → Dense RMSNorm: uses normalization (evidence: `model_compile/transformer.py`)
- NSA model → NSA attention layers: uses attention (evidence: `model_nsa_compile/transformer_nsa.py`)
- NSA model → NSA RMSNorm: uses normalization (evidence: `model_nsa_compile/transformer_nsa.py`)
- NSA model → Sparse attention core: dispatches sparse attention (evidence: `model_nsa_compile/transformer_nsa.py`)
- Sparse attention core → Compressed attention: calls compressed attention (evidence: `nsa/module/nsa.py`)
- Sparse attention core → Linear compression: calls linear compression (evidence: `nsa/module/nsa.py`)
- Sparse attention core → Top-k attention: calls top-k attention (evidence: `nsa/module/nsa.py`)
- Full-attention model → Point-cloud conditioner: uses conditioning (evidence: `model_compile/transformer.py`)
- NSA model → NSA point-cloud conditioner: uses conditioning (evidence: `model_nsa_compile/transformer_nsa.py`)
- Point-cloud conditioner → Michelangelo encoder: loads encoder (evidence: `model_compile/miche_conditioner.py`)
- NSA point-cloud conditioner → Michelangelo encoder: loads encoder (evidence: `model_nsa_compile/miche_conditioner.py`)
- Inference runner → Mesh postprocessor: processes predictions (evidence: `main.py`)
- Mesh postprocessor → BFS face tokenizer: undiscretizes tokens (evidence: `utils/data_process.py`)
- Mesh postprocessor → Generated mesh files: exports meshes (evidence: `utils/data_process.py`)
