[feat]: add workload-driven generation launcher - #18
Conversation
Add a model-agnostic FastVideo launcher that executes one generation mode from a versioned MotionKernel workload manifest. Writes structured result JSON for native-versus-optimized end-to-end measurement without model-specific callables.
📝 WalkthroughWalkthroughThe pull request adds a workload-driven FastVideo generation launcher and metadata-only optimization profiler. It validates workloads, runs configured generation modes, records results, profiles pipeline calls, and adds tests and documentation. ChangesOptimization execution
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant run_generation
participant VideoGenerator
participant ComposedPipelineBase
participant optimization_profile
participant JSONExport
CLI->>run_generation: workload and execution mode
run_generation->>VideoGenerator: create configured generator
VideoGenerator->>ComposedPipelineBase: execute generation
ComposedPipelineBase->>optimization_profile: profile pipeline call
optimization_profile->>JSONExport: write profiling metadata
run_generation->>JSONExport: write generation result
JSONExport-->>CLI: result paths and status
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Prefer exact mode_env keys, keep dry-run from mutating os.environ, import torch once for timing, and load the launcher in tests without rewriting sys.path at import time.
|
Addressed Greptile findings:
Left unmerged until review is fully clean. |
|
GPU validation update:
|
|
Want your agent to iterate on Greptile's feedback? Start a greploop in Codex and it will work through the open comments and keep going until this PR reviews clean. |
|
LTX GPU validation complete (SLURM job 907, exit 0):
This confirms the same launcher/profiler path works unchanged for both Wan and LTX. |
Summary
Model-agnostic FastVideo generation and profiling launcher driven by MotionKernel workload manifests.
torch.profilergenerationPairs with aryan5v/motionkernel#9.
Validation
pytest tests/local_tests/optimizations/test_generation_launcher_workload.py -q— 7 passedExample
Summary by CodeRabbit
New Features
Documentation
Tests
Greptile Summary
This PR introduces a workload-driven generation launcher (
generation_launcher.py) that runs a single FastVideo generation mode (native, optimized, fused, or candidate) from a versioned MotionKernel YAML/JSON manifest, and a companion worker-side profiler (fastvideo/optimization/profiler.py) that captures a metadata-only operator export from a designated post-warmup pipeline call.generation_launcher.py): loads and validates workload manifests (schema_version 1), resolves mode-specific env vars without leaking them in dry-run, times warmup+measurement runs, saves frames/logs/failure metadata, and writes structured result JSON files with deterministic write-then-replace atomicity.fastvideo/optimization/profiler.py): activated via theFASTVIDEO_OPTIMIZATION_PROFILE_*env vars, wraps the exact target pipeline forward pass withtorch.profiler, filters out duplicate CUDA-activity rows, and emits a portable JSON without prompts, tensor values, or executable paths.composed_pipeline_base.py): adds a per-instance_optimization_profile_callscounter so the worker can identify and profile exactly the configured forward pass number.Confidence Score: 5/5
Safe to merge — all functionality is additive, gated behind new env vars that default to no-ops, and the pipeline change is a transparent wrapper that passes through when profiling is not configured.
The launcher, profiler, and pipeline integration are all new code that leaves existing inference paths unaffected. The previously flagged issues (env var leaks in dry-run, empty-dict fallthrough in resolve_mode_env, repeated torch imports, module-level sys.path mutation) are all resolved in this revision. The key correctness invariants — one profile per designated call index, atomic file writes, no os.environ mutation in dry-run — are directly covered by the test suite.
Files Needing Attention: No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant CLI as generation_launcher CLI participant LCH as run_generation() participant VG as VideoGenerator (GPU worker) participant PPL as ComposedPipelineBase.forward() participant PRF as optimization_profile() CLI->>LCH: --workload, --mode, --output-dir, --profile-output LCH->>LCH: load_workload_dict() — validate schema_version 1 LCH->>LCH: apply_mode_env() — write mode-specific vars to os.environ LCH->>LCH: "set FASTVIDEO_OPTIMIZATION_PROFILE_* env vars (if --profile-output)" LCH->>VG: VideoGenerator.from_pretrained(model_id) loop warmup runs (0 .. warmups-1) LCH->>VG: generator.generate(request) VG->>PPL: forward(batch) PPL->>PRF: "optimization_profile(call_index < target) no-op yield" PRF-->>PPL: pass-through PPL-->>VG: ForwardBatch VG-->>LCH: result end opt --profile-output requested LCH->>VG: generator.generate(request) [dedicated profiling call] VG->>PPL: forward(batch) PPL->>PRF: "optimization_profile(call_index == target)" PRF->>PRF: "torch.profiler.profile — record shapes & CUDA time" PRF->>PRF: _write_export() to profile.json (atomic .tmp replace) PRF-->>PPL: exit context PPL-->>VG: ForwardBatch VG-->>LCH: result LCH->>LCH: assert profile_output.is_file() end loop timed runs (0 .. runs-1) LCH->>LCH: cuda.reset_peak_memory_stats + synchronize LCH->>VG: generator.generate(request) VG->>PPL: forward(batch) PPL->>PRF: "optimization_profile(call_index > target) no-op yield" PRF-->>PPL: pass-through PPL-->>VG: ForwardBatch VG-->>LCH: result + timings end LCH->>VG: generator.shutdown() LCH->>LCH: "write_json({mode}_result.json, payload) atomic" LCH-->>CLI: exit 0 (ok) or 1 (failed)Reviews (7): Last reviewed commit: "[fix]: honor empty mode overrides" | Re-trigger Greptile