MCPcopy Create free account

hub / github.com/Lightning-AI/pytorch-lightning / functions

Functions7,826 in github.com/Lightning-AI/pytorch-lightning

↓ 662 callersMethodfit
r"""Runs the full optimization routine. Args: model: Model to fit. train_dataloaders: An iterable or collection of i
src/lightning/pytorch/trainer/trainer.py:522
↓ 209 callersMethodjoin
(self)
tests/tests_pytorch/helpers/threading.py:30
↓ 187 callersMethodappend
(self, x: T)
src/lightning/fabric/utilities/throughput.py:687
↓ 170 callersMethodlog
Log a scalar to all loggers that were added to Fabric. Args: name: The name of the metric to log. value: The metric v
src/lightning/fabric/fabric.py:1076
↓ 163 callersMethoddevice
The current device this process runs on. Use this to create tensors directly on the device if needed.
src/lightning/fabric/fabric.py:179
↓ 144 callersMethoditems
(self, keep_base: bool = False, copy_state: bool = True)
tests/tests_pytorch/trainer/logging_/test_logger_connector.py:418
↓ 138 callersMethodget
Calls the registered strategy with the required parameters and returns the strategy object. Args: name (str): the name that ident
src/lightning/fabric/strategies/registry.py:85
↓ 117 callersMethodtest
r"""Perform one evaluation epoch over the test set. It's separated from fit to make sure you never run on your test set until you want to.
src/lightning/pytorch/trainer/trainer.py:754
↓ 100 callersFunctionseed_everything
r"""Function that sets the seed for pseudo-random number generators in: torch, numpy, and Python's random module. In addition, sets the following
src/lightning/fabric/utilities/seed.py:20
↓ 80 callersMethodlaunch
Launch and initialize all the processes needed for distributed execution. Args: function: Optional function to launch when using
src/lightning/fabric/fabric.py:955
↓ 72 callersMethodload
Load a checkpoint from a file and restore the state of objects (modules, optimizers, etc.). How and which processes load gets determined by t
src/lightning/fabric/fabric.py:869
↓ 64 callersMethodsave_hyperparameters
Save arguments to ``hparams`` attribute. Args: args: single object of `dict`, `NameSpace` or `OmegaConf` or strin
src/lightning/pytorch/core/mixins/hparams_mixin.py:51
↓ 50 callersMethodsave
r"""Save checkpoint contents to a file. How and which processes save gets determined by the `strategy`. For example, the `ddp` strategy
src/lightning/fabric/fabric.py:820
↓ 50 callersMethodsetup
r"""Set up a model and its optimizers for accelerated training. Args: module: A :class:`torch.nn.Module` to set up. *
src/lightning/fabric/fabric.py:229
↓ 48 callersMethodpredict
r"""Run inference on your data. This will call the model forward function to compute predictions. Useful to perform distributed and batched pr
src/lightning/pytorch/trainer/trainer.py:873
↓ 47 callersMethodisfile
(self, path)
tests/tests_fabric/utilities/test_cloud_io.py:67
↓ 45 callersMethodload_from_checkpoint
r"""Primary way of loading a model from a checkpoint. When Lightning saves a checkpoint it stores the arguments passed to ``__init__`` in the
src/lightning/pytorch/core/module.py:1702
↓ 44 callersMethodvalidate
r"""Perform one evaluation epoch over the validation set. Args: model: The model to validate. dataloaders: An iterab
src/lightning/pytorch/trainer/trainer.py:636
↓ 42 callersMethodoptimizers
(self)
src/lightning/pytorch/trainer/trainer.py:1277
↓ 41 callersMethodsave_checkpoint
r"""Runs routine to create a checkpoint. This method needs to be called on all processes in case the selected strategy is handling distribute
src/lightning/pytorch/trainer/trainer.py:1439
↓ 40 callersMethodzero_grad
(self, set_grads_to_None=False)
tests/tests_fabric/test_wrappers.py:524
↓ 39 callersMethod__init__
(self, test_arg, test_arg2)
tests/tests_pytorch/models/test_hparams.py:199
↓ 38 callersMethodconnect
Called by the Trainer to connect the strategy with the model.
src/lightning/pytorch/strategies/strategy.py:111
↓ 38 callersMethodstep
(self, batch)
tests/tests_pytorch/loops/test_loops.py:947
↓ 37 callersMethodcopy
(self)
tests/tests_pytorch/trainer/optimization/test_manual_optimization.py:329
↓ 37 callersMethodcpu
See :meth:`torch.nn.Module.cpu`.
src/lightning/fabric/utilities/device_dtype_mixin.py:83
↓ 37 callersMethodsize
(self)
src/lightning/fabric/utilities/types.py:62
↓ 34 callersMethodupdate
(self, x)
tests/tests_pytorch/core/test_metric_result_integration.py:50
↓ 33 callersMethodbroadcast
r"""Send a tensor from one process to all others. This method needs to be called on all processes. Failing to do so will cause your program t
src/lightning/fabric/fabric.py:640
↓ 33 callersFunctionis_overridden
(method_name: str, instance: Optional[object] = None, parent: Optional[type[object]] = None)
src/lightning/pytorch/utilities/model_helpers.py:29
↓ 33 callersMethodupdate
(self, metrics: dict[Any, Any])
src/lightning/pytorch/callbacks/progress/rich_progress.py:201
↓ 32 callersFunctioncall
(hook, *_, **__)
tests/tests_pytorch/callbacks/test_lambda_function.py:37
↓ 29 callersMethodmanual_backward
Call this directly from your :meth:`training_step` when doing optimizations manually. By using this, Lightning can ensure that all the proper
src/lightning/pytorch/core/module.py:1092
↓ 29 callersMethodmodel
The LightningModule, but possibly wrapped into DataParallel or DistributedDataParallel. To access the pure LightningModule, use :meth
src/lightning/pytorch/trainer/trainer.py:1297
↓ 27 callersMethodfloat
See :meth:`torch.nn.Module.float`.
src/lightning/fabric/utilities/device_dtype_mixin.py:95
↓ 27 callersMethodsetup_dataloaders
r"""Set up one or multiple dataloaders for accelerated training. If you need different settings for each dataloader, call this method individu
src/lightning/fabric/fabric.py:412
↓ 26 callersFunctionget_filesystem
(path: _PATH, **kwargs: Any)
src/lightning/fabric/utilities/cloud_io.py:80
↓ 26 callersMethodregister
Registers a strategy mapped to a name and with required metadata. Args: name : the name that identifies a strategy, e.g. "deepspe
src/lightning/fabric/strategies/registry.py:44
↓ 25 callersMethodto
(self, *args, **kwargs)
tests/tests_pytorch/models/test_gpu.py:205
↓ 25 callersMethodzero_grad
(self, *args, **kwargs)
tests/tests_pytorch/trainer/test_trainer.py:1570
↓ 24 callersMethodbackward
r"""Replaces ``loss.backward()`` in your training loop. Handles precision automatically for you. Args: tensor: The tensor (loss)
src/lightning/fabric/fabric.py:482
↓ 24 callersMethodscale_batch_size
Iteratively try to find the largest batch size for a given model that does not give an out of memory (OOM) error. Args: m
src/lightning/pytorch/tuner/tuning.py:31
↓ 23 callersMethodinit_module
Instantiate the model and its parameters under this context manager to reduce peak memory usage. The parameters get created on the device and
src/lightning/fabric/fabric.py:805
↓ 23 callersMethodmean
(t: Tensor)
src/lightning/fabric/strategies/dp.py:79
↓ 23 callersMethodprofile
Yields a context manager to encapsulate the scope of a profiled action. Example:: with self.profile('load training data'):
src/lightning/pytorch/profilers/profiler.py:58
↓ 23 callersMethodstep
(self, closure: Optional[Callable] = None)
src/lightning/fabric/wrappers.py:80
↓ 22 callersMethodattach_data
( self, model: "pl.LightningModule", train_dataloaders: Optional[TRAIN_DATALOADERS] =
src/lightning/pytorch/trainer/connectors/data_connector.py:104
↓ 22 callersMethodbarrier
Wait for all processes to enter this call. Use this to synchronize all parallel processes, but only if necessary, otherwise the overhead of s
src/lightning/fabric/fabric.py:629
↓ 22 callersMethodlr_find
Enables the user to do a range test of good initial learning rates, to reduce the amount of guesswork in picking a good starting learning rate
src/lightning/pytorch/tuner/tuning.py:119
↓ 22 callersMethodsetup_data
(self)
src/lightning/pytorch/loops/fit_loop.py:226
↓ 22 callersMethodstep
(self, model, batch)
tests/tests_fabric/strategies/test_fsdp_integration.py:83
↓ 21 callersMethodbackward
(self, *args, **kwargs)
tests/tests_pytorch/trainer/test_trainer.py:195
↓ 21 callersFunctionsummarize
Summarize the LightningModule specified by `lightning_module`. Args: lightning_module: `LightningModule` to summarize. max_depth
src/lightning/pytorch/utilities/model_summary/model_summary.py:552
↓ 20 callersMethod__init__
(self, model_param: int)
tests/tests_pytorch/test_cli.py:111
↓ 20 callersFunction_distributed_is_initialized
()
src/lightning/fabric/utilities/distributed.py:397
↓ 20 callersMethodto
See :meth:`torch.nn.Module.to`.
src/lightning/fabric/utilities/device_dtype_mixin.py:54
↓ 20 callersMethodto
(self, *args: Any, **kwargs: Any)
src/lightning/pytorch/trainer/connectors/logger_connector/result.py:306
↓ 19 callersMethodall_gather
Gather tensors or collections of tensors from multiple processes. This method needs to be called on all processes and the tensors need to hav
src/lightning/fabric/fabric.py:657
↓ 18 callersMethodtrain_dataloader
(self)
tests/tests_pytorch/test_cli.py:846
↓ 17 callersFunction_update_dataloader
(dataloader: DataLoader, sampler: Union[Sampler, Iterable])
src/lightning/fabric/utilities/data.py:75
↓ 16 callersFunction_device_check_helper
(batch_device, module_device)
tests/tests_pytorch/loops/test_all.py:21
↓ 16 callersMethodlog_dict
Log multiple scalars at once to all loggers that were added to Fabric. Args: metrics: A dictionary where the key is the name of t
src/lightning/fabric/fabric.py:1089
↓ 16 callersMethodseed_everything
r"""Helper function to seed everything without explicitly importing Lightning. See :func:`~lightning.fabric.utilities.seed.seed_everything` f
src/lightning/fabric/fabric.py:1104
↓ 16 callersMethodstep
(self)
tests/tests_pytorch/trainer/optimization/test_optimizers.py:613
↓ 15 callersMethod__init__
(self, *args, **kwargs)
tests/tests_fabric/utilities/test_data.py:310
↓ 15 callersFunction_train
( model: BoringModel, dataset: Dataset, tmp_path: str, callback: WeightAveraging, strategy
tests/tests_pytorch/callbacks/test_weight_averaging.py:284
↓ 15 callersFunctionfn
(model, device_mesh)
tests/tests_fabric/strategies/test_model_parallel_integration.py:126
↓ 15 callersMethodload_state_dict
Loads the state of this loop and all its children.
src/lightning/pytorch/loops/loop.py:84
↓ 15 callersMethodsave
(self)
src/lightning/pytorch/loggers/litlogger.py:278
↓ 15 callersMethodstart
(self, action_name: str)
src/lightning/pytorch/profilers/xla.py:52
↓ 15 callersMethodstate_dict
(self)
tests/tests_pytorch/loops/test_loops.py:91
↓ 15 callersMethodupdate
Update throughput metrics. Args: time: Total elapsed time in seconds. It should monotonically increase by the iteration time with
src/lightning/fabric/utilities/throughput.py:113
↓ 14 callersFunction_replace_dunder_methods
This context manager is used to add support for re-instantiation of custom (subclasses) of `base_cls`. It patches the ``__init__``, ``__setattr__
src/lightning/fabric/utilities/data.py:359
↓ 14 callersMethoddevice
(self)
src/lightning/fabric/utilities/load.py:146
↓ 14 callersMethodis_available
MPS is only available on a machine with the ARM-based Apple Silicon processors.
src/lightning/fabric/accelerators/mps.py:72
↓ 14 callersMethodlog_metrics
( # type: ignore[override] self, metrics: dict[str, Union[Tensor, float]], step: Optional[int] = None
src/lightning/fabric/loggers/csv_logs.py:146
↓ 14 callersFunctionmigrate_checkpoint
Applies Lightning version migrations to a checkpoint dictionary. Args: checkpoint: A dictionary with the loaded state from the checkpoint
src/lightning/pytorch/utilities/migration/utils.py:39
↓ 14 callersMethodsetup
(self, *args, **kwargs)
tests/tests_pytorch/core/test_datamodules.py:117
↓ 14 callersMethodsuggestion
This will propose a suggestion for an initial learning rate based on the point with the steepest negative gradient. Args:
src/lightning/pytorch/tuner/lr_finder.py:162
↓ 14 callersMethodto
(self, device)
tests/tests_fabric/utilities/test_apply_func.py:28
↓ 14 callersMethodto_torchscript
By default compiles the whole model to a ``torch.jit.ScriptModule``. If you want to use tracing, please provided the argument ``method='trace'
src/lightning/pytorch/core/module.py:1494
↓ 13 callersFunctionmove_data_to_device
Transfers a collection of data to the given device. Any object that defines a method ``to(device)`` will be moved and all other objects in the col
src/lightning/fabric/utilities/apply_func.py:78
↓ 13 callersMethodprint
r"""Print something only on the first process. If running on multiple machines, it will print from the first process in each machine.
src/lightning/fabric/fabric.py:619
↓ 13 callersMethodremove
Removes the registered strategy by name.
src/lightning/fabric/strategies/registry.py:103
↓ 12 callersFunction_set_version
Set the version of a Lightning checkpoint.
src/lightning/pytorch/utilities/migration/utils.py:167
↓ 12 callersMethod_validate_launched
(self)
src/lightning/fabric/fabric.py:1193
↓ 12 callersFunctionfn
(model, device_mesh)
tests/tests_pytorch/strategies/test_model_parallel_integration.py:81
↓ 12 callersMethodincrement_completed
(self)
src/lightning/pytorch/loops/progress.py:171
↓ 12 callersMethodrefresh
(self, hard: bool = False)
src/lightning/pytorch/callbacks/progress/rich_progress.py:411
↓ 12 callersMethodsetup_optimizers
r"""Set up one or more optimizers for accelerated training. Some strategies do not allow setting up model and optimizer independently. For th
src/lightning/fabric/fabric.py:376
↓ 12 callersMethodstep
(self, closure=None)
tests/tests_pytorch/core/test_lightning_optimizer.py:295
↓ 12 callersMethodupdate
(self, value: _VALUE, batch_size: int)
src/lightning/pytorch/trainer/connectors/logger_connector/result.py:207
↓ 11 callersFunction_is_sharded_checkpoint
A heuristic check to determine whether the path points to a directory with checkpoint shards.
src/lightning/fabric/strategies/fsdp.py:833
↓ 11 callersMethodbarrier
(self, name: Optional[str] = None, *args: Any, **kwargs: Any)
src/lightning/pytorch/strategies/xla.py:202
↓ 11 callersMethodbroadcast
(self, obj: TBroadcast, src: int = 0)
src/lightning/pytorch/strategies/xla.py:214
↓ 11 callersMethodclip_gradients
Clip the gradients of the model to a given max value or max norm. Args: module: The module whose parameters should be clipped.
src/lightning/fabric/fabric.py:527
↓ 11 callersMethoddescribe
Logs a profile report after the conclusion of run.
src/lightning/pytorch/profilers/profiler.py:116
↓ 11 callersMethoddetect
()
tests/tests_pytorch/strategies/test_ddp_integration.py:322
↓ 11 callersMethodglobal_rank
(self)
tests/tests_pytorch/strategies/test_ddp_integration.py:331
↓ 11 callersMethodis_available
()
tests/tests_pytorch/accelerators/test_common.py:47
next →1–100 of 7,826, ranked by callers