Diff Coverage

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

Source File Diff Coverage (%) Missing Lines
hyper_parallel/components/modules/shared_compressed_dsa_attention.py 95.2% 907
hyper_parallel/distributed/activation_checkpoint.py 91.9% 963,993,1002,1046,1052
hyper_parallel/components/modules/shared_compressed_dsa_attention.py
903
904
905
906
907
908
909
910
911
        each phase. Everything else in the forward is either recomputed
        unchanged or guarded by :func:`is_recomputing`, so a recompute reads the
        shared entries the forward pass published instead of writing its own.
        """
        object.__setattr__(
            self, "_selection_region", checkpoint_exclude_wrapper(self._select_tokens)
        )

    def _run_selection(
hyper_parallel/distributed/activation_checkpoint.py
959
960
961
962
963
964
965
966
        if any(
            child is not module and id(child) in root_ids
            for child in module.modules()
        ):
            raise ValueError(
                f"excluded recompute region {module_fqn!r} contains a recompute region root"
            )

989
990
991
992
993
994
995
996
997
            "requires RecomputePolicy.region_patterns"
        )
    selected_layer_fqns = _selected_checkpoint_layer_fqns(containers, selection)
    if not selected_layer_fqns:
        logger.info("Model-adapter recompute selected zero layers")
        return model
    if hasattr(model, "gradient_checkpointing_disable"):
        model.gradient_checkpointing_disable()
    checkpoint_kwargs = {"swap_inputs": swap_inputs} if not enable_compile else {}
 998
 999
1000
1001
1002
1003
1004
1005
1006

    module_by_fqn = dict(model.named_modules())
    roots = _select_layer_region_roots(module_by_fqn, selected_layer_fqns, recompute_spec)
    if not roots:
        raise ValueError(
            "model adapter recompute patterns matched no region in the selected layers"
        )
    excluded_count = _wrap_declared_exclusions(module_by_fqn, roots, recompute_spec)
    wrapped_count = _wrap_region_roots(model, module_by_fqn, roots, checkpoint_kwargs)
1042
1043
1044
1045
1046
1047
1048
1049
1050
        key=lambda item: item[0].count("."),
        reverse=True,
    ):
        if _is_checkpoint_wrapped(module):
            continue
        parent_fqn, child_name = module_fqn.rsplit(".", 1)
        parent = module_by_fqn[parent_fqn] if parent_fqn else model
        setattr(parent, child_name, checkpoint_wrapper(module, **checkpoint_kwargs))
        wrapped_count += 1
1048
1049
1050
1051
1052
1053
1054
1055
1056
        parent = module_by_fqn[parent_fqn] if parent_fqn else model
        setattr(parent, child_name, checkpoint_wrapper(module, **checkpoint_kwargs))
        wrapped_count += 1
    if wrapped_count == 0:
        raise ValueError("model adapter recompute matched no region to wrap")
    return wrapped_count


def _resolve_activation_checkpoint_containers(