Skip to content
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

[dtensor] quick fix to #109306 #109428

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 5 additions & 10 deletions torch/distributed/_tensor/op_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class RuntimeSchemaInfo:
# args/kwargs which would affect sharding propagation results. All args after this
# index would be hashed to our sharding cache.
# Note that only a few ops need this information, e.g. view, transpose, var.dim, etc.
static_argnum: int = -1
static_argnum: int = 100
# This static_kwargkey records static kwarg names which would affect sharding prop
static_kwargkey: Optional[List[str]] = None
# TODO: make use of this field
Expand Down Expand Up @@ -193,20 +193,15 @@ def __repr__(self) -> str:
)

def arg_type_tensor_or_tensor_list_like(self, arg_idx: int) -> bool:
op_arg_type = self.op._schema.arguments[arg_idx].type
is_tensor = isinstance(op_arg_type, torch.TensorType)
arg = self.args_schema[arg_idx]
is_tensor = isinstance(arg, DTensorSpec)
if is_tensor:
return True

is_list_like = isinstance(op_arg_type, torch.ListType)
if not is_list_like:
if not isinstance(arg, list):
return False

elem_type = op_arg_type.getElementType()
return isinstance(elem_type, torch.TensorType) or (
isinstance(elem_type, torch.OptionalType)
and isinstance(elem_type.getElementType(), torch.TensorType)
)
return all(isinstance(e, DTensorSpec) or e is None for e in arg)

def __hash__(self) -> int:
# Only hash args and kwargs that op indicates to hash
Expand Down