{"record":{"id":"09d5c2749876cf48","repo":"apache/beam","slug":"inference-args-were-provided-but-should-be-none-because-this","errorCode":null,"errorMessage":"inference_args were provided, but should be None because this framework does not expect extra arguments on inferences.","messagePattern":"inference_args were provided, but should be None because this framework does not expect extra arguments on inferences\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/tensorrt_inference.py","lineNumber":352,"sourceCode":"    \"\"\"\n    Returns:\n      The number of bytes of data for a batch of Tensors.\n    \"\"\"\n    return sum((np_array.itemsize for np_array in batch))\n\n  def get_metrics_namespace(self) -> str:\n    \"\"\"\n    Returns a namespace for metrics collected by the RunInference transform.\n    \"\"\"\n    return 'BeamML_TensorRT'\n\n  def validate_inference_args(self, inference_args: Optional[dict[str, Any]]):\n    \"\"\"\n    Currently, this model handler does not support inference args. Given that,\n    we will throw if any are passed in.\n    \"\"\"\n    if inference_args:\n      raise ValueError(\n          'inference_args were provided, but should be None because this '\n          'framework does not expect extra arguments on inferences.')\n","sourceCodeStart":334,"sourceCodeEnd":355,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/tensorrt_inference.py#L334-L355","documentation":"TensorRT model handlers in Apache Beam do not accept extra per-request arguments. validate_inference_args raises ValueError whenever a non-empty inference_args dict is passed, because the TensorRT runtime has no parameters to forward at inference time.","triggerScenarios":"Calling RunInference (or model_handler.predict/inference) with inference_args set to any non-empty dict, e.g. inference_args={'image_size': 512}, against a TensorRTModelHandler.","commonSituations":"Reusing pipeline code written for ONNX/PyTorch/sklearn handlers where inference_args like top_k or image size are supported; copying examples from another framework's docs.","solutions":["Remove the inference_args argument (or pass None) from the RunInference/inference call","Bake the would-be inference arguments into the model config or handler constructor (e.g. via tensorrt_dims/engine settings) instead of per-request","If you need per-request args, switch to a model handler that supports inference_args (e.g. PyTorch or ONNX handlers)"],"exampleFix":"// before\nresult = beam.RunInference(tensorrt_handler, inference_args={'image_size': 512})\n// after\nresult = beam.RunInference(tensorrt_handler, inference_args=None)","handlingStrategy":"validation","validationCode":"if inference_args is not None and len(inference_args) > 0:\n    raise TypeError('TensorRT handler does not accept inference_args; pass None')\nresult = beam.RunInference(tensorrt_handler, inference_args=None)","typeGuard":"def no_inference_args(args) -> bool:\n    return args is None or len(args) == 0","tryCatchPattern":null,"preventionTips":["Pass inference_args=None explicitly when using TensorRT handlers","Keep framework-specific call sites separated so args valid for PyTorch/ONNX are not reused for TensorRT"],"tags":["apache-beam","tensorrt","ml-inference","valueerror"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}