• 文档 >
  • 模块代码 >
  • torch >
  • torch.distributed >
  • torch.distributed.algorithms.ddp_comm_hooks.debugging_hooks
快捷键

torch.distributed.algorithms.ddp_comm_hooks.debugging_hooks 的源代码

从 typing 导入 Any,导入 torch,从 torch.distributed 导入 GradBucket __all__ = ["noop_hook"]
[文档]def noop_hook(_: Any, bucket: GradBucket) -> torch.futures.Future[torch.Tensor]: "" 返回一个包装输入的未来,使其成为一个不执行任何通信开销的无操作。 此钩子**仅**应用于 allreduce 优化中所有 reduce 分析的空闲空间分析, 而不是正常的梯度同步。 例如,如果在此钩子注册后只能观察到训练时间低于 10%的加速 通常意味着 allreduce 不是这种情况的性能瓶颈。 此类仪器特别有用 如果 GPU 追踪无法轻松检索或追踪分析复杂 一些因素,例如 allreduce 与计算之间的重叠或跨 rank 的解同步。 示例:: >>> # xdoctest: +SKIP >>> ddp_model.register_comm_hook(None, noop_hook) """ fut: torch.futures.Future[torch.Tensor] = torch.futures.Future() fut.set_result(bucket.buffer()) return fut

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

查看 PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源,获取您的疑问解答

查看资源