Skip to content

Commit 4c2b1f6

Browse files
committed
removing extra files
1 parent cb41176 commit 4c2b1f6

20 files changed

Lines changed: 37 additions & 4656 deletions

README.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -677,45 +677,60 @@ We added ring attention support for Wan models. Below are the stats for one `720
677677
python src/maxdiffusion/generate_flux.py src/maxdiffusion/configs/base_flux_schnell.yml jax_cache_dir=/tmp/cache_dir run_name=flux_test output_dir=/tmp/ prompt="photograph of an electronics chip in the shape of a race car with trillium written on its side" per_device_batch_size=1 ici_data_parallelism=1 ici_fsdp_parallelism=-1 offload_encoders=False
678678
```
679679

680-
## Flux.2-klein-4B
680+
## Flux.2-klein (4B & 9B)
681681

682-
MaxDiffusion supports JAX+TPU inference for the **Flux.2-klein-4B** model. We provide both a standard one-shot generation script and an **interactive generation mode** that reuses the JAX/XLA compiled graphs for instant subsequent runs.
682+
MaxDiffusion supports JAX+TPU inference for both **Flux.2-klein-4B** and **Flux.2-klein-9B** models. We provide both a standard one-shot generation script and an **interactive generation mode** that keeps parameters in TPU HBM and reuses compiled JAX/XLA execution graphs for instant subsequent image generation.
683683

684-
### Running Inference
684+
### 1. Running Inference
685685

686-
To generate images, run the following command:
686+
**One-Shot Mode (4B Model):**
687+
```bash
688+
python src/maxdiffusion/generate_flux2klein.py src/maxdiffusion/configs/base_flux2klein.yml \
689+
prompt="an anime corgi eating sushi in the mountains"
690+
```
687691

692+
**One-Shot Mode (9B Model):**
688693
```bash
689-
python src/maxdiffusion/generate_flux2klein.py src/maxdiffusion/configs/base_flux2klein.yml
694+
python src/maxdiffusion/generate_flux2klein.py src/maxdiffusion/configs/base_flux2klein_9B.yml \
695+
prompt="an anime corgi eating sushi in the mountains"
690696
```
691697

692-
To enable **interactive mode** (reusing the compiled graphs to avoid JIT compilation latency on subsequent prompts):
698+
> **Switching Between 4B & 9B**:
699+
> You can switch between 4B and 9B by passing the appropriate YAML config (`base_flux2klein.yml` for 4B, `base_flux2klein_9B.yml` for 9B) or by overriding `flux_name` via CLI arguments:
700+
> * For 4B: `flux_name="flux2-klein-4b" pretrained_model_name_or_path="black-forest-labs/FLUX.2-klein-4B"`
701+
> * For 9B: `flux_name="flux2-klein-9b" pretrained_model_name_or_path="black-forest-labs/FLUX.2-klein-9B"`
693702
703+
**Interactive Mode (Instant Subsequent Generation):**
704+
To avoid JIT re-compilation latency when testing multiple prompts, enable `interactive=True`. The model weights remain loaded in TPU memory, and after the initial warmup pass, each new prompt generates in **~0.9s**:
694705
```bash
695706
python src/maxdiffusion/generate_flux2klein.py src/maxdiffusion/configs/base_flux2klein.yml interactive=True
696707
```
697708

698-
### Running Tests & Verification
699-
700-
All tests and verification scripts are located in `src/maxdiffusion/tests/flux2klein/`.
709+
### 2. Running Tests & Verification
701710

702-
To run the 19-point mathematical parity verification suite against PyTorch CPU:
703-
704-
```bash
705-
python src/maxdiffusion/tests/flux2klein/verify_blockwise_parity.py
706-
```
711+
MaxDiffusion includes a full suite of unit, parity, and end-to-end smoke tests for Flux.2-klein:
707712

708-
To run the pure TPU latency benchmark (permanent HBM residence):
713+
* **Modular Component Unit Tests (Self-Contained Dummy Weights)**:
714+
Verifies SwiGLU MLP, Attention, FlowMatch Scheduler, Double/Single Transformer Blocks, and VAE Decoder:
715+
```bash
716+
pytest src/maxdiffusion/tests/flux2klein/generate_flux2klein_test.py -s -vv
717+
```
709718

710-
```bash
711-
python src/maxdiffusion/tests/flux2klein/benchmark_tpu_pure.py
712-
```
719+
* **End-to-End Smoke Test Suite (1024x1024 Reference Image Parity)**:
720+
Runs full 4B and 9B text-to-image pipelines and asserts `SSIM >= 0.90` against TPU-generated reference images:
721+
```bash
722+
pytest src/maxdiffusion/tests/generate_flux2klein_smoke_test.py -s -vv
723+
```
713724

714-
To run all unit and integration tests:
725+
* **PyTorch vs JAX 4B End-to-End Parity Test**:
726+
```bash
727+
pytest src/maxdiffusion/tests/flux2klein/test_4b_e2e_parity.py -s -vv
728+
```
715729

716-
```bash
717-
pytest src/maxdiffusion/tests/flux2klein/
718-
```
730+
* **PyTorch vs JAX 9B End-to-End Parity Test**:
731+
```bash
732+
pytest src/maxdiffusion/tests/flux2klein/test_9b_e2e_parity.py -s -vv
733+
```
719734
## Fused Attention for GPU:
720735
Fused Attention for GPU is supported via TransformerEngine. Installation instructions:
721736

0 commit comments

Comments
 (0)