mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
revert: inference_mode to no_grad
This commit is contained in:
parent
f155887b7d
commit
639d88afd6
@ -56,7 +56,7 @@ class CompelInvocation(BaseInvocation):
|
||||
},
|
||||
}
|
||||
|
||||
@torch.inference_mode()
|
||||
@torch.no_grad()
|
||||
def invoke(self, context: InvocationContext) -> CompelOutput:
|
||||
tokenizer_info = context.services.model_manager.get_model(
|
||||
**self.clip.tokenizer.dict(),
|
||||
|
@ -285,7 +285,7 @@ class TextToLatentsInvocation(BaseInvocation):
|
||||
# MultiControlNetModel has been refactored out, just need list[ControlNetData]
|
||||
return control_data
|
||||
|
||||
@torch.inference_mode()
|
||||
@torch.no_grad()
|
||||
def invoke(self, context: InvocationContext) -> LatentsOutput:
|
||||
noise = context.services.latents.get(self.noise.latents_name)
|
||||
|
||||
@ -369,7 +369,7 @@ class LatentsToLatentsInvocation(TextToLatentsInvocation):
|
||||
},
|
||||
}
|
||||
|
||||
@torch.inference_mode()
|
||||
@torch.no_grad()
|
||||
def invoke(self, context: InvocationContext) -> LatentsOutput:
|
||||
noise = context.services.latents.get(self.noise.latents_name)
|
||||
latent = context.services.latents.get(self.latents.latents_name)
|
||||
@ -461,7 +461,7 @@ class LatentsToImageInvocation(BaseInvocation):
|
||||
},
|
||||
}
|
||||
|
||||
@torch.inference_mode()
|
||||
@torch.no_grad()
|
||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||
latents = context.services.latents.get(self.latents.latents_name)
|
||||
|
||||
@ -599,7 +599,7 @@ class ImageToLatentsInvocation(BaseInvocation):
|
||||
},
|
||||
}
|
||||
|
||||
@torch.inference_mode()
|
||||
@torch.no_grad()
|
||||
def invoke(self, context: InvocationContext) -> LatentsOutput:
|
||||
# image = context.services.images.get(
|
||||
# self.image.image_type, self.image.image_name
|
||||
|
@ -526,7 +526,7 @@ class ModelPatcher:
|
||||
):
|
||||
original_weights = dict()
|
||||
try:
|
||||
with torch.inference_mode():
|
||||
with torch.no_grad():
|
||||
for lora, lora_weight in loras:
|
||||
#assert lora.device.type == "cpu"
|
||||
for layer_key, layer in lora.layers.items():
|
||||
@ -552,7 +552,7 @@ class ModelPatcher:
|
||||
yield # wait for context manager exit
|
||||
|
||||
finally:
|
||||
with torch.inference_mode():
|
||||
with torch.no_grad():
|
||||
for module_key, weight in original_weights.items():
|
||||
model.get_submodule(module_key).weight.copy_(weight)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user