python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch import nn class ModuleProxyWrapper(nn.Module): """ Wrap a DistributedDataParallel module and forwa...
flash_metaseq-main
metaseq/distributed/module_proxy_wrapper.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import types import torch def get_fused_adam_class(): """ Look for the FusedAdam optimizer from apex. We fir...
flash_metaseq-main
metaseq/optim/fused_adam.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging logger = logging.getLogger(__name__) class DynamicLossScaler(object): def __init__( self,...
flash_metaseq-main
metaseq/optim/dynamic_loss_scaler.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from metaseq import utils from metaseq.dataclass.utils import gen_parser_from_dataclass class BaseOptim...
flash_metaseq-main
metaseq/optim/base_optimizer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from torch.optim.optimizer import Optimizer, required from . import LegacyOptimizer, register_optimizer ...
flash_metaseq-main
metaseq/optim/sgd.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" import importlib import os from metaseq import registry from metaseq.optim.base_optimizer import...
flash_metaseq-main
metaseq/optim/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import defaultdict from itertools import chain import torch from omegaconf import DictConfig from me...
flash_metaseq-main
metaseq/optim/fp16_optimizer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict from metaseq.distributed import utils try: from fairscale.optim import OSS _has...
flash_metaseq-main
metaseq/optim/shard.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import math from collections.abc import Collection from dataclasses import dataclass, field from typing ...
flash_metaseq-main
metaseq/optim/adam.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" import importlib import os from metaseq import registry from metaseq.optim.lr_scheduler.base_lr_...
flash_metaseq-main
metaseq/optim/lr_scheduler/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field from typing import Optional, List from omegaconf import II from metaseq.data...
flash_metaseq-main
metaseq/optim/lr_scheduler/polynomial_decay_schedule.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections.abc import Collection from dataclasses import dataclass, field from typing import List from omegaconf...
flash_metaseq-main
metaseq/optim/lr_scheduler/inverse_square_root_schedule.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from metaseq.dataclass.utils import gen_parser_from_dataclass from metaseq.optim import BaseOptimizer class BaseLRSch...
flash_metaseq-main
metaseq/optim/lr_scheduler/base_lr_scheduler.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from collections.abc import Collection from dataclasses import dataclass, field from typing import List fr...
flash_metaseq-main
metaseq/optim/lr_scheduler/cosine_lr_scheduler.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import List, Optional import torch from torch import Tensor @torch.jit.script def script_skip_tensor_lis...
flash_metaseq-main
metaseq/models/model_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" import argparse import importlib import os from metaseq.dataclass import MetaseqDataclass from m...
flash_metaseq-main
metaseq/models/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Base classes for various metaseq models. """ import logging from argparse import Namespace from typing import Dict,...
flash_metaseq-main
metaseq/models/base_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, Optional, Tuple import torch.nn as nn from torch import Tensor from metaseq import uti...
flash_metaseq-main
metaseq/models/base_decoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import math from typing import Any, Dict, List, Optional import torch import torch.nn as nn from torch ...
flash_metaseq-main
metaseq/models/transformer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from dataclasses import dataclass, field from typing import Optional from omegaconf import II from m...
flash_metaseq-main
metaseq/models/transformer_lm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import torch.nn as nn from torch.nn.parallel import DistributedDataParallel from metaseq.distributed i...
flash_metaseq-main
metaseq/models/distributed_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from typing import Dict, Optional from torch import Tensor from metaseq.incremental_decoding_utils imp...
flash_metaseq-main
metaseq/models/incremental_decoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, NamedTuple, Optional import torch import torch.nn as nn from torch import Tensor Encod...
flash_metaseq-main
metaseq/models/base_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Train a network across multiple GPUs. """ import functools import torch.distributed as dist from metaseq.datacla...
flash_metaseq-main
metaseq/model_parallel/megatron_trainer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import criterions, models, modules # noqa
flash_metaseq-main
metaseq/model_parallel/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os # automatically import any Python files in the models/ directory models_dir = os.path.dirn...
flash_metaseq-main
metaseq/model_parallel/models/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from metaseq.model_parallel.modules import ( ModelParallelTransformerDecoderLayer, ModelParalle...
flash_metaseq-main
metaseq/model_parallel/models/transformer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from metaseq.model_parallel.models.transformer import ModelParallelTransformerDecode...
flash_metaseq-main
metaseq/model_parallel/models/transformer_lm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from functools import partial from typing import Dict, Optional, Tuple import torch from torch import Tens...
flash_metaseq-main
metaseq/model_parallel/modules/multihead_attention.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" from .multihead_attention import ModelParallelMultiheadAttention from .transformer_layer import (...
flash_metaseq-main
metaseq/model_parallel/modules/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from torch import nn, Tensor from metaseq.model_parallel.modules import ModelParallelMultihe...
flash_metaseq-main
metaseq/model_parallel/modules/transformer_layer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from metaseq import metrics, utils from metaseq.criterions import BaseCriterion, register_cri...
flash_metaseq-main
metaseq/model_parallel/criterions/vocab_parallel_cross_entropy.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os # automatically import any Python files in the criterions/ directory for file in os.listdi...
flash_metaseq-main
metaseq/model_parallel/criterions/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
flash_metaseq-main
metaseq/scripts/__init__.py
#!/usr/bin/env python """ Script for backing out of the MP-resharded (reshard.pt) files and getting back a non-flattened state dict. Particularly useful for converting our models to other repositories. Usage: $ ls 125m dict.txt gpt2-merges.txt gpt2-vocab.json reshard-model_part-0.pt reshard-m...
flash_metaseq-main
metaseq/scripts/convert_to_singleton.py
#!/usr/bin/env python # Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from metaseq.distributed.stitch_fsdp_ckpt import consolidate_fsdp_shards import fire if __name__ == "__main__": #...
flash_metaseq-main
metaseq/scripts/consolidate_fsdp_shards.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import sys from pathlib import Path from typing import List import torch import torch.nn.functional as ...
flash_metaseq-main
metaseq/scripts/reshard_mp.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys from dataclasses import _MISSING_TYPE, dataclass, field from typing import Any, List, Optional import torch...
flash_metaseq-main
metaseq/dataclass/configs.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" import logging from hydra.core.config_store import ConfigStore from metaseq.dataclass.configs i...
flash_metaseq-main
metaseq/dataclass/initialize.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from enum import Enum, EnumMeta from typing import List class StrEnumMeta(EnumMeta): # this is workaround for sub...
flash_metaseq-main
metaseq/dataclass/constants.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .configs import MetaseqDataclass from .constants import ChoiceEnum __all__ = [ "MetaseqDataclass", "Choi...
flash_metaseq-main
metaseq/dataclass/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import ast import inspect import logging import os import re from argparse import ArgumentError, ArgumentParser, Namesp...
flash_metaseq-main
metaseq/dataclass/utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import hashlib from queue import PriorityQueue import random class KeyedPriorityQueueCollection: """ Create a...
flash_metaseq-main
metaseq/service/queue.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import uuid import time from metaseq.service.constants import CHECKPOINT_LOCAL class OAIResponse: def __init__(se...
flash_metaseq-main
metaseq/service/responses.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os MAX_SEQ_LEN = 2048 BATCH_SIZE = 2048 # silly high bc we dynamically batch by MAX_BATCH_TOKENS MAX_BATCH_TOK...
flash_metaseq-main
metaseq/service/constants.py
# Copyright (c) Meta, 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.
flash_metaseq-main
metaseq/service/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import socket import logging import sys import os def normalize_newlines(s: str): """ normalizes new lines, i...
flash_metaseq-main
metaseq/service/utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from metaseq.service.queue import PriorityQueueRingShard from dataclasses import dataclass from typing import Any impor...
flash_metaseq-main
metaseq/service/workers.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Dict, Optional, Tuple import torch import torch.nn.functional as F from torch import Te...
flash_metaseq-main
metaseq/modules/multihead_attention.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, Optional import torch.nn as nn import torch.nn.functional as F from torch import Tensor from...
flash_metaseq-main
metaseq/modules/learned_positional_embedding.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. def checkpoint_wrapper(module, *args, **kwargs): try: from metaseq.modules.checkpoint_activation_wrapper.c...
flash_metaseq-main
metaseq/modules/checkpoint_activations.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from torch import Tensor from torch.nn import Module from torch.nn import functional as F fro...
flash_metaseq-main
metaseq/modules/linear.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ See "Gaussian Error Linear Units (GELUs)" by Dan Hendrycks and Kevin Gimpel with the corresponding GitHub repo: http...
flash_metaseq-main
metaseq/modules/gelu.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" from .dropout import Dropout from .gelu import gelu, gelu_accurate from .layer_norm import Fp32La...
flash_metaseq-main
metaseq/modules/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import torch logger = logging.getLogger(__name__) try: from megatron.model.fused_bias_...
flash_metaseq-main
metaseq/modules/fused_bias_gelu.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, Optional import torch import torch.nn as nn import torch.nn.functional as F from torch ...
flash_metaseq-main
metaseq/modules/transformer_layer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import torch.nn as nn import torch.nn.functional as F logger = logging.getLogger(__name__) class Dro...
flash_metaseq-main
metaseq/modules/dropout.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from .learned_positional_embedding import LearnedPositionalEmbedding from .sinusoid...
flash_metaseq-main
metaseq/modules/positional_embedding.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Any, Optional import torch import torch.onnx.operators from torch import Tensor, nn fr...
flash_metaseq-main
metaseq/modules/sinusoidal_positional_embedding.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from metaseq import distributed_utils as dist_utils ...
flash_metaseq-main
metaseq/modules/layer_norm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. import functools import threading import weakref from contextlib import contextmanager from typing import Any, Dict, Ge...
flash_metaseq-main
metaseq/modules/checkpoint_activation_wrapper/checkpoint_activations.py
flash_metaseq-main
metaseq/modules/checkpoint_activation_wrapper/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict import torch from torch.utils.data.dataloader import default_collate from . impor...
flash_metaseq-main
metaseq/data/nested_dictionary_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Optional import numpy as np import torch class StreamingTokenBlockDataset(torch.utils...
flash_metaseq-main
metaseq/data/streaming_token_block_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import numpy as np import torch.utils.data from metaseq.data import data_utils logger = logging.getLo...
flash_metaseq-main
metaseq/data/base_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import bisect import numpy as np from torch.utils.data.dataloader import default_collate from . import BaseDataset ...
flash_metaseq-main
metaseq/data/concat_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch class PartitionedStreamingDataset(torch.utils.data.IterableDataset): """Partition an IterableDataset...
flash_metaseq-main
metaseq/data/partitioned_streaming_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import BaseDataset class IdDataset(BaseDataset): def __getitem__(self, index): retur...
flash_metaseq-main
metaseq/data/id_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import numpy as np import torch import math class StreamingSrcTgtDataset(torch.utils.dat...
flash_metaseq-main
metaseq/data/streaming_src_tgt_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from metaseq.data import data_utils from . import BaseWrapperDataset class TruncateDataset(BaseWr...
flash_metaseq-main
metaseq/data/shorten_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from . import BaseWrapperDataset class SortDataset(BaseWrapperDataset): def __init__(self, da...
flash_metaseq-main
metaseq/data/sort_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseDataset, data_utils def collate(samples, pad_idx, eos_idx, fixed_p...
flash_metaseq-main
metaseq/data/monolingual_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch.utils.data.dataloader import default_collate from . import BaseDataset class BaseWrapperDataset(BaseDatas...
flash_metaseq-main
metaseq/data/base_wrapper_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class NumelDataset(BaseWrapperDataset): def __i...
flash_metaseq-main
metaseq/data/numel_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" from .dictionary import Dictionary, TruncatedDictionary from .base_dataset import BaseDataset fr...
flash_metaseq-main
metaseq/data/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from metaseq.data import data_utils class StreamingShuffleDataset(torch.utils.data.I...
flash_metaseq-main
metaseq/data/streaming_shuffle_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import BaseWrapperDataset class StripTokenDataset(BaseWrapperDataset): def __init__(self, dataset, id_to_s...
flash_metaseq-main
metaseq/data/strip_token_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. try: from collections.abc import Iterable except ImportError: from collections import Iterable import contextli...
flash_metaseq-main
metaseq/data/data_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class PrependTokenDataset(BaseWrapperDataset): ...
flash_metaseq-main
metaseq/data/prepend_token_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import BaseWrapperDataset class ListDataset(BaseWrapperDataset): def __init__(self, dataset, sizes=None): ...
flash_metaseq-main
metaseq/data/list_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import math import operator import os import queue import time from threading import Th...
flash_metaseq-main
metaseq/data/iterators.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import hashlib import json import subprocess import tempfile from typing import Hashable try: import pyarrow.plas...
flash_metaseq-main
metaseq/data/plasma_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import numpy as np from metaseq.data import BaseWrapperDataset, plasma_utils logger = logging.getLogg...
flash_metaseq-main
metaseq/data/resampling_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class AppendTokenDataset(BaseWrapperDataset): d...
flash_metaseq-main
metaseq/data/append_token_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from metaseq.data import data_utils from . import BaseWrapperDataset class PadDataset(Base...
flash_metaseq-main
metaseq/data/pad_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import shutil import struct from functools import lru_cache from typing import Union import numpy as np import torch ...
flash_metaseq-main
metaseq/data/indexed_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os from collections import Counter from multiprocessing import Pool import torch from metaseq import utils fro...
flash_metaseq-main
metaseq/data/dictionary.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import json import logging import mmap import os import sys import threading from pathlib import Path f...
flash_metaseq-main
metaseq/data/jsonl_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict import numpy as np import torch from metaseq.data.monolingual_dataset import MonolingualDatas...
flash_metaseq-main
metaseq/data/lm_context_window_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Tuple import numpy as np import torch from metaseq.data import BaseDataset, plasma_utils from meta...
flash_metaseq-main
metaseq/data/token_block_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field from metaseq import file_utils from metaseq.data.encoders import register_bpe...
flash_metaseq-main
metaseq/data/encoders/gpt2_bpe.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field from metaseq import file_utils from metaseq.data.encoders import register_bpe...
flash_metaseq-main
metaseq/data/encoders/hf_byte_bpe.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os from metaseq import registry build_tokenizer, register_tokenizer, TOKENIZER_REGISTRY, _ =...
flash_metaseq-main
metaseq/data/encoders/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Byte pair encoding utilities from GPT-2. Original source: https://github.com/openai/gpt-2/blob/master/src/encoder....
flash_metaseq-main
metaseq/data/encoders/gpt2_bpe_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ A standalone module for aggregating metrics. Metrics can be logged from anywhere using the `log_*` functions define...
flash_metaseq-main
metaseq/logging/metrics.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import bisect import time from collections import OrderedDict from typing import Dict, Optional try: import torch...
flash_metaseq-main
metaseq/logging/meters.py
flash_metaseq-main
metaseq/logging/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Wrapper around various loggers and progress bars (e.g., json). """ import logging from collections import OrderedD...
flash_metaseq-main
metaseq/logging/progress_bar/base_progress_bar.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from typing import Optional from metaseq.logging.progress_bar.base_progress_bar import logger from meta...
flash_metaseq-main
metaseq/logging/progress_bar/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import string import sys from numbers import Number import atexit import torch from metaseq.logging.meters ...
flash_metaseq-main
metaseq/logging/progress_bar/tensorboard_progress_bar.py