H100: ~395 GB/s per pair (dedicated NVLink). MI325X: ~49 GB/s per pair (448 GB/s shared across 7 links).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| from torch import Tensor | |
| #padding plus causal mask | |
| def create_combined_mask(seq_lengths: torch.Tensor, t: int) -> Tensor: | |
| # Create the Base Causal Mask (mask future tokens) | |
| base_causal_mask = torch.triu(torch.ones((t, t), dtype=torch.bool), diagonal=1) | |
| # Adjust for Padding (mask padding tokens on the left) | |
| padding_mask = torch.arange(t).expand(len(seq_lengths), t) < (t - seq_lengths.unsqueeze(1)) |
