[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-pytorch--xla":3,"tool-pytorch--xla":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":120,"forks":121,"last_commit_at":122,"license":123,"difficulty_score":124,"env_os":125,"env_gpu":126,"env_ram":127,"env_deps":128,"category_tags":135,"github_topics":136,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":139,"updated_at":140,"faqs":141,"releases":170},3553,"pytorch\u002Fxla","xla","Enabling PyTorch on XLA Devices (e.g. Google TPU)","PyTorch\u002FXLA 是一个连接 PyTorch 深度学习框架与谷歌云 TPU 硬件的桥梁工具。它利用 XLA（加速线性代数）编译器，让开发者能够直接在高性能的 TPU 设备上运行和训练 PyTorch 模型，无需大幅修改现有代码。\n\n这一工具主要解决了 PyTorch 原生对 TPU 支持不足的问题，打破了框架与特定硬件间的壁垒。对于习惯使用 PyTorch 生态的研究人员和工程师而言，这意味着可以低成本地利用 TPU 强大的并行计算能力来加速大规模模型的训练与推理，尤其适合处理如 Stable Diffusion 生成或大语言模型微调等计算密集型任务。\n\n其核心技术亮点在于独特的“懒执行”（Lazy Execution）机制：系统会先捕获整个计算图并进行全局优化，再下发给 TPU 执行，从而显著提升硬件利用率。此外，最新版本默认采用 C++11 ABI 构建，进一步优化了计算图追踪性能，有效缓解了因主机 CPU 忙于追踪而导致 TPU 闲置的瓶颈。无论是希望在 Kaggle 上免费体验 TPU 的初学者，还是需要在云端部署分布式训练的专业团队，PyTorch\u002FXLA 都是释放 T","PyTorch\u002FXLA 是一个连接 PyTorch 深度学习框架与谷歌云 TPU 硬件的桥梁工具。它利用 XLA（加速线性代数）编译器，让开发者能够直接在高性能的 TPU 设备上运行和训练 PyTorch 模型，无需大幅修改现有代码。\n\n这一工具主要解决了 PyTorch 原生对 TPU 支持不足的问题，打破了框架与特定硬件间的壁垒。对于习惯使用 PyTorch 生态的研究人员和工程师而言，这意味着可以低成本地利用 TPU 强大的并行计算能力来加速大规模模型的训练与推理，尤其适合处理如 Stable Diffusion 生成或大语言模型微调等计算密集型任务。\n\n其核心技术亮点在于独特的“懒执行”（Lazy Execution）机制：系统会先捕获整个计算图并进行全局优化，再下发给 TPU 执行，从而显著提升硬件利用率。此外，最新版本默认采用 C++11 ABI 构建，进一步优化了计算图追踪性能，有效缓解了因主机 CPU 忙于追踪而导致 TPU 闲置的瓶颈。无论是希望在 Kaggle 上免费体验 TPU 的初学者，还是需要在云端部署分布式训练的专业团队，PyTorch\u002FXLA 都是释放 TPU 算力的理想选择。","# PyTorch\u002FXLA\n\n> [!NOTE]\n> \u003Cb>10\u002F2025\u003C\u002Fb>: Based on community feedback, we have proposed a more native direction for PyTorch on TPU. Read the RFC and comment at [#9684](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F9684).\n>\n\n\u003Cb>Current CI status:\u003C\u002Fb>  ![GitHub Actions\nstatus](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Factions\u002Fworkflows\u002Fbuild_and_test.yml\u002Fbadge.svg)\n\nPyTorch\u002FXLA is a Python package that uses the [XLA deep learning\ncompiler](https:\u002F\u002Fwww.tensorflow.org\u002Fxla) to connect the [PyTorch deep learning\nframework](https:\u002F\u002Fpytorch.org\u002F) and [Cloud\nTPUs](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002F). You can try it right now, for free, on a\nsingle Cloud TPU VM with\n[Kaggle](https:\u002F\u002Fwww.kaggle.com\u002Fdiscussions\u002Fproduct-feedback\u002F369338)!\n\nTake a look at one of our [Kaggle\nnotebooks](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fcontrib\u002Fkaggle) to get\nstarted:\n\n* [Stable Diffusion with PyTorch\u002FXLA\n  2.0](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fcontrib\u002Fkaggle\u002Fpytorch-xla-2-0-on-kaggle.ipynb)\n* [Distributed PyTorch\u002FXLA\n  Basics](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fcontrib\u002Fkaggle\u002Fdistributed-pytorch-xla-basics-with-pjrt.ipynb)\n\n## Installation\n\n### TPU\n\nTo install PyTorch\u002FXLA stable build in a new TPU VM:\nNote: Builds are available for Python 3.8 to 3.11; please use one of the supported versions.\n\n```sh\n# - for venv\n# python3.11 -m venv py311\n# - for conda\n# conda create -n py311 python=3.11\n\npip install torch==2.8.0 'torch_xla[tpu]==2.8.0'\n\n# Optional: if you're using custom kernels, install pallas dependencies\npip install --pre torch_xla[pallas] --index-url https:\u002F\u002Fus-python.pkg.dev\u002Fml-oss-artifacts-published\u002Fjax\u002Fsimple\u002F --find-links https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html\n```\n**As of 07\u002F16\u002F2025 and starting from Pytorch\u002FXLA 2.8 release, PyTorch\u002FXLA will \nprovide nightly and release wheels for Python 3.11 to 3.13**\nTo install PyTorch\u002FXLA nightly build in a new TPU VM:\n\n```sh\npip install --pre torch torchvision --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcpu\n# Edit `cp310-cp310` to fit your desired Python version as needed\npip install 'torch_xla[tpu] @ https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl' \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-wheels\u002Findex.html\n```\n\n### C++11 ABI builds\n**As of 03\u002F18\u002F2025 and starting from Pytorch\u002FXLA 2.7 release, C++11 ABI builds\nare the default and we no longer provide wheels built with pre-C++11 ABI.**\n\nIn Pytorch\u002FXLA 2.6, we'll provide wheels and docker images built with\ntwo C++ ABI flavors: C++11 and pre-C++11. Pre-C++11 is the default to align with\nPyTorch upstream, but C++11 ABI wheels and docker images have better lazy tensor\ntracing performance.\n\nTo install C++11 ABI flavored 2.6 wheels (Python 3.10 example):\n\n```sh\npip install torch==2.6.0+cpu.cxx11.abi \\\n  https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl \\\n  'torch_xla[tpu]' \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-wheels\u002Findex.html \\\n  -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch\n```\n\nThe above command works for Python 3.10. We additionally have Python 3.9 and 3.11\nwheels:\n\n- 3.9: https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp39-cp39-manylinux_2_28_x86_64.whl\n- 3.10: https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl\n- 3.11: https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp311-cp311-manylinux_2_28_x86_64.whl\n\nTo access C++11 ABI flavored docker image:\n\n```\nus-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.6.0_3.10_tpuvm_cxx11\n```\n\nIf your model is tracing bound (e.g. you see that the host CPU is busy tracing\nthe model while TPUs are idle), switching to the C++11 ABI wheels\u002Fdocker images\ncan improve performance. Mixtral 8x7B benchmarking results on v5p-256, global\nbatch size 1024:\n\n- Pre-C++11 ABI MFU: 33%\n- C++ ABI MFU: 39%\n\n\n## Github Doc Map\n\nOur github contains many useful docs on working with different aspects of PyTorch XLA, here is a list of useful docs spread around our repository:\n\n- [docs\u002Fsource\u002Flearn](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Flearn): docs for learning concepts associated with XLA, troubleshooting, pjrt, eager mode, and dynamic shape.\n- [docs\u002Fsource\u002Faccelerators](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Faccelerators): references to `TPU` accelerator documents.\n- [docs\u002Fsource\u002Fperf](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Fperf): documentation about performance specific aspects of PyTorch\u002FXLA such as: `AMP`, `DDP`, `Dynamo`, Fori loop, `FSDP`, quantization, recompilation, and `SPMD`\n- [docs\u002Fsource\u002Ffeatures](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Ffeatures): documentation on distributed torch, pallas, scan, and stable hlo.\n- [docs\u002Fsource\u002Fcontribute](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Fcontribute): documents on setting up PyTorch for development, and guides for lowering operations.\n- PJRT plugins:\n  - [CPU](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fplugins\u002Fcpu\u002FREADME.md)\n- [torchax\u002Fdocs](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Ftorchax\u002Fdocs): torchax documents\n  - [torchax\u002Fexamples](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Ftorchax\u002Fexamples): torchax examples\n\n## Getting Started\n\nFollowing here are guides for two modes:\n- Single process: one Python interpreter controlling a single TPU at a time\n- Multi process: N Python interpreters are launched, corresponding to N TPUs\nfound on the system\n\nAnother mode is SPMD, where one Python interpreter controls all N TPUs found on\nthe system. Multi processing is more complex, and is not compatible with SPMD. This\ntutorial does not dive into SPMD. For more on that, check our\n[SPMD guide](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fdocs\u002Fsource\u002Fperf\u002Fspmd_basic.md).\n\n### Simple single process\n\nTo update your exisitng training loop, make the following changes:\n\n```diff\n+import torch_xla\n\n def train(model, training_data, ...):\n   ...\n   for inputs, labels in train_loader:\n+    with torch_xla.step():\n       inputs, labels = training_data[i]\n+      inputs, labels = inputs.to('xla'), labels.to('xla')\n       optimizer.zero_grad()\n       outputs = model(inputs)\n       loss = loss_fn(outputs, labels)\n       loss.backward()\n       optimizer.step()\n\n+  torch_xla.sync()\n   ...\n\n if __name__ == '__main__':\n   ...\n+  # Move the model paramters to your XLA device\n+  model.to('xla')\n   train(model, training_data, ...)\n   ...\n```\n\nThe changes above should get your model to train on the TPU.\n\n### Multi processing\n\nTo update your existing training loop, make the following changes:\n\n```diff\n-import torch.multiprocessing as mp\n+import torch_xla\n+import torch_xla.core.xla_model as xm\n\n def _mp_fn(index):\n   ...\n\n+  # Move the model paramters to your XLA device\n+  model.to('xla')\n\n   for inputs, labels in train_loader:\n+    with torch_xla.step():\n+      # Transfer data to the XLA device. This happens asynchronously.\n+      inputs, labels = inputs.to('xla'), labels.to('xla')\n       optimizer.zero_grad()\n       outputs = model(inputs)\n       loss = loss_fn(outputs, labels)\n       loss.backward()\n-      optimizer.step()\n+      # `xm.optimizer_step` combines gradients across replicas\n+      xm.optimizer_step(optimizer)\n\n if __name__ == '__main__':\n-  mp.spawn(_mp_fn, args=(), nprocs=world_size)\n+  # torch_xla.launch automatically selects the correct world size\n+  torch_xla.launch(_mp_fn, args=())\n```\n\nIf you're using `DistributedDataParallel`, make the following changes:\n\n\n```diff\n import torch.distributed as dist\n-import torch.multiprocessing as mp\n+import torch_xla\n+import torch_xla.distributed.xla_backend\n\n def _mp_fn(rank):\n   ...\n\n-  os.environ['MASTER_ADDR'] = 'localhost'\n-  os.environ['MASTER_PORT'] = '12355'\n-  dist.init_process_group(\"gloo\", rank=rank, world_size=world_size)\n+  # Rank and world size are inferred from the XLA device runtime\n+  dist.init_process_group(\"xla\", init_method='xla:\u002F\u002F')\n+\n+  model.to('xla')\n+  ddp_model = DDP(model, gradient_as_bucket_view=True)\n\n-  model = model.to(rank)\n-  ddp_model = DDP(model, device_ids=[rank])\n\n   for inputs, labels in train_loader:\n+    with torch_xla.step():\n+      inputs, labels = inputs.to('xla'), labels.to('xla')\n       optimizer.zero_grad()\n       outputs = ddp_model(inputs)\n       loss = loss_fn(outputs, labels)\n       loss.backward()\n       optimizer.step()\n\n if __name__ == '__main__':\n-  mp.spawn(_mp_fn, args=(), nprocs=world_size)\n+  torch_xla.launch(_mp_fn, args=())\n```\n\nAdditional information on PyTorch\u002FXLA, including a description of its semantics\nand functions, is available at [PyTorch.org](http:\u002F\u002Fpytorch.org\u002Fxla\u002F). See the\n[API Guide](API_GUIDE.md) for best practices when writing networks that run on\nXLA devices (TPU, CPU and...).\n\nOur comprehensive user guides are available at:\n\n[Documentation for the latest release](https:\u002F\u002Fpytorch.org\u002Fxla)\n\n[Documentation for master branch](https:\u002F\u002Fpytorch.org\u002Fxla\u002Fmaster)\n\n\n## PyTorch\u002FXLA tutorials\n\n* [Cloud TPU VM quickstart](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Frun-calculation-pytorch)\n* [Cloud TPU Pod slice quickstart](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Fpytorch-pods)\n* [Profiling on TPU VM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Fpytorch-xla-performance-profiling-tpu-vm)\n\n## Reference implementations\n\nThe [AI-Hypercomputer\u002Ftpu-recipes](https:\u002F\u002Fgithub.com\u002FAI-Hypercomputer\u002Ftpu-recipes)\nrepo. contains examples for training and serving many LLM and diffusion models.\n\n## Available docker images and wheels\n\n### Python packages\n\nPyTorch\u002FXLA releases starting with version r2.1 will be available on PyPI. You\ncan now install the main build with `pip install torch_xla`. To also install the\nCloud TPU plugin corresponding to your installed `torch_xla`, install the optional `tpu` dependencies after installing the main build with\n\n```\npip install torch_xla[tpu]\n```\n\nTPU nightly builds are available in our public GCS bucket.\n\n| Version | Cloud TPU Nightly Wheels |\n| --- | ----------- |\n| nightly (Python 3.11) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp311-cp311-linux_x86_64.whl` |\n| nightly (Python 3.12) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl` |\n| nightly (Python 3.13) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl` |\n\n#### Use nightly build\n\nYou can also add `yyyymmdd` like `torch_xla-2.9.0.devyyyymmdd` (or the latest dev version)\nto get the nightly wheel of a specified date. Here is an example:\n\n```\npip3 install torch==2.9.0.dev20250423+cpu --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcpu\npip3 install https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev20250423-cp310-cp310-linux_x86_64.whl\n```\n\nThe torch wheel version `2.9.0.dev20250423+cpu` can be found at https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Ftorch\u002F.\n\n\u003Cdetails>\n\n\u003Csummary>older versions\u003C\u002Fsummary>\n\n| Version | Cloud TPU VMs Wheel |\n|---------|-------------------|\n| 2.7 (Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.7.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.6 (Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.5 (Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.5.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.4 (Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.4.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.3 (Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.3.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.2 (Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.1 (XRT + Python 3.10) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Fxrt\u002Ftpuvm\u002Ftorch_xla-2.1.0%2Bxrt-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.1 (Python 3.8) | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.1.0-cp38-cp38-linux_x86_64.whl` |\n\n\u003C\u002Fdetails>\n\n### Docker\nNOTE: Since PyTorch\u002FXLA 2.7, all builds will use the C++11 ABI by default\n| Version | Cloud TPU VMs Docker |\n| --- | ----------- |\n| 2.7 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.7.0_3.10_tpuvm` |\n| 2.6 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.6.0_3.10_tpuvm` |\n| 2.6 (C++11 ABI) | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.6.0_3.10_tpuvm_cxx11` |\n| 2.5 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.5.0_3.10_tpuvm` |\n| 2.4 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.4.0_3.10_tpuvm` |\n| 2.3 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.3.0_3.10_tpuvm` |\n| 2.2 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.2.0_3.10_tpuvm` |\n| 2.1 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.1.0_3.10_tpuvm` |\n| nightly python | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:nightly_3.10_tpuvm` |\n\nTo use the above dockers, please pass `--privileged --net host --shm-size=16G` along. Here is an example:\n```bash\ndocker run --privileged --net host --shm-size=16G -it us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:nightly_3.10_tpuvm \u002Fbin\u002Fbash\n```\n\n## Troubleshooting\n\nIf PyTorch\u002FXLA isn't performing as expected, see the [troubleshooting\nguide](docs\u002Fsource\u002Flearn\u002Ftroubleshoot.md), which has suggestions for debugging and optimizing\nyour network(s).\n\n## Providing Feedback\n\nThe PyTorch\u002FXLA team is always happy to hear from users and OSS contributors!\nThe best way to reach out is by filing an issue on this Github. Questions, bug\nreports, feature requests, build issues, etc. are all welcome!\n\n## Contributing\n\nSee the [contribution guide](CONTRIBUTING.md).\n\n## Disclaimer\n\nThis repository is jointly operated and maintained by Google, Meta and a\nnumber of individual contributors listed in the\n[CONTRIBUTORS](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fgraphs\u002Fcontributors) file. For\nquestions directed at Meta, please send an email to opensource@fb.com. For\nquestions directed at Google, please send an email to\npytorch-xla@googlegroups.com. For all other questions, please open up an issue\nin this repository [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues).\n\n## Additional Reads\n\nYou can find additional useful reading materials in\n* [Performance debugging on Cloud TPU\n  VM](https:\u002F\u002Fcloud.google.com\u002Fblog\u002Ftopics\u002Fdevelopers-practitioners\u002Fpytorchxla-performance-debugging-tpu-vm-part-1)\n* [Lazy tensor\n  intro](https:\u002F\u002Fpytorch.org\u002Fblog\u002Funderstanding-lazytensor-system-performance-with-pytorch-xla-on-cloud-tpu\u002F)\n* [Scaling deep learning workloads with PyTorch \u002F XLA and Cloud TPU\n  VM](https:\u002F\u002Fcloud.google.com\u002Fblog\u002Ftopics\u002Fdevelopers-practitioners\u002Fscaling-deep-learning-workloads-pytorch-xla-and-cloud-tpu-vm)\n* [Scaling PyTorch models on Cloud TPUs with\n  FSDP](https:\u002F\u002Fpytorch.org\u002Fblog\u002Fscaling-pytorch-models-on-cloud-tpus-with-fsdp\u002F)\n\n## Related Projects\n\n* [OpenXLA](https:\u002F\u002Fgithub.com\u002Fopenxla)\n* [HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Faccelerate\u002Fen\u002Fbasic_tutorials\u002Ftpu)\n* [JetStream](https:\u002F\u002Fgithub.com\u002Fgoogle\u002FJetStream-pytorch)\n","# PyTorch\u002FXLA\n\n> [!NOTE]\n> \u003Cb>10\u002F2025\u003C\u002Fb>: 根据社区反馈，我们为 PyTorch 在 TPU 上提出了一个更原生的方向。请阅读 RFC 并在 [#9684](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F9684) 中发表评论。\n>\n\n\u003Cb>当前 CI 状态：\u003C\u002Fb>  ![GitHub Actions\n状态](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Factions\u002Fworkflows\u002Fbuild_and_test.yml\u002Fbadge.svg)\n\nPyTorch\u002FXLA 是一个 Python 包，它使用 [XLA 深度学习编译器](https:\u002F\u002Fwww.tensorflow.org\u002Fxla) 将 [PyTorch 深度学习框架](https:\u002F\u002Fpytorch.org\u002F) 和 [Cloud\nTPU](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002F) 连接起来。您现在就可以在单个 Cloud TPU 虚拟机上免费试用，只需通过\n[Kaggle](https:\u002F\u002Fwww.kaggle.com\u002Fdiscussions\u002Fproduct-feedback\u002F369338) 即可！\n\n请查看我们的其中一个 [Kaggle\n笔记本](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fcontrib\u002Fkaggle) 来开始使用：\n\n* [使用 PyTorch\u002FXLA\n2.0 的 Stable Diffusion](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fcontrib\u002Fkaggle\u002Fpytorch-xla-2-0-on-kaggle.ipynb)\n* [分布式 PyTorch\u002FXLA\n基础](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fcontrib\u002Fkaggle\u002Fdistributed-pytorch-xla-basics-with-pjrt.ipynb)\n\n## 安装\n\n### TPU\n\n要在新的 TPU 虚拟机中安装 PyTorch\u002FXLA 稳定版：\n注意：构建版本适用于 Python 3.8 至 3.11；请使用受支持的版本之一。\n\n```sh\n# - 对于 venv\n# python3.11 -m venv py311\n# - 对于 conda\n# conda create -n py311 python=3.11\n\npip install torch==2.8.0 'torch_xla[tpu]==2.8.0'\n\n# 可选：如果您正在使用自定义内核，请安装 pallas 依赖项\npip install --pre torch_xla[pallas] --index-url https:\u002F\u002Fus-python.pkg.dev\u002Fml-oss-artifacts-published\u002Fjax\u002Fsimple\u002F --find-links https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html\n```\n**自 2025 年 7 月 16 日起，并从 Pytorch\u002FXLA 2.8 版本开始，PyTorch\u002FXLA 将为 Python 3.11 至 3.13 提供 nightly 和 release 轮子**\n要在新的 TPU 虚拟机中安装 PyTorch\u002FXLA nightly 版本：\n\n```sh\npip install --pre torch torchvision --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcpu\n# 根据需要将 `cp310-cp310` 编辑为您所需的 Python 版本\npip install 'torch_xla[tpu] @ https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl' \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-wheels\u002Findex.html\n```\n\n### C++11 ABI 构建\n**自 2025 年 3 月 18 日起，并从 Pytorch\u002FXLA 2.7 版本开始，C++11 ABI 构建已成为默认选项，我们不再提供使用 pre-C++11 ABI 构建的轮子。**\n\n在 Pytorch\u002FXLA 2.6 中，我们将提供使用两种 C++ ABI 风格构建的轮子和 Docker 镜像：C++11 和 pre-C++11。Pre-C++11 是默认设置，以与 PyTorch 上游保持一致，但 C++11 ABI 轮子和 Docker 镜像具有更好的延迟张量跟踪性能。\n\n要安装 C++11 ABI 风格的 2.6 轮子（以 Python 3.10 为例）：\n\n```sh\npip install torch==2.6.0+cpu.cxx11.abi \\\n  https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl \\\n  'torch_xla[tpu]' \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-wheels\u002Findex.html \\\n  -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch\n```\n\n上述命令适用于 Python 3.10。我们还提供了 Python 3.9 和 3.11 的轮子：\n\n- 3.9：https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp39-cp39-manylinux_2_28_x86_64.whl\n- 3.10：https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl\n- 3.11：https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp311-cp311-manylinux_2_28_x86_64.whl\n\n要访问 C++11 ABI 风格的 Docker 镜像：\n\n```\nus-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.6.0_3.10_tpuvm_cxx11\n```\n\n如果您的模型处于跟踪瓶颈状态（例如，您会发现主机 CPU 正在忙于跟踪模型，而 TPU 处于空闲状态），切换到 C++11 ABI 轮子或 Docker 镜像可以提高性能。Mixtral 8x7B 在 v5p-256 上的基准测试结果，全局批次大小为 1024：\n\n- Pre-C++11 ABI MFU：33%\n- C++ ABI MFU：39%\n\n\n## Github 文档地图\n\n我们的 GitHub 存储库包含许多关于如何使用 PyTorch XLA 不同方面的有用文档，以下是分布在我们仓库中的有用文档列表：\n\n- [docs\u002Fsource\u002Flearn](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Flearn)：关于 XLA 相关概念、故障排除、pjrt、eager 模式和动态形状的文档。\n- [docs\u002Fsource\u002Faccelerators](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Faccelerators)：指向 `TPU` 加速器文档的参考。\n- [docs\u002Fsource\u002Fperf](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Fperf)：关于 PyTorch\u002FXLA 性能相关方面的文档，例如：`AMP`、`DDP`、`Dynamo`、Fori 循环、`FSDP`、量化、重新编译和 `SPMD`。\n- [docs\u002Fsource\u002Ffeatures](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Ffeatures)：关于分布式 torch、pallas、scan 和稳定 hlo 的文档。\n- [docs\u002Fsource\u002Fcontribute](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Fdocs\u002Fsource\u002Fcontribute)：关于设置 PyTorch 进行开发以及降低操作指南的文档。\n- PJRT 插件：\n  - [CPU](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fplugins\u002Fcpu\u002FREADME.md)\n- [torchax\u002Fdocs](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Ftorchax\u002Fdocs)：torchax 文档\n  - [torchax\u002Fexamples](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Ftree\u002Fmaster\u002Ftorchax\u002Fexamples)：torchax 示例\n\n## 入门\n\n以下是两种模式的指南：\n- 单进程：一个 Python 解释器一次控制一个 TPU\n- 多进程：启动 N 个 Python 解释器，分别对应系统中的 N 个 TPU\n\n另一种模式是 SPMD，即一个 Python 解释器控制系统中的所有 N 个 TPU。多进程模式更为复杂，且与 SPMD 不兼容。本教程不涉及 SPMD。如需了解更多信息，请参阅我们的\n[SPMD 指南](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fdocs\u002Fsource\u002Fperf\u002Fspmd_basic.md)。\n\n### 简单的单进程模式\n\n要更新您现有的训练循环，请进行以下更改：\n\n```diff\n+import torch_xla\n\n def train(model, training_data, ...):\n   ...\n   for inputs, labels in train_loader:\n+    with torch_xla.step():\n       inputs、labels = training_data[i]\n+      inputs、labels = inputs.to('xla')、labels.to('xla')\n       optimizer.zero_grad()\n       outputs = model(inputs)\n       loss = loss_fn(outputs、labels)\n       loss.backward()\n       optimizer.step()\n\n+  torch_xla.sync()\n   ...\n\n if __name__ == '__main__':\n   ...\n+  # 将模型参数移动到您的 XLA 设备\n+  model.to('xla')\n   train(model、training_data、...)\n   ...\n```\n\n上述更改应能使您的模型在 TPU 上进行训练。\n\n### 多进程\n\n要更新您现有的训练循环，请进行以下更改：\n\n```diff\n-import torch.multiprocessing as mp\n+import torch_xla\n+import torch_xla.core.xla_model as xm\n\n def _mp_fn(index):\n   ...\n\n+  \u002F\u002F 将模型参数移动到您的 XLA 设备\n+  model.to('xla')\n\n   for inputs, labels in train_loader:\n+    with torch_xla.step():\n+      \u002F\u002F 将数据传输到 XLA 设备。此操作异步进行。\n+      inputs, labels = inputs.to('xla'), labels.to('xla')\n       optimizer.zero_grad()\n       outputs = model(inputs)\n       loss = loss_fn(outputs, labels)\n       loss.backward()\n-      optimizer.step()\n+      \u002F\u002F `xm.optimizer_step` 会跨副本合并梯度\n+      xm.optimizer_step(optimizer)\n\n if __name__ == '__main__':\n-  mp.spawn(_mp_fn, args=(), nprocs=world_size)\n+  \u002F\u002F torch_xla.launch 会自动选择正确的世界大小\n+  torch_xla.launch(_mp_fn, args=())\n```\n\n如果您正在使用 `DistributedDataParallel`，请进行以下更改：\n\n\n```diff\n import torch.distributed as dist\n-import torch.multiprocessing as mp\n+import torch_xla\n+import torch_xla.distributed.xla_backend\n\n def _mp_fn(rank):\n   ...\n\n-  os.environ['MASTER_ADDR'] = 'localhost'\n-  os.environ['MASTER_PORT'] = '12355'\n-  dist.init_process_group(\"gloo\", rank=rank, world_size=world_size)\n+  \u002F\u002F 从 XLA 设备运行时推断出排名和世界大小\n+  dist.init_process_group(\"xla\", init_method='xla:\u002F\u002F')\n+\n+  model.to('xla')\n+  ddp_model = DDP(model, gradient_as_bucket_view=True)\n\n-  model = model.to(rank)\n-  ddp_model = DDP(model, device_ids=[rank])\n\n   for inputs, labels in train_loader:\n+    with torch_xla.step():\n+      inputs, labels = inputs.to('xla'), labels.to('xla')\n       optimizer.zero_grad()\n       outputs = ddp_model(inputs)\n       loss = loss_fn(outputs, labels)\n       loss.backward()\n       optimizer.step()\n\n if __name__ == '__main__':\n-  mp.spawn(_mp_fn, args=(), nprocs=world_size)\n+  torch_xla.launch(_mp_fn, args=())\n```\n\n有关 PyTorch\u002FXLA 的更多信息，包括其语义和功能的描述，可在 [PyTorch.org](http:\u002F\u002Fpytorch.org\u002Fxla\u002F) 上找到。有关在 XLA 设备（TPU、CPU 等）上运行网络的最佳实践，请参阅 [API 指南](API_GUIDE.md)。\n\n我们的完整用户指南可在以下位置找到：\n\n[最新版本的文档](https:\u002F\u002Fpytorch.org\u002Fxla)\n\n[主分支的文档](https:\u002F\u002Fpytorch.org\u002Fxla\u002Fmaster)\n\n\n## PyTorch\u002FXLA 教程\n\n* [Cloud TPU VM 快速入门](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Frun-calculation-pytorch)\n* [Cloud TPU Pod slice 快速入门](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Fpytorch-pods)\n* [TPU VM 上的性能分析](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Fpytorch-xla-performance-profiling-tpu-vm)\n\n## 参考实现\n\n[AI-Hypercomputer\u002Ftpu-recipes](https:\u002F\u002Fgithub.com\u002FAI-Hypercomputer\u002Ftpu-recipes) 仓库包含用于训练和部署多种 LLM 和扩散模型的示例。\n\n## 可用的 Docker 镜像和轮子包\n\n### Python 包\n\n从 r2.1 版本开始，PyTorch\u002FXLA 将在 PyPI 上发布。您现在可以使用 `pip install torch_xla` 安装主构建。要在安装主构建后同时安装与已安装 `torch_xla` 对应的 Cloud TPU 插件，请执行以下命令：\n\n```\npip install torch_xla[tpu]\n```\n\nTPU 的每日构建版本可在我们的公共 GCS 存储桶中找到。\n\n| 版本 | Cloud TPU 每日轮子包 |\n| --- | ----------- |\n| 每日版（Python 3.11） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp311-cp311-linux_x86_64.whl` |\n| 每日版（Python 3.12） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl` |\n| 每日版（Python 3.13） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl` |\n\n#### 使用每日构建\n\n您还可以添加 `yyyymmdd`，例如 `torch_xla-2.9.0.devyyyymmdd`（或最新的开发版本），以获取指定日期的每日轮子包。以下是一个示例：\n\n```\npip3 install torch==2.9.0.dev20250423+cpu --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcpu\npip3 install https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev20250423-cp310-cp310-linux_x86_64.whl\n```\n\ntorch 轮子包版本 `2.9.0.dev20250423+cpu` 可在 https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Ftorch\u002F 上找到。\n\n\u003Cdetails>\n\n\u003Csummary>旧版本\u003C\u002Fsummary>\n\n| 版本 | Cloud TPU VM 轮子包 |\n|---------|-------------------|\n| 2.7（Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.7.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.6（Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.5（Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.5.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.4（Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.4.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.3（Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.3.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.2（Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.1（XRT + Python 3.10） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Fxrt\u002Ftpuvm\u002Ftorch_xla-2.1.0%2Bxrt-cp310-cp310-manylinux_2_28_x86_64.whl` |\n| 2.1（Python 3.8） | `https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.1.0-cp38-cp38-linux_x86_64.whl` |\n\n\u003C\u002Fdetails>\n\n### Docker\n注意：自 PyTorch\u002FXLA 2.7 版本起，所有构建默认将使用 C++11 ABI\n| 版本 | Cloud TPU VM Docker |\n| --- | ----------- |\n| 2.7 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.7.0_3.10_tpuvm` |\n| 2.6 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.6.0_3.10_tpuvm` |\n| 2.6（C++11 ABI） | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.6.0_3.10_tpuvm_cxx11` |\n| 2.5 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.5.0_3.10_tpuvm` |\n| 2.4 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.4.0_3.10_tpuvm` |\n| 2.3 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.3.0_3.10_tpuvm` |\n| 2.2 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.2.0_3.10_tpuvm` |\n| 2.1 | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:r2.1.0_3.10_tpuvm` |\n| 每日版 Python | `us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:nightly_3.10_tpuvm` |\n\n要使用上述 Docker 镜像，请务必添加 `--privileged --net host --shm-size=16G` 参数。以下是一个示例：\n```bash\ndocker run --privileged --net host --shm-size=16G -it us-central1-docker.pkg.dev\u002Ftpu-pytorch-releases\u002Fdocker\u002Fxla:nightly_3.10_tpuvm \u002Fbin\u002Fbash\n```\n\n## 故障排除\n\n如果 PyTorch\u002FXLA 的性能未达到预期，请参阅[故障排除指南](docs\u002Fsource\u002Flearn\u002Ftroubleshoot.md)，其中提供了调试和优化您的网络的建议。\n\n## 提供反馈\n\nPyTorch\u002FXLA 团队始终乐于听取用户和开源社区贡献者的意见！与我们联系的最佳方式是在此 GitHub 仓库中提交一个问题。问题、错误报告、功能请求、构建问题等均欢迎！\n\n## 贡献\n\n请参阅[贡献指南](CONTRIBUTING.md)。\n\n## 免责声明\n\n本仓库由 Google、Meta 以及 [CONTRIBUTORS](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fgraphs\u002Fcontributors) 文件中列出的多位个人贡献者共同运营和维护。如有关于 Meta 的问题，请发送邮件至 opensource@fb.com。如有关于 Google 的问题，请发送邮件至 pytorch-xla@googlegroups.com。对于其他所有问题，请在此仓库中[提交一个问题](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues)。\n\n## 更多阅读材料\n\n您可以在以下链接中找到更多有用的阅读材料：\n* [在 Cloud TPU VM 上进行性能调试](https:\u002F\u002Fcloud.google.com\u002Fblog\u002Ftopics\u002Fdevelopers-practitioners\u002Fpytorchxla-performance-debugging-tpu-vm-part-1)\n* [懒张量简介](https:\u002F\u002Fpytorch.org\u002Fblog\u002Funderstanding-lazytensor-system-performance-with-pytorch-xla-on-cloud-tpu\u002F)\n* [使用 PyTorch \u002F XLA 和 Cloud TPU VM 扩展深度学习工作负载](https:\u002F\u002Fcloud.google.com\u002Fblog\u002Ftopics\u002Fdevelopers-practitioners\u002Fscaling-deep-learning-workloads-pytorch-xla-and-cloud-tpu-vm)\n* [使用 FSDP 在 Cloud TPU 上扩展 PyTorch 模型](https:\u002F\u002Fpytorch.org\u002Fblog\u002Fscaling-pytorch-models-on-cloud-tpus-with-fsdp\u002F)\n\n## 相关项目\n\n* [OpenXLA](https:\u002F\u002Fgithub.com\u002Fopenxla)\n* [HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Faccelerate\u002Fen\u002Fbasic_tutorials\u002Ftpu)\n* [JetStream](https:\u002F\u002Fgithub.com\u002Fgoogle\u002FJetStream-pytorch)","# PyTorch\u002FXLA 快速上手指南\n\nPyTorch\u002FXLA 是一个 Python 包，它利用 XLA 深度学习编译器将 PyTorch 框架与 Google Cloud TPU 连接起来，使您能够在 TPU 上高效训练和部署模型。\n\n## 1. 环境准备\n\n*   **硬件要求**：需要访问 Google Cloud TPU VM 或通过 Kaggle 免费使用 TPU 资源。\n*   **系统要求**：Linux x86_64 环境（TPU VM 默认环境）。\n*   **Python 版本**：\n    *   稳定版支持：Python 3.8 - 3.11\n    *   夜间版（Nightly）支持：Python 3.11 - 3.13\n*   **前置依赖**：建议先创建独立的虚拟环境（venv 或 conda）。\n\n> **注意**：自 2025 年 3 月起，C++11 ABI 构建已成为默认选项，不再提供旧版 ABI 轮子，以获得更好的懒张量追踪性能。\n\n## 2. 安装步骤\n\n### 方案 A：安装稳定版（推荐）\n\n适用于生产环境或追求稳定性的开发。以下命令以 Python 3.11 为例：\n\n```bash\n# 创建并激活虚拟环境 (以 venv 为例)\npython3.11 -m venv py311\nsource py311\u002Fbin\u002Factivate\n\n# 安装 PyTorch 和 PyTorch\u002FXLA (包含 TPU 插件)\npip install torch==2.8.0 'torch_xla[tpu]==2.8.0'\n\n# (可选) 如果使用自定义内核 (custom kernels)，安装 pallas 依赖\npip install --pre torch_xla[pallas] --index-url https:\u002F\u002Fus-python.pkg.dev\u002Fml-oss-artifacts-published\u002Fjax\u002Fsimple\u002F --find-links https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html\n```\n\n### 方案 B：安装夜间版 (Nightly)\n\n适用于需要最新特性或修复的开发场景。以下命令以 Python 3.12 为例：\n\n```bash\n# 安装夜间版 PyTorch (CPU 基础包)\npip install --pre torch torchvision --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcpu\n\n# 安装对应版本的 PyTorch\u002FXLA TPU 轮子\n# 注意：请根据实际 Python 版本调整 cp312-cp312 部分\npip install 'torch_xla[tpu] @ https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.9.0.dev-cp312-cp312-linux_x86_64.whl' \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-wheels\u002Findex.html\n```\n\n## 3. 基本使用\n\nPyTorch\u002FXLA 提供了两种主要运行模式：**单进程模式**（控制单个 TPU）和 **多进程模式**（控制多个 TPU）。\n\n### 模式一：单进程模式 (Single Process)\n\n最简单的修改方式，只需在现有训练循环中引入 `torch_xla` 并将数据\u002F模型移至 `xla` 设备。\n\n```python\nimport torch\nimport torch_xla\n\ndef train(model, training_data, optimizer, loss_fn):\n    # 将模型参数移动到 XLA 设备\n    model.to('xla')\n    \n    for inputs, labels in training_data:\n        # 使用 step 上下文管理器\n        with torch_xla.step():\n            # 异步将数据转移到 XLA 设备\n            inputs, labels = inputs.to('xla'), labels.to('xla')\n            \n            optimizer.zero_grad()\n            outputs = model(inputs)\n            loss = loss_fn(outputs, labels)\n            loss.backward()\n            optimizer.step()\n    \n    # 同步以确保所有计算完成\n    torch_xla.sync()\n\nif __name__ == '__main__':\n    # 初始化模型和数据加载器...\n    train(model, train_loader, optimizer, criterion)\n```\n\n### 模式二：多进程模式 (Multi Processing)\n\n用于利用整个 TPU Pod 或多芯片系统进行分布式训练。需使用 `torch_xla.launch` 替代原生的 `mp.spawn`。\n\n```python\nimport torch\nimport torch.nn as nn\nimport torch_xla\nimport torch_xla.core.xla_model as xm\nimport torch.distributed as dist\nfrom torch.nn.parallel import DistributedDataParallel as DDP\n\ndef _mp_fn(index):\n    # 初始化分布式进程组，XLA 后端会自动推断 rank 和 world_size\n    dist.init_process_group(\"xla\", init_method='xla:\u002F\u002F')\n    \n    # 创建模型并移至 xla 设备\n    model = MyModel().to('xla')\n    # 包装为 DDP\n    ddp_model = DDP(model, gradient_as_bucket_view=True)\n    \n    optimizer = torch.optim.SGD(ddp_model.parameters(), lr=0.01)\n    loss_fn = nn.MSELoss()\n\n    for inputs, labels in train_loader:\n        with torch_xla.step():\n            inputs, labels = inputs.to('xla'), labels.to('xla')\n            \n            optimizer.zero_grad()\n            outputs = ddp_model(inputs)\n            loss = loss_fn(outputs, labels)\n            loss.backward()\n            # 使用 xm.optimizer_step 跨副本合并梯度\n            xm.optimizer_step(optimizer)\n\nif __name__ == '__main__':\n    # torch_xla.launch 会自动选择正确的进程数量\n    torch_xla.launch(_mp_fn, args=())\n```\n\n### 关键修改点总结\n1.  **导入库**：引入 `torch_xla` 和 `torch_xla.core.xla_model`。\n2.  **设备迁移**：将模型和数据 `.to('xla')` 而不是 `.to('cuda')`。\n3.  **执行步**：在训练循环内部使用 `with torch_xla.step():`。\n4.  **优化器步进**：多进程下使用 `xm.optimizer_step(optimizer)`。\n5.  **启动方式**：多进程下使用 `torch_xla.launch` 启动主函数。","一家生成式 AI 初创公司正试图在 Google Cloud TPU v5p 集群上微调 Mixtral 8x7B 大语言模型，以降低成本并提升训练效率。\n\n### 没有 xla 时\n- **硬件资源浪费**：由于默认构建版本追踪效率低，主机 CPU 忙于编译计算图，而昂贵的 TPU 核心却处于空闲等待状态，导致算力利用率不足 40%。\n- **训练速度缓慢**：无法利用 XLA 编译器对算子进行融合与优化，每个训练步的耗时显著增加，原本预计 3 天的任务需运行超过一周。\n- **显存溢出频繁**：缺乏针对 TPU 架构的内存优化，处理长序列数据时极易触发 OOM（内存溢出）错误，迫使团队不断缩小 Batch Size。\n- **生态迁移成本高**：团队现有的 PyTorch 代码无法直接运行在 TPU 上，需要花费大量时间重写为 JAX 或 TensorFlow 格式。\n\n### 使用 xla 后\n- **算力满负荷运转**：通过安装 C++11 ABI 版本的 xla，大幅降低了主机追踪开销，TPU 利用率飙升至 90% 以上，实现了“计算不等人”。\n- **训练效率倍增**：xla 自动融合算子并优化执行计划，使 Mixtral 8x7B 的吞吐量提升数倍，将训练周期从一周压缩回 3 天内。\n- **支持更大规模数据**：借助 xla 的懒张量（Lazy Tensor）机制和内存管理优化，团队成功在单卡上运行更大的 Batch Size，提升了模型收敛稳定性。\n- **代码零改动迁移**：仅需引入 `torch_xla` 包并微调启动脚本，原有的 PyTorch 训练逻辑即可无缝在 TPU 集群上运行，保护了既有代码资产。\n\nxla 的核心价值在于打破了框架与硬件的壁垒，让开发者能用熟悉的 PyTorch 代码，直接释放 Google TPU 的极致算力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fpytorch_xla_026dcbd7.png","pytorch","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fpytorch_be722ba8.jpg","",null,"https:\u002F\u002Fpytorch.org","https:\u002F\u002Fgithub.com\u002Fpytorch",[83,87,91,95,99,103,107,111,115,118],{"name":84,"color":85,"percentage":86},"C++","#f34b7d",46.7,{"name":88,"color":89,"percentage":90},"Python","#3572A5",40.9,{"name":92,"color":93,"percentage":94},"Jupyter Notebook","#DA5B0B",9.7,{"name":96,"color":97,"percentage":98},"Shell","#89e051",1.2,{"name":100,"color":101,"percentage":102},"HCL","#844FBA",0.8,{"name":104,"color":105,"percentage":106},"Starlark","#76d275",0.6,{"name":108,"color":109,"percentage":110},"Dockerfile","#384d54",0.1,{"name":112,"color":113,"percentage":114},"Makefile","#427819",0,{"name":116,"color":117,"percentage":114},"C","#555555",{"name":119,"color":79,"percentage":114},"Linker Script",2764,568,"2026-04-04T07:47:17","NOASSERTION",4,"Linux","不需要 NVIDIA GPU。该工具专为 Google Cloud TPU 设计，运行需依赖 TPU 硬件或 TPU VM 环境。","未说明",{"notes":129,"python":130,"dependencies":131},"1. 主要运行环境为 Google Cloud TPU VM，也可在 Kaggle 免费试用。\n2. 自 2025 年 3 月起，默认使用 C++11 ABI 构建版本，不再提供旧版 ABI，切换至 C++11 ABI 可提升懒张量追踪性能。\n3. 支持单进程、多进程及 SPMD（单程序多数据）模式，其中多进程与 SPMD 不兼容。\n4. 安装 TPU 版本时需指定额外的 wheel 索引源和查找链接。","3.8 - 3.13 (稳定版支持 3.8-3.11，夜间版支持 3.11-3.13)",[132,133,134],"torch==2.8.0 (或对应版本)","torch_xla[tpu]==2.8.0 (或对应版本)","pallas (可选，用于自定义内核)",[13],[137,138,76,67],"compiler","deep-learning","2026-03-27T02:49:30.150509","2026-04-06T05:17:32.753107",[142,147,152,156,161,166],{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},16272,"如何在 PyTorch XLA (TPU) 上解决 pack_padded_sequence 导致的 NaN 损失或兼容性问题？","由于 PyTorch XLA 使用图模式（graph mode）而非逐操作模式（op-by-op），它无法处理依赖输入数据的动态控制流（如 if-else 分支）。pack_padded_sequence 通常涉及此类动态逻辑，导致在 TPU 上出现 NaN 或损失不下降。解决方案是避免使用动态打包，或者将条件逻辑转换为静态图操作（例如使用 tf.where 替代 if-else，确保两个分支都被执行但根据条件选择结果）。维护者建议参考专门的示例训练器代码来适配 LSTM 等序列模型，确保生成的图不依赖输入数据形状。","https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F1522",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},16273,"在 Kaggle TPU 上使用 PyTorch XLA 训练大模型（如 XLM-R）遇到 OOM（内存溢出）错误怎么办？","PyTorch XLA 在 TPU 上的内存管理与 TensorFlow 不同，且环境初始化脚本（env-setup.py）本身可能占用大量内存（约 3GB）。如果遇到 OOM，首先尝试减小批次大小（batch size）或使用更小的模型变体（如 base 代替 large）。其次，确保所有非 XLA 变量（数据集、模型定义等）在全局范围内定义，避免被复制 8 次。如果问题依旧，检查是否可以在脚本运行前手动清理内存，或考虑使用多进程接口（注意旧版多线程接口已弃用）。目前 PyTorch XLA 对某些复杂模型的内存优化可能不如 TF 成熟，需针对性调整代码结构。","https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F1870",{"id":153,"question_zh":154,"answer_zh":155,"source_url":151},16274,"如何在 PyTorch XLA 中正确保存模型检查点以避免文件存在错误（FileExistsError）？","在使用 xm.save 保存模型时，如果目标文件或目录已存在，可能会抛出 FileExistsError。解决方法是修改序列化模块的行为，使其像 torch.save() 一样覆盖现有的检查点文件。确保在调用保存函数前处理文件冲突，或者在代码逻辑中允许覆盖操作。维护者指出这是一个已修复的问题，确保使用的是包含该修复的最新版本或 nightly 版本。",{"id":157,"question_zh":158,"answer_zh":159,"source_url":160},16275,"在 TPU 上训练 DLRM 模型时在特定步数（如 20k 步）发生段错误（segfault）如何解决？","这是一个已知问题，通常与特定的数据处理或模型并行配置有关。维护者建议首先尝试运行完整的 epoch 测试以确认是否为偶发问题。如果问题复现，检查是否使用了最新版本的 pytorch\u002Fxla，因为相关修复可能已被合并。对于使用 Kaggle 数据集的情况，确保数据加载器配置正确（如使用 memory-map 选项），并验证 tpu-model-parallel-group-len 等并行参数是否与核心数匹配。如果经过多次测试（1-2 天）未再复现，可视为已修复；否则需提交包含最小复现步骤的 Colab 笔记本以便进一步调试。","https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F2366",{"id":162,"question_zh":163,"answer_zh":164,"source_url":165},16276,"如何将原本为 GPU 设计的 PyTorch 代码（特别是使用 AMP 自动混合精度）迁移到 TPU (PyTorch XLA)？","TPU 不支持 torch.cuda.amp.GradScaler 和 torch.cuda.amp.autocast，因为这些是 CUDA 特有的 API。在迁移代码时，必须移除所有 torch.cuda 相关的调用。对于混合精度训练，PyTorch XLA 通常不需要显式的 GradScaler，因为 TPU 默认使用 bfloat16 进行计算。应将 optimizer.step() 替换为 xm.optimizer_step(optimizer)，并确保数据和设备放置正确（使用 .to(device) 其中 device 为 xla:0 等）。如果代码中保留了 use_amp 标志并调用了 CUDA 专用函数，会导致 'Input contains NaN' 或属性错误，需彻底清理这些 GPU 特有逻辑。","https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F2789",{"id":167,"question_zh":168,"answer_zh":169,"source_url":146},16277,"为什么我的模型在 TPU 上训练时损失变为 NaN 或在验证时表现异常，而在 GPU 上正常？","这通常是因为代码中包含了 TPU 不支持的动态操作或数据类型不匹配。常见原因包括：1. 使用了依赖输入值的控制流（如动态 unpacking），这在图模式下会导致计算图构建失败或数值不稳定；2. 输入数据包含 NaN 或无穷大值，需在前向传播前检查数据清洗逻辑；3. 错误地混用了 GPU 特有的 API（如 AMP scaler）。解决方法是将动态逻辑转换为静态图操作，严格检查输入数据的有效性，并移除所有 torch.cuda 相关的代码路径。建议使用 xm.master_print 打印中间张量统计信息以定位数值发散的具体位置。",[171,176,181,186,191,196,201,206,211,216,221,226,231,236,241,246,251,256,261,266],{"id":172,"version":173,"summary_zh":174,"released_at":175},98579,"v2.9.0","## 变更内容\n* 由 @bhavya01 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9423 中提出，直接安装 libtpu 而不是通过 torch_xla[tpu] 进行安装。\n* 由 @vanbasten23 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9412 中优化了 w8a8 量化矩阵乘法内核。\n* 由 @bhavya01 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9427 中更新 CI Docker 镜像以使用 Python 3.12。\n* 由 @pgmoka 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9425 中添加了 2.8-rc1 版本的构建触发器。\n* 错误处理：由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9386 中重构 `XlaCoordinator` 以使用状态类型。\n* 由 @tengyifei 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9438 中为 Python 3.12 添加 JAX 依赖。\n* 由 @bhavya01 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9434 中更新 TPU CI 容器镜像。\n* 由 @bfolie 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9424 中修改 update_deps 脚本，使其拉取最新的稳定版本而非最新 nightly 版本。\n* 由 @bhavya01 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9443 中修复了 Python 3.12 的 CPU 测试。\n* 由 @bhavya01 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9463 中部分禁用 tpu-info CLI 测试。\n* 由 @pgmoka 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9461 中将 nightly_package_version 更改为 2.9。\n* 由 @qihqi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9460 中使 assume_pure 能够处理依赖随机性的函数。\n* 由 @tengyifei 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9428 中支持使用 setuptools>=80.0.0 的可编辑安装。\n* 由 @vanbasten23 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9452 中统一了 w8a8 矩阵乘法在回退实现和实际实现之间的返回类型。\n* 由 @vanbasten23 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9465 中移除了对张量进行对称量化时的 clamp 操作。\n* 由 @zzzwen 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9468 中默认将 to(\"jax\") 路由到 TPU。\n* 错误处理：由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9419 中重构 PjRt 注册表以使用状态 QOL 函数。\n* 由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9448 中抑制 `XLA_CHECK*()` 调用时的 C++ 堆栈跟踪。\n* 由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9457 中将 `XLA_CHECK_OK()` 替换为状态函数。\n* 由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9440 中修复了状态源代码位置逻辑。\n* 由 @pgmoka 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9469 中更新了 CUDA 版本检查。\n* 由 @pgmoka 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9471 中移除了 2.8.0-rc1 的重复构件创建。\n* 由 @vanbasten23 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9470 中在量化矩阵乘法内核中动态计算 vmem 上限。\n* 由 @qihqi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9455 中将 torch 兼容版本更新至 2.7.1。\n* 由 @jeffhataws 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9458 中添加了 dtensor 放置测试。\n* [内核] 由 @yaochengji 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9476 中更新了稀疏注意力块表。\n* 由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F9464 中将 `ConsumeValue` 替换为 `GetValueOrThrow`。\n* 实现集体归约操作。","2025-11-17T22:43:23",{"id":177,"version":178,"summary_zh":179,"released_at":180},98580,"v2.8.0","# 亮点\n\n- 更广泛的平台支持：现已添加对 Python 3.12 和 3.13 的构建支持。\n\n- 新的量化特性：引入了权重8位、激活8位（w8a8）量化矩阵乘法的支持，包括内核以及 Torch\u002FXLA 封装层。\n\n- Torchax 增强：torchax 库得到了显著改进，新增了 torchax.amp.autocast、双三次和双线性重采样支持，以及与 Flax 更好的互操作性。\n\n- 分布式计算：新增了对 torch.distributed.scatter 集体操作的支持，并修复了 all_gather_into_tensor 的逻辑。\n\n## 错误修复\n\n- 通过移除将 padding_idx 不必要地转换为 double 类型的操作，修复了 EmbeddingDenseBackward 中的一个问题。\n- 纠正了 all_gather_into_tensor 的逻辑。\n- 解决了 Allgather 会错误检查元组形状的问题。\n- 修复了自定义调用中的未指定行为。\n- 通过应用 KV 掩码过滤 NaN 值，修复了稀疏分页注意力内核中的一个错误。\n- 纠正了分片优化器参数组和主权重的重新加载问题。\n- 修复了 NoneRemover 未返回修改后的列表\u002F元组的问题。\n\n## 已弃用功能\n- 如果在初始化时使用已弃用的 XLA:CUDA 设备，现在会显示警告。夜间版 CUDA 构建已被移除。\n- xla_model.xla_device 中的 devkind 字段已被弃用。\n- ShapeOfXlaOp 已被弃用，取而代之的是 GetShape。\n\n## 变更内容\n* [torchax] 由 @dvhg 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8814 中修复了 functional.max_pool。\n* 支持 xb.call_jax 中的未使用参数，由 @tengyifei 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8830 中实现。\n* 移除 xla_mark_sharding_dynamo_custom_op，由 @tengyifei 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8823 中完成。\n* 适配 Neuron 数据类型测试，由 @rpsilva-aws 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8835 中完成。\n* 重构 SPMD 指南，由 @tengyifei 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8807 中完成。\n* 添加 2.7-rc1 的构建触发器，由 @zpcore 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8828 中实现。\n* 修复 Triton 引脚更新问题，由 @ysiraichi 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8825 中完成。\n* 将 mark_sharding_with_gradients 公开为公共 API，由 @iwknow 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8826 中完成。\n* 添加与代码生成相关的信息，由 @pgmoka 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8834 中完成。\n* 在 codegen\u002Fxla_native_functions.yaml 中添加关于代码生成的信息，由 @pgmoka 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8817 中完成。\n* 默认安装 JAX 依赖以解除 PyTorch CI 的阻塞，由 @zpcore 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8845 中完成。\n* 将 cxx_abi 默认启用，由 @zpcore 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8844 中完成。\n* 修复现有的 Bazel 链接移除问题，由 @zpcore 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8848 中完成。\n* 修复依赖问题，由 @zpcore 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8852 中完成。\n* [ragged-paged-attn] 在 kv 缓存中使用隐藏状态，并支持任意 num_kv_head 数量，由 @bythew3i 在 https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8851 中完成。\n* 将 TPU CI 节点数量从 2 增加到 32 个，由 @tengyifei 在 https:","2025-08-13T22:39:50",{"id":182,"version":183,"summary_zh":184,"released_at":185},98581,"v2.7.0","# 亮点\n\n- 使用 [TorchPrime](https:\u002F\u002Fgithub.com\u002FAI-Hypercomputer\u002Ftorchprime) 在 Cloud TPU 上进行更轻松的训练\n- 基于 Pallas 的新型稀疏分页注意力内核，可在 [vLLM TPU](https:\u002F\u002Fdocs.vllm.ai\u002Fen\u002Fv0.5.5\u002Fgetting_started\u002Ftpu-installation.html) 上实现进一步优化（[#8791](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8791)）\n- 易用性改进\n- JAX 操作的实验性互操作性（[#8781](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8781)、[#8789](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8789)、[#8830](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8830)、[#8878](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8878)）\n- 重新启用 GPU CI 构建 [[#8593](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8593)]\n\n# 稳定特性\n- 算子降级\n  - 将 `as_strided_copy` 降级为使用 `slice` 的快速路径（[#8374](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8734)）\n  - 降级 `_conj_copy`。（[#8686](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8686)）\n- 支持在 SPMD 网格中拆分物理轴（[#8698](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8698)）\n- 支持占位符张量（[#8785](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8785)）。\n- Dynamo\u002FAOTAutograd 可跟踪的 Flash Attention（[#8654](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8654)）\n- 默认构建 C++11 ABI\n\n# 实验性特性\n- 使用 scan 实现门控循环单元 (GRU)（[#8777](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8777)）\n- 引入 `apply_xla_patch_to_nn_linear` 以提升 `einsum` 性能（[#8793](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8739)）\n- 启用步进屏障的默认缓冲区捐赠（[#8721](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8982)、[#8982](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8982)）\n\n# 易用性\n- 更好的性能分析控制：通过新的性能分析 API 可以控制性能分析会话的开始和结束（[#8743](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8743)）\n- 查询缓存编译图数量的 API（[#8822](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8822)）\n- 主机到设备传输的增强（[#8849](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8849)）\n\n# 错误修复\n- 修复张量 `flatten` 中的一个错误（[#8680](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8680)）\n- `cummax`：修复零尺寸维度的约简问题。（[#8653](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8653)）\n- 修复 TPU Flash Attention 中的 `dk\u002Fdv` 自动求导错误（[#8685](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8685)）\n- 修复 Flash Attention 中的一个错误，即 `kv_seq_len` 应该能被 `block_k_major` 整除。（[#8671](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8671)）\n- [scan] 确保传入函数的输入不是设备数据 IR 节点（[#8769](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8769)）\n\n# Libtpu 稳定版本\n- 将 2.7 版本固定为稳定的 libtpu 版本 '0.0.11.1'\n\n# 已弃用功能\n- 弃用 `torch.export`，改用 `torchax` 将图导出为 StableHLO，以支持完全动态性\n- 移除 `torch_xla.core.xla_model.xrt_world_size`，替换为 `torch_xla.runtime.world_size`\n- 移除 `torch_xla.core.xla_model.get_ordinal`，替换为 `torch_xla.runtime.global_ordinal`\n- ","2025-04-24T00:17:23",{"id":187,"version":188,"summary_zh":189,"released_at":190},98582,"v2.6.0","# 亮点\n\n\n#### vLLM 的内核改进：多查询分页注意力 Pallas 内核\n\n\n\n* 添加了多查询分页注意力 Pallas 内核（[#8328](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8328)）。这为 vLLM 解锁了诸如前缀缓存等新机会。\n* 性能提升：仅在最后一次迭代时才写入 HBM（[#8393](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8393)）\n\n\n#### 实验性扫描算子（[#7901](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7901)）\n\n此前，在 PyTorch\u002FXLA 中遍历多个结构相同的 `nn.Module` 时，循环会在图跟踪阶段展开，从而导致计算图变得极其庞大。这种展开会显著延长编译时间，对于包含大量解码器层的大型语言模型模块，编译时间甚至可能长达一小时。在本版本中，我们提供了一个名为“scan”的实验性 API 来缩短编译时间，该 API 模仿了 JAX 中的 `jax.lax.scan` 变换。当你用 scan 替代 Python 的 for 循环时，系统不会对每次迭代单独编译，而是只编译第一次迭代，并将编译好的 HLO 重复用于后续的所有迭代。基于 `torch_xla.experimental.scan`，`torch_xla.experimental.scan_layers` 提供了一个便捷的接口，用于遍历一系列 `nn.Module` 而无需展开循环。\n\n文档链接：[https:\u002F\u002Fpytorch.org\u002Fxla\u002Frelease\u002Fr2.6\u002Ffeatures\u002Fscan.html](https:\u002F\u002Fpytorch.org\u002Fxla\u002Frelease\u002Fr2.6\u002Ffeatures\u002Fscan.html)\n\n\n### C++11 ABI 构建\n\n从 PyTorch\u002FXLA 2.6 开始，我们将提供两种 C++ ABI 风格构建的 wheel 包和 Docker 镜像：C++11 和 pre-C++11。默认使用 pre-C++11 以与 PyTorch 上游保持一致，但 C++11 ABI 的 wheel 包和 Docker 镜像在延迟张量跟踪性能方面表现更优。\n\n安装 C++11 ABI 风格的 2.6 版本 wheel 包（以 Python 3.10 为例）：\n\n```bash\npip install torch==2.6.0+cpu.cxx11.abi \\\n  https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl \\\n  'torch_xla[tpu]' \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html \\\n  -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-wheels\u002Findex.html \\\n  -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch\n```\n\n上述命令适用于 Python 3.10。我们还提供了 Python 3.9 和 3.11 的 wheel 包：\n\n* 3.9：[https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp39-cp39-manylinux_2_28_x86_64.whl](https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp39-cp39-manylinux_2_28_x86_64.whl)\n* 3.10：[https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl](https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp310-cp310-manylinux_2_28_x86_64.whl)\n* 3.11：[https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp311-cp311-manylinux_2_28_x86_64.whl](https:\u002F\u002Fstorage.googleapis.com\u002Fpytorch-xla-releases\u002Fwheels\u002Ftpuvm\u002Ftorch_xla-2.6.0%2Bcxx11-cp311-cp311-manylinux_2_28_x86_64.whl)","2025-01-30T21:54:36",{"id":192,"version":193,"summary_zh":194,"released_at":195},98583,"v2.5.1","PyTorch\u002FXLA 2.5.1 修复了 `torch_xla[tpu]` PyPI 项目说明中的安装指南，与 PyTorch 2.5.1 的热修复版本保持一致；在 PyTorch\u002FXLA 2.5.0 和 2.5.1 之间没有新增功能。","2024-10-30T23:24:38",{"id":197,"version":198,"summary_zh":199,"released_at":200},98584,"v2.5.0","Cloud TPU 现已通过 PyTorch\u002FXLA 集成支持 PyTorch 2.5 版本。除了 PyTorch 2.5 版本本身的底层改进和错误修复外，此次发布还引入了多项新功能，并针对 PyTorch\u002FXLA 特有的问题进行了修复。\n\n# 亮点\n我们很高兴地宣布 PyTorch XLA 2.5 的正式发布！PyTorch 2.5 支持 `torch_xla.compile` 函数，该函数可显著改善开发者在开发过程中的调试体验，并使分布式 API 与上游 PyTorch 保持一致，同时为 Dynamo 和非 Dynamo 场景提供可追踪的集体通信支持。自 PyTorch\u002FXLA 2.5 起，我们提出了一个[更清晰的愿景](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues\u002F8000)，即逐步弃用旧版 torch_xla API，转而采用现有的 PyTorch API，从而为开发者提供更加简化的开发体验。\n\n如果您曾使用 [vLLM](https:\u002F\u002Fdocs.vllm.ai\u002Fen\u002Flatest\u002Findex.html) 在 GPU 上部署模型，现在可以无缝切换到其 TPU 后端。vLLM 是一款被广泛采用的推理框架，同时也是推动加速器互操作性的绝佳工具。借助 vLLM on TPU，用户将保留我们熟悉的 vLLM 接口，并直接集成 [Hugging Face Models](https:\u002F\u002Fhuggingface.co\u002Fmodels)，从而轻松进行模型实验。\n\n\n# 稳定特性\n## Eager 模式\n- 提高飞行中操作的最大数量，以适应 eager 模式 [[#7263](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7263)]\n- 统一检查 eager 模式的逻辑 [[#7709](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7709)]\n- 更新 `eager.md` 文件 [[#7710](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7710)]\n- 优化 eager 模式下具有多个输出的操作执行效率 [[#7680](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7680)]\n\n\n## 量化\u002F低精度\n- 支持非对称量化的 `matmul` 运算 [[#7626](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7626)]\n- 添加分块量化点积支持 [[#7605](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7605)]\n- 在量化矩阵乘法\u002F线性层中支持 `int4` 权重 [[#7235](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7235)]\n- 支持 `fp8e5m2` 数据类型 [[#7740](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7740)]\n- 增加 `fp8e4m3fn` 支持 [[#7842](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7842)]\n- 支持按通道量化的矩阵乘法中的动态激活量化 [[#7867](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7867)]\n- 为 xla autocast 启用交叉熵损失，并使用 FP32 精度 [[#8094]](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F8094)\n\n\n## Pallas 内核\n- 支持 `flash_attention` 中的 `ab` 参数 [[#7840](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7840)]，实际内核已在 [JAX](https:\u002F\u002Fgithub.com\u002Fjax-ml\u002Fjax\u002Fblob\u002F3e634d95304afae56e01de0145d9cb068351df3c\u002Fjax\u002Fexperimental\u002Fpallas\u002Fops\u002Ftpu\u002Fflash_attention.py#L144) 中实现\n- 支持 `paged_attention` 中的 `logits_soft_cap` 参数 [[#7704](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7704)]，实际内核已在 [JAX](https:\u002F\u002Fgithub.com\u002Fjax-ml\u002Fjax\u002Fblob\u002F3e634d95304afae56e01de0145d9cb068351df3c\u002Fjax\u002Fexperimental\u002Fpallas\u002Fops\u002Ftpu\u002Fpa","2024-10-18T23:19:25",{"id":202,"version":203,"summary_zh":204,"released_at":205},98585,"v2.4.0","Cloud TPU 现已通过 PyTorch\u002FXLA 集成支持 PyTorch 2.4 版本。除了 PyTorch 2.4 版本中底层的改进和错误修复外，本次发布还引入了多项新功能以及针对 PyTorch\u002FXLA 的特定错误修复。\n\n**:rocket: PyTorch\u002FXLA 2.4 版本在使用 `openxla_eval` Dynamo 后端的 TPU 上，基于 [torchbench](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fbenchmark) 评估基准测试，相比 2.3 版本实现了 4% 的速度提升（几何平均）。**\n\n# 亮点\n我们很高兴宣布 PyTorch XLA 2.4 版本正式发布！PyTorch 2.4 提供了对使用 Pallas 自定义内核的更好支持，包括 FlashAttention 和 Group Matrix Multiplication 等内核，这些内核可以像其他 torch 操作符一样使用，并且新增了对 PagedAttention 内核的推理支持。此外，我们还添加了实验性的 eager 模式支持，该模式会编译并执行每个操作符，从而提供更好的调试和开发体验。\n\n# 稳定特性\n## PJRT\n- 默认启用动态插件 [#7270](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7270)\n\n## GSPMD\n- 支持手动分片，并引入高级手动分片 API [#6915](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6915), [#6931](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6931)\n- 支持 SPMDFullToShardShape 和 SPMDShardToFullShape [#6922](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6922), [#6925](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6925)\n\n## Torch Compile\n- 添加 DynamoSyncInputExecuteTime 计数器 [#6813](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6813)\n- 修复在使用分析器作用域运行 Dynamo 时出现的运行时错误 [#6913](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6913)\n\n## Export\n- 添加 fx 传递以支持无界动态性 [#6653](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6653)\n- 为 conv1d、view 和 softmax 增加动态性支持 [#6653](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6653)\n- 为 aten.embedding 和 aten.split_with_sizes 增加动态性支持 [#6781](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6781)\n- 在导出路径中默认内联所有标量 [#6803](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6803)\n- 对插入的 fx 节点执行形状传播 [#6805](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6805)\n- 添加不生成权重的选项 [#6909](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6909)\n- 支持将自定义算子导出为 stablehlo custom call [#7017](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7017)\n- 支持 stablehlo composite 中的数组属性 [#6840](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6840)\n- 添加将 FX 节点元数据导出到 StableHLO 的选项 [#7046](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F7046)\n\n# 测试版特性\n## Pallas\n- 支持 FlashAttention 反向传播内核 [#6870](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6870)\n- 将 FlashAttention 实现为 torch.autograd.Function [#6886](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6886)\n- 移除追踪中的 torch.empty，以避免分配额外内存 [#6897](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6897)\n- 将 FlashAttention 与 SPMD 集成 [#6935](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6935)\n- 支持注意力权重的缩放因子","2024-07-25T00:10:16",{"id":207,"version":208,"summary_zh":209,"released_at":210},98586,"v2.3.0","# 亮点\n我们很高兴地宣布 PyTorch XLA 2.3 正式发布！PyTorch 2.3 在单台 TPU 主机上提供了 SPMD 自动分片的实验性支持，用户只需进行一次配置更改，即可在 TPU 上对模型进行分片。此外，我们还新增了针对推理的 Pallas 自定义算子的实验性支持，使用户能够在 TPU 上使用诸如 Flash Attention 和分页注意力等流行的自定义算子。\n\n# 稳定特性\n## PJRT\n- GPU PJRT 插件实验版 ([#6240](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6240))\n- 在 C++ 中定义 PJRT 插件接口 [(](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002Fbd95eb1300c84efbf0a5885963a52a8aa7c861ae)[#6360](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6360)[)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002Fbd95eb1300c84efbf0a5885963a52a8aa7c861ae)\n- 为 TPU 的最大并发计算数量设置上限 ([#6533](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6533))\n- 移除 TPU_C_API 设备类型 ([#6435](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6435))\n\n## GSPMD\n- 引入全局网格 ([#6498](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6498))\n- 引入 xla_distribute_module 用于 DTensor 集成 [(](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002Fb6b9c6dabe6359196596a9890e60d6c15c0b7a7d)[#6683](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6683)[)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002Fb6b9c6dabe6359196596a9890e60d6c15c0b7a7d)\n\n## Torch Compile\n- 支持 torch.compile 内部的激活值分片 [(](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002Fa80f1d7903ff9074c13e529ca1acf579206c2879)[#6524](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6524)[)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002Fa80f1d7903ff9074c13e529ca1acf579206c2879)\n- 不在 dynamo 桥接中缓存 FX 输入参数，以避免内存泄漏 [(](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002F6aeab3006e48e2e70e8b7daa98b5add63824afc3)[#6553](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6553)[)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002F6aeab3006e48e2e70e8b7daa98b5add63824afc3)\n- 忽略非 XLA 节点及其直接依赖项。([#6170](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6170))\n\n## Export\n- 支持具有无界动态性的隐式广播 ([#6219](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6219))\n- 支持多个 StableHLO Composite 输出 ([#6295](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6295))\n- 为 add 操作增加动态性支持 [(](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002F8d91ff585c883e5ab6ffd11c1461d9029ca11263)[#6443](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6443)[)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002F8d91ff585c883e5ab6ffd11c1461d9029ca11263)\n- 在 conv、softmax、addmm 和 slice 操作上启用无界动态性 ([#6494](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6494))\n- 处理常量变量 [(](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002F0fa24a136c8db152273f40e85a79b37827f8b5df)[#6510](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6510)[)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fcommit\u002F0fa24a136c8db152273f40e85a79b37827f8b5df)\n\n# 测试特性\n## CoreAtenOpSet\n### 支持 `torch.export` 使用的所有 Core Aten 操作\n- 降低 reflection_pad1d、reflection_pad1d_backward 和 reflection_pa","2024-04-08T21:31:22",{"id":212,"version":213,"summary_zh":214,"released_at":215},98587,"v2.2.0","Cloud TPU 现已通过 PyTorch\u002FXLA 集成支持 [PyTorch 2.2 版本](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases)。在 PyTorch 2.2 版本底层改进和错误修复的基础上，本次发布引入了多项新功能，并针对 PyTorch\u002FXLA 进行了特定的错误修复。\n\n安装 PyTorch 和 PyTorch\u002FXLA 2.2.0 轮子包：\n\n```bash\npip install torch~=2.2.0 torch_xla[tpu]~=2.2.0 -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html\n```\n\n请注意，根据您之前的安装情况，可能需要在 TPUVM 上重新安装 libtpu：\n\n```bash\npip install torch_xla[tpu] -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html\n```\n\n* 注意：如果您在使用 2.2.0 Docker 镜像中的 torchvision 时遇到 `RuntimeError: operator torchvision::nms does not exist` 错误，请尝试以下命令来修复问题：\n```bash\npip uninstall torch -y; pip install torch==2.2.0\n```\n\n# 稳定特性\n## PJRT\n- `PJRT_DEVICE=GPU` 已更名为 `PJRT_DEVICE=CUDA`（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5754）。\n    - `PJRT_DEVICE=GPU` 将在 2.3 版本中被移除。\n- 优化 **主机到设备** 传输（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5772）和 **设备到主机** 传输（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5825）。\n- 其他低级重构和性能改进（[#5799](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5799), [#5737](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5737), [#5794](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5794), [#5793](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5793), [#5546](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5546)）。\n\n# 测试版特性\n## GSPMD\n- 支持 **DTensor API** 集成，并将 GSPMD 从实验性阶段移出（[#5776](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5776)）。\n- 启用调试可视化函数 `visualize_tensor_sharding`（[#5742](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5742)），并添加了相关文档（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fdocs\u002Fspmd.md#spmd-debugging-tool）。\n- 支持 `mark_shard` 标量张量（[#6158](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6158)）。\n- 添加 `apply_backward_optimization_barrier`（[#6157](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6157)）。\n\n## 导出\n- 处理了 Torch 导出中的提升常量（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F6111）。\n- 在处理前先运行分解操作（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5713）。\n- 支持将包含未使用参数的模型导出为 `tf.saved_model` 格式（https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5694）。\n- 增加了不保存权重的选项（[#5964](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5964)）。\n- 实验性地支持在 Torch 导出到 StableHLO 时使用动态维度大小（[#5790](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5790), [openxla\u002Fxla#6897](https:\u002F\u002Fgithub.com\u002Fopenxla\u002Fxla\u002Fpull\u002F6897)）。\n\n## CoreAtenOpSet\n- PyTorch\u002FXLA 计划在 2.3 版本中支持所有 PyTorch 核心 ATen 操作。我们正在积极推进这项工作，尚未解决的问题可以在 [问题列表](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fissues?q=is%3Aopen+is%3Aissue+label%3A%22core+aten+opset%2\" 中找到。","2024-01-31T21:24:00",{"id":217,"version":218,"summary_zh":219,"released_at":220},98588,"v2.1.0","Cloud TPU 现已通过 PyTorch\u002FXLA 集成支持 [PyTorch 2.1 版本](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases)。除了 PyTorch 2.1 版本中底层的改进和错误修复外，该版本还引入了多项新功能以及针对 PyTorch\u002FXLA 的特定错误修复。\n\nPJRT 现在已成为 PyTorch\u002FXLA 官方支持的运行时！PJRT 能带来更高的性能、更出色的易用性以及更广泛的设备支持。PyTorch\u002FXLA r2.1 将是最后一个仍提供 XRT 作为旧版运行时的版本。我们的主发布构建将不再包含 XRT，但它会以单独的软件包形式提供。在大多数情况下，我们预计迁移到 PJRT 所需的改动非常小。更多信息请参阅我们的 [PJRT 文档](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr2.1\u002Fdocs\u002Fpjrt.md)。\n\nGSPMD 支持现已作为实验性功能添加到 PyTorch\u002FXLA 2.1 版本中。GSPMD 将根据用户提供的分片提示，把单设备程序转换为带有适当集体通信操作的分区化程序。此功能使开发者能够像在单个大型设备上一样编写 PyTorch 程序，而无需使用任何自定义的分片计算算子和\u002F或集体通信来实现扩展。我们已发布一篇 [博客文章](https:\u002F\u002Fpytorch.org\u002Fblog\u002Fpytorch-xla-spmd\u002F)，详细解释了技术细节和预期用法；您也可以在本 [用户指南](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr2.1\u002Fdocs\u002Fspmd.md) 中找到更多详细信息。\n\nPyTorch\u002FXLA 已从依赖 TensorFlow 转为依赖新的 OpenXLA 代码库。这使得我们可以减小二进制文件大小并简化构建系统。自 2.1 版本起，PyTorch\u002FXLA 将在 [pypi](https:\u002F\u002Fpypi.org\u002Fproject\u002Ftorch-xla\u002F) 上发布我们的 TPU whl 包。\n\n要安装 PyTorch\u002FXLA 2.1.0 轮子，请参阅以下安装说明：\n\n安装 PyTorch 和 PyTorch\u002FXLA 2.1.0 轮子：\n```bash\npip install torch~=2.1.0 torch_xla[tpu]~=2.1.0 -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html\n```\n\n请注意，根据您之前的安装情况，可能需要在您的 TPUVM 上重新安装 libtpu：\n```bash\npip install torch_xla[tpu] -f https:\u002F\u002Fstorage.googleapis.com\u002Flibtpu-releases\u002Findex.html\n```\n\n# 稳定特性\n## OpenXLA\n* 从 TensorFlow 迁移到 OpenXLA 获取 XLA，并逐步淘汰对 TensorFlow 的固定版本依赖（[#5202](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5202)）\n* 使用 OpenXLA 构建 PyTorch\u002FXLA 的说明可在 [此文档](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr2.1\u002FCONTRIBUTING.md#building-manually) 中找到。\n## PjRt 运行时\n* 将 PJRT API 从实验性状态移至 `torch_xla.runtime`（[#5011](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5011)）\n* 启用 PJRT C API 客户端及针对 Neuron 的其他更改（[#5428](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5428)）\n* 为 Intel XPU 启用 PJRT C API 客户端（[#4891](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4891)）\n* 将 pjrt:\u002F\u002F 初始化方法改为 xla:\u002F\u002F（[#5560](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5560)）\n* 提高 TPU 检测的鲁棒性（[#5271](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F5271)）","2023-09-07T16:14:00",{"id":222,"version":223,"summary_zh":224,"released_at":225},98589,"v2.0.0","Cloud TPUs now support the [PyTorch 2.0 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases), via PyTorch\u002FXLA integration. On top of the underlying improvements and bug fixes in PyTorch's 2.0 release, this release introduces several features, and PyTorch\u002FXLA specific bug fixes.\r\n\r\n# Beta Features\r\n## PJRT runtime\r\n* Checkout our newest [document](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr2.0\u002Fdocs\u002Fpjrt.md); PjRt is the default runtime in 2.0.\r\n* New Implementation of xm.rendezvous with XLA collective communication which scales better ([#4181](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4181))\r\n* New PJRT TPU backend through the C-API ([#4077](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4077))\r\n* Use PJRT to default if no runtime is configured ([#4599](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4599))\r\n* Experimental support for torch.distributed and DDP on TPU v2 and v3 ([#4520](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4520))\r\n\r\n## FSDP\r\n* Add auto_wrap_policy into XLA FSDP for automatic wrapping ([#4318](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4318))\r\n\r\n# Stable Features\r\n## Lazy Tensor Core Migration\r\n* Migration is completed, checkout this [dev discussion](https:\u002F\u002Fdev-discuss.pytorch.org\u002Ft\u002Fpytorch-xla-2022-q4-dev-update\u002F961) for more detail.\r\n* Naively inherits LazyTensor ([#4271](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4271))\r\n* Adopt even more LazyTensor interfaces ([#4317](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4317))\r\n* Introduce XLAGraphExecutor ([#4270](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4270))\r\n* Inherits LazyGraphExecutor ([#4296](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4296))\r\n* Adopt more LazyGraphExecutor virtual interfaces ([#4314](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4314))\r\n* Rollback to use xla::Shape instead of torch::lazy::Shape ([#4111](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4111))\r\n* Use TORCH_LAZY_COUNTER\u002FMETRIC ([#4208](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4208))\r\n\r\n## Improvements & Additions\r\n* Add an option to increase the worker thread efficiency for data loading ([#4727](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4727))\r\n* Improve numerical stability of torch.sigmoid ([#4311](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4311))\r\n* Add an api to clear counter and metrics ([#4109](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4109))\r\n* Add met.short_metrics_report to display more concise metrics report ([#4148](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4148))\r\n* Document environment variables ([#4273](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4273))\r\n* Op Lowering\r\n    * _linalg_svd ([#4537](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4537))\r\n    * Upsample_bilinear2d with scale ([#4464](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4464))\r\n\r\n# Experimental Features\r\n## TorchDynamo (torch.compile) support\r\n* Checkout our newest [doc](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr2.0\u002Fdocs\u002Fdynamo.md).\r\n* Dynamo bridge python binding ([#4119](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4119))\r\n* Dynamo bridge backend implementation ([#4523](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4523))\r\n* Training optimization: make execution async ([#4425](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4425))\r\n* Training optimization: reduce graph execution per step ([#4523](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4523))\r\n\r\n## PyTorch\u002FXLA GSPMD on single host\r\n* Preserve parameter sharding with sharded data placeholder ([#4721)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4721)\r\n* Transfer shards from server to host ([#4508](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4508))\r\n* Store the sharding annotation within XLATensor(#[4390](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4390))\r\n* Use d2d replication for more efficient input sharding ([#4336](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4336))\r\n* Mesh to support custom device order. ([#4162](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4162))\r\n* Introduce virtual SPMD device to avoid unpartitioned data transfer ([#4091](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4091))\r\n\r\n# Ongoing development\r\n## Ongoing Dynamic Shape implementation\r\n* Implement missing `XLASymNodeImpl::Sub` ([#4551](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4551))\r\n* Make empty_symint support dynamism. ([#4550](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4550))\r\n* Add dynamic shape support to SigmoidBackward ([#4322](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4322))\r\n* Add a forward pass NN model with dynamism test ([#4256](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4256)) \r\n## Ongoing SPMD multi host execution ([#4573](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4573))\r\n\r\n# Bug fixes & improvements\r\n* Support int as index type ([#4602](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4602))\r\n* Only alias inputs and outputs when force_ltc_sync == True ([#4575](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4575))\r\n* Fix race condition between execution and buffer tear down on GPU when using bfc_allocator ([#4542](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4542))\r\n* Release the GIL during TransferFromServer ([#4504](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4504))\r\n* Fix type annotations in FSDP ([#4371](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F4371))","2023-08-12T07:23:55",{"id":227,"version":228,"summary_zh":229,"released_at":230},98590,"v1.13.0","Cloud TPUs now support the [PyTorch 1.13 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), [FairSeq Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE and LM](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nOn top of the underlying improvements and bug fixes in PyTorch's 1.13 release, this release adds several features and PyTorch\u002FXLA specified bug fixes.\r\n\r\n## New Features\r\n- GPU enhancement\r\n  - Add upsample_nearest\u002Fbilinear implementation for CPU and GPU ([#3990](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3990))\r\n  - Set three_fry as the default RNG for GPU ([#3951](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3951))\r\n- FSDP enhancement\r\n  - allow FSDP wrapping and sharding over modules on CPU devices ([#3992](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3992))\r\n  - Support param sharding dim and pinning memory ([#3830](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3830))\r\n- Lower torch::einsum using xla::einsum which provide significant speedup ([#3843](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3843))\r\n- Support large models with >3200 graph input on TPU + PJRT ([#3920](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3920))\r\n\r\n## Experimental Features\r\n- PJRT experimental support on Cloud TPU v4\r\n  - Check the instruction and example code in [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr1.13\u002Fdocs\u002Fpjrt.md)\r\n- DDP experimental support on Cloud TPU and GPU\r\n  - Check the instruction, analysis and example code in [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr1.13\u002Fdocs\u002Fddp.md)\r\n\r\n## Ongoing development\r\n- Ongoing Dynamic Shape implementation (POC completed)\r\n- Ongoing SPMD implementation (POC completed)\r\n- Ongoing LTC migration\r\n\r\n## Bug fixes and improvements\r\n- Make XLA_HLO_DEBUG populate the scope metadata ([#3985](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3985))\r\n","2022-11-29T01:07:30",{"id":232,"version":233,"summary_zh":234,"released_at":235},98591,"v1.12.0","Cloud TPUs now support the [PyTorch 1.12 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), [FairSeq Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE and LM](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nOn top of the underlying improvements and bug fixes in PyTorch's 1.12 release, this release adds several features and PyTorch\u002FXLA specified bug fixes.\r\n\r\n## New feature\r\n- FSDP\r\n  - Check the instruction and example code in [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fr1.12\u002Ftorch_xla\u002Fdistributed\u002Ffsdp\u002FREADME.md)\r\n  - FSDP support for PyTorch\u002FXLA (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3431)\r\n  - Bfloat 16 and float 16 support in FSDP (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3617)\r\n- PyTorch\u002FXLA gradident checkpoint api (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3524)\r\n- Optimization_barrier which enables gradient checkpointing (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3482)\r\n- Ongoing LTC migration\r\n- Device lock position optimization to speed up tracing (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3457)\r\n- Experimental support for PJRT TPU client (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3550)\r\n- Send\u002FRecv CC op support (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3494)\r\n- Performance profiling tool enhancement (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3498)\r\n- TPU-V4 pod official support (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3440)\r\n- Roll lowering (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3505)\r\n- Celu, celu_, selu, selu_ lowering (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3547)\r\n\r\n\r\n## Bug fixes and improvements\r\n- Fixed a view bug which will create unnecessary IR graph (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3411)","2022-06-29T01:22:25",{"id":237,"version":238,"summary_zh":239,"released_at":240},98592,"v1.5.0","Cloud TPUs and Cloud TPU Pods now support [PyTorch 1.5](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases\u002Ftag\u002Fv1.5.0) via the PyTorch\u002FXLA integration. This integration aims to make it possible for PyTorch users to do everything they can do on GPUs on Cloud TPUs as well while minimizing changes to the user experience. You can try out PyTorch on an 8-core Cloud TPU device for free via Google Colab, and you can use PyTorch on Cloud TPUs at a much larger scale on Google Cloud (all the way up to full Cloud TPU Pods).\r\n\r\nThree PyTorch models have been added to our list of supported models, which are rigorously and continuously tested:\r\n- ResNet-50\r\n- Fairseq Transformer\r\n- Fairseq RoBERTa\r\n\r\nAdditional notes:\r\n- New Operators added\r\n  - masked_scatter (#1525)\r\n  - logdet (#1407)\r\n  - reflection_pad2d (#1409) \r\n  - gelu(#1278) \r\n  - take(#1389) \r\n  - upsample_bilinear2d (#1239)\r\n  - upsample_nearest2d (#1233) \r\n  - mse_loss(#1206) \r\n- Exposed APIs to enable different types of cross-replica reduce operations using the TPU interconnect link (#1709)\r\n- Exposed API to perform rendezvous operations among the different replica processes (#1669) \r\n- Added support for reading\u002Fwriting GCS files (#1230) \r\n- Added support to read TFRecords (#1220) \r\n- Miscellaneous bug fixes","2020-04-21T15:25:31",{"id":242,"version":243,"summary_zh":244,"released_at":245},98593,"v1.6.0","# Highlights\r\nCloud TPUs now support the PyTorch 1.6 release, via PyTorch\u002FXLA integration. With this release we mark our general availability (GA) with the models such as ResNet, FairSeq Transformer and RoBERTa, and HuggingFace GLUE task models that have been rigorously tested and optimized.\r\n\r\nIn addition, with our PyTorch\u002FXLA 1.6 release, you no longer need to run the env-setup.py script on Colab\u002FKaggle as those are now compatible with native `torch` wheels. See [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002Fcontrib\u002Fcolab\u002Fgetting-started.ipynb) for an example of the new Colab\u002FKaggle install step. You can still continue to use that script if you would like to run with our latest unstable releases.\r\n\r\n# New Features\r\n* XLA RNG state checkpointing\u002Floading (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2096)\r\n* Device Memory XRT API (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2295)\r\n* [Kaggle\u002FColab] Small host VM memory environment utility (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2025)\r\n* [Advanced User] XLA Builder Support (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2125) \r\n* New ops supported on PyTorch\u002FXLA\r\n  * Hardsigmoid (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F1940)\r\n  * true_divide (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F1782)\r\n  * max_unpool2d (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2188)\r\n  * max_unpool3d (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2188)\r\n  * Replication_pad1d (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2188)\r\n  * Replication_pad2d (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2188)\r\n* Dynamic shape support on XLA:CPU and XLA:GPU (experimental)\r\n \r\n# Bug Fixes\r\n* RNG Fix (proper randomness with bernoulli and dropout) (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F1932)\r\n* Manual all-reduce in backward pass (https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2325)","2020-08-19T21:19:18",{"id":247,"version":248,"summary_zh":249,"released_at":250},98594,"v1.8.0","# Summary\r\n\r\nCloud TPUs now support the [PyTorch 1.8 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases\u002Ftag\u002Fv1.8.0), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), FairSeq [Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers) and LM, and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nThis release focused on making PyTorch XLA easier to use and debug. See below for a list of new features.\r\n\r\n# New Features\r\n* Enhanced usability:\r\n    * Profiler tools to help you pinpoint the areas where you can improve the memory usage or speed of your TPU models. The tools are ready to use; check out our [main README](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fblob\u002Fmaster\u002FREADME.md) for some upcoming tutorials.\r\n    * Simpler error messages (#2771)\r\n    * Less log spam using TPU Pods (#2662)\r\n    * Able to view images in Tensorboard (#2679)\r\n* `TriangularSolve` (#2498) (example)\r\n* New ops supported by PyTorch\u002FXLA:\r\n    * `random_` (#2617)\r\n    * `adaptive_avg_pool3d` (#2616)\r\n    * `UpsampleNearest2D` (#2597)\r\n\r\n# Bug Fixes\r\n* Crashing while using dynamic shapes (#2602)\r\n* `all_to_all` crashing on TPU pods (#2601)\r\n* `SiLU` fix (#2721)","2021-03-04T23:45:21",{"id":252,"version":253,"summary_zh":254,"released_at":255},98595,"v1.10.0","Cloud TPUs now support the [PyTorch 1.10 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), [FairSeq Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE and LM](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nOn top of the underlying improvements and bug fixes in PyTorch's 1.10 release, this release adds several PyTorch\u002FXLA-specific bug fixes:\r\n\r\n-  Add support for [reduce_scatter](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3075)\r\n-  Introduce the [AMP Zero gradients optimization](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3119)  for XLA:GPU\r\n- Introduce the environment variable [XLA_DOWN_CAST_BF16](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2999) and [XLA_DOWNCAST_FP16](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2999) to downcast input tensors\r\n- [adaptive_max_pool2d](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3083) lowering\r\n- [nan_to_num](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3093) lowering\r\n- [sgn](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3045) lowering\r\n- [logical_not](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3084)\u002F[logical_xor](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3084)\u002F[logical_or](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3084)\u002F[logical_and](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3054) lowering\r\n- [amax](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3027) lowering\r\n- [amin](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3034) lowering\r\n- [std_mean](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3004) lowering\r\n- [var_mean](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3014) lowering\r\n- [lerp](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2972) lowering\r\n- [isnan](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2969) lowering","2021-10-25T17:10:54",{"id":257,"version":258,"summary_zh":259,"released_at":260},98596,"v1.11.0","Cloud TPUs now support the [PyTorch 1.11 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), [FairSeq Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE and LM](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nOn top of the underlying improvements and bug fixes in PyTorch's 1.11 release, this release adds several features and PyTorch\u002FXLA specified bug fixes.\r\n\r\n## New feature\r\n\r\n- Enable [asynchronous RNG seed sending](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3292) by environment variable `XLA_TRANSFER_SEED_ASYNC `\r\n- Add a [native torch.distributed backend](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3339)\r\n- Introduce a [Eager debug mode](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3306) by environment variable `XLA_USE_EAGER_DEBUG_MODE `\r\n- Add synchronous free [Adam and AdamW optimizers](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3294) for PyTorch\u002FXLA:GPU AMP\r\n- Add synchronous free [SGD](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3145) optimizers for PyTorch\u002FXLA:GPU AMP\r\n- [linspace](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3335) lowering\r\n- [mish](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3236) lowering\r\n- [prelu](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3222) lowering\r\n- [slogdet](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3183) lowering\r\n- [stable sort](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3246) lowering\r\n- [index_add with alpha scaling](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3227) lowering\r\n\r\n## Bug fixes && improvements\r\n- Improve [`torch.var`](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3262) performance and numerical stability on TPU\r\n- Improve [`torch.pow`](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3251) performance\r\n- Fix the [incorrect output dtype](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3229) when divide a f32 by a f64\r\n- Fix the [incorrect result](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F3144) of `nll_loss` when reduction = \"mean\" and whole target is equal to ignore_index","2022-03-15T23:46:46",{"id":262,"version":263,"summary_zh":264,"released_at":265},98597,"v1.9.0","Cloud TPUs now support the [PyTorch 1.9 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases\u002Ftag\u002Fv1.9), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), [FairSeq Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE and LM](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nOn top of the underlying improvements and bug fixes in PyTorch's 1.9 release, this release adds several PyTorch\u002FXLA-specific bug fixes:\r\n\r\n* [Floor division fix](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2950)\r\n* [Clamp fix](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2929)\r\n* [Softplus fix](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2902)\r\n* [as_strided_](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2912)\r\n* [std abd var lowering](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fxla\u002Fpull\u002F2891)","2021-06-15T23:17:21",{"id":267,"version":268,"summary_zh":269,"released_at":270},98598,"v1.8.1","Cloud TPUs now support the [PyTorch 1.8.1 release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Freleases\u002Ftag\u002Fv1.8.1), via PyTorch\u002FXLA integration. The release has daily automated testing for the supported models: [Torchvision ResNet](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fresnet-pytorch), [FairSeq Transformer](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Ftransformer-pytorch) and [RoBERTa](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Froberta-pytorch), [HuggingFace GLUE and LM](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), and [Facebook Research DLRM](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Ftutorials\u002Fpytorch-dlrm).\r\n\r\nOn top of the underlying bug fixes in PyTorch's 1.8.1 release, this release adds a few bug fixes on the PyTorch XLA side around the XRT server and TPU Pods training.","2021-04-21T17:38:17"]