You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Loading the data is supported both locally from the disk created above, or from `gcs`. In this guide, we'll be using a gcs bucket to train. First copy the data to the GCS bucket.
@@ -266,7 +266,7 @@ After installation completes, run the training script.
266
266
- per_device_batch_size can be a fractional, but must be a whole number when multiplied by number of devices. In this example, 0.25 * 4 (devices) = effective global batch size = 1.
267
267
- The step time in v5p-8 with global batch size = 1 is large due to using `FULL` remat. On larger number of chips we can run larger batch sizes greatly increasing MFU, as we will see in the next session of deploying with xpk.
268
268
- To enable eval during training set `eval_every` to a value > 0.
269
-
- In Wan2.1, the ici_fsdp_parallelism axis is used for sequence parallelism, the ici_tensor_parallelism axis is used for head parallelism.
269
+
- In Wan2.1, the ici_fsdp_parallelism axis is used for sequence parallelism, the ici_tensor_parallelism axis is used for head parallelism.
270
270
- You can enable both, keeping in mind that Wan2.1 has 40 heads and 40 must be evenly divisible by ici_tensor_parallelism.
271
271
- For Sequence parallelism, the code pads the sequence length to evenly divide the sequence. Try out different ici_fsdp_parallelism numbers, but we find 2 and 4 to be the best right now.
272
272
- For use on GPU it is recommended to enable the cudnn_te_flash attention kernel for optimal performance.
@@ -309,7 +309,7 @@ After installation completes, run the training script.
309
309
### Deploying with XPK
310
310
311
311
This assumes the user has already created an xpk cluster, installed all dependencies and the also created the dataset from the step above. For getting started with MaxDiffusion and xpk see [this guide](docs/getting_started/run_maxdiffusion_via_xpk.md).
312
-
312
+
313
313
Using v5p-256 Then the command to run on xpk is as follows:
314
314
315
315
```bash
@@ -523,8 +523,8 @@ To generate images, run the following command:
Add conditioning image path as conditioning_media_paths in the form of ["IMAGE_PATH"] along with other generation parameters in the ltx_video.yml file. Then follow same instruction as above.
@@ -751,7 +751,7 @@ The optimal attention tile sizes (`block_q` / `block_kv`) depend on the sequence
751
751
752
752
If you are using a TPU v6e (Trillium), you can use optimized flash block sizes for faster inference. Uncomment Flux-dev [config](src/maxdiffusion/configs/base_flux_dev.yml#60) and Flux-schnell [config](src/maxdiffusion/configs/base_flux_schnell.yml#68)
753
753
754
-
To keep text encoders, vae and transformer on HBM memory at all times, the following command shards the model across devices.
754
+
To keep text encoders, vae and transformer on HBM memory at all times, the following command shards the model across devices.
755
755
756
756
```bash
757
757
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
@@ -900,13 +900,40 @@ MaxDiffusion started as a fork of [Diffusers](https://github.com/huggingface/dif
900
900
Whether you are forking MaxDiffusion foryour own needs or intending to contribute back to the community, a full suite of tests can be foundin`tests` and `src/maxdiffusion/tests`.
901
901
902
902
To run unit tests simply run:
903
-
```
903
+
```bash
904
904
python -m pytest
905
905
```
906
906
907
-
This project uses `pylint` and `pyink` to enforce code style. Before submitting a pull request, please ensure your code passes these checks by running:
907
+
### Pre-commit Hooks
908
+
909
+
We use [pre-commit](https://pre-commit.com/) to automatically check and format code before each commit (using `pyink`, `ruff`, `pylint`, and general git hygiene checks).
910
+
911
+
>**Important:** Make sure you are in your active virtual environment (e.g. `maxdiffusion_venv` or your active venv) before running `pre-commit install`, so that hooks run using the environment's installed dependencies.
912
+
913
+
```bash
914
+
# 1. Activate your virtual environment first
915
+
source <path-to-venv>/bin/activate
916
+
917
+
# 2. Install pre-commit (if not already installed)
918
+
pip install pre-commit
908
919
920
+
# 3. Install git pre-commit hooks
921
+
pre-commit install
909
922
```
923
+
924
+
Once installed, pre-commit will automatically run on staged files whenever you run `git commit`.
925
+
926
+
You can also run all pre-commit checks manually across the entire repository at any time:
927
+
928
+
```bash
929
+
pre-commit run --all-files
930
+
```
931
+
932
+
### Code Style
933
+
934
+
This project uses `pylint` and `pyink` to enforce code style. Before submitting a pull request, please ensure your code passes these checks by running:
935
+
936
+
```bash
910
937
bash code_style.sh
911
938
```
912
939
@@ -919,4 +946,4 @@ The full suite of -end-to end tests is in `tests` and `src/maxdiffusion/tests`.
919
946
To learn how to enable ML Diagnostics and XProf profiling for your runs, please see our [ML Diagnostics Guide](docs/profiling.md).
920
947
921
948
## Metrics
922
-
To learn how to enable ML Diagnostics metrics tracking for your runs, please see our [Metrics Guide](docs/metrics.md).
949
+
To learn how to enable ML Diagnostics metrics tracking for your runs, please see our [Metrics Guide](docs/metrics.md).
0 commit comments