{"record":{"id":"e8b6df24770585ca","repo":"Lightning-AI/pytorch-lightning","slug":"the-pytorch-profiler-default-schedule-will-be-over","errorCode":null,"errorMessage":"The PyTorch Profiler default schedule will be overridden as there is not enough steps to properly record traces.","messagePattern":"The PyTorch Profiler default schedule will be overridden as there is not enough steps to properly record traces\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lightning/pytorch/profilers/pytorch.py","lineNumber":460,"sourceCode":"\n    @override\n    def stop(self, action_name: str) -> None:\n        if action_name in self._recording_map:\n            self._recording_map[action_name].__exit__(None, None, None)\n            del self._recording_map[action_name]\n\n        if not _KINETO_AVAILABLE or self._emit_nvtx:\n            return\n\n        if self.profiler is not None and any(action_name.endswith(func) for func in self.STEP_FUNCTIONS):\n            assert isinstance(self.profiler, torch.profiler.profile)\n            if self._schedule is not None:\n                self._schedule.pre_step(action_name)\n\n            # the default schedule requires a minimum of 5 steps to properly work: `wait=1, warmup=1, active=3`.\n            # otherwise, this will raise a `segmentation fault`.\n            if self._should_override_schedule():\n                warning_cache.warn(\n                    \"The PyTorch Profiler default schedule will be overridden as there is not enough \"\n                    \"steps to properly record traces.\"\n                )\n                self._schedule = None\n                self.profiler.schedule = torch.profiler.profiler._default_schedule_fn\n\n            def on_trace_ready(profiler: _PROFILER) -> None:\n                if self.dirpath is not None:\n                    if self._export_to_chrome:\n                        handler = tensorboard_trace_handler(\n                            str(self.dirpath), self._prepare_filename(action_name=action_name, extension=\"\")\n                        )\n                        handler(profiler)\n\n                    if self._export_to_flame_graph:\n                        path = os.path.join(\n                            self.dirpath, self._prepare_filename(action_name=action_name, extension=\".stack\")\n                        )","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/profilers/pytorch.py#L442-L478","documentation":"PyTorch Profiler's default schedule (wait=1, warmup=1, active=3) needs at least 5 steps; with fewer steps a segmentation fault would occur, so Lightning overrides the schedule to none and warns.","triggerScenarios":"Trainer(profiler=PyTorchProfiler(...)) with default schedule and fast_dev_run or max_steps/train batches < 5, or running predict/validate with very few batches.","commonSituations":"Quick profiling smoke tests with tiny datasets; fast_dev_run=True combined with the profiler.","solutions":["Increase steps: run with at least 5 optimizer steps (more data or epochs)","Or set an explicit schedule with fewer steps: schedule=torch.profiler.schedule(wait=0, warmup=0, active=1) via ProfilerAction config","Or accept the override — profiling still works, just unscheduled"],"exampleFix":"# before\nprofiler = PyTorchProfiler()  # default schedule, <5 steps\ntrainer = Trainer(profiler=profiler, fast_dev_run=True)\n# after\nprofiler = PyTorchProfiler(schedule=torch.profiler.schedule(wait=0, warmup=0, active=3))\ntrainer = Trainer(profiler=profiler, limit_train_batches=4)","handlingStrategy":"validation","validationCode":"steps = min(trainer.max_steps or 10**9, num_batches)\nassert steps >= 5 or custom_schedule_set, 'profiler schedule needs >=5 steps'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run profiling on a slice with >=5 batches","Set an explicit short schedule for smoke tests"],"tags":["profiler","pytorch-profiler","schedule","lightning"],"backgroundTag":"profiler-schedule-too-short","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}