Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 16 additions & 5 deletions .cursor/rules/ltx2-patch-reverify.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ alwaysApply: false

# LTX-2 bump → re-check `services.patches`

If this change updates `ltx-core` or `ltx-pipelines` (version pin, git tag, or `tool.uv.dependency-metadata`), treat every module imported from `backend/services/patches/` in `backend/ltx2_server.py` as suspect.
Delete-first. If this change updates `ltx-core` or `ltx-pipelines` (version pin, git tag, or `tool.uv.dependency-metadata`), treat every module imported from `backend/services/patches/` in `backend/ltx2_server.py` as suspect — plus any out-of-directory swaps such as `distilled_keyframe_guiding`.

Those patches rebind private upstream symbols. A bump can rename the target (import-time assert should fail) or change the contract (assert still passes, behavior is wrong).
Those patches rebind private upstream symbols. A bump can rename the target (import-time assert should fail) or change the contract (assert still passes, behavior is wrong). Default is **delete** the patch; keep only what still fails on the new revision.

For each patch:

1. Read the module's "Remove once ..." docstring. If upstream now includes the fix, delete the patch and its `ltx2_server.py` import.
2. Otherwise diff the upstream function against the replacement and keep the contract identical.
3. Run that patch's tests (`backend/tests/test_<patch>.py`).
1. Read the module's "Remove once ..." docstring. If upstream now includes the fix, delete the patch, its `ltx2_server.py` import, and its tests.
2. Cautionary example: `diffvae_mps_tiling_budget` asserted `DiffusionVideoDecoder.recommended_tiling_config`, which 1.3.0 removed. Keeping it made the backend unable to boot. `safetensors_metadata_fix` is the opposite kind of patch (Windows 1455 / never-`safe_open` the 46GB distilled-1.1 checkpoint) — keep until that contract is upstream.
3. Otherwise diff the upstream function against the replacement and keep the contract identical. Re-earn; do not copy blindly.
4. Run that patch's tests (`backend/tests/test_<patch>.py`) plus the patch import-smoke test.

Forked pipeline classes copy upstream bodies, and a signature test does not catch body drift. On every bump diff these against the new upstream and re-run their tests:

- `TiledICLoraPipeline._video_conditionings` (`ic_lora_pipeline/tiled_ic_lora_pipeline.py`) copies upstream `ICLoraPipeline._video_conditionings`; keep the `apply_ic_lora` gate and only change `encode_tiling`.
- `DistilledPipelineWithSkipStage2._call_stage_1_only` mirrors stage 1 of `DistilledPipeline`.
- `DistilledA2VPipeline` and `LTXRetakePipeline` call `DiffusionStage` directly.

Size latents with `stage.video_scale_factors` (transformer geometry). `tiling_scale_factors_for_vae` is the decoder's tiling scale (2x8x8 on the 2.5 DiffVAE) and is only for `ensure_tiling_config`.

Unit tests cannot prove a forked pipeline still generates correctly. After the patch review, run the live regression suite on each platform (`backend/performance_runner/README.md`, "Live regression suite"): `sanity.py --tags smoke` at minimum, `--tags smoke full bump` for a release, on both the deterministic (2.3) and ancestral (2.5) models.

`safetensors_metadata_fix` is in this set (Windows 1455 / LTX-Desktop#158: do not `safe_open` the 46GB distilled-1.1 checkpoint in `_read_scales` or `_scan_checkpoint_keys`).
73 changes: 55 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0

- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

Expand Down Expand Up @@ -51,43 +53,78 @@ jobs:
- name: TypeScript type check
run: pnpm run typecheck:ts

- name: ESLint
run: pnpm run lint

- name: Pack helper tests
run: pnpm run scripts:test

test-python:
name: Python Tests (${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: macos
runner: macos-latest
- os: windows
runner: windows-latest
- os: linux
runner: ubuntu-latest
- name: File size check
run: bash scripts/check-file-sizes.sh origin/main

test-python-windows:
name: Python Tests (windows)
runs-on: windows-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- &checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
- &setup-uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
version: "latest"
enable-cache: true
cache-dependency-glob: "backend/uv.lock"

- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- &setup-python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"

- name: Install dependencies
- &install-backend
name: Install dependencies
run: uv sync --frozen --extra test --extra dev

# The full suite runs on Linux. Windows only runs tests that call the
# real Win32 DLL APIs. `--` keeps `-m` from being read as a uv flag.
- name: Run tests
run: uv run -- pytest -v --tb=short -m ci_os

# One Linux pytest job was the wait. Four shards run together.
# The matrix length and `--splits` below are the same number.
test-python-linux:
name: Python Tests (linux ${{ matrix.shard }}/4)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
defaults:
run:
working-directory: backend
steps:
- *checkout
- *setup-uv
- *setup-python
- *install-backend
# `--` keeps `--splits` from being read as a uv flag.
# least_duration deals tests round-robin when there is no durations file,
# so a slow module is not collected entirely onto the first shard.
- name: Run tests
run: uv run pytest -v --tb=short
run: uv run -- pytest -v --tb=short --splits 4 --group ${{ matrix.shard }} --splitting-algorithm least_duration

# Branch protection still looks for this name. It passes when every Linux shard passes.
test-python-linux-gate:
name: Python Tests (linux)
needs: test-python-linux
if: always()
runs-on: ubuntu-latest
steps:
- name: Require every Linux shard
run: test "${{ needs.test-python-linux.result }}" = "success"

build-check:
name: Frontend Build
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/
# Build outputs
dist/
dist-electron/
dist-remote/
.vite/
release/
*.tsbuildinfo
Expand Down Expand Up @@ -35,6 +36,8 @@ backend/**/__pycache__/
.vscode/*
!.vscode/launch.json
!.vscode/tasks.json
!.vscode/settings.json
!.vscode/extensions.json
*.swp
*.swo
*~
Expand Down
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
dist
dist-electron
dist-remote
.vite
release
coverage
.vscode
backend
frontend/generated
pnpm-lock.yaml
*.min.js
24 changes: 24 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copied from LTX Studio `infinity-formatter` (vl-web-client).
*
* @type {import("prettier").Config}
*/
export default {
importOrder: [
// 1. All global packages from node_modules (react, lodash, etc.)
"^(?!@/|\\.).*$",
// 2. All global imports starting with @/
"^@/",
// 3. Relative imports from parent directories
"^../",
// 4. Relative imports from current directory
"./",
],
importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
printWidth: 90,
arrowParens: "always",
objectWrap: "preserve",
plugins: ["@trivago/prettier-plugin-sort-imports"],
};
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true,
"prettier.requireConfig": true,
"editor.indentSize": 2,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false
}
42 changes: 40 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PRs must pass: `pnpm typecheck` + `pnpm backend:test` + frontend Vite build.
- **IPC bridge**: All Electron communication through `window.electronAPI` (defined in `electron/preload.ts`)
- **Backend calls**: Always use `backendFetch` from `frontend/lib/backend.ts` for app backend HTTP requests (it attaches auth/session details). Do not call `fetch` directly for backend endpoints.
- **Styling**: Tailwind with custom semantic color tokens via CSS variables; utilities from `class-variance-authority` + `clsx` + `tailwind-merge`
- **No frontend tests** currently exist
- Frontend, Electron, and shared tests are `node:test` files. `pnpm run scripts:test` runs them. Which ones are worth writing is in [Tests](#tests).

## Backend Architecture

Expand All @@ -57,8 +57,10 @@ Key patterns:

- Integration-first using Starlette `TestClient` against real FastAPI app
- **No mocks**: `test_no_mock_usage.py` enforces no `unittest.mock`. Swap services via `ServiceBundle` fakes only.
- Assert the status, the body, the resulting state, or the persisted row. A call assertion on a fake is out.
- Fakes live in `tests/fakes/`; `conftest.py` wires fresh `AppHandler` per test
- Pyright strict mode is also enforced as a test (`test_pyright.py`)
- Pyright strict mode runs in the CI typecheck job (`uv run pyright`). Pytest does not run it again.
- Which tests are worth writing is in [Tests](#tests)

### Adding a Backend Feature

Expand Down Expand Up @@ -89,3 +91,39 @@ Key patterns:
- Electron builder config: `electron-builder.yml`
- Video editor (largest frontend file): `frontend/views/VideoEditor.tsx`
- Project types: `frontend/types/project.ts`

## Tests

Before writing tests, list the cases you intend to cover and wait for approval.
Each line names one bug. Do not create or edit a test file until that list is approved.

Each test must correspond to a specific bug a reasonable developer could
introduce. Put that bug in the test name. Use a one-line comment only when the
name would be unreadable. If you can't name the bug, don't write the test.

Do NOT write tests that:

- assert a component renders without throwing
- assert a pure function returns its own obvious output (add(1, 2) === 3). A cap, an alignment grid, or None when over the cap is in scope
- verify that a mock you just configured was called with what you configured
- re-assert types the compiler already guarantees
- re-assert a Pydantic model, dataclass, or TypedDict field type that Pyright or the schema already enforces. A wire alias (currentStep present, current_step absent) and the error envelope (code, message) are in scope
- snapshot entire component trees
- test library behaviour (Zustand's set, React's useState, Radix internals)
- exist to raise coverage
- fail only when the entire module is deleted

DO write tests for:

- branch and boundary conditions (empty, single, off-by-one, null vs undefined)
- error paths and failure modes
- state transitions and their ordering
- anything with non-obvious business rules
- regressions: bugs previously fixed

Prefer fewer tests with real assertions over many shallow ones.
Test observable behaviour through the public interface.

When you touch a file that already has tests, delete any that break the rules
above. On legacy surfaces (GenSpace and similar), keep the smallest set that
still catches the cases above. Do not grow those suites.
42 changes: 20 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ LTX Desktop is an open-source desktop app for generating videos with LTX models

## Local vs API mode

See [`docs/local-compat-matrix.md`](docs/local-compat-matrix.md) for the tool × hardware projection of the same generate decisions (not a second Yes table). CUDA **16 GB** cards are local-viable but do not advertise Fast 720p/20s or 1080p/10s.

| Platform / hardware | Generation mode | Notes |
| --- | --- | --- |
| Windows + CUDA GPU with **≥16GB VRAM** | Local generation | Downloads model weights locally |
| Windows (no CUDA, <16GB VRAM, or unknown VRAM) | API-only | **LTX API key required** |
| Linux + CUDA GPU with **≥16GB VRAM** | Local generation | Downloads model weights locally |
| Linux (no CUDA, <16GB VRAM, or unknown VRAM) | API-only | **LTX API key required** |
| macOS, Apple Silicon with **≥15GB free RAM** | Local generation | Downloads model weights locally; runs on MPS |
| macOS, Apple Silicon with <15GB free RAM, or Intel Mac | API-only | **LTX API key required** |
| Windows + CUDA GPU with **≥15 GiB VRAM** | Local generation | Integer GiB from `total_memory // 1024**3` |
| Windows (no CUDA, <15 GiB VRAM, or unknown VRAM) | Local unsupported | Cloud API is optional if configured |
| Linux + CUDA GPU with **≥15 GiB VRAM** | Local generation | Integer GiB from `total_memory // 1024**3` |
| Linux (no CUDA, <15 GiB VRAM, or unknown VRAM) | Local unsupported | Cloud API is optional if configured |
| macOS, Apple Silicon with **≥32 GiB total RAM** | Local generation | Downloads model weights locally; runs on MPS |
| macOS, Apple Silicon with <32 GiB total RAM, or Intel Mac | Local unsupported | Cloud API is optional if configured |

In API-only mode, available resolutions/durations may be limited to what the API supports. The API path also offers **LTX 2.5 Fast**, **LTX 2.5 Pro**, and 2.3 Fast/Pro.
When local generation is unsupported, the app does not require an LTX API key. The optional API path still offers **LTX 2.5 Fast**, **LTX 2.5 Pro**, and 2.3 Fast/Pro.

### Local models

Expand All @@ -59,30 +61,26 @@ Switch the active local checkpoint in **Settings > Models**. Newer weights (incl
### Windows (local generation)

- Windows 10/11 (x64)
- NVIDIA GPU with CUDA support and **≥16GB VRAM** (more is better)
- NVIDIA GPU with CUDA support and **≥15 GiB VRAM** (integer GiB from `total_memory // 1024**3`; more is better)
- 16GB+ RAM (32GB recommended)
- **160GB+ free disk space** (for model weights, Python environment, and outputs)
- **~72 GB free disk** for the 2.5 Fast core pack (transformer, text encoder, VAEs). Kitchen-sink installs (2.3, image models, processors, prompt enhancer) are larger.

### Linux (local generation)

- Ubuntu 22.04+ or similar distro (x64 or arm64)
- NVIDIA GPU with CUDA support and **≥16GB VRAM** (more is better)
- NVIDIA GPU with CUDA support and **≥15 GiB VRAM** (integer GiB from `total_memory // 1024**3`; more is better)
- NVIDIA driver installed (PyTorch bundles the CUDA runtime)
- 16GB+ RAM (32GB recommended)
- Plenty of free disk space for model weights and outputs
- Plenty of free disk space for model weights and outputs (~72 GB for the 2.5 Fast core pack; kitchen-sink is larger)

### macOS (local generation)

- Apple Silicon (arm64) — Intel Macs have no MPS backend and stay in API-only mode
- Apple Silicon (arm64) — Intel Macs have no MPS backend and cannot run local generation
- macOS 13+ (Ventura)
- **≥15GB free RAM** (not total — the OS/Electron/app already use some); more avoids weight streaming from disk
- Plenty of free disk space for model weights and outputs

Below the free-RAM floor, or on an Intel Mac, the app falls back to API-only mode instead — same as underpowered Windows/Linux hardware (see the table above). API-only mode just needs a stable internet connection.

**How the RAM check works.** The app checks *free* RAM — not total — and only **once**, at launch (when the Python backend process starts). It is not re-checked while the app is running. If other apps are using memory at that moment, you can land in API-only mode even on a capable Mac.
- **≥32 GiB total RAM** (machine SKU, integer GiB from physical memory; not free RAM at launch)
- Plenty of free disk space for model weights and outputs (~72 GB for the 2.5 Fast core pack; kitchen-sink is larger)

If you have 32GB+ of total RAM but still see API-only mode: close memory-heavy apps (browsers are usually the biggest offender), then **quit and relaunch LTX Desktop** — freeing memory while the app is already open has no effect, since the check doesn't run again until the next launch.
Below the total-RAM floor, or on an Intel Mac, local generation is unsupported — same as underpowered Windows/Linux hardware (see the table above). An LTX API key is not required.

## Install

Expand Down Expand Up @@ -155,10 +153,10 @@ Open the selector to tick one or more LoRAs and adjust each one's strength. If y
The LTX API is used for:

- **Cloud text encoding and prompt enhancement** — **FREE**; text encoding is highly recommended to speed up inference and save memory
- API-based video generations (required on unsupported hardware; optional Fast/Pro cloud generations including **LTX 2.5**) — paid
- API-based video generations (optional Fast/Pro cloud generations including **LTX 2.5**) — paid
- Retake — paid

An LTX API key is required in API-only mode, but optional for local generation if you enable the Local Text Encoder.
An LTX API key is optional. Local generation does not require one. Cloud text encoding, prompt enhancement, and API video generation use it when configured.

Generate a FREE API key at the [LTX Console](https://console.ltx.video/). Text encoding is free; video generation API usage is paid. [Read more](https://ltx.io/model/model-blog/ltx-2-better-control-for-real-workflows).

Expand Down Expand Up @@ -256,7 +254,7 @@ Building installers:

## Telemetry

LTX Desktop collects minimal, anonymous usage analytics (app version, platform, and a random installation ID) to help prioritize development. No personal information or generated content is collected. Analytics is enabled by default and can be disabled in **Settings > General > Anonymous Analytics**. See [`TELEMETRY.md`](docs/TELEMETRY.md) for details.
LTX Desktop collects minimal, anonymous usage analytics (app version, platform, hardware information, and a random installation ID) to help prioritize development. No personal information or generated content is collected. Analytics is enabled by default and can be disabled in **Settings > General > Anonymous Analytics**. See [`TELEMETRY.md`](docs/TELEMETRY.md) for details.

## Docs

Expand Down
Loading
Loading