Remove torch.distributed.tensor.OpSchema.has_symints (#163667)

It appears to be unused based on `cd torch; rg has_symints`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/163667
Approved by: https://github.com/xmfan, https://github.com/azahed98, https://github.com/albanD
ghstack dependencies: #162990
This commit is contained in:
Scott Wolchok 2025-10-30 02:56:54 +00:00 committed by PyTorch MergeBot
parent 398775a43e
commit 639a0b1239
2 changed files with 1 additions and 38 deletions

View File

@ -842,7 +842,6 @@ static bool arg_type_tensor_or_tensor_list_like(py::handle arg) {
_(_local_tensor) \
_(_spec) \
_(args_schema) \
_(has_symints) \
_(kwargs_schema) \
_(op) \
_(schema_info) \
@ -1104,40 +1103,6 @@ static PyObject* DTensor_OpSchema_post_init(PyObject* mod, PyObject* self) {
return nullptr;
}
const auto dtensor_spec_class = get_dtensor_spec_class();
bool has_symints = false;
for (const auto& a : args_schema) {
if (Py_TYPE(a.ptr()) != (PyTypeObject*)(dtensor_spec_class.ptr()) &&
!py::isinstance(a, dtensor_spec_class)) {
continue;
}
const py::handle tensor_meta = a.attr(dtensor_interned_strings.tensor_meta);
if (tensor_meta.is_none()) {
continue;
}
const auto contains_any_symint = [](const py::tuple& sequence) {
for (const auto& s : sequence) {
if (THPUtils_checkLong(s.ptr())) {
continue;
}
if (torch::is_symint(s)) {
return true;
}
}
return false;
};
// Specifically it's supposed to be torch.Size.
py::object raw_shape = tensor_meta.attr(dtensor_interned_strings.shape);
if (!PyTuple_Check(raw_shape.ptr())) {
PyErr_SetString(PyExc_TypeError, "OpSchema.shape must be a tuple!");
return nullptr;
}
const auto shape = py::reinterpret_steal<py::tuple>(raw_shape.release());
if (contains_any_symint(shape)) {
has_symints = true;
}
}
self_handle.attr(dtensor_interned_strings.has_symints) = has_symints;
Py_RETURN_NONE;
END_HANDLE_TH_ERRORS
}

View File

@ -24,7 +24,7 @@ These schema definitions enable the DTensor system to:
"""
from collections.abc import Sequence
from dataclasses import dataclass, field
from dataclasses import dataclass
from functools import cached_property
from typing import Any, Optional, Union
from typing_extensions import deprecated
@ -335,8 +335,6 @@ class OpSchema:
_comparison_key: Optional[tuple[object, ...]] = None
has_symints: bool = field(init=False)
@property
def args_spec(self) -> tuple[DTensorSpec, ...]:
"""