已关闭
[Usage]: test目录下torch.distributed.FileStore,torch.distributed.Store, torch.distributed.TCPStore API的测试用例缺失 #1580
Nice try创建于 3月17日关闭于 4月10日
3月17日 添加了label:usage
3月17日 修改了issue 的描述
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 关联了pull request:test(distributed): add test for FileStore,HashStore,PrefixStore,Store,TCPStore
3月17日 修改标题为 “[Usage]: test目录下torch.distributed.FileStore,torch.distributed.Store, torch.distributed.TCPStore API的测试用例缺失”,原标题为“[Usage]: test目录下torch.distributed.FileStore,torch.distributed.HashStore,torch.distributed.PrefixStore,torch.distributed.Store, torch.distributed.TCPStore API的测试用例缺失”
3月17日 修改标题为 “[Usage]: test目录下torch.distributed.FileStore,torch.distributed.Store, torch.distributed.TCPStore API的测试用例缺失”,原标题为“[Usage]: test目录下torch.distributed.FileStore,torch.distributed.HashStore,torch.distributed.PrefixStore,torch.distributed.Store, torch.distributed.TCPStore API的测试用例缺失”
3月17日 修改了issue 的描述
huangyunlong
3月18日 评论:
3月18日 评论:
3月20日 修改了issue 的描述
3月25日 关联了pull request:test(distributed): add test for FileStore,Store,TCPStore
3月30日 关联了pull request:docs(distributed): add api docs for FileStore,Store,TCPStore
4月10日 issue状态由 TODO 改变为 DONE
4月10日 关闭了 issue
4月10日 添加了label:event: api-consistency
4月10日 添加了label:resolved


在提交新问题之前,请确保您已经在社区中搜索过相关问题,并使用了社区中提供的资源/工具后,仍未找到满意的解决方式。
环境信息
API功能介绍
torch.distributed.Store、torch.distributed.HashStore、torch.distributed.FileStore、torch.distributed.TCPStore 是 PyTorch 分布式训练的基础核心 API,构成进程间元数据共享与同步的存储体系,支撑分布式训练中初始化、容错和协调等关键机制,核心功能如下:
torch.distributed.Store
PyTorch 分布式存储的抽象基类,为分布式训练中的键值对存储提供统一接口,支撑进程间元数据共享与同步:
1.定义键值对存储的核心操作:set(key, value)、get(key)、add(key, delta)、wait(keys) 等,屏蔽底层实现差异;
2.支持超时设置,确保分布式初始化过程中对关键数据的等待不会无限阻塞;
3.为进程组初始化提供协调机制,所有进程通过共享存储交换地址和同步状态;
4.派生类可实现不同后端(文件、内存、TCP),适配单机多卡或多机多卡等多种训练场景;
5.作为 rendezvous 机制的底层基础,帮助分布式作业的进程发现彼此并建立连接。
torch.distributed.FileStore
基于文件系统的分布式存储实现,通过共享文件在单机多进程间传递数据:
1.利用操作系统文件锁保证多个进程并发读写同一文件的原子性和一致性;
2.适用于单机多进程训练场景(如使用 gloo 后端),无需网络配置即可建立共享存储;
3.所有进程通过约定文件路径访问同一存储,数据持久化在磁盘上,进程重启后可能残留;
4.支持 set、get、add、wait 等基础操作,性能受文件 I/O 速度影响;
5.简单可靠,但受文件锁限制,扩展性有限,不适合大规模跨节点分布式训练。
torch.distributed.TCPStore
基于 TCP 协议的分布式存储,采用服务器-客户端模式实现跨网络的键值存储:
1.服务端进程(master)绑定端口提供存储服务,客户端进程通过 TCP 连接进行读写操作;
2.支持多租户模式,允许多个独立作业共享同一服务端端口(通过 multi_tenant 标志);
3.自动管理连接生命周期,支持超时重试和故障容错,确保分布式初始化鲁棒性;
4.可指定使用 libuv 后端或传统 socket 后端,适应不同系统对事件循环的支持
5.广泛应用于多机多卡分布式训练,如初始化进程组时通过 MASTER_ADDR:MASTER_PORT 配置的存储;
6.提供 wait_for_workers 机制,确保所有工作节点加入后再开始训练,避免竞争条件。
社区用例现状
PyTorch中具备原生测试用例,文件路径为
test/distributed/test_store.py,torch_npu目前没有相关测试用例。test_store.py中缺少部分API的直接测试用例,缺失的API包含:
针对缺失直接测试用例的API创建自定义测试用例用以覆盖。