Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def __init__(self, *args, **kwargs):
logger.debug("Building custom VocabParallelEmbedding for Spyre")

self._target_device = torch.device("spyre")
self._target_dtype = None
# The inputs for spyre need to be torch.int64
self._input_target_dtype = torch.int64
# The weights for spyre need to be torch.float16
self._weight_target_dtype = torch.float16
self.maybe_compiled_forward_spyre = self.maybe_compile(self.forward_spyre)

self._layer_name = register_layer(self, "spyre_vocab_parallel_embedding")
Expand Down Expand Up @@ -154,8 +157,8 @@ def _forward_spyre_impl(self, x: torch.Tensor) -> torch.Tensor:
out_device = x.device

out = self.maybe_compiled_forward_spyre(
convert(x, dtype=self._target_dtype, device=self._target_device),
convert(self.weight.data, dtype=self._target_dtype, device=self._target_device),
convert(x, dtype=self._input_target_dtype, device=self._target_device),
convert(self.weight.data, dtype=self._weight_target_dtype, device=self._target_device),
)

# Transfer back to original device and restore original dtype
Expand Down
Loading