Skip to content

feat: Add support for Groot N1.5 model #3736

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ def index_dtype_validator(


@dynamo_tensorrt_converter(
torch.ops.aten.index.Tensor, capability_validator=index_dtype_validator
torch.ops.aten.index.Tensor,
capability_validator=index_dtype_validator,
supports_dynamic_shapes=True,
)
@enforce_tensor_types(
{
Expand Down
6 changes: 4 additions & 2 deletions py/torch_tensorrt/dynamo/conversion/converter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
import numpy as np
import tensorrt as trt
import torch
import torch_tensorrt.dynamo.conversion.impl as impl
from torch.fx.experimental.proxy_tensor import unset_fake_temporarily
from torch.fx.node import Argument, Target
from torch.fx.passes.shape_prop import TensorMetadata

import torch_tensorrt.dynamo.conversion.impl as impl
from torch_tensorrt import _enums
from torch_tensorrt.dynamo._settings import CompilationSettings
from torch_tensorrt.dynamo._SourceIR import SourceIR
Expand Down Expand Up @@ -73,6 +72,9 @@ def format_tensor_metadata(metadata: Union[Any, Sequence[Any]]) -> str:
# If the provided data is a scalar, return it as is
elif isinstance(metadata, (int, float, bool)):
return f"{metadata}@Python-{type(metadata)}"
# If the provided data is a SymInt, return it as is
elif isinstance(metadata, (torch.SymInt)):
return f"{metadata}@SymInt"
# If the provided data is a sequence, recursively parse it
elif isinstance(metadata, collections.abc.Sequence):
formatted_str = "("
Expand Down
32 changes: 20 additions & 12 deletions py/torch_tensorrt/dynamo/conversion/impl/matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,25 @@ def matrix_multiply(
input, other = broadcast(
ctx, input, other, f"{name}_input", f"{name}_other", preset_diff
)
if ctx.net.get_flag(trt.NetworkDefinitionCreationFlag.STRONGLY_TYPED):
promoted_type = _enums.dtype._from(
torch.promote_types(
_enums.dtype._from(input.dtype).to(torch.dtype),
_enums.dtype._from(other.dtype).to(torch.dtype),
)
if (
ctx.net.get_flag(trt.NetworkDefinitionCreationFlag.STRONGLY_TYPED)
and ctx.compilation_settings.use_fp32_acc
):
input = cast_trt_tensor(ctx, input, torch.float32, f"{name}_input_casted")
other = cast_trt_tensor(ctx, other, torch.float32, f"{name}_other_casted")

matmul_layer = ctx.net.add_matrix_multiply(
input, input_matrix_op, other, other_matrix_op
)
matmul_output = matmul_layer.get_output(0)

if (
ctx.net.get_flag(trt.NetworkDefinitionCreationFlag.STRONGLY_TYPED)
and ctx.compilation_settings.use_fp32_acc
):
matmul_output = cast_trt_tensor(
ctx, matmul_output, torch.float16, f"{name}_output_casted"
)
trt_promoted_type = promoted_type.to(trt.DataType)
input = cast_trt_tensor(ctx, input, trt_promoted_type, f"{name}_input_casted")
other = cast_trt_tensor(ctx, other, trt_promoted_type, f"{name}_other_casted")

layer = ctx.net.add_matrix_multiply(input, input_matrix_op, other, other_matrix_op)
set_layer_name(layer, target, name, source_ir)
return layer.get_output(0)
set_layer_name(matmul_layer, target, name, source_ir)
return matmul_output
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from torch_tensorrt.dynamo._settings import CompilationSettings
from torch_tensorrt.dynamo.utils import is_tegra_platform

from .accumulate_fp32_matmul import accumulate_fp32_matmul
from .complex_graph_rewrite import complex_graph_detection
from .constant_folding import constant_fold
from .fuse_distributed_ops import fuse_distributed_ops
Expand All @@ -25,7 +24,6 @@
fuse_prims_broadcast,
replace_max_pool_with_indices,
remove_assert_nodes,
accumulate_fp32_matmul,
remove_num_users_is_0_nodes,
complex_graph_detection,
]
Expand Down
102 changes: 0 additions & 102 deletions py/torch_tensorrt/dynamo/lowering/passes/accumulate_fp32_matmul.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def compile(self) -> None:
enabled_precisions=self.enabled_precisions,
**self.additional_settings,
)
deallocate_module(self.original_model, delete_module=False)
if self.additional_settings.get("offload_module_to_cpu", False):
deallocate_module(self.original_model, delete_module=False)
if self.enable_weight_streaming:
self.set_weight_streaming_ctx(self.weight_streaming_budget)

Expand Down