ai-toolkit icon indicating copy to clipboard operation
ai-toolkit copied to clipboard

LTX-2 support

Open CraftBlack opened this issue 10 months ago • 12 comments

https://huggingface.co/Lightricks/LTX-2 https://github.com/Lightricks/LTX-2

CraftBlack avatar Jan 07 '26 15:01 CraftBlack

https://x.com/ostrisai/status/2008688876039376949

ppc2017 avatar Jan 08 '26 02:01 ppc2017

https://x.com/ostrisai/status/2008688876039376949

awesome! i got Runpod credits put aside just for this <3 my PC can't train it locally sadly

neggy555 avatar Jan 08 '26 02:01 neggy555

https://x.com/ostrisai/status/2010034787512398134?s=20

MMaximuss avatar Jan 11 '26 20:01 MMaximuss

https://x.com/ostrisai/status/2008688876039376949

For those that want to skip twitter, here's what he said:

Yes. It will take some time because having video with sound is a whole new paradigm, but it is the top priority now.

motowntek avatar Jan 13 '26 03:01 motowntek

I was just looking at the branch, now it got merged lol https://github.com/ostris/ai-toolkit/commit/5b5aadadb8310a0ed435fd142e5571c7cc0e0385

gitmylo avatar Jan 13 '26 12:01 gitmylo

I am getting the following error when starting the training.

Running 1 job

Diffusers import error: cannot import name 'LTX2Pipeline' from 'diffusers' (C:\Users\xxx\Documents\ai-toolkit\AI-Toolkit\venv\Lib\site-packages\diffusers\__init__.py)

Error running job: Diffusers is out of date. Update diffusers to the latest version by doing pip uninstall diffusers and then pip install -r requirements.txt

Error running on_error: cannot access local variable 'job' where it is not associated with a value

========================================

Result:

 - 0 completed jobs

 - 1 failure

========================================

Traceback (most recent call last):

Traceback (most recent call last):

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\ltx2\ltx2.py", line 25, in <module>

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\ltx2\ltx2.py", line 25, in <module>

        from diffusers import LTX2Pipelinefrom diffusers import LTX2Pipeline

ImportErrorImportError: : cannot import name 'LTX2Pipeline' from 'diffusers' (C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\venv\Lib\site-packages\diffusers\__init__.py)cannot import name 'LTX2Pipeline' from 'diffusers' (C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\venv\Lib\site-packages\diffusers\__init__.py). Did you mean: 'LTXPipeline'?. Did you mean: 'LTXPipeline'?

During handling of the above exception, another exception occurred:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

Traceback (most recent call last):

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\run.py", line 120, in <module>

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\run.py", line 120, in <module>

        main()main()

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\run.py", line 108, in main

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\run.py", line 108, in main

        raise eraise e

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\run.py", line 95, in main

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\run.py", line 95, in main

        job = get_job(config_file, args.name)job = get_job(config_file, args.name)

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\toolkit\job.py", line 29, in get_job

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\toolkit\job.py", line 29, in get_job

        return ExtensionJob(config)return ExtensionJob(config)

                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\jobs\ExtensionJob.py", line 12, in __init__

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\jobs\ExtensionJob.py", line 12, in __init__

        self.process_dict = get_all_extensions_process_dict()self.process_dict = get_all_extensions_process_dict()

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\toolkit\extension.py", line 53, in get_all_extensions_process_dict

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\toolkit\extension.py", line 53, in get_all_extensions_process_dict

        all_extensions = get_all_extensions()all_extensions = get_all_extensions()

                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\toolkit\extension.py", line 39, in get_all_extensions

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\toolkit\extension.py", line 39, in get_all_extensions

        module = importlib.import_module(f"{sub_dir}.{name}")module = importlib.import_module(f"{sub_dir}.{name}")

                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "importlib\__init__.py", line 90, in import_module

  File "importlib\__init__.py", line 90, in import_module

  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load

  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load

  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked

  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 999, in exec_module

  File "<frozen importlib._bootstrap_external>", line 999, in exec_module

  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed

  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\__init__.py", line 10, in <module>

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\__init__.py", line 10, in <module>

        from .ltx2 import LTX2Modelfrom .ltx2 import LTX2Model

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\ltx2\__init__.py", line 1, in <module>

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\ltx2\__init__.py", line 1, in <module>

        from .ltx2 import LTX2Modelfrom .ltx2 import LTX2Model

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\ltx2\ltx2.py", line 52, in <module>

  File "C:\Users\xxxx\Documents\ai-toolkit\AI-Toolkit\extensions_built_in\diffusion_models\ltx2\ltx2.py", line 52, in <module>

        raise ImportError(raise ImportError(

ImportErrorImportError: : Diffusers is out of date. Update diffusers to the latest version by doing pip uninstall diffusers and then pip install -r requirements.txtDiffusers is out of date. Update diffusers to the latest version by doing pip uninstall diffusers and then pip install -r requirements.txt

Running on Windows, installation has been working fine for WAn / FLUX etc..
I updated with

git pull
pip install -r requirements.txt

I have updated the venv and pip freeze shows

...
decorator==5.1.1
diffusers @ git+https://github.com/huggingface/diffusers@8600b4c10d67b0ce200f664204358747bd53c775
dill==0.3.8
...

Will the code automatically download the LTX2 models ordo I have to do that manually?

FlareP1 avatar Jan 13 '26 12:01 FlareP1

Update: If I run python direct from the venv the diffusers libraray does load but throws a warning about trition? Do I need to install trition windows wheels?

C:\Users\xxxx\Documents\ai-toolkit>venv-AI-Toolkit.bat (venv) C:\Users\xxxx\Documents\ai-toolkit>python Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import diffusers from diffusers import LTX2Pipeline WARNING:torchao.kernel.intmm:Warning: Detected no triton, on systems without Triton certain kernels will not work

Is this working for anyone else?

FlareP1 avatar Jan 13 '26 14:01 FlareP1

It looks like when I updated it somehow broke the association with the correct venv. I reinstalled from scratch and now it seems to be running. Sorry for the bother.

FlareP1 avatar Jan 13 '26 15:01 FlareP1

I got this working on my 5090 with 50% transformer offloading and doing every option to unload the text encoder, took ~4hrs to train a picture LoRA and it works great.

edit:

I trained to 3000 steps at 512 resolution with a simple keyword caption, and the videos come out great. The likeness works well at the 1400 steps LoRA output. The samples that were generated during training were blurry and otherwise terrible, but when I load the LoRA in comfyUI it looks really good. In future training I'm going to forego the samples because it's just wasted time.

edit2:

my huggingface library cache is 89GB after running this, and when you cache the latents to disk it's ~390mb per 512px image, so keep that all in mind when allocating disk space for containers

edit3:

it works at 25% offloading, and it's reporting 3.69s/iter for a 512px training image

billautomata avatar Jan 14 '26 04:01 billautomata

@billautomata how did you structure your text encoder folder and where? I am getting endless errors regardless of how I attempt to do it.

eldragon0 avatar Jan 15 '26 20:01 eldragon0

@eldragon0 I used the default settings where the name or path is "Lightricks/LTX-2" and it downloaded everything to the .cache/huggingface/hub/models--Lightricks--LTX-2 in my home directory

it's 85GB so I assume it has the text encoder as well as the AV model

billautomata avatar Jan 16 '26 08:01 billautomata

I got this working on my 5090 with 50% transformer offloading and doing every option to unload the text encoder, took ~4hrs to train a picture LoRA and it works great.

edit:

I trained to 3000 steps at 512 resolution with a simple keyword caption, and the videos come out great. The likeness works well at the 1400 steps LoRA output. The samples that were generated during training were blurry and otherwise terrible, but when I load the LoRA in comfyUI it looks really good. In future training I'm going to forego the samples because it's just wasted time.

edit2:

my huggingface library cache is 89GB after running this, and when you cache the latents to disk it's ~390mb per 512px image, so keep that all in mind when allocating disk space for containers

edit3:

it works at 25% offloading, and it's reporting 3.69s/iter for a 512px training image

can u share the training config pls?

zappazack avatar Jan 17 '26 22:01 zappazack