riteshghorse commented on code in PR #27989:
URL: https://github.com/apache/beam/pull/27989#discussion_r1304406827


##########
sdks/python/apache_beam/ml/inference/huggingface_inference.py:
##########
@@ -289,6 +289,8 @@ def load_model(self):
     if self._framework == 'pt':
       if self._device == "GPU" and is_gpu_available_torch:
         model.to(torch.device("cuda"))
+    if callable(getattr(model, 'requires_grad_', None)):
+      model.requires_grad_(False)

Review Comment:
   ```suggestion
         if callable(getattr(model, 'requires_grad_', None)):
           model.requires_grad_(False)
   ```
   
   Since this is pytorch specific operation, we could put this inside the block



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to