Skip to content

Fix pyre error for logits #8687

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

Merged
merged 1 commit into from
Feb 25, 2025
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
44 changes: 23 additions & 21 deletions examples/models/llama/llama_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,29 @@ def forward(
if self.apply_output:
logits = self.output(h)

if self.output_prune_map is not None:
# expand to original size so that downstream applications can use the logits as-is.
if self.generate_full_logits:
# (1, seq_len, pruned_size) -> (1, seq_len, original_size)
expanded_logits = torch.full(
[logits.shape[0], logits.shape[1], self.vocab_size],
float("-inf"),
device=logits.device,
dtype=logits.dtype,
)
expanded_logits[:, :, list(self.output_prune_map.values())] = logits
else:
# (1, pruned_size) -> (1, original_size)
expanded_logits = torch.full(
[logits.shape[0], self.vocab_size],
float("-inf"),
device=logits.device,
dtype=logits.dtype,
)
expanded_logits[:, list(self.output_prune_map.values())] = logits
logits = expanded_logits
if self.output_prune_map is not None:
# expand to original size so that downstream applications can use the logits as-is.
if self.generate_full_logits:
# (1, seq_len, pruned_size) -> (1, seq_len, original_size)
expanded_logits = torch.full(
[logits.shape[0], logits.shape[1], self.vocab_size],
float("-inf"),
device=logits.device,
dtype=logits.dtype,
)
expanded_logits[:, :, list(self.output_prune_map.values())] = logits
else:
# (1, pruned_size) -> (1, original_size)
expanded_logits = torch.full(
[logits.shape[0], self.vocab_size],
float("-inf"),
device=logits.device,
dtype=logits.dtype,
)
expanded_logits[:, list(self.output_prune_map.values())] = logits
logits = expanded_logits
else:
logits = h

if attn_options_update is not None:
return logits, attn_options_update
Expand Down
Loading