python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
from .components import LinearActivation, Activation, Normalization, DropoutNd
| hyena-dna-main | src/models/nn/__init__.py |
""" Utility wrappers around modules to let them handle Args and extra arguments """
import inspect
from functools import wraps
import torch
from torch import nn
def wrap_kwargs(f):
"""
Given a callable f that can consume some named arguments,
wrap it with a kwargs that passes back any unused args
EXA... | hyena-dna-main | src/models/nn/utils.py |
""" Defines flexible gating mechanisms based on ideas from LSSL paper and UR-LSTM paper https://arxiv.org/abs/1910.09890 """
import torch
import torch.nn as nn
class Gate(nn.Module):
""" Implements gating mechanisms. TODO update this with more detailed description with reference to LSSL paper when it's on arxiv
... | hyena-dna-main | src/models/nn/gate.py |
"""Implementations of several types of Discrete Sin/Cosine Transforms with various reductions to FFT.
Currently not used by S4
"""
import torch
import torch.nn as nn
import numpy as np
import scipy.fft
from einops import rearrange, repeat
class DCT(nn.Module):
""" Reductions adapted from https://dsp.stackexchang... | hyena-dna-main | src/models/nn/dxt.py |
""" Utility nn components, in particular handling activations, initializations, and normalization layers """
from functools import partial
import math
from typing import ForwardRef
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
from opt_einsum import contract
def stoc... | hyena-dna-main | src/models/nn/components.py |
# Copyright (c) 2023, Tri Dao, Dan Fu.
# Simplified, mostly standalone version of LongConvLM for synthetics.
import math
from functools import partial
from collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.ops import StochasticDepth
from einops import ... | hyena-dna-main | src/models/sequence/simple_lm.py |
""" Implementation of FFN block in the style of Transformers """
from functools import partial
from torch import nn
from src.models.sequence.base import SequenceModule
from src.models.nn import LinearActivation, DropoutNd
class FF(SequenceModule):
def __init__(self, d_input, expand=2, d_output=None, transposed=Fa... | hyena-dna-main | src/models/sequence/ff.py |
'''PyTorch version of the block FFT convolution as described in the H3 paper.'''
import torch
from einops import rearrange
import math
from torch import nn
from src.models.nn import Activation
from src.utils.train import OptimModule
def ref_dft_matrix(N, H=1):
"""Compute the DFT matrix of size N x N.
Thi... | hyena-dna-main | src/models/sequence/block_fft.py |
from .base import SequenceModule, TransposedModule
from .model import SequenceModel
from .ff import FF
| hyena-dna-main | src/models/sequence/__init__.py |
from functools import partial
import torch
import torch.nn as nn
from flash_attn.utils.generation import GenerationMixin
from flash_attn.utils.distributed import sync_shared_params
try:
from flash_attn.ops.fused_dense import ColumnParallelLinear
except ImportError:
ColumnParallelLinear = None
# grab all func... | hyena-dna-main | src/models/sequence/dna_embedding.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
import opt_einsum as oe
optimized = True
if optimized:
contract = oe.contract
else:
contract = torch.einsum
from src.models.nn import LinearActivation, Activation, DropoutNd
from src.models.sequence.block_fft impo... | hyena-dna-main | src/models/sequence/long_conv.py |
import copy
import math
import re
from functools import partial
from collections import namedtuple, OrderedDict
from collections.abc import Sequence
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.checkpoint import checkpoint
from transformers.models.gpt2.configuration_gpt2 import... | hyena-dna-main | src/models/sequence/long_conv_lm.py |
""" Isotropic deep sequence model backbone, in the style of ResNets / Transformers.
The SequenceModel class implements a generic (batch, length, d_input) -> (batch, length, d_output) transformation
"""
from functools import partial
import torch
import torch.nn as nn
from einops import rearrange
from src.utils.confi... | hyena-dna-main | src/models/sequence/model.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import repeat
from src.utils.train import OptimModule
class LongConvKernel(OptimModule):
def __init__(
self,
H,
L,
channels=1,
learning_rate=None,
lam=0.1,
causal=True,
... | hyena-dna-main | src/models/sequence/long_conv_kernel.py |
import math
import sys
from re import U
import torch
import torch.nn as nn
import torch.nn.functional as F
from functools import partial
from einops import rearrange, repeat
try:
from src.ops.fftconv import fftconv_ref, fftconv_func, fftconv_heads_ref
except ImportError:
fftconv_func = None
try:
from f... | hyena-dna-main | src/models/sequence/hyena.py |
""" Implements a full residual block around a black box layer
Configurable options include:
normalization position: prenorm or postnorm
normalization type: batchnorm, layernorm etc.
subsampling/pooling
residual options: feedforward, residual, affine scalars, depth-dependent scaling, etc.
"""
from torch import nn
fro... | hyena-dna-main | src/models/sequence/block.py |
"""Implements downsampling and upsampling on sequences."""
import torch
from torch import nn
import torch.nn.functional as F
from einops import rearrange, repeat, reduce
from src.models.sequence import SequenceModule
from src.models.nn import LinearActivation
""" Simple pooling functions that just downsample or repe... | hyena-dna-main | src/models/sequence/pool.py |
from torch import nn
import functools
class SequenceModule(nn.Module):
"""Abstract sequence model class. All models must adhere to this interface
A SequenceModule is generally a model that transforms an input of shape
(n_batch, l_sequence, d_model) to (n_batch, l_sequence, d_output)
REQUIRED methods ... | hyena-dna-main | src/models/sequence/base.py |
""" Wrapper around nn.MultiheadAttention to adhere to SequenceModule interface. """
import torch
import torch.nn.functional as F
from torch import nn
import hydra
from src.models.sequence.base import SequenceModule, TransposedModule
import src.models.nn.utils as U
from einops import rearrange
@TransposedModule
class ... | hyena-dna-main | src/models/sequence/mha.py |
import math
import torch
import torch.nn.functional as F
from einops import rearrange
from fftconv import fftconv_fwd, fftconv_bwd
@torch.jit.script
def _mul_sum(y, q):
return (y * q).sum(dim=1)
# reference convolution with residual connection
def fftconv_ref(u, k, D, dropout_mask, gelu=True, k_rev=None):
... | hyena-dna-main | src/ops/fftconv.py |
"""pykeops implementations of the Vandermonde matrix multiplication kernel used in the S4D kernel."""
import math
import torch
from einops import rearrange, repeat
from opt_einsum import contract
import os
try:
import pykeops
from pykeops.torch import LazyTensor, Genred
except:
pass
try:
from cauchy... | hyena-dna-main | src/ops/vandermonde.py |
""" Old utilities for parallel scan implementation of Linear RNNs. """
# TODO this file could use much cleanup
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import math
from src.models.functional.toeplitz import triangular_toeplitz_multiply, triangular_toeplitz_multiply_padded
... | hyena-dna-main | src/ops/unroll.py |
""" Compute a Krylov function efficiently. (S4 renames the Krylov function to a "state space kernel")
A : (N, N)
b : (N,)
c : (N,)
Return: [c^T A^i b for i in [L]]
"""
import torch
import torch.nn.functional as F
from einops import rearrange, repeat
from src.ops.toeplitz import causal_convolution
def krylov_sequent... | hyena-dna-main | src/ops/krylov.py |
""" Utilities for computing convolutions.
There are 3 equivalent views:
1. causal convolution
2. multiplication of (lower) triangular Toeplitz matrices
3. polynomial multiplication (mod x^N)
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
def construct_toeplitz(v, f=0.0):
"""E... | hyena-dna-main | src/ops/toeplitz.py |
#!/usr/bin/env python3
# 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 sys
from setuptools import Extension, find_packages, setup
if sys.version_inf... | flash_metaseq-main | setup.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.
"""
Utils for gpu_tests.
"""
import os
import unittest
def is_this_circleci():
"""
Return if we are currently ... | flash_metaseq-main | gpu_tests/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 copy
import logging
import unittest
import torch
from omegaconf import OmegaConf
from metaseq.optim.fp16_optim... | flash_metaseq-main | gpu_tests/test_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.
import unittest
import torch
import torch.nn as nn
from torch.utils.checkpoint import checkpoint
from metaseq.modules... | flash_metaseq-main | gpu_tests/test_activation_checkpointing.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 logging
import unittest
import torch
from omegaconf import OmegaConf
from metaseq.optim.adam im... | flash_metaseq-main | tests/test_polynomial_lr.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 collections
import unittest
import numpy as np
from metaseq.data import ListDataset, ResamplingDataset
class... | flash_metaseq-main | tests/test_resampling_dataset.py |
flash_metaseq-main | tests/__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 json
import os
import random
import string
import tempfile
import unittest
import torch
from tests.utils impor... | flash_metaseq-main | tests/test_streaming_language_modeling_task.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 os
import random
from typing import Optional
import numpy as np
import torch
import torch.nn.fu... | flash_metaseq-main | tests/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 argparse
import logging
import unittest
import torch
from omegaconf import OmegaConf
from metaseq.optim.adam i... | flash_metaseq-main | tests/test_memory_efficient_fp16.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 tempfile
import unittest
import torch
import tests.utils as test_utils
from metaseq import sea... | flash_metaseq-main | tests/test_sequence_generator.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 unittest
try:
import boto3
from metaseq.s3_utils import S3PathHandler
except ImportError:
... | flash_metaseq-main | tests/test_s3_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 unittest
import torch
from metaseq.data import MonolingualDataset
from metaseq.tasks.language_modeling import ... | flash_metaseq-main | tests/test_lm_context_window.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 shutil
import sys
import tempfile
import unittest
from typing import Optional
from unittest.mock impor... | flash_metaseq-main | tests/test_file_io.py |
#!/usr/bin/env python3
# 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 tempfile
import unittest
import torch
from metaseq.data.dictionary impo... | flash_metaseq-main | tests/test_export.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 functools
import sys
import unittest
import torch
from metaseq.distributed import utils as dist_utils
from .ut... | flash_metaseq-main | tests/distributed/test_utils.py |
flash_metaseq-main | tests/distributed/__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 functools
import tempfile
import torch
def spawn_and_init(fn, world_size, args=None):
if args is None:
... | flash_metaseq-main | tests/distributed/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 io
import os
import string
import tempfile
import unittest
import torch
from metaseq import tokenizer
from meta... | flash_metaseq-main | cpu_tests/test_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 unittest
import torch
from metaseq import utils
class TestUtils(unittest.TestCase):
def test_make_positio... | flash_metaseq-main | cpu_tests/test_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 unittest
import uuid
from metaseq import metrics
class TestMetrics(unittest.TestCase):
def test_nesting(s... | flash_metaseq-main | cpu_tests/test_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 argparse
import unittest
import tests.utils as test_utils
import torch
from metaseq.sequence_scorer import Sequ... | flash_metaseq-main | cpu_tests/test_sequence_scorer.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 unittest
import torch
from metaseq.modules.multihead_attention import MultiheadAttention
class TestMultiheadA... | flash_metaseq-main | cpu_tests/test_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.
import unittest
import numpy as np
from metaseq.data.data_utils_fast import batch_by_size_fn
from metaseq.data.data_ut... | flash_metaseq-main | cpu_tests/test_data_utils.py |
flash_metaseq-main | cpu_tests/__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 unittest
import numpy as np
import torch
from metaseq.data import StreamingTokenBlockDataset
class TensorLis... | flash_metaseq-main | cpu_tests/test_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 unittest
import torch
from metaseq.data import PartitionedStreamingDataset
class TensorListIterableDataset(t... | flash_metaseq-main | cpu_tests/test_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 unittest
import tests.utils as test_utils
import torch
from metaseq.data import TokenBlockDataset
class TestT... | flash_metaseq-main | cpu_tests/test_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 os
import shutil
import tempfile
import unittest
from typing import Optional
class TestFileChunker(unittest.Te... | flash_metaseq-main | cpu_tests/test_file_chunker_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 unittest
import torch
from metaseq.data import StreamingShuffleDataset
class TensorListDataset(torch.utils.d... | flash_metaseq-main | cpu_tests/test_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.
import unittest
import torch
from metaseq.data import iterators
class TensorListIterableDataset(torch.utils.data.It... | flash_metaseq-main | cpu_tests/test_streaming_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 json
import os
import random
import string
import tempfile
import unittest
from unittest.mock import MagicMock
... | flash_metaseq-main | cpu_tests/test_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.
import unittest
import torch
from torch import nn
from metaseq.distributed import ModuleProxyWrapper
from tests.dist... | flash_metaseq-main | cpu_tests/distributed/test_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 logging
import signal
import time
import unittest
import torch
from torch import nn
from metaseq.distributed i... | flash_metaseq-main | cpu_tests/distributed/test_distributed_timeout_wrapper.py |
flash_metaseq-main | cpu_tests/distributed/__init__.py | |
#!/usr/bin/env python3 -u
# 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.
"""
Host the demo.
Launch with `python -m metaseq_cli.interactive_hosted` to run locally.
Se... | flash_metaseq-main | metaseq_cli/interactive_hosted.py |
flash_metaseq-main | metaseq_cli/__init__.py | |
#!/usr/bin/env python3 -u
# 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 sys
from argparse import Namespace
from itertools import chai... | flash_metaseq-main | metaseq_cli/validate.py |
#!/usr/bin/env python3 -u
# 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 new model on one or across multiple GPUs.
"""
import argparse
import functools
im... | flash_metaseq-main | metaseq_cli/train.py |
#!/usr/bin/env python3 -u
# 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.
"""
Host the demo.
Launch with `python -m metaseq_cli.interactive_hosted` to run locally.
Se... | flash_metaseq-main | metaseq_cli/interactive_cli.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
from typing import Callable, List, Optional
import torch
from metaseq import utils
from metaseq.datac... | flash_metaseq-main | metaseq/options.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
logger = logging.getLogger(__name__)
class NanDetector:
"""
Detects the first N... | flash_metaseq-main | metaseq/nan_detector.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 argparse import Namespace
from typing import Union
from hydra.core.config_store import ConfigStore
from omegaconf... | flash_metaseq-main | metaseq/registry.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 typing as tp
def _safe_readline(fd) -> str:
pos = fd.tell()
while True:
try:
... | flash_metaseq-main | metaseq/file_chunker_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 os
import sys
try:
from .version import __version__ # noqa
except ImportError:
v... | flash_metaseq-main | metaseq/__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 math
from typing import Dict, List, Optional
import torch
import torch.nn as nn
from torch impor... | flash_metaseq-main | metaseq/sequence_generator.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 multiprocessing
import os
import pdb
import sys
__all__ = ["set_trace"]
_stdin = [None]
_stdin_lock = multip... | flash_metaseq-main | metaseq/pdb.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 datetime as dt
import io
import logging
import os
import shutil
import types
from functools import partial
from ... | flash_metaseq-main | metaseq/s3_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 re
SPACE_NORMALIZER = re.compile(r"\s+")
def tokenize_line(line):
line = SPACE_NORMALIZER.sub(" ", line)... | flash_metaseq-main | metaseq/tokenizer.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 ast
import copy
import logging
import os
import time
from argparse import Namespace
from typing ... | flash_metaseq-main | metaseq/hub_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 sys
import torch
from metaseq import utils
class SequenceScorer(object):
"""Scores the target for a give... | flash_metaseq-main | metaseq/sequence_scorer.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
from typing import Dict, Optional
from torch import Tensor
from typing_extensions import Protocol
class ... | flash_metaseq-main | metaseq/incremental_decoding_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 argparse
import copy
import importlib
import logging
import os
import random
import sys
import warnings
from typ... | flash_metaseq-main | metaseq/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 ast
import collections
import functools
import logging
import os
import re
import traceback
from glob import glo... | flash_metaseq-main | metaseq/checkpoint_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.
"""
Utilities for working with the local dataset cache.
This file is adapted from `AllenNLP <https://github.com/allenai... | flash_metaseq-main | metaseq/file_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 typing import Optional
import torch
import torch.nn as nn
from torch import Tensor
class Search(nn.Module):
... | flash_metaseq-main | metaseq/search.py |
#!/usr/bin/env python3
# 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 json
import logging
import os
import shutil
from typing import List, Optional
import to... | flash_metaseq-main | metaseq/file_io.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 contextlib
import logging
import re
import sys
import time
from i... | flash_metaseq-main | metaseq/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.
import logging
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import torch
fr... | flash_metaseq-main | metaseq/benchmark/dummy_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.
from . import dummy_lm # noqa
| flash_metaseq-main | metaseq/benchmark/__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
from enum import Enum
@dataclass
class Size:
n_layers: int
emb_size: int
... | flash_metaseq-main | metaseq/launcher/opt_job_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.
import datetime
import fnmatch
import hashlib
import itertools
import os
import random
import shlex
import shutil
impor... | flash_metaseq-main | metaseq/launcher/slurm.py |
flash_metaseq-main | metaseq/launcher/__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 argparse
import datetime
import os
import subprocess
from typing import Optional, List, Callable, MutableMapping... | flash_metaseq-main | metaseq/launcher/sweep.py |
#!/usr/bin/env python3 -u
# 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.
"""
This sweep script takes some additional optional arguments. See add_extra_options_func
fo... | flash_metaseq-main | metaseq/launcher/opt_baselines.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.
"""
Streaming Language Modeling task that loads corpora in src-tgt format and performs
on-the-fly tokenization.
"""
imp... | flash_metaseq-main | metaseq/tasks/streaming_finetune_language_modeling.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
from dataclasses import dataclass, field
from typing import Optional, List
import numpy as np... | flash_metaseq-main | metaseq/tasks/language_modeling_inference_for_models_trained_with_streaming.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
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
impor... | flash_metaseq-main | metaseq/tasks/language_modeling.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 warnings
from argparse import Namespace
from typing import Any, Callable, Dict, List
import torc... | flash_metaseq-main | metaseq/tasks/base_task.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.
"""
Streaming Language Modeling task that loads corpora in plaintext and performs
on-the-fly tokenization.
"""
import l... | flash_metaseq-main | metaseq/tasks/streaming_language_modeling.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/tasks/__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 signal
import threading
from torch import nn
logger = logging.getLogger(__name__)
c... | flash_metaseq-main | metaseq/distributed/distributed_timeout_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 contextlib
import logging
import os
from typing import Optional
import torch
from metaseq.dataclass.configs im... | flash_metaseq-main | metaseq/distributed/fully_sharded_data_parallel.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 .distributed_timeout_wrapper import DistributedTimeoutWrapper
from .fully_sharded_data_parallel import (
fsdp_... | flash_metaseq-main | metaseq/distributed/__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 io
import logging
import os
import pickle
import random
import signal
import socket
import struct
import subproc... | flash_metaseq-main | metaseq/distributed/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 gc
import logging
import os
import re
import time
from collections import defaultdict, OrderedDict
from glob imp... | flash_metaseq-main | metaseq/distributed/stitch_fsdp_ckpt.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.