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
| from copy import deepcopy | |
| import torch | |
| from datasets import load_dataset | |
| from torch.optim import SGD | |
| from torch.utils.data import DataLoader | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import random | |
| import os | |
| import numpy as np |
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.nn import functional as F | |
| from torch import distributed as dist | |
| import os | |
| import numpy as np | |
| import random | |
| def set_random_seed(seed: int): | |
| torch.manual_seed(seed) | |
| if torch.cuda.is_available(): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| #VERBOSE=0 torchrun --nproc_per_node 3 self_contained_pp_LOC.py | |
| import os, random, numpy as np, torch, torch.nn as nn, torch.distributed as dist, torch.nn.functional as F | |
| from torch.optim import AdamW | |
| from torch.utils.data import DataLoader, DistributedSampler | |
| from datasets import load_dataset | |
| from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer | |
| STEP, local_rank, world_size, verbose = 0, int(os.environ["LOCAL_RANK"]), int(os.environ["WORLD_SIZE"]), os.environ.get("VERBOSE", "0") == "1" | |
| def set_all_seed(seed): |
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 os | |
| import torch | |
| import torch.distributed as dist | |
| import lovely_tensors as lt; lt.monkey_patch() | |
| def split_tensor(data: torch.Tensor, dim: int) -> torch.Tensor: | |
| rank = dist.get_rank() | |
| world_size = dist.get_world_size() |
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 | |
| import triton | |
| import triton.language as tl | |
| def assert_is_matrix(x): | |
| if x.ndim != 2: | |
| raise ValueError(f'Expected 2-tensor but got {x.ndim}-tensor') | |
| def assert_is_vector(x): | |
| if x.ndim != 1: |
OlderNewer