[{"data":1,"prerenderedAt":904},["ShallowReactive",2],{"content-query-Ujb1b2yMgb":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":898,"_id":899,"_source":900,"_file":901,"_stem":902,"_extension":903},"/technology-blogs/zh/3850","zh",false,"","MindSpore SafeTensors 技术详解：高效模型存储与懒加载机制","MindSpore完整集成了SafeTensors格式，并实现了独特的懒加载机制，让普通硬件也能处理大规模模型。","2025-09-29","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/10/13/a8542ceff953435097a1ff31e628fb0a.png","technology-blogs",{"type":14,"children":15,"toc":874},"root",[16,24,30,35,52,57,61,76,81,86,96,101,106,111,116,124,132,150,155,160,165,170,185,190,195,200,205,220,236,241,246,251,256,261,276,285,290,295,300,305,310,318,323,328,333,338,343,358,363,372,377,382,387,392,397,402,407,412,417,422,427,432,437,446,451,456,461,466,471,476,481,486,491,496,501,506,511,516,521,526,531,536,541,546,555,560,565,570,575,580,585,590,595,600,605,610,615,620,625,634,639,649,657,662,682,687,705,710,728,743,748,757,762,767,776,781,786,801,809,814,819,824,829,844,849,854,859,864,869],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"mindspore-safetensors-技术详解高效模型存储与懒加载机制",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":23,"value":29},"作者：yide12",{"type":17,"tag":25,"props":31,"children":32},{},[33],{"type":23,"value":34},"来源：昇思论坛",{"type":17,"tag":18,"props":36,"children":38},{"id":37},"_01-概述",[39,45,47],{"type":17,"tag":40,"props":41,"children":42},"strong",{},[43],{"type":23,"value":44},"# 01",{"type":23,"value":46}," ",{"type":17,"tag":40,"props":48,"children":49},{},[50],{"type":23,"value":51},"概述",{"type":17,"tag":25,"props":53,"children":54},{},[55],{"type":23,"value":56},"深度学习模型规模快速增长，给模型存储和加载带来了挑战。SafeTensors格式解决了传统格式的安全隐患，支持高效的大规模模型存储和快速加载。",{"type":17,"tag":25,"props":58,"children":59},{},[60],{"type":23,"value":9},{"type":17,"tag":18,"props":62,"children":64},{"id":63},"_02-safetensors-格式概述",[65,70,71],{"type":17,"tag":40,"props":66,"children":67},{},[68],{"type":23,"value":69},"# 02",{"type":23,"value":46},{"type":17,"tag":40,"props":72,"children":73},{},[74],{"type":23,"value":75},"SafeTensors 格式概述",{"type":17,"tag":25,"props":77,"children":78},{},[79],{"type":23,"value":80},"SafeTensors是新一代机器学习模型存储格式，解决了传统存储方式的局限性。",{"type":17,"tag":25,"props":82,"children":83},{},[84],{"type":23,"value":85},"pickle格式存在安全问题，反序列化时可能执行恶意代码。SafeTensors采用标准化二进制格式，避免代码执行风险，通过精心设计的文件结构，天然支持零拷贝加载和内存映射。",{"type":17,"tag":87,"props":88,"children":90},"h3",{"id":89},"safetensors-文件结构",[91],{"type":17,"tag":40,"props":92,"children":93},{},[94],{"type":23,"value":95},"SafeTensors 文件结构",{"type":17,"tag":25,"props":97,"children":98},{},[99],{"type":23,"value":100},"SafeTensors文件分为三个部分：",{"type":17,"tag":25,"props":102,"children":103},{},[104],{"type":23,"value":105},"1.文件头：记录文件的基本信息",{"type":17,"tag":25,"props":107,"children":108},{},[109],{"type":23,"value":110},"2.目录页：列出所有参数的位置和大小",{"type":17,"tag":25,"props":112,"children":113},{},[114],{"type":23,"value":115},"3.数据区：存放实际的模型参数",{"type":17,"tag":87,"props":117,"children":119},{"id":118},"与传统格式的对比",[120],{"type":17,"tag":40,"props":121,"children":122},{},[123],{"type":23,"value":118},{"type":17,"tag":25,"props":125,"children":126},{},[127],{"type":17,"tag":128,"props":129,"children":131},"img",{"alt":7,"src":130},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/10/13/da3e6ca20d02465188561e0f7c3b207b.png",[],{"type":17,"tag":18,"props":133,"children":135},{"id":134},"_03-安全性分析",[136,141,142],{"type":17,"tag":40,"props":137,"children":138},{},[139],{"type":23,"value":140},"# 03",{"type":23,"value":46},{"type":17,"tag":40,"props":143,"children":144},{},[145],{"type":17,"tag":40,"props":146,"children":147},{},[148],{"type":23,"value":149},"安全性分析",{"type":17,"tag":25,"props":151,"children":152},{},[153],{"type":23,"value":154},"SafeTensors格式就像给你的模型加了一把安全锁：",{"type":17,"tag":25,"props":156,"children":157},{},[158],{"type":23,"value":159},"- 防止恶意代码：不会执行任何危险的代码",{"type":17,"tag":25,"props":161,"children":162},{},[163],{"type":23,"value":164},"- 数据完整性：自动检查文件是否被篡改",{"type":17,"tag":25,"props":166,"children":167},{},[168],{"type":23,"value":169},"- 格式验证：确保文件格式正确无误",{"type":17,"tag":18,"props":171,"children":173},{"id":172},"_04-mindspore-中的-safetensors-集成",[174,179,180],{"type":17,"tag":40,"props":175,"children":176},{},[177],{"type":23,"value":178},"# 04",{"type":23,"value":46},{"type":17,"tag":40,"props":181,"children":182},{},[183],{"type":23,"value":184},"MindSpore 中的 SafeTensors 集成",{"type":17,"tag":25,"props":186,"children":187},{},[188],{"type":23,"value":189},"MindSpore已经完美支持SafeTensors格式，具有以下特点：",{"type":17,"tag":25,"props":191,"children":192},{},[193],{"type":23,"value":194},"- 无缝切换：只需修改一个配置参数",{"type":17,"tag":25,"props":196,"children":197},{},[198],{"type":23,"value":199},"- 完全兼容：支持所有常用的模型操作",{"type":17,"tag":25,"props":201,"children":202},{},[203],{"type":23,"value":204},"- 自动优化：系统会自动选择最佳的加载策略",{"type":17,"tag":18,"props":206,"children":208},{"id":207},"_05-懒加载机制",[209,214,215],{"type":17,"tag":40,"props":210,"children":211},{},[212],{"type":23,"value":213},"# 05",{"type":23,"value":46},{"type":17,"tag":40,"props":216,"children":217},{},[218],{"type":23,"value":219},"懒加载机制",{"type":17,"tag":221,"props":222,"children":224},"h2",{"id":223},"_51-什么是懒加载",[225,230,231],{"type":17,"tag":40,"props":226,"children":227},{},[228],{"type":23,"value":229},"5.1",{"type":23,"value":46},{"type":17,"tag":40,"props":232,"children":233},{},[234],{"type":23,"value":235},"什么是懒加载",{"type":17,"tag":25,"props":237,"children":238},{},[239],{"type":23,"value":240},"懒加载（Lazy Loading）是一种延迟加载策略，就像看书一样，你不需要把整本书都记在脑子里，只需要知道每章在第几页，需要的时候再翻到那一页。",{"type":17,"tag":25,"props":242,"children":243},{},[244],{"type":23,"value":245},"对于AI模型来说，懒加载意味着：",{"type":17,"tag":25,"props":247,"children":248},{},[249],{"type":23,"value":250},"- 不一次性加载：不把整个模型都放进内存",{"type":17,"tag":25,"props":252,"children":253},{},[254],{"type":23,"value":255},"- 按需获取：需要哪部分参数就加载哪部分",{"type":17,"tag":25,"props":257,"children":258},{},[259],{"type":23,"value":260},"- 快速启动：几秒钟就能开始工作",{"type":17,"tag":221,"props":262,"children":264},{"id":263},"_52-为什么需要懒加载",[265,270,271],{"type":17,"tag":40,"props":266,"children":267},{},[268],{"type":23,"value":269},"5.2",{"type":23,"value":46},{"type":17,"tag":40,"props":272,"children":273},{},[274],{"type":23,"value":275},"为什么需要懒加载",{"type":17,"tag":277,"props":278,"children":280},"h4",{"id":279},"传统加载方式的问题",[281],{"type":17,"tag":40,"props":282,"children":283},{},[284],{"type":23,"value":279},{"type":17,"tag":25,"props":286,"children":287},{},[288],{"type":23,"value":289},"想象一下，如果你要查一个词典里的单词，传统方式就像把整本词典都背下来：",{"type":17,"tag":25,"props":291,"children":292},{},[293],{"type":23,"value":294},"1.内存爆炸：一个大型AI模型可能有几十GB甚至上百GB的参数",{"type":17,"tag":25,"props":296,"children":297},{},[298],{"type":23,"value":299},"2.启动缓慢：加载完整模型可能需要几分钟甚至更久",{"type":17,"tag":25,"props":301,"children":302},{},[303],{"type":23,"value":304},"3.资源浪费：很多参数可能根本用不到，但也要占用内存",{"type":17,"tag":25,"props":306,"children":307},{},[308],{"type":23,"value":309},"4.硬件限制：普通电脑的内存根本装不下大型模型",{"type":17,"tag":25,"props":311,"children":312},{},[313],{"type":17,"tag":40,"props":314,"children":315},{},[316],{"type":23,"value":317},"懒加载的优势：",{"type":17,"tag":25,"props":319,"children":320},{},[321],{"type":23,"value":322},"懒加载就像一个智能助手，只在你需要的时候提供帮助：",{"type":17,"tag":25,"props":324,"children":325},{},[326],{"type":23,"value":327},"1.内存友好：只占用实际需要的内存空间",{"type":17,"tag":25,"props":329,"children":330},{},[331],{"type":23,"value":332},"2.快速启动：几秒钟就能开始工作",{"type":17,"tag":25,"props":334,"children":335},{},[336],{"type":23,"value":337},"3.硬件兼容：普通电脑也能运行大型模型",{"type":17,"tag":25,"props":339,"children":340},{},[341],{"type":23,"value":342},"4.动态调整：根据实际使用情况调整内存占用",{"type":17,"tag":221,"props":344,"children":346},{"id":345},"_53-mindspore的懒加载实现原理",[347,352,353],{"type":17,"tag":40,"props":348,"children":349},{},[350],{"type":23,"value":351},"5.3",{"type":23,"value":46},{"type":17,"tag":40,"props":354,"children":355},{},[356],{"type":23,"value":357},"MindSpore的懒加载实现原理",{"type":17,"tag":25,"props":359,"children":360},{},[361],{"type":23,"value":362},"MindSpore采用了多层次的懒加载架构，每一层都有其独特的作用：",{"type":17,"tag":277,"props":364,"children":366},{"id":365},"内存映射技术memory-mapping",[367],{"type":17,"tag":40,"props":368,"children":369},{},[370],{"type":23,"value":371},"内存映射技术（Memory Mapping）",{"type":17,"tag":25,"props":373,"children":374},{},[375],{"type":23,"value":376},"内存映射就像在文件上贴了很多智能标签：",{"type":17,"tag":25,"props":378,"children":379},{},[380],{"type":23,"value":381},"工作原理：",{"type":17,"tag":25,"props":383,"children":384},{},[385],{"type":23,"value":386},"- 操作系统将文件内容映射到虚拟内存空间",{"type":17,"tag":25,"props":388,"children":389},{},[390],{"type":23,"value":391},"- 程序访问数据时，系统自动从文件读取对应部分",{"type":17,"tag":25,"props":393,"children":394},{},[395],{"type":23,"value":396},"- 不需要的数据不会占用物理内存",{"type":17,"tag":25,"props":398,"children":399},{},[400],{"type":23,"value":401},"技术细节：",{"type":17,"tag":25,"props":403,"children":404},{},[405],{"type":23,"value":406},"- 使用mmap系统调用建立文件到内存的映射",{"type":17,"tag":25,"props":408,"children":409},{},[410],{"type":23,"value":411},"- 支持随机访问，可以快速跳转到任意位置",{"type":17,"tag":25,"props":413,"children":414},{},[415],{"type":23,"value":416},"- 操作系统自动管理页面换入换出",{"type":17,"tag":25,"props":418,"children":419},{},[420],{"type":23,"value":421},"实际效果：",{"type":17,"tag":25,"props":423,"children":424},{},[425],{"type":23,"value":426},"- 一个100GB的模型文件，可能只占用几百MB的实际内存",{"type":17,"tag":25,"props":428,"children":429},{},[430],{"type":23,"value":431},"- 访问速度接近内存访问速度",{"type":17,"tag":25,"props":433,"children":434},{},[435],{"type":23,"value":436},"- 多个进程可以共享同一份映射",{"type":17,"tag":277,"props":438,"children":440},{"id":439},"元数据预解析metadata-parsing",[441],{"type":17,"tag":40,"props":442,"children":443},{},[444],{"type":23,"value":445},"元数据预解析（Metadata Parsing）",{"type":17,"tag":25,"props":447,"children":448},{},[449],{"type":23,"value":450},"这就像先看书的目录，了解每章的内容和位置：",{"type":17,"tag":25,"props":452,"children":453},{},[454],{"type":23,"value":455},"解析内容：",{"type":17,"tag":25,"props":457,"children":458},{},[459],{"type":23,"value":460},"- 参数名称和层次结构",{"type":17,"tag":25,"props":462,"children":463},{},[464],{"type":23,"value":465},"- 每个参数的数据类型和形状",{"type":17,"tag":25,"props":467,"children":468},{},[469],{"type":23,"value":470},"- 参数在文件中的精确位置和大小",{"type":17,"tag":25,"props":472,"children":473},{},[474],{"type":23,"value":475},"- 数据的字节序和对齐信息",{"type":17,"tag":25,"props":477,"children":478},{},[479],{"type":23,"value":480},"存储结构：",{"type":17,"tag":25,"props":482,"children":483},{},[484],{"type":23,"value":485},"文件头部信息：",{"type":17,"tag":25,"props":487,"children":488},{},[489],{"type":23,"value":490},"├── 版本信息",{"type":17,"tag":25,"props":492,"children":493},{},[494],{"type":23,"value":495},"├── 参数总数",{"type":17,"tag":25,"props":497,"children":498},{},[499],{"type":23,"value":500},"├── 文件大小",{"type":17,"tag":25,"props":502,"children":503},{},[504],{"type":23,"value":505},"└── 校验和",{"type":17,"tag":25,"props":507,"children":508},{},[509],{"type":23,"value":510},"参数索引表：",{"type":17,"tag":25,"props":512,"children":513},{},[514],{"type":23,"value":515},"├── 参数1: {名称, 类型, 形状, 偏移量, 大小}",{"type":17,"tag":25,"props":517,"children":518},{},[519],{"type":23,"value":520},"├── 参数2: {名称, 类型, 形状, 偏移量, 大小}",{"type":17,"tag":25,"props":522,"children":523},{},[524],{"type":23,"value":525},"└── …",{"type":17,"tag":25,"props":527,"children":528},{},[529],{"type":23,"value":530},"优化策略：",{"type":17,"tag":25,"props":532,"children":533},{},[534],{"type":23,"value":535},"- 索引表采用哈希表结构，支持O(1)查找",{"type":17,"tag":25,"props":537,"children":538},{},[539],{"type":23,"value":540},"- 预计算常用参数的访问路径",{"type":17,"tag":25,"props":542,"children":543},{},[544],{"type":23,"value":545},"- 缓存频繁访问的元数据",{"type":17,"tag":277,"props":547,"children":549},{"id":548},"代理对象系统proxy-objects",[550],{"type":17,"tag":40,"props":551,"children":552},{},[553],{"type":23,"value":554},"代理对象系统（Proxy Objects）",{"type":17,"tag":25,"props":556,"children":557},{},[558],{"type":23,"value":559},"为每个参数创建一个\"智能代理\"：",{"type":17,"tag":25,"props":561,"children":562},{},[563],{"type":23,"value":564},"代理对象的职责：",{"type":17,"tag":25,"props":566,"children":567},{},[568],{"type":23,"value":569},"- 存储参数的元数据信息",{"type":17,"tag":25,"props":571,"children":572},{},[573],{"type":23,"value":574},"- 管理实际数据的加载和释放",{"type":17,"tag":25,"props":576,"children":577},{},[578],{"type":23,"value":579},"- 提供统一的访问接口",{"type":17,"tag":25,"props":581,"children":582},{},[583],{"type":23,"value":584},"- 实现透明的数据获取",{"type":17,"tag":25,"props":586,"children":587},{},[588],{"type":23,"value":589},"延迟实例化：",{"type":17,"tag":25,"props":591,"children":592},{},[593],{"type":23,"value":594},"- 创建代理时不加载实际数据",{"type":17,"tag":25,"props":596,"children":597},{},[598],{"type":23,"value":599},"- 首次访问时才触发数据加载",{"type":17,"tag":25,"props":601,"children":602},{},[603],{"type":23,"value":604},"- 支持部分加载（只加载需要的切片）",{"type":17,"tag":25,"props":606,"children":607},{},[608],{"type":23,"value":609},"内存管理：",{"type":17,"tag":25,"props":611,"children":612},{},[613],{"type":23,"value":614},"- 自动检测数据使用情况",{"type":17,"tag":25,"props":616,"children":617},{},[618],{"type":23,"value":619},"- 实现LRU缓存策略",{"type":17,"tag":25,"props":621,"children":622},{},[623],{"type":23,"value":624},"- 支持手动释放不需要的数据",{"type":17,"tag":87,"props":626,"children":628},{"id":627},"核心类_fast_safe_open详解",[629],{"type":17,"tag":40,"props":630,"children":631},{},[632],{"type":23,"value":633},"核心类：_fast_safe_open详解",{"type":17,"tag":25,"props":635,"children":636},{},[637],{"type":23,"value":638},"这是MindSpore中实现懒加载的核心类，就像一个智能的文件管理器：",{"type":17,"tag":640,"props":641,"children":643},"pre",{"code":642},"class _fast_safe_open:\n    \"\"\"\n    Open a safetensors file and access its metadata and tensors efficiently.\n    \n    This function is designed to work similarly to `safetensors.safe_open`,\n    providing a fast way to open and interact with safetensors files.\n    \"\"\"\n    \n    def __init__(self, filename, framework=None, device=\"cpu\"):\n        self.filename = filename\n        self.framework = framework\n        self.file = open(self.filename, \"rb\")\n        self.file_mmap = mmap.mmap(self.file.fileno(), 0, access=mmap.ACCESS_COPY)\n        try:\n            self.base, self.tensors_decs, self.__metadata__ = read_metadata(self.file)\n        except ValueError:\n            raise ValueError(f\"Fail to parse the input safetensors file: '{self.filename}'. \"\n                             f\"Please check the correctness of the file.\")\n        self.tensors = OrderedDict()\n        for key, info in self.tensors_decs.items():\n            self.tensors[key] = PySafeSlice(info, self.file, self.base, self.file_mmap)\n            self.tensors[key].key = key\n    \n    def __enter__(self):\n        return self\n   \n    def __exit__(self, *args):\n        self.file.close()\n    \n    def metadata(self):\n        return self.__metadata__\n    \n    def keys(self):\n        return list(self.tensors.keys())\n   \n    def get_tensor(self, name):\n        return self.tensors[name].get()\n",[644],{"type":17,"tag":645,"props":646,"children":647},"code",{"__ignoreMap":7},[648],{"type":23,"value":642},{"type":17,"tag":25,"props":650,"children":651},{},[652],{"type":17,"tag":40,"props":653,"children":654},{},[655],{"type":23,"value":656},"初始化过程",{"type":17,"tag":25,"props":658,"children":659},{},[660],{"type":23,"value":661},"1.文件验证：",{"type":17,"tag":663,"props":664,"children":665},"ul",{},[666,672,677],{"type":17,"tag":667,"props":668,"children":669},"li",{},[670],{"type":23,"value":671},"检查文件格式和完整性",{"type":17,"tag":667,"props":673,"children":674},{},[675],{"type":23,"value":676},"验证SafeTensors文件头",{"type":17,"tag":667,"props":678,"children":679},{},[680],{"type":23,"value":681},"确认文件版本兼容性",{"type":17,"tag":25,"props":683,"children":684},{},[685],{"type":23,"value":686},"2.元数据解析：",{"type":17,"tag":663,"props":688,"children":689},{},[690,695,700],{"type":17,"tag":667,"props":691,"children":692},{},[693],{"type":23,"value":694},"读取并解析文件头部信息",{"type":17,"tag":667,"props":696,"children":697},{},[698],{"type":23,"value":699},"构建参数索引表",{"type":17,"tag":667,"props":701,"children":702},{},[703],{"type":23,"value":704},"建立名称到位置的映射关系",{"type":17,"tag":25,"props":706,"children":707},{},[708],{"type":23,"value":709},"3.内存映射建立：",{"type":17,"tag":663,"props":711,"children":712},{},[713,718,723],{"type":17,"tag":667,"props":714,"children":715},{},[716],{"type":23,"value":717},"创建文件到内存的映射",{"type":17,"tag":667,"props":719,"children":720},{},[721],{"type":23,"value":722},"设置访问权限和保护模式",{"type":17,"tag":667,"props":724,"children":725},{},[726],{"type":23,"value":727},"初始化页面管理器",{"type":17,"tag":18,"props":729,"children":731},{"id":730},"_06-性能优化",[732,737,738],{"type":17,"tag":40,"props":733,"children":734},{},[735],{"type":23,"value":736},"# 06",{"type":23,"value":46},{"type":17,"tag":40,"props":739,"children":740},{},[741],{"type":23,"value":742},"性能优化",{"type":17,"tag":25,"props":744,"children":745},{},[746],{"type":23,"value":747},"SafeTensors的懒加载机制可以显著提升性能：",{"type":17,"tag":221,"props":749,"children":751},{"id":750},"_61-内存优化",[752],{"type":17,"tag":40,"props":753,"children":754},{},[755],{"type":23,"value":756},"6.1 内存优化",{"type":17,"tag":25,"props":758,"children":759},{},[760],{"type":23,"value":761},"- 按需加载：只加载当前需要的参数",{"type":17,"tag":25,"props":763,"children":764},{},[765],{"type":23,"value":766},"- 内存映射：直接从文件读取，不占用额外内存",{"type":17,"tag":221,"props":768,"children":770},{"id":769},"_62-加载速度优化",[771],{"type":17,"tag":40,"props":772,"children":773},{},[774],{"type":23,"value":775},"6.2 加载速度优化",{"type":17,"tag":25,"props":777,"children":778},{},[779],{"type":23,"value":780},"- 并行读取：支持多线程同时加载不同参数",{"type":17,"tag":25,"props":782,"children":783},{},[784],{"type":23,"value":785},"- 格式优化：二进制格式比文本格式快很多",{"type":17,"tag":18,"props":787,"children":789},{"id":788},"_07-实际应用场景",[790,795,796],{"type":17,"tag":40,"props":791,"children":792},{},[793],{"type":23,"value":794},"# 07",{"type":23,"value":46},{"type":17,"tag":40,"props":797,"children":798},{},[799],{"type":23,"value":800},"实际应用场景",{"type":17,"tag":87,"props":802,"children":804},{"id":803},"大规模模型训练",[805],{"type":17,"tag":40,"props":806,"children":807},{},[808],{"type":23,"value":803},{"type":17,"tag":25,"props":810,"children":811},{},[812],{"type":23,"value":813},"训练大型AI模型时，SafeTensors就像一个智能仓库：",{"type":17,"tag":25,"props":815,"children":816},{},[817],{"type":23,"value":818},"- 快速启动：几秒钟就能开始训练",{"type":17,"tag":25,"props":820,"children":821},{},[822],{"type":23,"value":823},"- 节省内存：只加载正在使用的部分",{"type":17,"tag":25,"props":825,"children":826},{},[827],{"type":23,"value":828},"- 分布式友好：多台机器可以各自加载需要的部分",{"type":17,"tag":18,"props":830,"children":832},{"id":831},"_08-总结",[833,838,839],{"type":17,"tag":40,"props":834,"children":835},{},[836],{"type":23,"value":837},"# 08",{"type":23,"value":46},{"type":17,"tag":40,"props":840,"children":841},{},[842],{"type":23,"value":843},"总结",{"type":17,"tag":25,"props":845,"children":846},{},[847],{"type":23,"value":848},"SafeTensors是一个让AI模型存储变得更安全、更快速的新技术。主要好处体现在下面几个方面：",{"type":17,"tag":25,"props":850,"children":851},{},[852],{"type":23,"value":853},"- 更安全：不会有恶意代码，就像给模型加了安全锁",{"type":17,"tag":25,"props":855,"children":856},{},[857],{"type":23,"value":858},"- 更快速：几秒钟就能开始使用，不用等很久",{"type":17,"tag":25,"props":860,"children":861},{},[862],{"type":23,"value":863},"- 更省内存：只用需要的部分，其他暂时不管",{"type":17,"tag":25,"props":865,"children":866},{},[867],{"type":23,"value":868},"- 更简单：使用起来很容易，不需要改很多代码",{"type":17,"tag":25,"props":870,"children":871},{},[872],{"type":23,"value":873},"MindSpore已经完美支持SafeTensors，让每个人都能享受到这些好处。无论你是刚开始学AI，还是经验丰富的专家，都可以轻松使用这个技术。",{"title":7,"searchDepth":875,"depth":875,"links":876},4,[877,879,880,883,887,894,895],{"id":89,"depth":878,"text":95},3,{"id":118,"depth":878,"text":118},{"id":223,"depth":881,"text":882},2,"5.1 什么是懒加载",{"id":263,"depth":881,"text":884,"children":885},"5.2 为什么需要懒加载",[886],{"id":279,"depth":875,"text":279},{"id":345,"depth":881,"text":888,"children":889},"5.3 MindSpore的懒加载实现原理",[890,891,892,893],{"id":365,"depth":875,"text":371},{"id":439,"depth":875,"text":445},{"id":548,"depth":875,"text":554},{"id":627,"depth":878,"text":633},{"id":750,"depth":881,"text":756},{"id":769,"depth":881,"text":775,"children":896},[897],{"id":803,"depth":878,"text":803},"markdown","content:technology-blogs:zh:3850.md","content","technology-blogs/zh/3850.md","technology-blogs/zh/3850","md",1776506136077]