Lightning-AI / Lightning-AI/pytorch-lightning
Cannot pass `schedule` for `PyTorchProfiler` using `LightningCLI`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Bug description
In config file, something like this would work:
```
profiler:
class_path: lightning.pytorch.profilers.PyTorchProfiler
init_args:
filename: perf_logs
export_to_chrome: True
dict_kwargs:
with_stack: true
```
`dict_kwargs` is the recommended way to pass PyTorch profiler args and avoids validation. But for schedule, it needs to be a callable. How should I pass `torch.profiler.schedule`?
I tried this
```
profiler:
class_path: lightning.pytorch.profilers.PyTorchProfiler
init_args:
filename: perf_logs
export_to_chrome: True
dict_kwargs:
schedule: torch.profiler.schedule
init_args:
skip_first: 10
wait: 1
warmup: 1
active: 2
repeat: 1
with_stack: true
```
But it complains
```
Subtypes: (, , )
Errors:
- Schedule should be a callable. Found: torch.profiler.schedule
- Expected a
- Expected a
Given value type:
```
### What version are you seeing the problem on?
v2.2
### How to reproduce the bug
_No response_
### Error messages and logs
```
# Error messages and logs here please
```
### Environment
Current environment
```
#- PyTorch Lightning Version (e.g., 1.5.0):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
```
### More info
_No response_
cc @carmocca @mauvilsa
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the LightningCLI configuration path for PyTorchProfiler and inspect how dict_kwargs handles the schedule value and its nested arguments. Reproduce the reported v2.2 configuration, then verify that a torch.profiler.schedule callable can be configured without the validation errors shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- cli, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100