repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
pytorch-lightning | tests/tests_pytorch/helpers/advanced_models.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 271 | 8,824 |
pytorch-lightning | tests/tests_pytorch/helpers/threading.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 34 | 1,050 |
pytorch-lightning | tests/tests_pytorch/helpers/simple_models.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 128 | 4,439 |
pytorch-lightning | tests/tests_pytorch/helpers/dataloaders.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 53 | 1,650 |
pytorch-lightning | tests/tests_pytorch/helpers/pipelines.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 121 | 4,680 |
pytorch-lightning | tests/tests_pytorch/helpers/datamodules.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 131 | 4,754 |
pytorch-lightning | tests/tests_pytorch/helpers/deterministic_model.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 101 | 3,386 |
pytorch-lightning | tests/tests_fabric/test_wrappers.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 702 | 27,490 |
pytorch-lightning | tests/tests_fabric/test_connector.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 1,147 | 47,033 |
pytorch-lightning | tests/tests_fabric/test_fabric.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 1,391 | 54,334 |
pytorch-lightning | tests/tests_fabric/test_cli.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 205 | 8,191 |
pytorch-lightning | tests/tests_fabric/conftest.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 267 | 10,877 |
pytorch-lightning | tests/tests_fabric/loggers/test_tensorboard.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 250 | 9,498 |
pytorch-lightning | tests/tests_fabric/loggers/test_csv.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 229 | 8,454 |
pytorch-lightning | tests/tests_fabric/strategies/test_deepspeed_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 420 | 16,506 |
pytorch-lightning | tests/tests_fabric/strategies/test_ddp.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 221 | 9,265 |
pytorch-lightning | tests/tests_fabric/strategies/test_fsdp_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 672 | 27,826 |
pytorch-lightning | tests/tests_fabric/strategies/test_registry.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 66 | 2,306 |
pytorch-lightning | tests/tests_fabric/strategies/test_model_parallel_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 768 | 31,192 |
pytorch-lightning | tests/tests_fabric/strategies/test_dp.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 95 | 3,573 |
pytorch-lightning | tests/tests_fabric/strategies/test_strategy.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 279 | 12,499 |
pytorch-lightning | tests/tests_fabric/strategies/test_ddp_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 133 | 5,614 |
pytorch-lightning | tests/tests_fabric/strategies/test_single_device.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 108 | 3,893 |
pytorch-lightning | tests/tests_fabric/strategies/test_xla.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 209 | 8,615 |
pytorch-lightning | tests/tests_fabric/strategies/test_model_parallel.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 431 | 19,834 |
pytorch-lightning | tests/tests_fabric/strategies/test_xla_fsdp.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 135 | 5,558 |
pytorch-lightning | tests/tests_fabric/strategies/test_xla_fsdp_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 209 | 8,188 |
pytorch-lightning | tests/tests_fabric/strategies/test_deepspeed.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 487 | 21,199 |
pytorch-lightning | tests/tests_fabric/strategies/test_fsdp.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 688 | 29,800 |
pytorch-lightning | tests/tests_fabric/strategies/launchers/test_multiprocessing_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 63 | 2,331 |
pytorch-lightning | tests/tests_fabric/strategies/launchers/test_multiprocessing.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 123 | 5,514 |
pytorch-lightning | tests/tests_fabric/strategies/launchers/test_subprocess_script.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 185 | 8,426 |
pytorch-lightning | tests/tests_fabric/accelerators/test_cuda.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 155 | 5,671 |
pytorch-lightning | tests/tests_fabric/accelerators/test_registry.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 186 | 6,078 |
pytorch-lightning | tests/tests_fabric/accelerators/test_cpu.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 47 | 1,565 |
pytorch-lightning | tests/tests_fabric/accelerators/test_mps.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 57 | 1,866 |
pytorch-lightning | tests/tests_fabric/accelerators/test_xla.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 52 | 1,995 |
pytorch-lightning | tests/tests_fabric/utilities/test_imports.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 91 | 3,021 |
pytorch-lightning | tests/tests_fabric/utilities/test_device_dtype_mixin.py | .py | import pytest
import torch
from torch import nn as nn
from lightning.fabric.plugins.precision.utils import _DtypeContextManager
from lightning.fabric.utilities.device_dtype_mixin import _DeviceDtypeModuleMixin
from tests_fabric.helpers.runif import RunIf
class SubSubModule(_DeviceDtypeModuleMixin):
pass
class ... | 172 | 5,406 |
pytorch-lightning | tests/tests_fabric/utilities/test_device_parser.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 86 | 3,451 |
pytorch-lightning | tests/tests_fabric/utilities/test_optimizer.py | .py | import dataclasses
import pytest
import torch
from torch import Tensor
from lightning.fabric.utilities.optimizer import _optimizer_to_device
from tests_fabric.helpers.runif import RunIf
@pytest.mark.parametrize(
"optimizer_class",
[
torch.optim.Adam,
torch.optim.AdamW,
torch.optim.SG... | 87 | 2,786 |
pytorch-lightning | tests/tests_fabric/utilities/test_cloud_io.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 298 | 10,896 |
pytorch-lightning | tests/tests_fabric/utilities/test_distributed.py | .py | import functools
import os
from functools import partial
from pathlib import Path
from unittest import mock
from unittest.mock import Mock
import pytest
import torch
from lightning_utilities.core.imports import RequirementCache
from lightning.fabric.accelerators import CPUAccelerator, CUDAAccelerator, MPSAccelerator
... | 336 | 13,022 |
pytorch-lightning | tests/tests_fabric/utilities/test_spike.py | .py | import contextlib
import pytest
import torch
from lightning.fabric import Fabric
from lightning.fabric.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_1_0_0
from lightning.fabric.utilities.spike import SpikeDetection, TrainingSpikeException
from tests_fabric.helpers.runif import RunIf
def spike_detection_test(... | 84 | 3,720 |
pytorch-lightning | tests/tests_fabric/utilities/test_registry.py | .py | import contextlib
from unittest import mock
from unittest.mock import MagicMock, Mock
from lightning.fabric.utilities.imports import _PYTHON_GREATER_EQUAL_3_10_0
from lightning.fabric.utilities.registry import _load_external_callbacks
class ExternalCallback:
"""A callback in another library that gets registered ... | 61 | 2,105 |
pytorch-lightning | tests/tests_fabric/utilities/test_throughput.py | .py | import warnings
from unittest import mock
from unittest.mock import Mock, call
import pytest
import torch
from lightning.fabric import Fabric
from lightning.fabric.plugins import Precision
from lightning.fabric.utilities.throughput import (
Throughput,
ThroughputMonitor,
_MonotonicWindow,
get_availabl... | 409 | 15,334 |
pytorch-lightning | tests/tests_fabric/utilities/test_seed.py | .py | import os
import random
import warnings
from unittest import mock
from unittest.mock import Mock
import numpy
import pytest
import torch
from lightning.fabric.utilities.seed import (
_collect_rng_states,
_generate_seed_sequence,
_set_rng_states,
pl_worker_init_function,
reset_seed,
seed_everyt... | 177 | 6,616 |
pytorch-lightning | tests/tests_fabric/utilities/test_consolidate_checkpoint.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 135 | 5,746 |
pytorch-lightning | tests/tests_fabric/utilities/test_load.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 173 | 6,002 |
pytorch-lightning | tests/tests_fabric/utilities/test_apply_func.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 60 | 2,327 |
pytorch-lightning | tests/tests_fabric/utilities/test_warnings.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 151 | 5,594 |
pytorch-lightning | tests/tests_fabric/utilities/test_logger.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 216 | 6,535 |
pytorch-lightning | tests/tests_fabric/utilities/test_runif.py | .py | import pytest
from tests_fabric.helpers.runif import RunIf
@RunIf(min_torch="99")
def test_always_skip():
exit(1)
@pytest.mark.parametrize("arg1", [0.5, 1.0, 2.0])
@RunIf(min_torch="0.0")
def test_wrapper(arg1: float):
assert arg1 > 0.0
| 15 | 250 |
pytorch-lightning | tests/tests_fabric/utilities/test_data.py | .py | import contextlib
import os
import random
from unittest import mock
from unittest.mock import Mock
import numpy as np
import pytest
import torch
from lightning_utilities.test.warning import no_warning_call
from torch import Tensor
from torch.utils.data import BatchSampler, DataLoader, RandomSampler
import lightning.f... | 707 | 25,508 |
pytorch-lightning | tests/tests_fabric/utilities/test_rank_zero.py | .py | import os
import sys
from unittest import mock
import pytest
from lightning.fabric.utilities.rank_zero import _get_rank
@pytest.mark.parametrize(
("env_vars", "expected"),
[
({"RANK": "0"}, 1),
({"SLURM_PROCID": "0"}, 1),
({"LOCAL_RANK": "0"}, 1),
({"JSM_NAMESPACE_RANK": "0"}... | 52 | 1,785 |
pytorch-lightning | tests/tests_fabric/utilities/test_init.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 118 | 4,161 |
pytorch-lightning | tests/tests_fabric/graveyard/test_tpu.py | .py | from importlib import import_module
import pytest
import torch
@pytest.mark.parametrize(
("import_path", "name"),
[
("lightning.fabric.strategies", "SingleTPUStrategy"),
("lightning.fabric.strategies.single_tpu", "SingleTPUStrategy"),
],
)
def test_graveyard_single_tpu(import_path, name):... | 42 | 1,534 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_slurm.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 183 | 6,920 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_mpi.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 131 | 4,938 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_lightning.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 89 | 3,161 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_kubeflow.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 81 | 2,679 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_xla.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 161 | 6,425 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_lsf.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 118 | 4,136 |
pytorch-lightning | tests/tests_fabric/plugins/environments/test_torchelastic.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 95 | 3,242 |
pytorch-lightning | tests/tests_fabric/plugins/collectives/test_single_device.py | .py | from unittest import mock
import pytest
from lightning.fabric.plugins.collectives import SingleDeviceCollective
def test_can_instantiate_without_args():
SingleDeviceCollective()
def test_create_group():
collective = SingleDeviceCollective()
assert collective.is_initialized()
with pytest.raises(Ru... | 27 | 829 |
pytorch-lightning | tests/tests_fabric/plugins/collectives/test_torch_collective.py | .py | import contextlib
import datetime
import os
from functools import partial
from unittest import mock
import pytest
import torch
from lightning.fabric.accelerators import CPUAccelerator, CUDAAccelerator
from lightning.fabric.plugins.collectives import TorchCollective
from lightning.fabric.plugins.environments import Li... | 316 | 12,972 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_deepspeed_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 42 | 1,538 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_all.py | .py | import pytest
import torch
from lightning.fabric.plugins import DeepSpeedPrecision, DoublePrecision, FSDPPrecision, HalfPrecision
@pytest.mark.parametrize(
"precision",
[
DeepSpeedPrecision("16-true"),
DoublePrecision(),
HalfPrecision(),
"fsdp",
],
)
def test_default_dtype... | 31 | 927 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_bitsandbytes.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 278 | 11,464 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_xla_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 68 | 2,382 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_amp.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 107 | 3,944 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_amp_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 107 | 3,864 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_double.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 33 | 1,232 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_xla.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 64 | 2,216 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_double_integration.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 57 | 2,020 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_half.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 76 | 2,397 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_transformer_engine.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 150 | 6,254 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_deepspeed.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 106 | 3,527 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_fsdp.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 182 | 6,833 |
pytorch-lightning | tests/tests_fabric/plugins/precision/test_utils.py | .py | import pytest
import torch
from lightning.fabric.plugins.precision.utils import _ClassReplacementContextManager, _DtypeContextManager
def test_dtype_context_manager():
# regular issue
assert torch.get_default_dtype() is torch.float32
with _DtypeContextManager(torch.float16):
assert torch.get_defa... | 49 | 1,737 |
pytorch-lightning | tests/tests_fabric/helpers/datasets.py | .py | from collections.abc import Iterator
import torch
from torch import Tensor
from torch.utils.data import Dataset, IterableDataset
class RandomDataset(Dataset):
def __init__(self, size: int, length: int) -> None:
self.len = length
self.data = torch.randn(length, size)
def __getitem__(self, ind... | 28 | 704 |
pytorch-lightning | tests/legacy/simple_classif_training.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 57 | 2,048 |
pytorch-lightning | tests/parity_pytorch/test_basic_parity.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 143 | 5,295 |
pytorch-lightning | tests/parity_pytorch/models.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 64 | 2,362 |
pytorch-lightning | tests/parity_pytorch/__init__.py | .py | import pytest
from lightning.pytorch.utilities.testing import _runif_reasons
def RunIf(**kwargs):
reasons, marker_kwargs = _runif_reasons(**kwargs)
return pytest.mark.skipif(condition=len(reasons) > 0, reason=f"Requires: [{' + '.join(reasons)}]", **marker_kwargs)
| 9 | 275 |
pytorch-lightning | tests/parity_pytorch/measure.py | .py | import gc
import time
from typing import Callable
import torch
from tqdm import tqdm
def measure_loops(cls_model, kind: str, loop: Callable, num_runs: int = 10, num_epochs: int = 10):
"""Returns an array with the last loss from each epoch for each run."""
hist_losses = []
hist_durations = []
hist_mem... | 36 | 1,147 |
pytorch-lightning | tests/parity_pytorch/test_sync_batchnorm_parity.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 115 | 4,395 |
pytorch-lightning | tests/parity_pytorch/generate_comparison.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 56 | 2,201 |
pytorch-lightning | examples/pytorch/tensor_parallel/parallelism.py | .py | import torch
from model import Transformer
from torch.distributed._composable.fsdp import MixedPrecisionPolicy
from torch.distributed._composable.fsdp.fully_shard import fully_shard
from torch.distributed._tensor import Replicate, Shard
from torch.distributed.algorithms._checkpoint.checkpoint_wrapper import checkpoint_... | 107 | 4,677 |
pytorch-lightning | examples/pytorch/tensor_parallel/train.py | .py | import torch
import torch.nn.functional as F
from data import RandomTokenDataset
from model import ModelArgs, Transformer
from parallelism import parallelize
from torch.distributed.tensor.parallel import loss_parallel
from torch.utils.data import DataLoader
import lightning as L
from lightning.pytorch.strategies impor... | 82 | 2,773 |
pytorch-lightning | examples/pytorch/tensor_parallel/model.py | .py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# Llama 2 is licensed under the LLAMA 2 Community License,
# Copyright (c) Meta Platforms, Inc. All Rights Res... | 457 | 17,272 |
pytorch-lightning | examples/pytorch/tensor_parallel/data.py | .py | import torch
from torch.utils.data import Dataset
class RandomTokenDataset(Dataset):
def __init__(self, vocab_size: int, seq_length: int):
self.vocab_size = vocab_size
self.seq_length = seq_length
self.tokens = torch.randint(
self.vocab_size,
size=(len(self), self.s... | 22 | 678 |
pytorch-lightning | examples/pytorch/fp8_distributed_transformer/train.py | .py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributed._composable.fsdp.fully_shard import fully_shard
from torch.utils.data import DataLoader
from torchao.float8 import Float8LinearConfig, convert_to_float8_training
import lightning as L
from lightning.pytorch.demos import Transform... | 87 | 2,673 |
pytorch-lightning | examples/pytorch/bug_report/bug_report_model.py | .py | import os
import torch
from torch.utils.data import DataLoader, Dataset
from lightning.pytorch import LightningModule, Trainer
class RandomDataset(Dataset):
def __init__(self, size, length):
self.len = length
self.data = torch.randn(length, size)
def __getitem__(self, index):
return... | 67 | 1,701 |
pytorch-lightning | examples/pytorch/basics/autoencoder.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 197 | 7,196 |
pytorch-lightning | examples/pytorch/basics/transformer.py | .py | import torch
import torch.nn.functional as F
from torch.utils.data import DataLoader, random_split
import lightning as L
from lightning.pytorch.demos import Transformer, WikiText2
class LanguageModel(L.LightningModule):
def __init__(self, vocab_size):
super().__init__()
self.model = Transformer(v... | 63 | 1,913 |
pytorch-lightning | examples/pytorch/basics/profiler_example.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 115 | 4,250 |
pytorch-lightning | examples/pytorch/basics/backbone_image_classifier.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 141 | 4,566 |
pytorch-lightning | examples/pytorch/servable_module/production.py | .py | import base64
from dataclasses import dataclass
from io import BytesIO
from os import path
from typing import Optional
import numpy as np
import torch
import torchvision
import torchvision.transforms as T
from PIL import Image as PILImage
from lightning.pytorch import LightningDataModule, LightningModule, cli_lightni... | 125 | 4,212 |
pytorch-lightning | examples/pytorch/domain_templates/generative_adversarial_net.py | .py | # Copyright The Lightning AI team.
#
# 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 or agreed to in wri... | 235 | 7,390 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.