[Generate] Fix no grad on some models (#39008)
Some checks are pending
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Waiting to run
Build documentation / build (push) Waiting to run
New model PR merged notification / Notify new model (push) Waiting to run
Slow tests on important models (on Push - A10) / Get all modified files (push) Waiting to run
Slow tests on important models (on Push - A10) / Slow & FA2 tests (push) Blocked by required conditions
Self-hosted runner (push-caller) / Check if setup was changed (push) Waiting to run
Self-hosted runner (push-caller) / build-docker-containers (push) Blocked by required conditions
Self-hosted runner (push-caller) / Trigger Push CI (push) Blocked by required conditions
Secret Leaks / trufflehog (push) Waiting to run
Update Transformers metadata / build_and_package (push) Waiting to run

fixes on torch no grad for generate
This commit is contained in:
Anton Vlasjuk 2025-06-26 13:06:09 +02:00 committed by GitHub
parent 583db52bc6
commit f85b47d1b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 0 deletions

View File

@ -1265,6 +1265,7 @@ class BarkFineModel(BarkPreTrainedModel):
attentions=all_self_attentions,
)
@torch.no_grad()
def generate(
self,
coarse_output: torch.Tensor,

View File

@ -1720,6 +1720,7 @@ class PatchTSMixerForPrediction(PatchTSMixerPreTrainedModel):
scale=scale,
)
@torch.no_grad()
def generate(
self,
past_values: torch.Tensor,
@ -2104,6 +2105,7 @@ class PatchTSMixerForRegression(PatchTSMixerPreTrainedModel):
hidden_states=model_output.hidden_states,
)
@torch.no_grad()
def generate(
self,
past_values: torch.Tensor,

View File

@ -1724,6 +1724,7 @@ class PatchTSTForPrediction(PatchTSTPreTrainedModel):
scale=scale,
)
@torch.no_grad()
def generate(
self,
past_values: torch.Tensor,
@ -1933,6 +1934,7 @@ class PatchTSTForRegression(PatchTSTPreTrainedModel):
attentions=model_output.attentions,
)
@torch.no_grad()
def generate(
self,
past_values: torch.Tensor,