python_code
stringlengths
0
290k
repo_name
stringclasses
30 values
file_path
stringlengths
6
125
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import logging from http import HTTPStatus from typing import Any from libcommon.constants import PROCESSING_STEP_DATASET_INFO_VERSION from libcommon.exceptions import PreviousStepFormatError from libcommon.simple_cache import ( Cache...
datasets-server-main
services/worker/src/worker/job_runners/dataset/info.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import logging from typing import Optional from datasets import get_dataset_config_names from datasets.data_files import EmptyDatasetError as _EmptyDatasetError from libcommon.constants import PROCESSING_STEP_DATASET_CONFIG_NAMES_VERSION ...
datasets-server-main
services/worker/src/worker/job_runners/dataset/config_names.py
import argparse import glob import multiprocessing as mp import os import pickle import random import struct import numpy as np from datasets import load_from_disk from tqdm import tqdm from transformers import GPT2Tokenizer, T5Tokenizer parser = argparse.ArgumentParser(description="Load a dataset.") parser.add_argum...
datablations-main
filtering/deduplication/hf_dataset_to_file.py
import argparse import glob import os from functools import partial from multiprocessing import Pool, cpu_count from datasets import DatasetDict, load_from_disk def save_dataset(dataset_name, base_dir, sample_size=100000, token=None): print("Processing", dataset_name) ds = load_from_disk(base_dir + dataset_n...
datablations-main
filtering/deduplication/save_dataset_sample.py
import os from multiprocessing import cpu_count from datasets import load_dataset HUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN") print(HUGGINGFACE_TOKEN) oscar = load_dataset( "oscar-corpus/OSCAR-2201", "en", use_auth_token=HUGGINGFACE_TOKEN, num_proc=cpu_count(), ignore_verifications=True ) oscar.save_...
datablations-main
filtering/deduplication/save_dataset.py
import os from collections import Counter from datasets import load_dataset HUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN") oscar = load_dataset( "oscar-corpus/OSCAR-2201", "en", use_auth_token=HUGGINGFACE_TOKEN, num_proc=128, ignore_verifications=True, ) # oscar.save_to_disk("/home/piktu...
datablations-main
filtering/deduplication/download_oscar.py
import jsonlines from collections import defaultdict from datasets import load_from_disk, load_dataset, concatenate_datasets from multiprocessing import Pool, cpu_count from tqdm import tqdm oscar = load_from_disk("/home/piktus_huggingface_co/lumi/preprocessed_data/oscar-dedup-exapanded/") # oscar = load_dataset("ola1...
datablations-main
filtering/deduplication/filter_oscar_jsonl.py
import argparse import os import sys from datasets import load_dataset sys.path.append("/home/piktus_huggingface_co/lumi/text-dedup") print(sys.path) from text_dedup.suffix_array import suffix_array def get_args(): """ parser = argparse.ArgumentParser() parser.add_argument('--name', type=str, require...
datablations-main
filtering/deduplication/suffix_dedup.py
from datasets import load_from_disk import string def find_whitespace(text): for i, c in enumerate(text): if c in string.whitespace: yield i def def get_segmentation(text, passage_tokens, overlap_tokens): whitespace_idx = [-1] + list(find_whitespace(text)) unique_tokens = passage_tok...
datablations-main
filtering/deduplication/dedup_oscar.py
import argparse import ast import glob import os from datasets import DatasetDict, concatenate_datasets, load_from_disk def get_perplexity(meta): meta = ast.literal_eval(meta) if isinstance(meta, str) else meta perplexity_score = meta["perplexity_score"] return float(perplexity_score) if __name__ == "_...
datablations-main
filtering/deduplication/save_roots_sample.py
import argparse import os import pickle from bisect import bisect_right from collections import defaultdict from multiprocessing import cpu_count from datasets import load_from_disk from tqdm import tqdm def get_pairs(byterange): """ Returns pairs generated by https://github.com/google-research/deduplica...
datablations-main
filtering/deduplication/add_dedup_info.py
# import csv import pandas as pd import string from datasets import load_dataset from tqdm import tqdm def find_whitespace(text): for i, c in enumerate(text): if c in string.whitespace: yield i oscar_small = pd.DataFrame(load_dataset("ola13/small-oscar")["train"][:10]) query_length = 100 ...
datablations-main
filtering/deduplication/save_rust_format.py
""" muP Preparation from https://github.com/microsoft/mutransformers#basic-usage-of-models !git clone https://github.com/microsoft/mutransformers.git %cd mutransformers !pip install -r requirements.txt !pip install -e . !pip install -q datasets With our CC-like architectures we found that 7m params & 100M tokens -> 8...
datablations-main
training/mup.py
import os import shutil # shutil.rmtree() checkpoint_dirs = [dir_name for dir_name in os.listdir() if dir_name.startswith('checkpoint')] for dir_name in checkpoint_dirs: latest_file_path = os.path.join(dir_name, 'latest') with open(latest_file_path, 'r') as f: latest_checkpoint = f.read().strip() ...
datablations-main
utils/cleandirs.py
#!/usr/bin/env python # this script converts results.json: # # "results": { # "arc_challenge": { # "acc": 0.24232081911262798, # "acc_stderr": 0.01252159329580012, # "acc_norm": 0.2764505119453925, # "acc_norm_stderr": 0.013069662474252425 # }, # # into a format expected by a spreadsh...
datablations-main
utils/csv_generative.py
def full_flops(dataset_size, hidden_size, num_heads, num_layers, seq_len=2048, vocab_size=32000, ffw_size=None): if ffw_size is None: ffw_size = 4 * hidden_size embeddings_flops = 2 * seq_len * vocab_size * hidden_size attention_kqv_proj = 2 * 3 * seq_len * hidden_size * hidden_size attention_kq...
datablations-main
utils/flops-params_py.py
""" Saves a merged.json file in the provided directory python merge_all_json.py DIRECTORY """ import json import os from pathlib import Path import sys from typing import Dict def find_all_json(root_dir: Path): if root_dir.is_file(): if root_dir.name.endswith(".json"): return [root_dir] ...
datablations-main
utils/merge_generative.py
#!/usr/bin/env python # creates a local auth token file which can then be safely used by other programs without leaking # the password in public git import getpass import json from pathlib import Path from huggingface_hub import HfApi HUB_DATA_PATH_SHARED = "/pfs/lustrep4/scratch/project_462000119/muennighoff/nov-20...
datablations-main
utils/hub_auth.py
""" Script for searching through logs to look for failing nodes. """ import sys import re NODE_RANK_RE = re.compile(r'Launching on (\S+) \((\d+)/(\d+)\)') ERROR_STRINGS = [ 'Segmentation fault', 'Failed to initialize RSMI device mutex', 'ERROR:torch.distributed.elastic.multiprocessing.api:failed', ] ...
datablations-main
utils/errornodes.py
#!/usr/bin/env python # # This tool automatically pushes newly added and modified files into the hub repo, if they match the # provided one or more patterns. # # If the program fails to run the first time make sure to run `hub-auth.py` to authenticate and save # the token, and user name/email locally which will then b...
datablations-main
utils/hub_sync.py
import argparse import os from typing import List, Dict import subprocess import shlex import numpy as np import pyarrow as pa from datasets import load_dataset, Dataset, concatenate_datasets from tqdm import tqdm def get_args(): parser = argparse.ArgumentParser() parser.add_argument('--name', type=str, requ...
datablations-main
utils/hf_dataset_subsampling.py
############################################################################### # Language Modeling on Penn Tree Bank # # This file generates new sentences sampled from the language model # ############################################################################### import argparse import torch from torch.autograd...
awd-lstm-lm-master
generate.py
import torch import torch.nn as nn from torch.autograd import Variable from embed_regularize import embedded_dropout from locked_dropout import LockedDropout from weight_drop import WeightDrop class RNNModel(nn.Module): """Container module with an encoder, a recurrent module, and a decoder.""" def __init__(s...
awd-lstm-lm-master
model.py
from torch.autograd import Variable def repackage_hidden(h): """Wraps hidden states in new Variables, to detach them from their history.""" if type(h) == Variable: return Variable(h.data) else: return tuple(repackage_hidden(v) for v in h) def batchify(data, bsz, args): # Work out how c...
awd-lstm-lm-master
utils.py
import argparse import time import math import numpy as np import torch import torch.nn as nn from torch.autograd import Variable import data import model from utils import batchify, get_batch, repackage_hidden parser = argparse.ArgumentParser(description='PyTorch PennTreeBank RNN/LSTM Language Model') parser.add_ar...
awd-lstm-lm-master
pointer.py
import numpy as np import torch from torch.autograd import Variable def embedded_dropout(embed, words, dropout=0.1, scale=None): if dropout: mask = embed.weight.data.new().resize_((embed.weight.size(0), 1)).bernoulli_(1 - dropout).expand_as(embed.weight) / (1 - dropout) mask = Variable(mask) masked_embe...
awd-lstm-lm-master
embed_regularize.py
import torch from torch.nn import Parameter from functools import wraps class WeightDrop(torch.nn.Module): def __init__(self, module, weights, dropout=0, variational=False): super(WeightDrop, self).__init__() self.module = module self.weights = weights self.dropout = dropout ...
awd-lstm-lm-master
weight_drop.py
import argparse import time import math import numpy as np import torch import torch.nn as nn from torch.autograd import Variable import data import model from utils import batchify, get_batch, repackage_hidden parser = argparse.ArgumentParser(description='PyTorch PennTreeBank RNN/LSTM Language Model') parser.add_ar...
awd-lstm-lm-master
main.py
from collections import defaultdict import torch import torch.nn as nn import numpy as np class SplitCrossEntropyLoss(nn.Module): r'''SplitCrossEntropyLoss calculates an approximate softmax''' def __init__(self, hidden_size, splits, verbose=False): # We assume splits is [0, split1, split2, N] where ...
awd-lstm-lm-master
splitcross.py
import argparse import time import math import numpy as np np.random.seed(331) import torch import torch.nn as nn from torch.autograd import Variable import data import model from utils import batchify, get_batch, repackage_hidden parser = argparse.ArgumentParser(description='PyTorch PennTreeBank RNN/LSTM Language M...
awd-lstm-lm-master
finetune.py
import torch import torch.nn as nn from torch.autograd import Variable class LockedDropout(nn.Module): def __init__(self): super().__init__() def forward(self, x, dropout=0.5): if not self.training or not dropout: return x m = x.data.new(1, x.size(1), x.size(2)).bernoulli_(...
awd-lstm-lm-master
locked_dropout.py
import os import torch from collections import Counter class Dictionary(object): def __init__(self): self.word2idx = {} self.idx2word = [] self.counter = Counter() self.total = 0 def add_word(self, word): if word not in self.word2idx: self.idx2word.append(...
awd-lstm-lm-master
data.py
#!/usr/bin/env python # coding=utf-8 import os import sys import zipfile if os.path.exists('train.txt'): print('Tokenized enwik8 already exists - skipping processing') sys.exit() data = zipfile.ZipFile('enwik8.zip').read('enwik8') print('Length of enwik8: {}'.format(len(data))) num_test_chars = 5000000 tr...
awd-lstm-lm-master
data/enwik8/prep_enwik8.py
import os import deepspeed import torch.distributed as dist from distill_bloom import build_train_val_test_dataset from distill_bloom import parse_args args = parse_args() local_rank = int(os.getenv("LOCAL_RANK", "0")) world_size = int(os.getenv("WORLD_SIZE", "1")) deepspeed.init_distributed("nccl") rank = dist....
distill-bloom-deepspeed-main
test_dataset.py
# usage: # deepspeed --num_gpus 8 teacher-inference-script.py --name bigscience/bloom # # to run benchmarks: # deepspeed --num_gpus 8 teacher-inference-script.py --name bigscience/bloom --benchmark # # This is going to improve, but at the moment, the process is a bit cumbersome - we first use # 1. use Deepspeed-ZeRO ...
distill-bloom-deepspeed-main
teacher-inference-script.py
# Dataset imports from .arguments.arguments import parse_args from .dataset.get_dataset import build_train_val_test_dataset from .dataset.dataloader import DistributedDataset, DistributedDataLoader # Arguments import from .init_wrapper import DeepSpeedInitWrapper, print_rank0
distill-bloom-deepspeed-main
distill_bloom/__init__.py
# usage: # deepspeed --num_gpus 8 teacher-inference-script.py --name bigscience/bloom # # to run benchmarks: # deepspeed --num_gpus 8 teacher-inference-script.py --name bigscience/bloom --benchmark # # This is going to improve, but at the moment, the process is a bit cumbersome - we first use # 1. use Deepspeed-ZeRO ...
distill-bloom-deepspeed-main
distill_bloom/teacher-inference-script.py
import io, json from pathlib import Path import torch import torch.distributed as dist from transformers.models.bloom.modeling_bloom import BloomBlock as BloomBlock class DeepSpeedInitWrapper(object): r""" This is a wrapper around DeepSpeed inference / training script initialisation. It is used ...
distill-bloom-deepspeed-main
distill_bloom/init_wrapper.py
import torch.distributed as dist from .utils import build_dataset_group def build_train_val_test_dataset(args): r""" This function wraps all the dataset building functions from megatron. """ if args.train_samples: train_samples = args.train_samples else: train_samples = args.trai...
distill-bloom-deepspeed-main
distill_bloom/dataset/get_dataset.py
import os import time import numpy as np import torch from .megatron import mpu def print_rank_0(message): """If distributed is initialized, print only on rank 0.""" if torch.distributed.is_initialized(): if torch.distributed.get_rank() == 0: print(message, flush=True) else: ...
distill-bloom-deepspeed-main
distill_bloom/dataset/gpt_dataset.py
import time import numpy as np import torch from .gpt_dataset import GPTDataset from .indexed_dataset import (IndexedDataset, MMapIndexedDataset, create_doc_idx, data_file_path, index_file_path) def print_rank_0(message): """If distributed is initialized, print only on rank 0.""" ...
distill-bloom-deepspeed-main
distill_bloom/dataset/utils.py
import torch class DistributedDataset(torch.utils.data.Dataset): r""" Wrapper for torch.utils.data.Dataset to make it distributed. Args: dataset (torch.utils.data.Dataset): Dataset to be distributed. rank (int): Rank of the current process. world_size (int): Num...
distill-bloom-deepspeed-main
distill_bloom/dataset/dataloader.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # copied from fairseq/fairseq/data/indexed_dataset.py # Removed IndexedRawTextDataset since it relied on Fairseq dictionary # other slight mo...
distill-bloom-deepspeed-main
distill_bloom/dataset/indexed_dataset.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/cross_entropy.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/initialize.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/__init__.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/random.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/utils.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/layers.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/data.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/mappings.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/test_cross_entropy.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/test_layers.py
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/__init__.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/commons.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/test_data.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/test_initialize.py
# coding=utf-8 # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
distill-bloom-deepspeed-main
distill_bloom/dataset/megatron/mpu/tests/test_random.py
# coding=utf-8 # Copyright 2020 Optuna, Hugging Face # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
distill-bloom-deepspeed-main
distill_bloom/arguments/logging.py
# Arguments for distillation import argparse import collections import os import re import time import deepspeed from .logging import log_levels def parse_args(extra_args_provider=None, defaults={}, ignore_unknown_args=False): r""" Helper function to parse all necessarly arguments to perform teacher / stud...
distill-bloom-deepspeed-main
distill_bloom/arguments/arguments.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
setup.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_big_modeling.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_optimizer.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_data_loader.py
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class MockLaunchConfig(SageMakerConfig): compute_environment = ...
accelerate-wip-main
tests/test_sagemaker.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_utils.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_cpu.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_memory_utils.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_metrics.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_kwargs_handlers.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_scheduler.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_modeling_utils.py
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientState, PartialState from accele...
accelerate-wip-main
tests/test_accelerator.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_tracking.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_hooks.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_multigpu.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_grad_sync.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/xla_spawn.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_offload.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_cli.py
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_tpu.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_examples.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/test_state_checkpointing.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/deepspeed/test_deepspeed.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
tests/fsdp/test_fsdp.py
# Copyright 2022 The HuggingFace Team, the AllenNLP library authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
accelerate-wip-main
utils/stale.py
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate hf_table_format = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("", "|", "|"), datarow=DataRow("", "|", "|"...
accelerate-wip-main
utils/log_reports.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/nlp_example.py
import argparse import runhouse as rh import torch from nlp_example import training_function from accelerate.utils import PrepareForLaunch, patch_environment def launch_train(*args): num_processes = torch.cuda.device_count() print(f"Device count: {num_processes}") with patch_environment( world_s...
accelerate-wip-main
examples/multigpu_remote_launcher.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/complete_cv_example.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/complete_nlp_example.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/cv_example.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/by_feature/gradient_accumulation.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
examples/by_feature/memory.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/by_feature/local_sgd.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-wip-main
examples/by_feature/automatic_gradient_accumulation.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
accelerate-wip-main
examples/by_feature/deepspeed_with_config_support.py
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/by_feature/multi_process_metrics.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
accelerate-wip-main
examples/by_feature/megatron_lm_gpt_pretraining.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
accelerate-wip-main
examples/by_feature/fsdp_with_peak_mem_tracking.py