Diff Coverage

Diff: origin/master...HEAD, staged and unstaged changes

Source File Diff Coverage (%) Missing Lines
hyper_parallel/platform/mindspore/activation_checkpoint/activation_swap.py 100%  
hyper_parallel/platform/torch/activation_checkpoint/activation_swap.py 80.0% 67,123
hyper_parallel/platform/torch/activation_checkpoint/activation_swap.py
63
64
65
66
67
68
69
70
71

def _is_callable_exempt_from_overlap_check(callable_obj: Callable) -> bool:
    """Return True for callables that cannot be reliably overlap-tracked by object marks."""
    if isinstance(callable_obj, types.MethodType):
        return True
    if not isinstance(callable_obj, (types.FunctionType, types.BuiltinFunctionType)):
        return False
    module_name = getattr(callable_obj, "__module__", "")
    return module_name == "torch" or module_name.startswith("torch.")
119
120
121
122
123
124
125
126
127


def _check_and_mark_callable(callable_obj: Callable) -> None:
    if _is_callable_exempt_from_overlap_check(callable_obj):
        return
    if getattr(callable_obj, '_is_wrapped', False):
        raise ValueError(
            f"Callable '{callable_obj.__class__.__name__}' or one of its ancestors is already wrapped. "
            "Wrapping overlapping module regions is not allowed."