-
Notifications
You must be signed in to change notification settings - Fork 364
chore: Fixes required for LLM models #3002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…llm_examples_main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-19 21:00:09.967336+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-19 21:00:32.451960+00:00
@@ -224,20 +224,22 @@
"""Format shapes and dtypes of input Tensors into a readable string"""
def input_formatter_helper(shapes: Any, dtypes: Any) -> str:
"""Helper for input formatter"""
# Base case 1 - single static/dynamic shape, single dtype
- if isinstance(shapes, tuple) and all(isinstance(elt, (int, tuple)) for elt in shapes):
+ if isinstance(shapes, tuple) and all(
+ isinstance(elt, (int, tuple)) for elt in shapes
+ ):
input_shape_string = "Tensor: ("
for elt in shapes:
if isinstance(elt, tuple):
- input_shape_string+= f"(min={elt[0]}, max={elt[1]}), "
+ input_shape_string += f"(min={elt[0]}, max={elt[1]}), "
else:
- input_shape_string+= f"{elt}, "
+ input_shape_string += f"{elt}, "
input_shape_string = input_shape_string[:-2] + ")" + f"@{str(dtypes)[6:]}, "
return input_shape_string
-
+
# Base case 2 - dynamic shape, single dtype
elif (
isinstance(shapes, dict)
and len(shapes) == 3
and all(
--- /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-19 21:00:10.003336+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-19 21:00:37.999905+00:00
@@ -28,19 +28,16 @@
}
def load_hf_model(model_name_hf):
print("Loading user-specified HF model: ", model_name_hf)
- model_hf = (
- AutoModelForCausalLM.from_pretrained(
- model_name_hf,
- trust_remote_code=True,
- use_cache=False,
- attn_implementation="eager",
- )
- .eval()
- )
+ model_hf = AutoModelForCausalLM.from_pretrained(
+ model_name_hf,
+ trust_remote_code=True,
+ use_cache=False,
+ attn_implementation="eager",
+ ).eval()
return {"model": model_hf}
class ModelStorage:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-20 22:09:12.087830+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-20 22:09:32.444447+00:00
@@ -224,20 +224,22 @@
"""Format shapes and dtypes of input Tensors into a readable string"""
def input_formatter_helper(shapes: Any, dtypes: Any) -> str:
"""Helper for input formatter"""
# Base case 1 - single static/dynamic shape, single dtype
- if isinstance(shapes, tuple) and all(isinstance(elt, (int, tuple)) for elt in shapes):
+ if isinstance(shapes, tuple) and all(
+ isinstance(elt, (int, tuple)) for elt in shapes
+ ):
input_shape_string = "Tensor: ("
for elt in shapes:
if isinstance(elt, tuple):
- input_shape_string+= f"(min={elt[0]}, max={elt[1]}), "
+ input_shape_string += f"(min={elt[0]}, max={elt[1]}), "
else:
- input_shape_string+= f"{elt}, "
+ input_shape_string += f"{elt}, "
input_shape_string = input_shape_string[:-2] + ")" + f"@{str(dtypes)[6:]}, "
return input_shape_string
-
+
# Base case 2 - dynamic shape, single dtype
elif (
isinstance(shapes, dict)
and len(shapes) == 3
and all(
--- /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-20 22:09:12.123831+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-20 22:09:37.620289+00:00
@@ -28,19 +28,16 @@
}
def load_hf_model(model_name_hf):
print("Loading user-specified HF model: ", model_name_hf)
- model_hf = (
- AutoModelForCausalLM.from_pretrained(
- model_name_hf,
- trust_remote_code=True,
- use_cache=False,
- attn_implementation="eager",
- )
- .eval()
- )
+ model_hf = AutoModelForCausalLM.from_pretrained(
+ model_name_hf,
+ trust_remote_code=True,
+ use_cache=False,
+ attn_implementation="eager",
+ ).eval()
return {"model": model_hf}
class ModelStorage:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-21 00:33:04.790449+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-21 00:33:27.241394+00:00
@@ -224,20 +224,22 @@
"""Format shapes and dtypes of input Tensors into a readable string"""
def input_formatter_helper(shapes: Any, dtypes: Any) -> str:
"""Helper for input formatter"""
# Base case 1 - single static/dynamic shape, single dtype
- if isinstance(shapes, tuple) and all(isinstance(elt, (int, tuple)) for elt in shapes):
+ if isinstance(shapes, tuple) and all(
+ isinstance(elt, (int, tuple)) for elt in shapes
+ ):
input_shape_string = "Tensor: ("
for elt in shapes:
if isinstance(elt, tuple):
- input_shape_string+= f"(min={elt[0]}, max={elt[1]}), "
+ input_shape_string += f"(min={elt[0]}, max={elt[1]}), "
else:
- input_shape_string+= f"{elt}, "
+ input_shape_string += f"{elt}, "
input_shape_string = input_shape_string[:-2] + ")" + f"@{str(dtypes)[6:]}, "
return input_shape_string
-
+
# Base case 2 - dynamic shape, single dtype
elif (
isinstance(shapes, dict)
and len(shapes) == 3
and all(
--- /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-21 00:33:04.830449+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-21 00:33:32.549136+00:00
@@ -28,19 +28,16 @@
}
def load_hf_model(model_name_hf):
print("Loading user-specified HF model: ", model_name_hf)
- model_hf = (
- AutoModelForCausalLM.from_pretrained(
- model_name_hf,
- trust_remote_code=True,
- use_cache=False,
- attn_implementation="eager",
- )
- .eval()
- )
+ model_hf = AutoModelForCausalLM.from_pretrained(
+ model_name_hf,
+ trust_remote_code=True,
+ use_cache=False,
+ attn_implementation="eager",
+ ).eval()
return {"model": model_hf}
class ModelStorage:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-21 00:41:21.928115+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/_DryRunTracker.py 2024-08-21 00:41:47.424333+00:00
@@ -224,20 +224,22 @@
"""Format shapes and dtypes of input Tensors into a readable string"""
def input_formatter_helper(shapes: Any, dtypes: Any) -> str:
"""Helper for input formatter"""
# Base case 1 - single static/dynamic shape, single dtype
- if isinstance(shapes, tuple) and all(isinstance(elt, (int, tuple)) for elt in shapes):
+ if isinstance(shapes, tuple) and all(
+ isinstance(elt, (int, tuple)) for elt in shapes
+ ):
input_shape_string = "Tensor: ("
for elt in shapes:
if isinstance(elt, tuple):
- input_shape_string+= f"(min={elt[0]}, max={elt[1]}), "
+ input_shape_string += f"(min={elt[0]}, max={elt[1]}), "
else:
- input_shape_string+= f"{elt}, "
+ input_shape_string += f"{elt}, "
input_shape_string = input_shape_string[:-2] + ")" + f"@{str(dtypes)[6:]}, "
return input_shape_string
-
+
# Base case 2 - dynamic shape, single dtype
elif (
isinstance(shapes, dict)
and len(shapes) == 3
and all(
--- /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-21 00:41:21.964116+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/perf/utils.py 2024-08-21 00:41:52.826949+00:00
@@ -28,19 +28,16 @@
}
def load_hf_model(model_name_hf):
print("Loading user-specified HF model: ", model_name_hf)
- model_hf = (
- AutoModelForCausalLM.from_pretrained(
- model_name_hf,
- trust_remote_code=True,
- use_cache=False,
- attn_implementation="eager",
- )
- .eval()
- )
+ model_hf = AutoModelForCausalLM.from_pretrained(
+ model_name_hf,
+ trust_remote_code=True,
+ use_cache=False,
+ attn_implementation="eager",
+ ).eval()
return {"model": model_hf}
class ModelStorage:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: