detrium.utils.dist

RT-DETRv4: Painlessly Furthering Real-Time Object Detection with Vision Foundation Models Copyright (c) 2025 The RT-DETRv4 Authors. All Rights Reserved. --------------------------------------------------------------------------------- Modified from RT-DETR (https://github.com/lyuwenyu/RT-DETR) reference - https://github.com/pytorch/vision/blob/main/references/detection/utils.py - https://github.com/facebookresearch/detr/blob/master/util/misc.py#L406 Copyright(c) 2023 lyuwenyu. All Rights Reserved.

setup_distributed(print_rank: int=0, print_method: str='builtin', seed: int=None)

env setup args: print_rank, print_method, (builtin, rich) seed,

名称类型默认值
print_rankint0
print_methodstr'builtin'
seedintNone
setup_print(is_main, method='builtin')

This function disables printing when not in master process

名称类型默认值
is_main——
method—'builtin'
save_on_master(*args, **kwargs)

Save checkpoint on rank 0 atomically (temp file + flush/fsync + os.replace) for path targets.

名称类型默认值
args——
kwargs——
warp_model(model: torch.nn.Module, sync_bn: bool=False, dist_mode: str='ddp', find_unused_parameters: bool=False, compile: bool=False, compile_mode: str='reduce-overhead', **kwargs)
名称类型默认值
modeltorch.nn.Module—
sync_bnboolFalse
dist_modestr'ddp'
find_unused_parametersboolFalse
compileboolFalse
compile_modestr'reduce-overhead'
kwargs——
all_gather(data)

Run all_gather on arbitrary picklable data (not necessarily tensors) Args: data: any picklable object Returns: list[data]: list of data gathered from each rank

名称类型默认值
data——
setup_seed(seed: int, deterministic=False)

setup_seed for reproducibility torch.manual_seed(3407) is all you need. https://arxiv.org/abs/2109.08203

名称类型默认值
seedint—
deterministic—False