From 726b60dc2915acee0a089d0b25254bb87af3d49b Mon Sep 17 00:00:00 2001 From: Mike Teehan Date: Mon, 1 Jun 2026 19:46:36 -0400 Subject: [PATCH] Add .env.example, Makefile; fix fp8_scaled_mm quantization policy - Use build_policy(checkpoint_path) for fp8_scaled_mm - Add .env.example template - Add Makefile with common targets (install, api, docs, clean, lint) --- Makefile | 33 +++++++++++++++++++++++++++++++++ app/service.py | 10 ++-------- 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d8cf993 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +PYTHON := .venv/bin/python +PIp := .venv/bin/pip +UVICORN := .venv/bin/uvicorn +LTX_PKG := libs/LTX-2 +DB := app/jobs.db +PORT ?= 8000 +RELOAD ?= --reload + +.PHONY: install lint api clean docs + +# Install project deps (LTX packages must be installed first manually) +install: + $(PIP) install -r requirements.txt + +# Run the API server +api: + PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \ + $(UVICORN) app.main:app --host 0.0.0.0 --port $(PORT) $(RELOAD) + +# Generate OpenAPI docs as JSON +docs: + $(PYTHON) -c "import json; from app.main import app; json.dump(app.openapi(), open('openapi.json', 'w'), indent=2)" + +# Clean up generated artifacts +clean: + rm -rf videos/*.mp4 $(DB) *.db __pycache__ app/__pycache__ + +# Lint +lint: + @command -v ruff >/dev/null && .venv/bin/ruff check app/ || echo "ruff not installed" + @command -v flake8 >/dev/null && .venv/bin/flake8 app/ || echo "flake8 not installed" + $(PYTHON) -m py_compile app/main.py app/config.py app/models.py app/service.py app/database.py + @echo "Syntax OK" diff --git a/app/service.py b/app/service.py index f8f3fe7..98aefc2 100644 --- a/app/service.py +++ b/app/service.py @@ -83,15 +83,9 @@ class LtxService: fuse_rule=fp8_cast_fuse_rule, ) if q == "fp8_scaled_mm": - from ltx_core.quantization.fp8_scaled_mm import ( - FP8_SCALED_MM_MODULE_OPS, - fp8_scaled_mm_fuse_rule, - ) - from ltx_core.quantization.policy import QuantizationPolicy + from ltx_core.quantization.fp8_scaled_mm import build_policy as fp8_build - return QuantizationPolicy( - module_ops=FP8_SCALED_MM_MODULE_OPS, fuse_rule=fp8_scaled_mm_fuse_rule - ) + return fp8_build(settings.ltx_distilled_checkpoint) return None async def submit_job(