This is an automated email from the ASF dual-hosted git repository. riteshghorse pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 475a0c78690 Fix syntax (#29719) 475a0c78690 is described below commit 475a0c7869051331a03f2bcb65af45113fd984a3 Author: Ritesh Ghorse <riteshgho...@gmail.com> AuthorDate: Tue Dec 12 14:08:45 2023 -0500 Fix syntax (#29719) * correct syntax * remove unused inference_args --- .../apache_beam/ml/inference/huggingface_inference.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/sdks/python/apache_beam/ml/inference/huggingface_inference.py b/sdks/python/apache_beam/ml/inference/huggingface_inference.py index 1bc92c462c9..25367d22eaa 100644 --- a/sdks/python/apache_beam/ml/inference/huggingface_inference.py +++ b/sdks/python/apache_beam/ml/inference/huggingface_inference.py @@ -221,7 +221,6 @@ class HuggingFaceModelHandlerKeyedTensor(ModelHandler[Dict[str, *, inference_fn: Optional[Callable[..., Iterable[PredictionResult]]] = None, load_model_args: Optional[Dict[str, Any]] = None, - inference_args: Optional[Dict[str, Any]] = None, min_batch_size: Optional[int] = None, max_batch_size: Optional[int] = None, max_batch_duration_secs: Optional[int] = None, @@ -250,10 +249,6 @@ class HuggingFaceModelHandlerKeyedTensor(ModelHandler[Dict[str, load_model_args (Dict[str, Any]): (Optional) Keyword arguments to provide load options while loading models from Hugging Face Hub. Defaults to None. - inference_args (Dict[str, Any]): (Optional) Non-batchable arguments - required as inputs to the model's inference function. Unlike Tensors - in `batch`, these parameters will not be dynamically batched. - Defaults to None. min_batch_size: the minimum batch size to use when batching inputs. max_batch_size: the maximum batch size to use when batching inputs. max_batch_duration_secs: the maximum amount of time to buffer a batch @@ -273,7 +268,6 @@ class HuggingFaceModelHandlerKeyedTensor(ModelHandler[Dict[str, self._device = device self._inference_fn = inference_fn self._model_config_args = load_model_args if load_model_args else {} - self._inference_args = inference_args if inference_args else {} self._batching_kwargs = {} self._env_vars = kwargs.get("env_vars", {}) if min_batch_size is not None: @@ -293,7 +287,7 @@ class HuggingFaceModelHandlerKeyedTensor(ModelHandler[Dict[str, model = self._model_class.from_pretrained( self._model_uri, **self._model_config_args) if self._framework == 'pt': - if self._device == "GPU" and is_gpu_available_torch: + 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) @@ -407,7 +401,6 @@ class HuggingFaceModelHandlerTensor(ModelHandler[Union[tf.Tensor, torch.Tensor], *, inference_fn: Optional[Callable[..., Iterable[PredictionResult]]] = None, load_model_args: Optional[Dict[str, Any]] = None, - inference_args: Optional[Dict[str, Any]] = None, min_batch_size: Optional[int] = None, max_batch_size: Optional[int] = None, max_batch_duration_secs: Optional[int] = None, @@ -436,10 +429,6 @@ class HuggingFaceModelHandlerTensor(ModelHandler[Union[tf.Tensor, torch.Tensor], load_model_args (Dict[str, Any]): (Optional) keyword arguments to provide load options while loading models from Hugging Face Hub. Defaults to None. - inference_args (Dict[str, Any]): (Optional) Non-batchable arguments - required as inputs to the model's inference function. Unlike Tensors - in `batch`, these parameters will not be dynamically batched. - Defaults to None. min_batch_size: the minimum batch size to use when batching inputs. max_batch_size: the maximum batch size to use when batching inputs. max_batch_duration_secs: the maximum amount of time to buffer a batch @@ -459,7 +448,6 @@ class HuggingFaceModelHandlerTensor(ModelHandler[Union[tf.Tensor, torch.Tensor], self._device = device self._inference_fn = inference_fn self._model_config_args = load_model_args if load_model_args else {} - self._inference_args = inference_args if inference_args else {} self._batching_kwargs = {} self._env_vars = kwargs.get("env_vars", {}) if min_batch_size is not None: @@ -586,7 +574,6 @@ class HuggingFacePipelineModelHandler(ModelHandler[str, device: Optional[str] = None, inference_fn: PipelineInferenceFn = _default_pipeline_inference_fn, load_pipeline_args: Optional[Dict[str, Any]] = None, - inference_args: Optional[Dict[str, Any]] = None, min_batch_size: Optional[int] = None, max_batch_size: Optional[int] = None, max_batch_duration_secs: Optional[int] = None, @@ -623,9 +610,6 @@ class HuggingFacePipelineModelHandler(ModelHandler[str, Default is _default_pipeline_inference_fn. load_pipeline_args (Dict[str, Any]): keyword arguments to provide load options while loading pipelines from Hugging Face. Defaults to None. - inference_args (Dict[str, Any]): Non-batchable arguments - required as inputs to the model's inference function. - Defaults to None. min_batch_size: the minimum batch size to use when batching inputs. max_batch_size: the maximum batch size to use when batching inputs. max_batch_duration_secs: the maximum amount of time to buffer a batch @@ -644,7 +628,6 @@ class HuggingFacePipelineModelHandler(ModelHandler[str, self._model = model self._inference_fn = inference_fn self._load_pipeline_args = load_pipeline_args if load_pipeline_args else {} - self._inference_args = inference_args if inference_args else {} self._batching_kwargs = {} self._framework = "torch" self._env_vars = kwargs.get('env_vars', {})