# 1981rupal/lssn_research_model architecture

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

- Interactive diagram: https://gitdiagram.com/1981rupal/lssn_research_model
- Repository: https://github.com/1981rupal/lssn_research_model

## Overview

LSSN is a research implementation for aligning text- and image-conditioned latent trajectories during diffusion-model training. The workflow samples a timestep and noise, corrupts a clean latent, then trains a U-Net on fused conditioning while comparing intermediate features from separate text-only and image-only passes with an invariance loss. The README also describes symmetric cross-attention and dual-path conditioning; these are represented alongside the denoising workflow. The implementation uses dummy batches rather than a production data pipeline. Edges reflect the supplied excerpts and README; unsampled behavior is not inferred.

Main entry points: [`train_lssn.py`](https://github.com/1981rupal/lssn_research_model/blob/main/train_lssn.py) (Dual-path trainer), [`lssn_model.py`](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py) (LSSN U-Net), [`lssn_modules.py`](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py) (Transformer block), [`noise_schedule.py`](https://github.com/1981rupal/lssn_research_model/blob/main/noise_schedule.py) (Noise schedule)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training workflow"]
  node_dummy_batches["Dummy batches<br/>[train_lssn.py]"]
  node_trainer["Dual-path trainer<br/>[train_lssn.py]"]
  node_metrics["Training losses"]
end

subgraph group_diffusion["Diffusion model"]
  node_noise_schedule["Noise schedule<br/>[noise_schedule.py]"]
  node_unet["LSSN U-Net<br/>[lssn_model.py]"]
  node_time_conditioning["Time conditioning<br/>[lssn_model.py]"]
  node_resnet_blocks["Residual blocks<br/>[lssn_model.py]"]
  node_spatial_transformer["Spatial transformer<br/>[lssn_model.py]"]
  node_sampling_blocks["Scale sampling blocks<br/>[lssn_model.py]"]
end

subgraph group_sync["Synchronization layers"]
  node_transformer_block["Transformer block<br/>[lssn_modules.py]"]
  node_sync_attention["Synchronization attention<br/>[lssn_modules.py]"]
  node_feed_forward["Feed-forward layer<br/>[lssn_modules.py]"]
end

subgraph group_objectives["Training objectives"]
  node_invariance_loss["Invariance loss<br/>[loss.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts training"| node_dummy_batches
node_dummy_batches -->|"supplies batches"| node_trainer
node_trainer -->|"corrupts latents"| node_noise_schedule
node_trainer -->|"runs three passes"| node_unet
node_noise_schedule -->|"returns noisy latent"| node_trainer
node_unet -->|"returns prediction and features"| node_trainer
node_trainer -->|"compares path features"| node_invariance_loss
node_invariance_loss -->|"returns alignment loss"| node_trainer
node_trainer -->|"reports losses"| node_metrics
node_unet -->|"embeds timesteps"| node_time_conditioning
node_unet -->|"applies residual blocks"| node_resnet_blocks
node_unet -->|"applies attention layers"| node_spatial_transformer
node_unet -->|"scales feature maps"| node_sampling_blocks
node_spatial_transformer -->|"runs transformer layers"| node_transformer_block
node_transformer_block -->|"applies cross-attention"| node_sync_attention
node_transformer_block -->|"applies feed-forward"| node_feed_forward

click node_dummy_batches "https://github.com/1981rupal/lssn_research_model/blob/main/train_lssn.py"
click node_trainer "https://github.com/1981rupal/lssn_research_model/blob/main/train_lssn.py"
click node_noise_schedule "https://github.com/1981rupal/lssn_research_model/blob/main/noise_schedule.py"
click node_unet "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py"
click node_time_conditioning "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py"
click node_resnet_blocks "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py"
click node_spatial_transformer "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py"
click node_sampling_blocks "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py"
click node_transformer_block "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py"
click node_sync_attention "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py"
click node_feed_forward "https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py"
click node_invariance_loss "https://github.com/1981rupal/lssn_research_model/blob/main/loss.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_dummy_batches,node_trainer,node_metrics toneBlue
class node_noise_schedule,node_unet,node_time_conditioning,node_resnet_blocks,node_spatial_transformer,node_sampling_blocks toneAmber
class node_transformer_block,node_sync_attention,node_feed_forward toneMint
class node_invariance_loss toneRose
class node_researcher toneIndigo
```

## Components

### Training workflow

- [Dummy batches](https://github.com/1981rupal/lssn_research_model/blob/main/train_lssn.py): `train_lssn.py`
- [Dual-path trainer](https://github.com/1981rupal/lssn_research_model/blob/main/train_lssn.py): `train_lssn.py`
- **Training losses**

### Diffusion model

- [Noise schedule](https://github.com/1981rupal/lssn_research_model/blob/main/noise_schedule.py): `noise_schedule.py`
- [LSSN U-Net](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py): `lssn_model.py`
- [Time conditioning](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py): `lssn_model.py`
- [Residual blocks](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py): `lssn_model.py`
- [Spatial transformer](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py): `lssn_model.py`
- [Scale sampling blocks](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_model.py): `lssn_model.py`

### Synchronization layers

- [Transformer block](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py): `lssn_modules.py`
- [Synchronization attention](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py): `lssn_modules.py`
- [Feed-forward layer](https://github.com/1981rupal/lssn_research_model/blob/main/lssn_modules.py): `lssn_modules.py`

### Training objectives

- [Invariance loss](https://github.com/1981rupal/lssn_research_model/blob/main/loss.py): `loss.py`

### Other components

- **Researcher**

## Connections

- Researcher → Dummy batches: starts training (evidence: `README.md`)
- Dummy batches → Dual-path trainer: supplies batches (evidence: `train_lssn.py`)
- Dual-path trainer → Noise schedule: corrupts latents (evidence: `train_lssn.py`)
- Dual-path trainer → LSSN U-Net: runs three passes (evidence: `train_lssn.py`)
- Noise schedule → Dual-path trainer: returns noisy latent (evidence: `train_lssn.py`)
- LSSN U-Net → Dual-path trainer: returns prediction and features (evidence: `train_lssn.py`)
- Dual-path trainer → Invariance loss: compares path features (evidence: `train_lssn.py`)
- Invariance loss → Dual-path trainer: returns alignment loss (evidence: `train_lssn.py`)
- Dual-path trainer → Training losses: reports losses (evidence: `train_lssn.py`)
- LSSN U-Net → Time conditioning: embeds timesteps (evidence: `lssn_model.py`)
- LSSN U-Net → Residual blocks: applies residual blocks (evidence: `lssn_model.py`)
- LSSN U-Net → Spatial transformer: applies attention layers (evidence: `lssn_model.py`)
- LSSN U-Net → Scale sampling blocks: scales feature maps (evidence: `lssn_model.py`)
- Spatial transformer → Transformer block: runs transformer layers (evidence: `lssn_model.py`)
- Transformer block → Synchronization attention: applies cross-attention (evidence: `lssn_modules.py`)
- Transformer block → Feed-forward layer: applies feed-forward (evidence: `lssn_modules.py`)
