Source code for nemo_automodel.checkpoint._backports.planner_helpers
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# taken from
# https://github.com/pytorch/pytorch/blob/c13e725edd8dd21406c629bf625f2d6c59ceedd1/torch/distributed/checkpoint/planner_helpers.py
from torch.distributed.checkpoint.planner import SavePlan
[docs]
def _contains_usable_plan(delta_plans: list[SavePlan]) -> bool:
"""
Check if any delta plan is usable, indicating the plan has changed.
Args:
delta_plans (List[SavePlan]): A list of delta plans to check.
Returns:
True if any delta plan is usable, False otherwise.
"""
return any(delta_plan and delta_plan.usable for delta_plan in delta_plans)