{"record":{"id":"b877a1c8de6b4132","repo":"Lightning-AI/pytorch-lightning","slug":"found-invalid-table-kwargs-key-key-should-be-w","errorCode":null,"errorMessage":"Found invalid table_kwargs key: {key}. Should be within {valid_table_keys}.","messagePattern":"Found invalid table_kwargs key: (.+?)\\. Should be within (.+?)\\.","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/profilers/pytorch.py","lineNumber":333,"sourceCode":"            self._init_kineto(profiler_kwargs)\n\n        if self._sort_by_key not in self.AVAILABLE_SORT_KEYS:\n            raise MisconfigurationException(\n                f\"Found sort_by_key: {self._sort_by_key}. Should be within {self.AVAILABLE_SORT_KEYS}. \"\n            )\n\n        for key in self._table_kwargs:\n            if key in {\"sort_by\", \"row_limit\"}:\n                raise KeyError(\n                    f\"Found invalid table_kwargs key: {key}. This is already a positional argument of the Profiler.\"\n                )\n            valid_table_keys = set(inspect.signature(EventList.table).parameters.keys()) - {\n                \"self\",\n                \"sort_by\",\n                \"row_limit\",\n            }\n            if key not in valid_table_keys:\n                raise KeyError(f\"Found invalid table_kwargs key: {key}. Should be within {valid_table_keys}.\")\n\n    def _init_kineto(self, profiler_kwargs: Any) -> None:\n        has_schedule = \"schedule\" in profiler_kwargs\n        self._has_on_trace_ready = \"on_trace_ready\" in profiler_kwargs\n\n        schedule = profiler_kwargs.get(\"schedule\", None)\n        if schedule is not None:\n            if not callable(schedule):\n                raise MisconfigurationException(f\"Schedule should be a callable. Found: {schedule}\")\n            action = schedule(0)\n            if not isinstance(action, ProfilerAction):\n                raise MisconfigurationException(\n                    f\"Schedule should return a `torch.profiler.ProfilerAction`. Found: {action}\"\n                )\n        self._default_schedule()\n        schedule = schedule if has_schedule else self._default_schedule()\n        self._schedule = ScheduleWrapper(schedule) if schedule is not None else schedule\n        self._profiler_kwargs[\"schedule\"] = self._schedule","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/profilers/pytorch.py#L315-L351","documentation":"After excluding 'sort_by' and 'row_limit', remaining table_kwargs keys are validated against the signature of torch.autograd.EventList.table. Any key not in that signature raises KeyError, since it would be silently ignored or crash later when passed through.","triggerScenarios":"PyTorchProfiler(table_kwargs={\"max_group_row_limit\": 5}) where the key is not a parameter of EventList.table in your installed PyTorch version.","commonSituations":"Using kwargs valid for a different PyTorch version's EventList.table (signature changed across releases); guessing kwarg names from other profiling APIs.","solutions":["Inspect allowed keys: import inspect, torch; print(inspect.signature(torch.autograd.EventList.table).parameters.keys()) and use only those","Upgrade/downgrade Lightning or PyTorch so the kwarg set matches what you pass","Drop the unsupported key if it's not essential"],"exampleFix":"# before\nprofiler = PyTorchProfiler(table_kwargs={\"n_cols\": 5})  # invalid key\n\n# after\nprofiler = PyTorchProfiler(table_kwargs={\"max_src_column_width\": 100})  # real EventList.table kwarg","handlingStrategy":"validation","validationCode":"import inspect, torch\nvalid = set(inspect.signature(torch.autograd.EventList.table).parameters) - {\"self\", \"sort_by\", \"row_limit\"}\nbad = set(table_kwargs) - valid\nassert not bad, f\"invalid table_kwargs: {bad}\"","typeGuard":"def valid_table_kwargs(kwargs: dict) -> dict:\n    import inspect, torch\n    valid = set(inspect.signature(torch.autograd.EventList.table).parameters) - {\"self\", \"sort_by\", \"row_limit\"}\n    return {k: v for k, v in kwargs.items() if k in valid}","tryCatchPattern":null,"preventionTips":["Validate kwargs against EventList.table's signature for your PyTorch version","Pin Lightning and PyTorch versions in CI to avoid signature drift","Filter unknown keys from config files before passing them"],"tags":["profiler","invalid-argument","kwargs","version-compat"],"backgroundTag":"invalid-argument-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}