Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lightx2v/models/schedulers/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def __init__(self, config):
self.config = config
self.latents = None
self.step_index = 0
self.infer_steps = config["infer_steps"]
self.caching_records = [True] * config["infer_steps"]
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved robustness, it's good practice to validate configuration values. This change uses config.get() to safely retrieve infer_steps and adds validation to ensure it's a positive integer. This prevents potential KeyError exceptions for missing keys and handles invalid values like zero, negative numbers, or non-integers, making the scheduler more resilient to configuration errors.

Suggested change
self.infer_steps = config["infer_steps"]
self.caching_records = [True] * config["infer_steps"]
self.infer_steps = config.get("infer_steps")
if not isinstance(self.infer_steps, int) or self.infer_steps <= 0:
raise ValueError(f"'infer_steps' must be a positive integer, but got {self.infer_steps!r}")
self.caching_records = [True] * self.infer_steps

self.flag_df = False
self.transformer_infer = None
self.infer_condition = True # cfg status
Expand Down