mirror of
https://github.com/THUDM/CogVideo.git
synced 2026-05-11 01:48:38 +08:00
Fix loop variable shadowing in validation that corrupts sample iteration
In the validate() method, the inner loop `for i, ... in enumerate(validation_artifacts)` shadows the outer loop variable `for i in range(num_validation_samples)`. After the inner loop completes, `i` holds the last enumerate index instead of the outer sample index. This causes subsequent validation samples to load incorrect prompts, images, and videos, and breaks DeepSpeed multi-GPU process distribution logic that depends on `i`. Renamed the inner variable to `artifact_idx` to prevent shadowing.
This commit is contained in:
parent
7a1af71545
commit
c54de34681
@ -588,9 +588,9 @@ class Trainer:
|
||||
"image": {"type": "image", "value": image},
|
||||
"video": {"type": "video", "value": video},
|
||||
}
|
||||
for i, (artifact_type, artifact_value) in enumerate(validation_artifacts):
|
||||
for artifact_idx, (artifact_type, artifact_value) in enumerate(validation_artifacts):
|
||||
artifacts.update(
|
||||
{f"artifact_{i}": {"type": artifact_type, "value": artifact_value}}
|
||||
{f"artifact_{artifact_idx}": {"type": artifact_type, "value": artifact_value}}
|
||||
)
|
||||
logger.debug(
|
||||
f"Validation artifacts on process {accelerator.process_index}: {list(artifacts.keys())}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user