sunandbean's picture
Add files using upload-large-folder tool
0a1df87 verified
|
Raw History Blame Contribute Delete
6.46 kB

TT-DiT: Tenstorrent Diffusion Transformers

This directory contains the implementation of the Tenstorrent Diffusion Transformer (TT-DiT) architecture, designed for optimized parallelism of DiTs for image and video generation.

Supported Models

For detailed information about each model including performance metrics, usage instructions, and specific requirements, see:

  • Stable Diffusion 3.5 Large - Text-to-image generation
  • Flux 1 - Text-to-image generation (schnell & dev variants)
  • Motif - Text-to-image generation model
  • Qwen-Image - Text-to-image generation model
  • Ideogram 4.0 - Text-to-image generation model (best-in-class typography; Blackhole)
  • Mochi-1 - Video generation model
  • Wan2.2-T2V-A14B - Text-to-video generation model
  • See experimental/ for in-progress model variants (AniSora, Wan2.2-Distill, LoRA adapters)
  • LTX-2.3 - Joint audio-video generation model (Pro and Fast variants)

Directory Structure

tt_dit/
β”œβ”€β”€ layers/              # Core neural network layers
β”œβ”€β”€ models/              # Model architectures and documentation
β”‚   β”œβ”€β”€ transformers/    # Transformer implementations (SD35, Mochi, Wan, LTX, Flux1, Motif, QwenImage)
β”‚   β”œβ”€β”€ vae/            # VAE/Autoencoder implementations
β”‚   β”œβ”€β”€ StableDiffusion35.md  # SD3.5 model documentation
β”‚   β”œβ”€β”€ Flux1.md         # Flux 1 model documentation
β”‚   β”œβ”€β”€ Motif.md         # Motif model documentation
β”‚   β”œβ”€β”€ QwenImage.md     # Qwen-Image model documentation
β”‚   β”œβ”€β”€ Mochi_1.md       # Mochi-1 model documentation
β”‚   β”œβ”€β”€ Wan2_2.md        # Wan2.2 model documentation
β”‚   └── LTX2.md          # LTX-2.3 model documentation
β”œβ”€β”€ encoders/            # Text encoder implementations
β”‚   β”œβ”€β”€ clip/           # CLIP encoder
β”‚   β”œβ”€β”€ gemma/          # Gemma encoder
β”‚   └── t5/             # T5 encoder
β”œβ”€β”€ parallel/            # Parallelization utilities
β”‚   β”œβ”€β”€ config.py        # Parallel configuration
β”‚   └── manager.py       # Parallel execution management
β”œβ”€β”€ pipelines/           # End-to-end model pipelines
β”‚   β”œβ”€β”€ stable_diffusion_35_large/
β”‚   β”œβ”€β”€ mochi/
β”‚   β”œβ”€β”€ wan/
β”‚   β”œβ”€β”€ ltx/
β”‚   β”œβ”€β”€ flux1/
β”‚   β”œβ”€β”€ motif/
β”‚   └── qwenimage/
β”œβ”€β”€ tests/              # Test suite
β”‚   β”œβ”€β”€ models/         # Model-level tests (sd35, mochi, wan2_2, ltx, flux1, motif, qwenimage)
β”‚   β”œβ”€β”€ encoders/       # Encoder tests
β”‚   β”œβ”€β”€ blocks/         # Block-level tests
β”‚   └── unit/          # Unit tests for layers
└── utils/             # Utility functions
    β”œβ”€β”€ check.py       # Validation utilities
    β”œβ”€β”€ padding.py     # Padding operations
    β”œβ”€β”€ substate.py    # State management
    └── tensor.py      # Tensor operations

Core Components

Layers

  • Embeddings: Position and token embedding implementations
  • Feedforward: MLP and feed-forward network components
  • Linear: Optimized linear transformation layers
  • Normalization: Layer normalization implementations

Models

  • Transformers: DiT transformer implementations for various generative models
    • Support for multiple architectures including SD3.5, Mochi, Wan2.2, LTX-2, Flux1, Motif, and Qwen-Image
    • Model-specific attention mechanisms and transformer architectures
  • Autoencoders: VAE implementations for different models

Parallel Processing

  • Config: Parallel configuration management with DiTParallelConfig
  • Manager: Parallel execution and device management

Pipelines

End-to-end pipeline implementations for multiple generative models:

  • Stable Diffusion 3.5 Large: Text-to-image generation (1024x1024px)
  • Flux 1: Text-to-image generation (schnell & dev variants, 1024x1024px)
  • Motif: Text-to-image generation (6B model, 1024x1024px)
  • Qwen-Image: Text-to-image generation (1024x1024px)
  • Mochi-1: Video generation model (824x480px, 168 frames)
  • Wan2.2-T2V-A14B: Text-to-video generation
  • LTX-2.3: Joint audio-video generation (Pro one-stage and Fast distilled two-stage)

Each pipeline includes:

  • Automatic parallel configuration for different device meshes
  • Optimized execution on Wormhole systems
  • Comprehensive timing collection and profiling

Testing

The test suite is organized into three main categories:

  1. Unit Tests (tests/unit/):

    • Layer-level testing
    • Individual component validation
    • Coverage for embeddings, feedforward, linear, and normalization layers
  2. Model Tests (tests/models/):

    • Smoke tests for model components
    • Performance testing
    • Pipeline validation

Running tests:

# Run tests from tt-metal/

# Run unit tests
python -m pytest  models/tt_dit/tests/unit/

# Run all model tests
python -m pytest  models/tt_dit/tests/models/

# Run specific model pipeline tests
python -m pytest models/tt_dit/tests/models/sd35/test_pipeline_sd35.py -v
python -m pytest models/tt_dit/tests/models/flux1/test_pipeline_flux1.py -v
python -m pytest models/tt_dit/tests/models/motif/test_pipeline_motif.py -v
python -m pytest models/tt_dit/tests/models/qwenimage/test_pipeline_qwenimage.py -v
python -m pytest models/tt_dit/tests/models/mochi/test_pipeline_mochi.py -v
python -m pytest models/tt_dit/tests/models/wan2_2/test_pipeline_wan.py -v
python -m pytest models/tt_dit/tests/models/ltx/test_pipeline_ltx_distilled.py -v
python -m pytest models/tt_dit/tests/models/ltx/test_pipeline_ltx_two_stages.py -v

Key Features

  • Modular Architecture: Clean separation between layers, models, and parallel processing
  • Optimized Parallelism:
    • Automatic configuration of tensor and sequence parallelism
    • Efficient device mesh management
    • Dedicated parallel managers for different model components
  • Performance Monitoring:
    • Built-in timing collection
    • Performance profiling support
    • Tracing capabilities for optimization

Contributing

When adding new components:

  1. Place implementation in appropriate subdirectory
  2. Add corresponding unit tests
  3. Update model tests if necessary
  4. Ensure parallel processing compatibility