Skip to content

Commit 46bae3f

Browse files
committed
try fix Tile(block_id) error
1 parent cdfcbc8 commit 46bae3f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

helion/_compiler/type_propagation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,19 @@ def __init__(self, origin: Origin, block_id: int) -> None:
990990
self.block_id = block_id
991991

992992
def proxy(self) -> object:
993+
from ..language.tile_proxy import Tile as TileClass
994+
993995
with proxy_tensor.disable_proxy_modes_tracing():
994996
fake_mode = torch._C._unset_dispatch_mode( # pyright: ignore[reportAttributeAccessIssue]
995997
torch._C._TorchDispatchModeKey.FAKE # pyright: ignore[reportAttributeAccessIssue]
996998
)
997999
try:
998-
return Tile(self.block_id)
1000+
# Create a Tile instance using torch.as_subclass to properly handle tensor subclassing
1001+
# This avoids the "already associated to a python object" error
1002+
base_tensor = torch.empty([], dtype=torch.int64, device='meta')
1003+
tile = base_tensor.as_subclass(TileClass)
1004+
tile.block_id = self.block_id
1005+
return tile
9991006
finally:
10001007
assert fake_mode is not None
10011008
torch._C._set_dispatch_mode(fake_mode) # pyright: ignore[reportAttributeAccessIssue]

0 commit comments

Comments
 (0)