Diff Coverage

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

Source File Diff Coverage (%) Missing Lines
hyper_parallel/distributed/_builder/parameter_sharding.py 91.2% 424,431,463
hyper_parallel/distributed/apply.py 100%  
hyper_parallel/distributed/_builder/parameter_sharding.py
420
421
422
423
424
425
426
427
428

    source_is_dtensor = isinstance(source, DTensor)
    target_is_dtensor = isinstance(target, DTensor)
    if source_is_dtensor != target_is_dtensor:
        raise ValueError(
            "Tied parameters must both be DTensors or both be local Parameters: "
            f"{source_fqn}={type(source).__name__}, {target_fqn}={type(target).__name__}"
        )
    if not source_is_dtensor:
427
428
429
430
431
432
433
434
435
        )
    if not source_is_dtensor:
        return
    if source.device_mesh != target.device_mesh:
        raise ValueError(
            f"Tied DTensors must use the same device mesh: {source_fqn} and {target_fqn}"
        )
    if tuple(source.placements) != tuple(target.placements):
        raise ValueError(
459
460
461
462
463
464
465
466
        target,
    )
    _set_param_by_path(model, target_fqn, source)
    if _get_attr_by_path(model, target_fqn) is not source:
        raise ValueError(
            f"Failed to restore tied Parameter identity: {source_fqn} and {target_fqn}"
        )