{"record":{"id":"b0b6f74867ed3d0a","repo":"Lightning-AI/pytorch-lightning","slug":"you-are-trying-to-use-schedulewrapper-which-requ","errorCode":null,"errorMessage":"You are trying to use `ScheduleWrapper` which require kineto install.","messagePattern":"You are trying to use `ScheduleWrapper` which require kineto install\\.","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/profilers/pytorch.py","lineNumber":109,"sourceCode":"                    partial(self._stop_recording_forward, record_name=record_name)\n                )\n\n                self._handles[module_name] = [pre_forward_handle, post_forward_handle]\n\n    def __exit__(self, type: Any, value: Any, traceback: Any) -> None:\n        for handles in self._handles.values():\n            for h in handles:\n                h.remove()\n        self._handles = {}\n\n\nclass ScheduleWrapper:\n    \"\"\"This class is used to override the schedule logic from the profiler and perform recording for both\n    `training_step`, `validation_step`.\"\"\"\n\n    def __init__(self, schedule: Callable) -> None:\n        if not _KINETO_AVAILABLE:\n            raise ModuleNotFoundError(\"You are trying to use `ScheduleWrapper` which require kineto install.\")\n        self._schedule = schedule\n        self.reset()\n\n    def reset(self) -> None:\n        # handle properly `fast_dev_run`. PyTorch Profiler will fail otherwise.\n        self._num_training_step = 0\n        self._num_validation_step = 0\n        self._num_test_step = 0\n        self._num_predict_step = 0\n        self._training_step_reached_end = False\n        self._validation_step_reached_end = False\n        self._test_step_reached_end = False\n        self._predict_step_reached_end = False\n        # used to stop profiler when `ProfilerAction.RECORD_AND_SAVE` is reached.\n        self._current_action: Optional[str] = None\n        self._prev_schedule_action: Optional[ProfilerAction] = None\n        self._start_action_name: Optional[str] = None\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/profilers/pytorch.py#L91-L127","documentation":"ScheduleWrapper wraps a torch.profiler schedule for step-level recording with the PyTorch (kineto/LibTorch) profiler. It requires torch.profiler.profiler.ProfilerAction, which only exists when kineto is available in the installed PyTorch build; if the availability check fails, __init__ raises ModuleNotFoundError.","triggerScenarios":"Constructing ScheduleWrapper directly, or creating PyTorchProfiler with a schedule kwarg, on a PyTorch build without kineto support (e.g. some stripped/older builds or restricted environments).","commonSituations":"Running on unusual PyTorch installations (custom builds, very old versions, some mobile/embedded builds) where torch.profiler kineto components are absent; using lightning on such an environment with the default PyTorchProfiler setup.","solutions":["Install a standard PyTorch build that includes kineto (standard pip/conda wheels do)","Upgrade PyTorch to a recent version","If kineto is unavailable in your environment, use AdvancedProfiler or SimpleProfiler instead of PyTorchProfiler"],"exampleFix":"# before\nprofiler = PyTorchProfiler(schedule=torch.profiler.schedule(wait=1, warmup=1, active=3))\n\n# after (no kineto available)\nfrom lightning.pytorch.profilers import AdvancedProfiler\nprofiler = AdvancedProfiler()","handlingStrategy":"type-guard","validationCode":"from lightning.pytorch.profilers.pytorch import _KINETO_AVAILABLE\nif not _KINETO_AVAILABLE:\n    profiler = AdvancedProfiler()  # fallback\nelse:\n    profiler = PyTorchProfiler(...)","typeGuard":"def has_kineto() -> bool:\n    try:\n        from torch.profiler.profiler import ProfilerAction  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    profiler = PyTorchProfiler(schedule=torch.profiler.schedule(wait=1, warmup=1, active=3))\nexcept ModuleNotFoundError:\n    profiler = AdvancedProfiler()","preventionTips":["Use standard PyTorch wheels which bundle kineto","Feature-detect kineto before selecting PyTorchProfiler","Keep a fallback profiler choice in config"],"tags":["profiler","kineto","dependency-missing","pytorch"],"backgroundTag":"missing-optional-dependency","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}