Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Lightning-AI/pytorch-lightning
/ functions
Functions
7,826 in github.com/Lightning-AI/pytorch-lightning
⨍
Functions
7,826
◇
Types & classes
1,239
↳
Endpoints
362
↓ 662 callers
Method
fit
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 callers
Method
join
(self)
tests/tests_pytorch/helpers/threading.py:30
↓ 187 callers
Method
append
(self, x: T)
src/lightning/fabric/utilities/throughput.py:687
↓ 170 callers
Method
log
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 callers
Method
device
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 callers
Method
items
(self, keep_base: bool = False, copy_state: bool = True)
tests/tests_pytorch/trainer/logging_/test_logger_connector.py:418
↓ 138 callers
Method
get
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 callers
Method
test
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 callers
Function
seed_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 callers
Method
launch
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 callers
Method
load
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 callers
Method
save_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 callers
Method
save
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 callers
Method
setup
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 callers
Method
predict
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 callers
Method
isfile
(self, path)
tests/tests_fabric/utilities/test_cloud_io.py:67
↓ 45 callers
Method
load_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 callers
Method
validate
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 callers
Method
optimizers
(self)
src/lightning/pytorch/trainer/trainer.py:1277
↓ 41 callers
Method
save_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 callers
Method
zero_grad
(self, set_grads_to_None=False)
tests/tests_fabric/test_wrappers.py:524
↓ 39 callers
Method
__init__
(self, test_arg, test_arg2)
tests/tests_pytorch/models/test_hparams.py:199
↓ 38 callers
Method
connect
Called by the Trainer to connect the strategy with the model.
src/lightning/pytorch/strategies/strategy.py:111
↓ 38 callers
Method
step
(self, batch)
tests/tests_pytorch/loops/test_loops.py:947
↓ 37 callers
Method
copy
(self)
tests/tests_pytorch/trainer/optimization/test_manual_optimization.py:329
↓ 37 callers
Method
cpu
See :meth:`torch.nn.Module.cpu`.
src/lightning/fabric/utilities/device_dtype_mixin.py:83
↓ 37 callers
Method
size
(self)
src/lightning/fabric/utilities/types.py:62
↓ 34 callers
Method
update
(self, x)
tests/tests_pytorch/core/test_metric_result_integration.py:50
↓ 33 callers
Method
broadcast
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 callers
Function
is_overridden
(method_name: str, instance: Optional[object] = None, parent: Optional[type[object]] = None)
src/lightning/pytorch/utilities/model_helpers.py:29
↓ 33 callers
Method
update
(self, metrics: dict[Any, Any])
src/lightning/pytorch/callbacks/progress/rich_progress.py:201
↓ 32 callers
Function
call
(hook, *_, **__)
tests/tests_pytorch/callbacks/test_lambda_function.py:37
↓ 29 callers
Method
manual_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 callers
Method
model
The LightningModule, but possibly wrapped into DataParallel or DistributedDataParallel. To access the pure LightningModule, use :meth
src/lightning/pytorch/trainer/trainer.py:1297
↓ 27 callers
Method
float
See :meth:`torch.nn.Module.float`.
src/lightning/fabric/utilities/device_dtype_mixin.py:95
↓ 27 callers
Method
setup_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 callers
Function
get_filesystem
(path: _PATH, **kwargs: Any)
src/lightning/fabric/utilities/cloud_io.py:80
↓ 26 callers
Method
register
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 callers
Method
to
(self, *args, **kwargs)
tests/tests_pytorch/models/test_gpu.py:205
↓ 25 callers
Method
zero_grad
(self, *args, **kwargs)
tests/tests_pytorch/trainer/test_trainer.py:1570
↓ 24 callers
Method
backward
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 callers
Method
scale_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 callers
Method
init_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 callers
Method
mean
(t: Tensor)
src/lightning/fabric/strategies/dp.py:79
↓ 23 callers
Method
profile
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 callers
Method
step
(self, closure: Optional[Callable] = None)
src/lightning/fabric/wrappers.py:80
↓ 22 callers
Method
attach_data
( self, model: "pl.LightningModule", train_dataloaders: Optional[TRAIN_DATALOADERS] =
src/lightning/pytorch/trainer/connectors/data_connector.py:104
↓ 22 callers
Method
barrier
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 callers
Method
lr_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 callers
Method
setup_data
(self)
src/lightning/pytorch/loops/fit_loop.py:226
↓ 22 callers
Method
step
(self, model, batch)
tests/tests_fabric/strategies/test_fsdp_integration.py:83
↓ 21 callers
Method
backward
(self, *args, **kwargs)
tests/tests_pytorch/trainer/test_trainer.py:195
↓ 21 callers
Function
summarize
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 callers
Method
__init__
(self, model_param: int)
tests/tests_pytorch/test_cli.py:111
↓ 20 callers
Function
_distributed_is_initialized
()
src/lightning/fabric/utilities/distributed.py:397
↓ 20 callers
Method
to
See :meth:`torch.nn.Module.to`.
src/lightning/fabric/utilities/device_dtype_mixin.py:54
↓ 20 callers
Method
to
(self, *args: Any, **kwargs: Any)
src/lightning/pytorch/trainer/connectors/logger_connector/result.py:306
↓ 19 callers
Method
all_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 callers
Method
train_dataloader
(self)
tests/tests_pytorch/test_cli.py:846
↓ 17 callers
Function
_update_dataloader
(dataloader: DataLoader, sampler: Union[Sampler, Iterable])
src/lightning/fabric/utilities/data.py:75
↓ 16 callers
Function
_device_check_helper
(batch_device, module_device)
tests/tests_pytorch/loops/test_all.py:21
↓ 16 callers
Method
log_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 callers
Method
seed_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 callers
Method
step
(self)
tests/tests_pytorch/trainer/optimization/test_optimizers.py:613
↓ 15 callers
Method
__init__
(self, *args, **kwargs)
tests/tests_fabric/utilities/test_data.py:310
↓ 15 callers
Function
_train
( model: BoringModel, dataset: Dataset, tmp_path: str, callback: WeightAveraging, strategy
tests/tests_pytorch/callbacks/test_weight_averaging.py:284
↓ 15 callers
Function
fn
(model, device_mesh)
tests/tests_fabric/strategies/test_model_parallel_integration.py:126
↓ 15 callers
Method
load_state_dict
Loads the state of this loop and all its children.
src/lightning/pytorch/loops/loop.py:84
↓ 15 callers
Method
save
(self)
src/lightning/pytorch/loggers/litlogger.py:278
↓ 15 callers
Method
start
(self, action_name: str)
src/lightning/pytorch/profilers/xla.py:52
↓ 15 callers
Method
state_dict
(self)
tests/tests_pytorch/loops/test_loops.py:91
↓ 15 callers
Method
update
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 callers
Function
_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 callers
Method
device
(self)
src/lightning/fabric/utilities/load.py:146
↓ 14 callers
Method
is_available
MPS is only available on a machine with the ARM-based Apple Silicon processors.
src/lightning/fabric/accelerators/mps.py:72
↓ 14 callers
Method
log_metrics
( # type: ignore[override] self, metrics: dict[str, Union[Tensor, float]], step: Optional[int] = None
src/lightning/fabric/loggers/csv_logs.py:146
↓ 14 callers
Function
migrate_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 callers
Method
setup
(self, *args, **kwargs)
tests/tests_pytorch/core/test_datamodules.py:117
↓ 14 callers
Method
suggestion
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 callers
Method
to
(self, device)
tests/tests_fabric/utilities/test_apply_func.py:28
↓ 14 callers
Method
to_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 callers
Function
move_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 callers
Method
print
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 callers
Method
remove
Removes the registered strategy by name.
src/lightning/fabric/strategies/registry.py:103
↓ 12 callers
Function
_set_version
Set the version of a Lightning checkpoint.
src/lightning/pytorch/utilities/migration/utils.py:167
↓ 12 callers
Method
_validate_launched
(self)
src/lightning/fabric/fabric.py:1193
↓ 12 callers
Function
fn
(model, device_mesh)
tests/tests_pytorch/strategies/test_model_parallel_integration.py:81
↓ 12 callers
Method
increment_completed
(self)
src/lightning/pytorch/loops/progress.py:171
↓ 12 callers
Method
refresh
(self, hard: bool = False)
src/lightning/pytorch/callbacks/progress/rich_progress.py:411
↓ 12 callers
Method
setup_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 callers
Method
step
(self, closure=None)
tests/tests_pytorch/core/test_lightning_optimizer.py:295
↓ 12 callers
Method
update
(self, value: _VALUE, batch_size: int)
src/lightning/pytorch/trainer/connectors/logger_connector/result.py:207
↓ 11 callers
Function
_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 callers
Method
barrier
(self, name: Optional[str] = None, *args: Any, **kwargs: Any)
src/lightning/pytorch/strategies/xla.py:202
↓ 11 callers
Method
broadcast
(self, obj: TBroadcast, src: int = 0)
src/lightning/pytorch/strategies/xla.py:214
↓ 11 callers
Method
clip_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 callers
Method
describe
Logs a profile report after the conclusion of run.
src/lightning/pytorch/profilers/profiler.py:116
↓ 11 callers
Method
detect
()
tests/tests_pytorch/strategies/test_ddp_integration.py:322
↓ 11 callers
Method
global_rank
(self)
tests/tests_pytorch/strategies/test_ddp_integration.py:331
↓ 11 callers
Method
is_available
()
tests/tests_pytorch/accelerators/test_common.py:47
next →
1–100 of 7,826, ranked by callers