Skip to content

[MPS] Fix static llama AOT tracing #2800

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

Closed
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
7 changes: 6 additions & 1 deletion backends/apple/mps/operators/constant_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def define_node(
elif node.target == exir_ops.edge.aten.empty.memory_format:
fill_value = 0
elif node.target == exir_ops.edge.aten.scalar_tensor.default:
fill_value = float(node.args[0])
fill_value = cast(float, node.args[0])

if fill_value == float("-inf"):
fill_value = "-inf"
elif fill_value == float("inf"):
fill_value = "inf"

dtype = MPSDataType.mps_data_type_float32
if node.kwargs and "dtype" in node.kwargs and node.kwargs["dtype"] is not None:
Expand Down
5 changes: 2 additions & 3 deletions backends/apple/mps/operators/node_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,9 @@ def define_scalar(
"""
assert isinstance(val, int) or isinstance(val, float)

if val in self.tensor_to_id:
return self.tensor_to_id[val]
id = len(mps_graph.mps_values)
self.tensor_to_id[val] = id

id = self.get_serialized_id(val, mps_graph)
tensor = torch.tensor(val)
constant_buffer_size, constant_buffer, mps_data_type = self.get_serialized_data(
tensor, mps_graph, mps_data_type, id
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/mps/serialization/mps_graph_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class MPSFull:

@dataclass
class MPSFullLike(MPSNode1x1):
fill_value: float = 0.0
fill_value: Union[float, str] = 0.0
dtype: MPSDataType = MPSDataType.mps_data_type_float32


Expand Down