Deleting a branch is permanent. It CANNOT be undone. Continue?
Deleting a branch is permanent. It CANNOT be undone. Continue?
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》
完成:
1、结合storage整改load的流程,fix之前未覆盖的场景,目前整改legacy save/load, zipfile save/load(仅限 torch weights state dict)
2、legacy save/ zipfile save相关流程,以及涉及到的对象__reduce_ex__ 和 __setstate__整改
[WIP]load fixto [WIP]load/save fix 2 weeks agostorage_type没有_dtype对象,可调用dtype。
done
storage.TypedStorage 替换为_TypedStorage
done
_TypedStorage
done
_TypedStorage 需要新增一个_internal入参
同上
storage没有_untyped_storage,改为storage._untyped()
isinstance(state, tuple) 才进
直接删除
新增该函数
parameter new函数修改:
init函数修改:
找个合适的位置调用torch_disable, torch_pop
补充_check_container_source实现
当前有应该不支持as_subclass?什么场景会进这个函数?
补充了简单实现,浩宇的那个样例会进这个函数
已删除,当前不需要
和后面的变量重名了
这部分data_ptr的作用是否和内存访问相关,频繁调用性能较差
需验证,加载torch的pth,保存mindtorch的pth,再加载回来,整个流程的正确性
为什么不调用get_bytes? 如果效果等价,是不是修改get_bytes接口实现?
get_bytes是mindspore tensor的方法,之前是直接保存的tensor,所以用的get_bytes,现在我们保存的storage,直接保存storage的inner data数据就行
用torch_disable来解决该类问题
同上
import torch
a = torch.tensor(2.)
a.kkk = 3
pth = torch.save(a, './pt.pth')
tensor = torch.load('./pt.pth')
print(tensor)
print(tensor.kkk)
这个用例可以跑过。 但是mindtorch无法恢复出tensor.kkk这个值
import torch
a = torch.tensor(2.)
a.kkk = 3
pth = torch.save(a, './pt.pth')
import mindtorch.torch as ms_torch
tensor = ms_torch.load('./pt.pth')
print(tensor)
print(tensor.kkk)
需新增_set_obj_state
_rebuild_from_type_v2中调用
目前已经可以正常load torch具有额外属性的tensor,mindtorch也可以正确保存tensor的额外属性
直接创建一个tensor的方法快一点吧?
不可以直接创建tensor,加载场景是通过修改storage的值,同步改变tensor的值,如果直接场景tensor,外部storage和tensor直接没有建立连接,不会同步更新
不可以直接创建tensor,加载场景是通过修改storage的值,同步改变tensor的值,如果直接场景tensor,外部storage和tensor直接没有建立连接,不会同步更新
同上,是不是可以直接创建tensor?
不可以直接创建tensor,加载场景是通过修改storage的值,同步改变tensor的值,如果直接场景tensor,外部storage和tensor直接没有建立连接,不会同步更新
data=1和data = np.array(1)对结果的区别是dtype不同,现在这么写是因为要求int64?
可以修改,效果是一样的。
已修改
为啥要把set_接口删掉呢?
因为我们的parameter继承自Tensor,他直接可以使用Tensor的类内方法 set_。
现在还有要依赖pytorch的场景吗?
没有依赖pytorch的场景,在load torch的权重时,会读取到保存的torch函数指针,这个地方只是为了保证这个函数指针一定指向mindtorch实现的同名函数位置。
warnings是否要用mindtorch封装后的?这样可以受环境变量配置控制
已修改
这些用例注释掉的原因是什么?
已放开
这个用例在GPU和Ascend也是不能跑的,可以都先加上skip,如果后续需要跑再单独放开
已修改
[WIP]load/save fixto load/save fix 1 week ago遇到个问题:
_rebuild_tensor_v2() takes 6 positional arguments but 7 were given
在torch 2.1版本的rebuild_tensor_v2中第七个参数 metadata,主要作用是:
Currently, this only returns a dict[string, bool] specifing whether
conj
orneg
bit is set.用于指示tensor是否有共轭和取负。
目前我们并不支持tensor的metadata属性,所以设置该函数入参为None,unsupported_attr。可以正常传参,但是不会set metadata
修改了 parameter
__reduce_ex__
函数主要是为了和torch保持一致,能够为parameter设置额外的属性,比如a.kkk = 2这种情况下能够正确save和load。已验证最新修改, 在我这边场景可行。
默认值改成None,如果是None的时候走后面的判断。如果用户设0走非多进程
2bf20afdfb
.