From d7ecf76ea8d80b842874bfbd80e8753aad5fffd5 Mon Sep 17 00:00:00 2001 From: anton-l Date: Thu, 6 Oct 2022 15:39:18 +0200 Subject: [PATCH 1/2] Better steps deprecation for LMS --- .../schedulers/scheduling_lms_discrete.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/diffusers/schedulers/scheduling_lms_discrete.py b/src/diffusers/schedulers/scheduling_lms_discrete.py index a4c1d74bfe50..c2fee50fd035 100644 --- a/src/diffusers/schedulers/scheduling_lms_discrete.py +++ b/src/diffusers/schedulers/scheduling_lms_discrete.py @@ -215,9 +215,13 @@ def step( or isinstance(timestep, torch.IntTensor) or isinstance(timestep, torch.LongTensor) ): - warnings.warn( - "Integer timesteps in `LMSDiscreteScheduler.step()` are deprecated and will be removed in version" - " 0.5.0. Make sure to pass one of the `scheduler.timesteps`." + deprecate( + "timestep is an index", + "0.5.0", + "Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to" + " `LMSDiscreteScheduler.step()` is deprecated and will be removed in version 0.5.0. Make sure to pass" + " one of the `scheduler.timesteps` as a timestep.", + standard_warn=False, ) step_index = timestep else: @@ -257,9 +261,13 @@ def add_noise( schedule_timesteps = self.timesteps.to(original_samples.device) timesteps = timesteps.to(original_samples.device) if isinstance(timesteps, torch.IntTensor) or isinstance(timesteps, torch.LongTensor): - warnings.warn( - "Integer timesteps in `LMSDiscreteScheduler.add_noise()` are deprecated and will be removed in" - " version 0.5.0. Make sure to pass values from `scheduler.timesteps`." + deprecate( + "timesteps are indices", + "0.5.0", + "Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to" + " `LMSDiscreteScheduler.add_noise()` is deprecated and will be removed in version 0.5.0. Make sure to" + " pass values from `scheduler.timesteps` as timesteps.", + standard_warn=False, ) step_indices = timesteps else: From 9d4625346d7c32aa8a8a25cff0b0c6e3d6b41e6c Mon Sep 17 00:00:00 2001 From: anton-l Date: Thu, 6 Oct 2022 15:45:02 +0200 Subject: [PATCH 2/2] upd --- src/diffusers/schedulers/scheduling_lms_discrete.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffusers/schedulers/scheduling_lms_discrete.py b/src/diffusers/schedulers/scheduling_lms_discrete.py index c2fee50fd035..802da468cda6 100644 --- a/src/diffusers/schedulers/scheduling_lms_discrete.py +++ b/src/diffusers/schedulers/scheduling_lms_discrete.py @@ -216,10 +216,10 @@ def step( or isinstance(timestep, torch.LongTensor) ): deprecate( - "timestep is an index", + "timestep as an index", "0.5.0", "Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to" - " `LMSDiscreteScheduler.step()` is deprecated and will be removed in version 0.5.0. Make sure to pass" + " `LMSDiscreteScheduler.step()` will not be supported in future versions. Make sure to pass" " one of the `scheduler.timesteps` as a timestep.", standard_warn=False, ) @@ -262,10 +262,10 @@ def add_noise( timesteps = timesteps.to(original_samples.device) if isinstance(timesteps, torch.IntTensor) or isinstance(timesteps, torch.LongTensor): deprecate( - "timesteps are indices", + "timesteps as indices", "0.5.0", "Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to" - " `LMSDiscreteScheduler.add_noise()` is deprecated and will be removed in version 0.5.0. Make sure to" + " `LMSDiscreteScheduler.add_noise()` will not be supported in future versions. Make sure to" " pass values from `scheduler.timesteps` as timesteps.", standard_warn=False, )