TCDScheduler advances the generator on the final step of a strength-truncated custom schedule
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu từ phương thức step của TCDScheduler, nơi kiểm tra bước cuối so sánh chỉ số hiện tại với num_inference_steps rồi lấy mẫu nhiễu khi eta > 0. Chạy script tái hiện từ issue, script này dùng set_timesteps(timesteps=[999, 499, 19], strength=0.5), và xác nhận trạng thái của generator thay đổi. Hoàn thành khi phép kiểm tra dùng độ dài của self.timesteps, trạng thái generator không đổi ở bước cuối thực tế, và các test hiện có của TCD scheduler vẫn pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When TCDScheduler uses a non-empty custom timestep schedule truncated by
strength < 1, its actual final step advances the supplied random generator
when eta > 0.
For example, timesteps=[999, 499, 19] with strength=0.5 leaves only [19],
but num_inference_steps remains 3. The final-step check uses the original
step count and enters the noise-sampling branch.
In the tested case, the terminal output stays the same because the noise
coefficient is zero, but the generator state changes. Subsequent draws using
the same generator therefore differ.
I expected the actual final step to leave the generator state unchanged,
consistent with the scheduler's comment that noise is not used on the final
timestep.
A possible fix is to decide whether another step exists using the length of
self.timesteps. I have tested a candidate fix and can provide it for review.
Reproduction
import diffusers
import torch
from diffusers import TCDScheduler
print(f"torch={torch.__version__} diffusers={diffusers.__version__}")
print(f"source={diffusers.__file__}")
scheduler = TCDScheduler(prediction_type="sample")
scheduler.set_timesteps(timesteps=[999, 499, 19], strength=0.5, device="cpu")
generator = torch.Generator(device="cpu").manual_seed(0)
control = torch.Generator(device="cpu").manual_seed(0)
sample = torch.ones((1, 1), device="cpu")
before = generator.get_state().clone()
result = scheduler.step(
torch.zeros_like(sample),
scheduler.timesteps[0],
sample,
eta=0.3,
generator=generator,
)
after = generator.get_state()
next_draw = torch.randn(4, generator=generator, device="cpu")
control_draw = torch.randn(4, generator=control, device="cpu")
print(f"actual timesteps={scheduler.timesteps.tolist()}")
print(f"num_inference_steps={scheduler.num_inference_steps}")
print(f"prev_sample={result.prev_sample.item()}")
print(f"pred_noised_sample={result.pred_noised_sample.item()}")
print(f"RNG state preserved: {torch.equal(before, after)}")
print(f"next draw: {next_draw.tolist()}")
print(f"control: {control_draw.tolist()}")
assert torch.equal(before, after), "The terminal step advanced the generator"
Context
No response
Logs
Baseline: unmodified Diffusers source at commit
43e30028af5120d8b0868cb6975b9fad39cc4fab
torch=2.9.0+cu126
diffusers=0.44.0.dev0
actual timesteps=[19]
num_inference_steps=3
prev_sample=0.21879726648330688
pred_noised_sample=0.21879726648330688
RNG state preserved: False
next draw: [-0.293428897857666, -2.1787893772125244, 0.5684312582015991, -1.0845223665237427]
control: [1.5409960746765137, -0.293428897857666, -2.1787893772125244, 0.5684312582015991]
AssertionError: The terminal step advanced the generator
System Info
Platform: Windows 11
Python: 3.12.8
PyTorch: 2.9.0+cu126
Diffusers: 0.44.0.dev0, source checkout at commit 43e30028af5120d8b0868cb6975b9fad39cc4fab
Device used for reproduction: CPU
Who can help?
No response
- Ngôn ngữ chính
- Python
- Star
- 34.9k
- Fork
- 7.5k
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 65
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của huggingface/diffusers
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
huggingface/diffusers#15363 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeErrorCó thể đã có người làm @chessing234 đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
huggingface/diffusers#15337 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)Có thể đã có người làm @sunhouy đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
huggingface/diffusers#15313 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded againCó thể đã có người làm @sohailshk đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
huggingface/diffusers#15211 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
set_ip_adapter_scale(float) raises "Cannot assign 1 scale_configs to 2 IP-Adapter" when several IP-Adapters are loadedCó thể đã có người làm @sohailshk đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
huggingface/diffusers#15210 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của huggingface/diffusers
Issue tương tự
-
[dbt] exported dataset keys reference physical columnsCó thể đã có người làm @WilliamKelley đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/ossie-converters#251 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
cli difficulty: easy enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
desec-io/desec-stack#1312 ·
Maintainer thường phản hồi trong vòng 14 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws/aws-durable-execution-sdk-python#977 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
flashinfer-ai/flashinfer#9803 ·
Maintainer thường phản hồi trong vòng 1 ngày