{"record":{"id":"26b79c224217d6d0","repo":"Lightning-AI/pytorch-lightning","slug":"you-cannot-set-both-activation-checkpointing-and","errorCode":null,"errorMessage":"You cannot set both `activation_checkpointing` and `activation_checkpointing_policy`. Use the latter.","messagePattern":"You cannot set both `activation_checkpointing` and `activation_checkpointing_policy`\\. Use the latter\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/fsdp.py","lineNumber":708,"sourceCode":"        return self._process_group_backend or _get_default_process_group_backend_for_device(self.root_device)\n\n    def _set_world_ranks(self) -> None:\n        if self.cluster_environment is not None:\n            self.cluster_environment.set_global_rank(self.node_rank * self.num_processes + self.local_rank)\n            self.cluster_environment.set_world_size(self.num_nodes * self.num_processes)\n        # `LightningEnvironment.set_global_rank` will do this too, but we cannot rely on that implementation detail\n        # additionally, for some implementations, the setter is a no-op, so it's safer to access the getter\n        rank_zero_only.rank = utils_rank_zero_only.rank = self.global_rank\n\n\ndef _activation_checkpointing_kwargs(\n    activation_checkpointing: Optional[Union[type[Module], list[type[Module]]]],\n    activation_checkpointing_policy: Optional[\"_POLICY\"],\n) -> dict:\n    if activation_checkpointing is None and activation_checkpointing_policy is None:\n        return {}\n    if activation_checkpointing is not None and activation_checkpointing_policy is not None:\n        raise ValueError(\n            \"You cannot set both `activation_checkpointing` and `activation_checkpointing_policy`. Use the latter.\"\n        )\n    if activation_checkpointing is not None:\n        if isinstance(activation_checkpointing, list):\n            classes = tuple(activation_checkpointing)\n        else:\n            classes = (activation_checkpointing,)\n        rank_zero_deprecation(\n            f\"`FSDPStrategy(activation_checkpointing={activation_checkpointing})` is deprecated, use \"\n            f\"`FSDPStrategy(activation_checkpointing_policy={set(classes)})` instead.\"\n        )\n        return {\"check_fn\": lambda submodule: isinstance(submodule, classes)}\n    if isinstance(activation_checkpointing_policy, set):\n        return _auto_wrap_policy_kwargs(activation_checkpointing_policy, {})\n    return {\"auto_wrap_policy\": activation_checkpointing_policy}\n\n\ndef _auto_wrap_policy_kwargs(policy: Optional[\"_POLICY\"], kwargs: dict) -> dict:","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/fsdp.py#L690-L726","documentation":"FSDPStrategy exposes two ways to select which layers get activation checkpointing: the legacy activation_checkpointing (module class or list of classes) and the newer activation_checkpointing_policy (a policy dict). Passing both is rejected to avoid conflicting specifications; the policy kwarg is the recommended one.","triggerScenarios":"FSDPStrategy(activation_checkpointing=[TransformerBlock], activation_checkpointing_policy={TransformerBlock: ...}) — both kwargs non-None in the same constructor call.","commonSituations":"Copy-pasting config from an old example (activation_checkpointing) into a newer script that already sets a policy; merging YAML configs where both keys survive; upgrading Lightning and keeping the legacy kwarg while adding the new one.","solutions":["Remove activation_checkpointing and express the same selection via activation_checkpointing_policy","Translate class lists to policy form: {TransformerBlock: ...} or use checkpoint policies like every_other_transformer_layer_policy"],"exampleFix":"# before\nFSDPStrategy(\n    activation_checkpointing=[TransformerBlock],\n    activation_checkpointing_policy={TransformerBlock: None},\n)\n# after\nFSDPStrategy(\n    activation_checkpointing_policy={TransformerBlock: None},\n)","handlingStrategy":"validation","validationCode":"assert not (activation_checkpointing and activation_checkpointing_policy), 'pass only activation_checkpointing_policy'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer activation_checkpointing_policy in new code","Lint configs for legacy kwargs after Lightning upgrades"],"tags":["fsdp","activation-checkpointing","config","mutually-exclusive","pytorch-lightning"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}