[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-mlc-ai--web-stable-diffusion":3,"tool-mlc-ai--web-stable-diffusion":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},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,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},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 真正成长为懂上",160784,2,"2026-04-19T11:32:54",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":72,"owner_avatar_url":73,"owner_bio":74,"owner_company":74,"owner_location":74,"owner_email":74,"owner_twitter":74,"owner_website":74,"owner_url":75,"languages":76,"stars":96,"forks":97,"last_commit_at":98,"license":99,"difficulty_score":100,"env_os":101,"env_gpu":102,"env_ram":103,"env_deps":104,"category_tags":116,"github_topics":117,"view_count":32,"oss_zip_url":74,"oss_zip_packed_at":74,"status":17,"created_at":124,"updated_at":125,"faqs":126,"releases":156},9684,"mlc-ai\u002Fweb-stable-diffusion","web-stable-diffusion","Bringing stable diffusion models to web browsers. Everything runs inside the browser with no server support. ","web-stable-diffusion 是一款革命性的开源项目，它让强大的 Stable Diffusion 图像生成模型能够直接在网页浏览器中运行，无需任何后端服务器支持。这意味着用户只需打开浏览器标签页，即可在本地完成从文本到图像的生成过程。\n\n长期以来，运行此类大型 AI 模型依赖昂贵的 GPU 服务器和特定的深度学习框架，不仅成本高，还涉及数据隐私传输风险。web-stable-diffusion 通过将计算任务完全迁移至客户端，有效解决了这些问题，既降低了服务提供者的运营成本，又极大地提升了用户的隐私保护与个性化体验。\n\n该项目特别适合前端开发者、AI 研究人员以及希望探索去中心化 AI 应用的技术爱好者。对于普通用户而言，它也提供了无需安装复杂环境即可体验最新 AI 绘图能力的便捷途径。其核心技术亮点在于巧妙结合了 WebAssembly 与日益成熟的 WebGPU 标准，实现了浏览器内的原生 GPU 加速。此外，项目提供了一套可重复、可组合的\"Python 优先”工作流，支持开发者轻松优化模型并统一部署到包括网页在内的多种终端环境，展现了极高的灵活性与扩展性。","# Web Stable Diffusion\n\nThis project brings stable diffusion models onto web browsers. **Everything runs inside the browser with no server support.** To our knowledge, this is the world’s first stable diffusion completely running on the browser. Please checkout our [demo webpage](https:\u002F\u002Fwebsd.mlc.ai\u002F#text-to-image-generation-demo) to try it out.\n\nYou are also more than welcomed to checkout [Web LLM](https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-llm) if you are interested in deploying LLM-based chat bots to browser.\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_readme_c9f53faf6161.png\" alt=\"Browser screenshot\"\u002F>\n\nWe have been seeing amazing progress through AI models recently. Thanks to the open-source effort, developers can now easily compose open-source models together to produce amazing tasks. Stable diffusion enables the automatic creation of photorealistic images as well as images in various styles based on text input. These models are usually big and compute-heavy, which means we have to pipe through all computation requests to (GPU) servers when developing web applications based on these models. Additionally, most of the workloads have to run on a specific type of GPUs where popular deep-learning frameworks are readily available.\n\nThis project takes a step to change that status quo and bring more diversity to the ecosystem. There are a lot of reasons to get some (or all) of the computation to the client side. There are many possible benefits, such as cost reduction on the service provider side, as well as an enhancement for personalization and privacy protection. The development of personal computers (even mobile devices) is going in the direction that enables such possibilities. The client side is getting pretty powerful. \n\nBuilding special client apps for those applications is one option (which we also support), but won’t it be even more amazing if we can simply open a browser and directly bring AI natively to your browser tab? There is some level of readiness in the ecosystem. WebAssembly allows us to port more lower-level runtimes onto the web. To solve the compute problem, WebGPU is getting matured lately and enables native GPU executions on the browser.\n\nWe are just seeing necessary elements coming together on the client side, both in terms of hardware and browser ecosystem. Still, there are big hurdles to cross, to name a few:\n\n* We need to bring the models somewhere without the relevant GPU-accelerated Python frameworks.\n* Most of the AI frameworks have a heavy reliance on optimized computed libraries that are maintained by hardware vendors. We need to start from zero. To get the maximum benefit, we might also need to produce variants per client environment.\n* Careful planning of memory usage so we can fit the models into memory.\n\nWe do not want to only do it for just one model. Instead, we would like to present a repeatable, hackable, composable workflow that enables anyone to easily develop and optimize these models in a **Python-first** environment and universally **deploy** them everywhere, including the web.\n\n## Get Started\n\nWe have a [Jupyter notebook](https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fblob\u002Fmain\u002Fwalkthrough.ipynb) that walks you through all the stages, including\n\n* elaborate the key points of web ML model deployment and how we do to meet these points,\n* import the stable diffusion model,\n* optimize the model,\n* build the model,\n* deploy the model locally with native GPU runtime, and\n* deploy the model on web with WebGPU runtime.\n\nIf you want to go through these steps in command line, please follow the commands below:\n\n\u003Cdetails>\u003Csummary>Commands\u003C\u002Fsummary>\n\n* Install TVM Unity. You can either\n    * use `pip3 install mlc-ai-nightly -f https:\u002F\u002Fmlc.ai\u002Fwheels` to install the TVM Unity wheel, or\n    * follow [TVM’s documentation](https:\u002F\u002Ftvm.apache.org\u002Fdocs\u002Finstall\u002Ffrom_source.html) to build from source. **Please use `git checkout origin\u002Funity` to checkout to TVM Unity after git clone.**\n* To import, optimize and build the stable diffusion model:\n    ```shell\n    python3 build.py\n    ```\n    By default `build.py` takes `apple\u002Fm2-gpu` as build target. You can also specify CUDA target via\n    ```shell\n    python3 build.py --target cuda\n    ```\n* To deploy the model locally with native GPU runtime:\n    ```shell\n    python3 deploy.py --prompt \"A photo of an astronaut riding a horse on mars.\"\n    ```\n    You can substitute the prompt with your own one, and optionally use `--negative-prompt \"Your negative prompt\"` to specify a negative prompt.\n* To deploy the model on web with WebGPU runtime, the last section “Deploy on web” of the [walkthrough notebook](https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fblob\u002Fmain\u002Fwalkthrough.ipynb) has listed the full instructions which you can refer to. We also provide the same list of plain instructions here:\n    \u003Cdetails>\u003Csummary>Instructions\u003C\u002Fsummary>\n\n    First, let’s install all the prerequisite:\n    1. [emscripten](https:\u002F\u002Femscripten.org). It is an LLVM-based compiler which compiles C\u002FC++ source code to WebAssembly.\n        - Follow the [installation instruction](https:\u002F\u002Femscripten.org\u002Fdocs\u002Fgetting_started\u002Fdownloads.html#installation-instructions-using-the-emsdk-recommended) to install the latest emsdk.\n        - Source `emsdk_env.sh` by `source path\u002Fto\u002Femsdk_env.sh`, so that `emcc` is reachable from PATH and the command `emcc` works.\n    2. [Rust](https:\u002F\u002Fwww.rust-lang.org\u002Ftools\u002Finstall).\n    3. [`wasm-pack`](https:\u002F\u002Frustwasm.github.io\u002Fwasm-pack\u002Finstaller\u002F). It helps build Rust-generated WebAssembly, which used for tokenizer in our case here.\n    4. Install jekyll by following the [official guides](https:\u002F\u002Fjekyllrb.com\u002Fdocs\u002Finstallation\u002F). It is the package we use for website.\n    5. Install jekyll-remote-theme by command\n        ```shell\n        gem install jekyll-remote-theme\n        ```\n    6. Install [Chrome Canary](https:\u002F\u002Fwww.google.com\u002Fchrome\u002Fcanary\u002F). It is a developer version of Chrome that enables the use of WebGPU.\n\n    We can verify the success installation by trying out `emcc`, `jekyll` and `wasm-pack` in terminal respectively.\n\n    Then, prepare all the necessary dependencies for web build:\n    ```shell\n    .\u002Fscripts\u002Fprep_deps.sh\n    ```\n\n    We can now build the model to WebGPU backend and export the executable to disk in the WebAssembly file format, by running\n    ```shell\n    python3 build.py --target webgpu\n    ```\n\n    The last thing to do is setting up the site with\n    ```shell\n    .\u002Fscripts\u002Flocal_deploy_site.sh\n    ```\n\n    With the site set up, you can go to `localhost:8888\u002F` in Chrome Canary to try out the demo on your local machine. Don’t forget to use\n    ```shell\n    \u002FApplications\u002FGoogle\\ Chrome\\ Canary.app\u002FContents\u002FMacOS\u002FGoogle\\ Chrome\\ Canary --enable-dawn-features=disable_robustness\n    ```\n    to launch Chrome Canary to turn off the robustness check from Chrome.\n    \u003C\u002Fdetails>\n\u003C\u002Fdetails>\n\n## How?\n\nThe key technology here is machine learning compilation (MLC). Our solution is built on the shoulders of the open-source ecosystem, including PyTorch, Hugging Face diffusers and tokenizers, rust, wasm, and WebGPU. The main flow is built on Apache TVM Unity, an exciting ongoing development in the [Apache TVM](https:\u002F\u002Fgithub.com\u002Fapache\u002Ftvm)\n\n- We take [Runway’s stable diffusion v1-5](https:\u002F\u002Fhuggingface.co\u002Frunwayml\u002Fstable-diffusion-v1-5\u002Ftree\u002Fmain) models from the Hugging Face diffuser library.\n- We use [TorchDynamo](https:\u002F\u002Fpytorch.org\u002Ftutorials\u002Fintermediate\u002Fdynamo_tutorial.html) and [Torch FX](https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Ffx.html) to capture key model components into an IRModule in TVM.\n- Each function in TVM’s IRModule can be further transformed and generated with runnable code that can be deployed universally on any environment supported by minimum TVM runtime (javascript being one of them).\n- [TensorIR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2207.04296) and [MetaSchedule](https:\u002F\u002Farxiv.org\u002Fabs\u002F2205.13603) are used to build automated solutions to generate optimized programs. These transformations are tuned on a specific device through native GPU runtimes and then used to generate optimized GPU shaders. We provide a database that records these transformations so new builds can be done without tuning.\n- We build static memory planning optimizations to reuse memory across multiple layers.\n- We use [Emscripten](https:\u002F\u002Femscripten.org\u002F) and typescript to build a TVM web runtime that can deploy generated modules.\n- We also leverage the [wasm port](https:\u002F\u002Fblog.mithrilsecurity.io\u002Fporting-tokenizers-to-wasm\u002F) of the [rust tokenizers library](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftokenizers) from Hugging Face.\n\n![workflow](site\u002Fimg\u002Ffig\u002Fworkflow.svg)\n\nAll parts of this workflow are done in Python, except, of course, the last part which builds a 400-loc JavaScript app that connects things together. This is also a fun process of interactive development, bringing new models.\n\nAll these are made possible by the open-source ecosystem that we leverage. Specifically, we make heavy use of [TVM Unity](https:\u002F\u002Fdiscuss.tvm.apache.org\u002Ft\u002Festablish-tvm-unity-connection-a-technical-strategy\u002F13344), an exciting latest development in the TVM project that enables such Python-first interactive MLC development experiences which allows us to easily compose new optimizations, all in Python, and incrementally bring our app to the web. TVM Unity also provides an easy way to compose new solutions in the ecosystem. For example, we can bring in other WebGPU shader generators or shader libraries easily to this workflow in the future.\n\n## Comparison with Native GPU Runtime, Limitations, and Opportunities\n\nBesides the WebGPU runtime, we also provide options for native deployment with local GPU runtime. These options can be used both as a tool to deploy on a native environment as well as a reference point to compare native GPU driver performance and WebGPU.\n\nWebGPU works by translating WGSL (WebGPU Shading Language) shaders to native shaders. So, in theory, we can reach zero gaps between the WebGPU runtime and the native environment. If we directly use Chrome to check the current demo on Apple silicon, however, we can find a performance degradation (about 3x). This is because Chrome’s WebGPU implementation inserts bound clips for all array index access, such that `a[i]` becomes `a[min(i, a.size)]`. Ideally, downstream shader compilers should be able to optimize the bound clipping out, but here unfortunately, it is not the case. This gap can be fixed once WebGPU implementation becomes more mature, checks the index access range, and drops such clipping.\n\nYou can get around this by using a special flag to launch Chrome (thanks to Dawn developers for providing the pointers), by exiting Chrome completely, then in the command line, type\n```shell\n\u002Fpath\u002Fto\u002Fchrome-canary --enable-dawn-features=disable_robustness\n```\nThen you will find that the execution speed is as fast as the native GPU environment. We anticipate this problem will get resolved as WebGPU matures.\n\nWe are just seeing the dawn of what we believe to be an eruption. WebGPU is still evolving (though it is getting close to shipping this year), and only available through Chrome Canary, and can be unstable. It also still comes with limitations, such as only support for FP32 (FP16 shader extension is on the spec but not yet implemented). The stable diffusion here would require a GPU with a decent amount of RAM (8GB). We have only tested our solution through Apple silicons so far. There are also opportunities to support advanced optimizations such as [FlashAttention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2205.14135) and quantization to further improve the performance of the system.\n\nThese are opportunities to bring several times of performance improvements to the current solutions. We believe many of them can be tackled in the near future. A single component of this solution can still be useful. For example, one can choose just to deploy the text encoder part of the model. Additionally, the same Python-first development, universal deployment workflow can be used to bring ML models to other environments, such as new hardware or mobile cases. Finally, the same machine learning compilation stack is also shared with server class use cases and can be used to optimize server workloads as well.\n\n## Acknowledgement\n\nThis project is made possible thanks to collaboration with\n\n\u003Ca href=\"https:\u002F\u002Fwww.scs.cmu.edu\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_readme_6a7fea1277bb.png\" alt=\"CMU School of Computer Science\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fcatalyst.cs.cmu.edu\">\n\u003Cimg src=\"site\u002Fimg\u002Flogo\u002Fcatalyst.svg\" alt=\"Catalyst\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fmlc.ai\">\n\u003Cimg src=\"site\u002Fimg\u002Flogo\u002Fmlc-logo-with-text-landscape.svg\" alt=\"MLC\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Foctoml.ai\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_readme_7b88e1cab409.png\" alt=\"OctoML\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\nThis project is only possible thanks to the shoulders open-source ecosystems that we stand on. We want to thank the Apache TVM community and developers of the TVM Unity effort. We want to thank the open-source ML community members who make these models publicly available, and PyTorch, Hugging Face communities that make these models accessible. We would like to thank the tokenizer wasm port by Mithril Security. We also would like to thank the WebAssembly, Emscripten, Rust, and WebGPU communities. Finally, thanks to Dawn developers, who provide timely answers to questions on Chrome.\n","# Web 稳定扩散\n\n本项目将稳定扩散模型引入到网页浏览器中。**所有计算都在浏览器内部完成，无需服务器支持。** 据我们所知，这是全球首个完全在浏览器上运行的稳定扩散模型。请访问我们的[演示页面](https:\u002F\u002Fwebsd.mlc.ai\u002F#text-to-image-generation-demo)体验。\n\n如果您对将基于 LLM 的聊天机器人部署到浏览器感兴趣，也欢迎查看 [Web LLM](https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-llm)。\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_readme_c9f53faf6161.png\" alt=\"浏览器截图\"\u002F>\n\n近年来，AI 模型取得了令人瞩目的进展。得益于开源社区的努力，开发者现在可以轻松地组合各种开源模型，完成许多令人惊叹的任务。稳定扩散模型能够根据文本输入自动生成逼真的图像以及各种风格的艺术作品。然而，这些模型通常体积庞大、计算密集，因此在开发基于它们的 Web 应用时，我们必须将所有的计算请求转发到 GPU 服务器上处理。此外，大多数工作负载还需要在特定类型的 GPU 上运行，而这些 GPU 上往往已经预装了流行的深度学习框架。\n\n本项目旨在改变这一现状，为生态系统带来更多多样性。将部分（或全部）计算转移到客户端有许多理由。这样做不仅能够降低服务提供商的成本，还能提升个性化体验和隐私保护水平。个人电脑（甚至移动设备）的发展正朝着支持这种可能性的方向迈进——客户端设备的功能越来越强大。\n\n为这些应用构建专用的客户端应用程序是一种选择（我们也支持这种方式），但如果我们只需打开浏览器，就能直接将 AI 原生地集成到你的浏览器标签页中，岂不是更加令人兴奋？目前，生态系统已经具备了一定的基础：WebAssembly 允许我们将更多底层运行时移植到 Web 平台上。为了解决计算问题，WebGPU 技术也在不断成熟，使得在浏览器中进行原生 GPU 计算成为可能。\n\n我们正目睹客户端侧所需的各项要素逐渐就位，无论是硬件层面还是浏览器生态方面。尽管如此，我们仍需克服诸多挑战，例如：\n\n* 我们需要在没有相关 GPU 加速 Python 框架的情况下运行这些模型。\n* 大多数 AI 框架高度依赖由硬件厂商维护的优化计算库。我们需要从零开始构建。为了获得最佳性能，我们可能还需要针对不同的客户端环境生成不同的版本。\n* 必须精心规划内存使用，以确保模型能够完整加载到内存中。\n\n我们并不希望只为单一模型实现这一点。相反，我们希望提供一种可重复、可扩展、可组合的工作流程，使任何人都能在“Python 优先”的环境中轻松开发和优化这些模型，并将其普遍部署到包括 Web 在内的任何平台上。\n\n## 开始使用\n\n我们提供了一个 [Jupyter 笔记本](https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fblob\u002Fmain\u002Fwalkthrough.ipynb)，它将引导您完成整个流程，包括：\n\n* 详细阐述 Web ML 模型部署的关键点，以及我们如何满足这些要求；\n* 导入稳定扩散模型；\n* 对模型进行优化；\n* 构建模型；\n* 使用原生 GPU 运行时在本地部署模型；以及\n* 使用 WebGPU 运行时在 Web 上部署模型。\n\n如果您希望通过命令行完成这些步骤，请按照以下命令操作：\n\n\u003Cdetails>\u003Csummary>命令\u003C\u002Fsummary>\n\n* 安装 TVM Unity。您可以：\n    * 使用 `pip3 install mlc-ai-nightly -f https:\u002F\u002Fmlc.ai\u002Fwheels` 安装 TVM Unity 的 wheel 包，或者\n    * 参照 [TVM 官方文档](https:\u002F\u002Ftvm.apache.org\u002Fdocs\u002Finstall\u002Ffrom_source.html) 从源码编译。**请注意，在 git clone 之后，请使用 `git checkout origin\u002Funity` 切换到 TVM Unity 分支。**\n* 导入、优化并构建稳定扩散模型：\n    ```shell\n    python3 build.py\n    ```\n    默认情况下，`build.py` 会将 `apple\u002Fm2-gpu` 作为构建目标。您也可以通过以下命令指定 CUDA 目标：\n    ```shell\n    python3 build.py --target cuda\n    ```\n* 使用原生 GPU 运行时在本地部署模型：\n    ```shell\n    python3 deploy.py --prompt \"A photo of an astronaut riding a horse on mars.\"\n    ```\n    您可以替换提示词为自己想要的内容，还可以选择性地使用 `--negative-prompt \"Your negative prompt\"` 来指定负面提示词。\n* 要使用 WebGPU 运行时在 Web 上部署模型，[演示笔记本](https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fblob\u002Fmain\u002Fwalkthrough.ipynb) 的最后一节“Deploy on web”提供了完整的说明，您也可以参考此处的简明指令：\n    \u003Cdetails>\u003Csummary>说明\u003C\u002Fsummary>\n\n    首先，让我们安装所有必要的依赖项：\n    1. [emscripten](https:\u002F\u002Femscripten.org)。这是一个基于 LLVM 的编译器，可以将 C\u002FC++ 源代码编译成 WebAssembly。\n        - 请按照 [安装说明](https:\u002F\u002Femscripten.org\u002Fdocs\u002Fgetting_started\u002Fdownloads.html#installation-instructions-using-the-emsdk-recommended) 安装最新版本的 emsdk。\n        - 执行 `source path\u002Fto\u002Femsdk_env.sh` 以激活 `emsdk_env.sh`，从而使 `emcc` 能够通过 PATH 访问，并确保 `emcc` 命令正常运行。\n    2. [Rust](https:\u002F\u002Fwww.rust-lang.org\u002Ftools\u002Finstall)。\n    3. [`wasm-pack`](https:\u002F\u002Frustwasm.github.io\u002Fwasm-pack\u002Finstaller\u002F)。它用于构建由 Rust 生成的 WebAssembly，而在本例中则用于分词器。\n    4. 按照 [官方指南](https:\u002F\u002Fjekyllrb.com\u002Fdocs\u002Finstallation\u002F) 安装 Jekyll。这是我们用来搭建网站的工具包。\n    5. 使用以下命令安装 jekyll-remote-theme：\n        ```shell\n        gem install jekyll-remote-theme\n        ```\n    6. 安装 [Chrome Canary](https:\u002F\u002Fwww.google.com\u002Fchrome\u002Fcanary\u002F)。它是 Chrome 的开发者版本，支持 WebGPU 功能。\n\n    您可以通过分别在终端中尝试运行 `emcc`、`jekyll` 和 `wasm-pack` 来验证是否成功安装。\n\n    接下来，准备 Web 构建所需的所有依赖项：\n    ```shell\n    .\u002Fscripts\u002Fprep_deps.sh\n    ```\n    \n    现在，我们可以将模型构建为 WebGPU 后端，并以 WebAssembly 文件格式导出可执行文件：\n    ```shell\n    python3 build.py --target webgpu\n    ```\n\n    最后一步是设置站点：\n    ```shell\n    .\u002Fscripts\u002Flocal_deploy_site.sh\n    ```\n\n    站点搭建完成后，您可以在 Chrome Canary 中访问 `localhost:8888\u002F`，在本地机器上试用演示。请务必使用以下命令启动 Chrome Canary，以关闭 Chrome 的健壮性检查：\n    ```shell\n    \u002FApplications\u002FGoogle\\ Chrome\\ Canary.app\u002FContents\u002FMacOS\u002FGoogle\\ Chrome\\ Canary --enable-dawn-features=disable_robustness\n    ```\n    \u003C\u002Fdetails>\n\u003C\u002Fdetails>\n\n## 怎么做？\n\n这里的关键技术是机器学习编译（MLC）。我们的解决方案建立在开源生态系统的肩膀之上，包括 PyTorch、Hugging Face diffusers 和 tokenizers、Rust、Wasm 以及 WebGPU。主要流程基于 Apache TVM Unity 构建，这是 [Apache TVM](https:\u002F\u002Fgithub.com\u002Fapache\u002Ftvm) 中一项令人振奋的持续开发工作。\n\n- 我们从 Hugging Face 的 diffuser 库中获取 [Runway 的稳定扩散 v1-5](https:\u002F\u002Fhuggingface.co\u002Frunwayml\u002Fstable-diffusion-v1-5\u002Ftree\u002Fmain) 模型。\n- 我们使用 [TorchDynamo](https:\u002F\u002Fpytorch.org\u002Ftutorials\u002Fintermediate\u002Fdynamo_tutorial.html) 和 [Torch FX](https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Ffx.html) 将关键模型组件捕获为 TVM 中的 IRModule。\n- TVM 的 IRModule 中的每个函数都可以进一步转换并生成可运行的代码，这些代码可以在任何支持最小 TVM 运行时的环境中通用部署（JavaScript 就是其中之一）。\n- 我们使用 [TensorIR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2207.04296) 和 [MetaSchedule](https:\u002F\u002Farxiv.org\u002Fabs\u002F2205.13603) 来构建自动化方案以生成优化后的程序。这些转换会在特定设备上通过原生 GPU 运行时进行调优，然后用于生成优化的 GPU 着色器。我们提供一个记录这些转换的数据库，以便在无需再次调优的情况下完成新的构建。\n- 我们构建了静态内存规划优化，以实现跨多层的内存复用。\n- 我们使用 [Emscripten](https:\u002F\u002Femscripten.org\u002F) 和 TypeScript 构建了一个 TVM Web 运行时，用于部署生成的模块。\n- 我们还利用了来自 Hugging Face 的 [rust tokenizers 库](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftokenizers) 的 [Wasm 移植版](https:\u002F\u002Fblog.mithrilsecurity.io\u002Fporting-tokenizers-to-wasm\u002F)。\n\n![工作流](site\u002Fimg\u002Ffig\u002Fworkflow.svg)\n\n这个工作流的所有部分都是用 Python 完成的，当然，最后一部分除外——它构建了一个约 400 行的 JavaScript 应用程序来将各个部分连接起来。这也是一个有趣的交互式开发过程，可以不断引入新模型。\n\n这一切都得益于我们所依赖的开源生态系统。特别是，我们大量使用了 [TVM Unity](https:\u002F\u002Fdiscuss.tvm.apache.org\u002Ft\u002Festablish-tvm-unity-connection-a-technical-strategy\u002F13344)，这是 TVM 项目中一项令人兴奋的最新进展，它支持这种以 Python 为主导的交互式 MLC 开发体验，使我们能够轻松地用 Python 组合新的优化方法，并逐步将我们的应用推向 Web 平台。TVM Unity 还提供了一种简便的方式，可以在生态系统中组合新的解决方案。例如，未来我们可以轻松地将其他 WebGPU 着色器生成器或着色器库引入到这个工作流中。\n\n## 与原生 GPU 运行时的对比、局限性及机遇\n\n除了 WebGPU 运行时之外，我们还提供了使用本地 GPU 运行时进行原生部署的选项。这些选项既可以作为在原生环境中部署的工具，也可以作为比较原生 GPU 驱动性能与 WebGPU 性能的参考点。\n\nWebGPU 通过将 WGSL（WebGPU 着色语言）着色器转换为原生着色器来工作。因此，理论上，WebGPU 运行时与原生环境之间可以实现零差距。然而，如果我们直接使用 Chrome 在 Apple Silicon 上查看当前演示，会发现性能下降了约 3 倍。这是因为 Chrome 的 WebGPU 实现会对所有数组索引访问插入边界检查，例如将 `a[i]` 替换为 `a[min(i, a.size)]`。理想情况下，下游的着色器编译器应该能够优化掉这些边界检查，但遗憾的是，目前并未做到。随着 WebGPU 实现的逐渐成熟，能够更好地检查索引访问范围并移除此类检查后，这一差距将会得到解决。\n\n您可以通过使用特殊标志启动 Chrome 来绕过这个问题（感谢 Dawn 开发人员提供的提示），即完全退出 Chrome，然后在命令行中输入：\n```shell\n\u002Fpath\u002Fto\u002Fchrome-canary --enable-dawn-features=disable_robustness\n```\n这样您就会发现执行速度与原生 GPU 环境一样快。我们预计随着 WebGPU 的成熟，这个问题将会得到解决。\n\n我们正目睹一场我们认为即将爆发的变革的曙光。WebGPU 仍在不断发展（尽管今年已接近正式发布），目前仅可通过 Chrome Canary 使用，且可能不够稳定。它仍然存在一些限制，比如仅支持 FP32（FP16 着色器扩展已在规范中提出，但尚未实现）。这里的稳定扩散模型需要配备具有足够显存的 GPU（至少 8GB）。到目前为止，我们只在 Apple Silicon 上测试过我们的解决方案。此外，还有机会支持诸如 [FlashAttention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2205.14135) 和量化等高级优化技术，以进一步提升系统性能。\n\n这些都为当前解决方案带来了数倍的性能提升机会。我们相信其中许多问题在不久的将来都能够得到解决。即使只是该解决方案中的单个组件，也仍然具有实用价值。例如，用户可以选择仅部署模型的文本编码器部分。此外，同样的以 Python 为主导的开发和通用部署流程也可以用于将机器学习模型引入其他环境，比如新型硬件或移动设备。最后，相同的机器学习编译堆栈也可用于服务器级应用场景，从而优化服务器工作负载。\n\n## 致谢\n\n本项目得以实现，离不开以下机构的合作：\n\n\u003Ca href=\"https:\u002F\u002Fwww.scs.cmu.edu\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_readme_6a7fea1277bb.png\" alt=\"CMU 计算机科学学院\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fcatalyst.cs.cmu.edu\">\n\u003Cimg src=\"site\u002Fimg\u002Flogo\u002Fcatalyst.svg\" alt=\"Catalyst\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fmlc.ai\">\n\u003Cimg src=\"site\u002Fimg\u002Flogo\u002Fmlc-logo-with-text-landscape.svg\" alt=\"MLC\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Foctoml.ai\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_readme_7b88e1cab409.png\" alt=\"OctoML\" height=\"50\"\u002F>\n\u003C\u002Fa>\n\n本项目之所以能够实现，完全归功于我们所依托的开源生态系统。我们要感谢 Apache TVM 社区以及 TVM Unity 项目的开发者们。同时也要感谢那些公开提供这些模型的开源机器学习社区成员，以及让这些模型易于获取的 PyTorch 和 Hugging Face 社区。此外，还要感谢 Mithril Security 对分词器 Wasm 移植工作的贡献。我们也感谢 WebAssembly、Emscripten、Rust 和 WebGPU 社区的支持。最后，特别感谢 Dawn 开发人员，他们及时解答了我们在使用 Chrome 时遇到的问题。","# Web Stable Diffusion 快速上手指南\n\nWeb Stable Diffusion 是一个开创性的开源项目，它让 Stable Diffusion 模型能够完全在浏览器中运行，**无需任何服务器支持**。所有计算均在客户端（浏览器）通过 WebGPU 完成。\n\n## 环境准备\n\n### 系统要求\n*   **操作系统**: macOS (Apple Silicon 推荐), Linux, Windows\n*   **浏览器**: **Chrome Canary** (必须，用于启用 WebGPU 支持)\n*   **硬件**: 建议配备至少 **8GB 显存** 的 GPU。目前主要在 Apple Silicon 上经过充分测试。\n\n### 前置依赖\n请确保已安装以下工具：\n\n1.  **Python 环境**: 建议 Python 3.8+\n2.  **TVM Unity**: 机器学习编译后端\n3.  **Emscripten**: 用于将代码编译为 WebAssembly\n4.  **Rust & wasm-pack**: 用于构建分词器 (Tokenizer)\n5.  **Jekyll**: 用于搭建本地演示网站\n\n## 安装步骤\n\n### 1. 安装 TVM Unity\n你可以选择通过 pip 安装预编译包，或从源码构建（推荐高级用户）。\n\n**方式 A：使用 pip 安装 (推荐)**\n```shell\npip3 install mlc-ai-nightly -f https:\u002F\u002Fmlc.ai\u002Fwheels\n```\n\n**方式 B：从源码构建**\n```shell\ngit clone --recursive https:\u002F\u002Fgithub.com\u002Fapache\u002Ftvm tvm\ncd tvm\ngit checkout origin\u002Funity\n# 后续请参考 TVM 官方文档进行编译配置\n```\n\n### 2. 安装 Web 构建工具链\n按照以下顺序安装必要的环境工具：\n\n*   **Emscripten**: 下载并安装最新版的 `emsdk`，然后激活环境：\n    ```shell\n    source path\u002Fto\u002Femsdk_env.sh\n    ```\n    *(验证：终端输入 `emcc` 应能正常响应)*\n\n*   **Rust**: 访问 [rust-lang.org](https:\u002F\u002Fwww.rust-lang.org\u002Ftools\u002Finstall) 安装。\n\n*   **wasm-pack**:\n    ```shell\n    curl https:\u002F\u002Frustwasm.github.io\u002Fwasm-pack\u002Finstaller\u002Finit.sh -sSf | sh\n    ```\n\n*   **Jekyll 及相关插件**:\n    ```shell\n    gem install jekyll\n    gem install jekyll-remote-theme\n    ```\n    *(验证：终端输入 `jekyll` 和 `wasm-pack` 应能正常响应)*\n\n*   **Chrome Canary**: 下载并安装 [Google Chrome Canary](https:\u002F\u002Fwww.google.com\u002Fchrome\u002Fcanary\u002F)。\n\n### 3. 准备依赖与构建模型\n克隆本项目后，执行以下命令：\n\n**步骤 A: 准备 Web 构建依赖**\n```shell\n.\u002Fscripts\u002Fprep_deps.sh\n```\n\n**步骤 B: 构建模型 (针对 WebGPU)**\n默认构建目标为 `apple\u002Fm2-gpu`，若需部署到网页，请指定 `webgpu`：\n```shell\npython3 build.py --target webgpu\n```\n*(注：若仅需在本地原生环境测试，可使用 `--target cuda` 或不加参数)*\n\n**步骤 C: 搭建本地演示站点**\n```shell\n.\u002Fscripts\u002Flocal_deploy_site.sh\n```\n\n## 基本使用\n\n### 1. 启动演示服务\n运行上述 `local_deploy_site.sh` 脚本后，本地服务器将启动。\n\n### 2. 启动浏览器\n**重要**：必须使用特殊参数启动 Chrome Canary 以禁用鲁棒性检查，否则性能会大幅下降（约慢 3 倍）。\n\n在终端执行以下命令启动浏览器（macOS 示例）：\n```shell\n\u002FApplications\u002FGoogle\\ Chrome\\ Canary.app\u002FContents\u002FMacOS\u002FGoogle\\ Chrome\\ Canary --enable-dawn-features=disable_robustness\n```\n*(Windows\u002FLinux 用户请替换为对应的 Chrome Canary 可执行文件路径)*\n\n### 3. 生成图像\n1.  在浏览器中访问 `http:\u002F\u002Flocalhost:8888\u002F`。\n2.  在文本框中输入提示词（Prompt），例如：\n    ```text\n    A photo of an astronaut riding a horse on mars.\n    ```\n3.  点击生成按钮，即可在浏览器端直接看到由 GPU 加速生成的图像。\n\n### 4. 命令行本地测试 (可选)\n如果不通过浏览器，也可以直接在本地原生 GPU 环境下测试生成的模型：\n\n```shell\npython3 deploy.py --prompt \"A photo of an astronaut riding a horse on mars.\"\n```\n支持添加负面提示词：\n```shell\npython3 deploy.py --prompt \"...\" --negative-prompt \"blurry, low quality\"\n```","一家初创设计团队希望在其在线营销工具中集成\"AI 海报生成”功能，让中小商家无需离开网页即可定制宣传图。\n\n### 没有 web-stable-diffusion 时\n- **高昂的服务器成本**：团队必须租赁昂贵的 GPU 云服务器来运行庞大的 Stable Diffusion 模型，随着用户量增加，算力账单呈指数级增长。\n- **复杂的运维架构**：需要搭建专门的后端 API 服务来处理图像生成请求，并解决高并发下的排队拥堵问题，开发周期长且维护困难。\n- **隐私与延迟顾虑**：用户上传图片或输入创意时需传输至云端，存在数据泄露风险；同时网络往返导致生成等待时间过长，体验流畅度差。\n- **硬件依赖受限**：后端环境必须严格匹配特定的深度学习框架和 GPU 驱动版本，部署灵活性极低，难以快速迭代。\n\n### 使用 web-stable-diffusion 后\n- **零服务器算力支出**：利用 WebGPU 技术将模型推理完全迁移至用户浏览器本地运行，彻底消除了服务端的 GPU 租赁成本。\n- **极简的前端部署**：无需构建复杂的后端推理服务，只需将优化后的模型文件嵌入网页，通过标准的 Web 技术栈即可直接交付功能。\n- **数据隐私与即时响应**：所有计算在用户设备本地完成，原始数据不出域，极大提升了安全性；同时消除了网络传输延迟，生成速度仅受限于本地显卡性能。\n- **跨平台无缝兼容**：借助 WebAssembly 和统一的运行时环境，该方案可自动适配不同操作系统和设备，无需为特定硬件单独维护后端环境。\n\nweb-stable-diffusion 通过将重型 AI 模型原生带入浏览器，不仅大幅降低了企业的运营门槛，更重新定义了隐私安全且低延迟的 Web AI 交互体验。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmlc-ai_web-stable-diffusion_c9f53faf.png","mlc-ai","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmlc-ai_a1be60ad.jpg",null,"https:\u002F\u002Fgithub.com\u002Fmlc-ai",[77,81,85,89,93],{"name":78,"color":79,"percentage":80},"Jupyter Notebook","#DA5B0B",76.2,{"name":82,"color":83,"percentage":84},"Python","#3572A5",20.6,{"name":86,"color":87,"percentage":88},"JavaScript","#f1e05a",2.6,{"name":90,"color":91,"percentage":92},"HTML","#e34c26",0.3,{"name":94,"color":95,"percentage":92},"Shell","#89e051",3720,234,"2026-04-16T08:10:21","Apache-2.0",4,"macOS, Windows, Linux","WebGPU 运行需支持 WebGPU 的浏览器（如 Chrome Canary）及独立显卡；本地原生运行支持 Apple Silicon (M2) 或 NVIDIA CUDA GPU。显存需求至少 8GB。","未说明（建议 8GB+ 以容纳模型）",{"notes":105,"python":106,"dependencies":107},"1. 核心特性：模型完全在浏览器端运行，无需服务器支持。2. 浏览器要求：必须使用支持 WebGPU 的浏览器（目前主要为 Chrome Canary），且启动时需添加 '--enable-dawn-features=disable_robustness' 参数以获得最佳性能。3. 构建工具链：除了 Python 依赖外，还需安装 Emscripten (编译 C\u002FC++ 到 WebAssembly)、Rust 及 wasm-pack (用于分词器)、Jekyll (用于搭建演示网站)。4. 模型来源：基于 Runway 的 stable-diffusion-v1-5 模型。5. 局限性：目前 WebGPU 仅支持 FP32 精度，且主要在 Apple Silicon 上进行了测试。","3.x (文中使用 python3 命令，未指定具体小版本)",[108,109,110,111,112,113,114,115],"mlc-ai-nightly (TVM Unity)","PyTorch","Hugging Face Diffusers","Hugging Face Tokenizers","Emscripten","Rust","wasm-pack","Jekyll",[14,15],[118,119,120,121,122,123],"webgpu","deep-learning","stable-diffusion","web-assembly","webml","tvm","2026-03-27T02:49:30.150509","2026-04-20T04:05:16.590374",[127,132,137,142,147,152],{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},43476,"运行 build.py 时遇到 'IRModule contains duplicate global symbol: main' 错误怎么办？","该错误通常与环境配置或缓存冲突有关。建议尝试以下步骤：\n1. 清除构建缓存，使用 `--use-cache=0` 参数重新追踪模型。\n2. 确保依赖包版本正确，直接使用 `pip install -r requirements.txt` 安装所有依赖。\n3. 检查 Python 环境是否干净，避免不同版本的 TVM 或 PyTorch 冲突。\n如果问题依旧，请提供完整的 `pip list` 输出以便进一步排查。","https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fissues\u002F62",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},43477,"遇到 'AssertionError: Unsupported function type position_ids' 错误如何解决？","此问题是由于 PyTorch Dynamo 对某些算子支持不完善导致的。解决方案如下：\n1. 升级或降级 PyTorch 版本，建议尝试使用 `torch 2.0.0`。\n2. 该问题已在 TVM 上游修复，参考 PR: https:\u002F\u002Fgithub.com\u002Fapache\u002Ftvm\u002Fpull\u002F16690，确保你使用的 TVM 版本包含此修复。\n3. 如果无法立即升级，可以尝试在代码中绕过涉及 `position_ids` 的动态图捕获部分。","https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fissues\u002F54",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},43478,"在 CUDA 目标上进行 MetaSchedule 调优时出现 'Did you forget to bind?' 警告或错误？","这通常与调优参数配置不当有关。建议调整 `max_trials_global` 和 `max_trials_per_task` 参数：\n1. 对于大规模调优，尝试将 `max_trials_global` 设为 10000，`max_trials_per_task` 设为 2000。\n2. 如果是快速测试，可以将 `max_trials_global` 降至 100，`max_trials_per_task` 降至 2，并设置 `cooldown_sec=0` 以加快进程。\n3. 确保使用 `ms.relax_integration.tune_relax` 而非旧的 `tune_tir` 接口（视具体版本而定）。\n示例配置代码：\n```python\nlocal_runner = ms.runner.LocalRunner(cooldown_sec=0, timeout_sec=60)\ndatabase = ms.relax_integration.tune_relax(\n    mod=mod,\n    target=target,\n    work_dir=\"workdir\",\n    max_trials_global=100,\n    max_trials_per_task=2,\n    runner=local_runner,\n    params={}\n)\n```","https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fissues\u002F43",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},43479,"更新后运行时报错 'JSONReader: cannot find field purity' 是什么原因？","这是因为新引入的 `purity` 标志未包含在旧的日志数据库（log_db）中。解决方法：\n1. 项目维护者已在 PR #42 中修复了数据库结构，请拉取最新代码并重新构建。\n2. 如果仍需手动生成调优记录，请使用最新的脚本重新运行自动调优流程，以生成包含 `purity` 字段的新数据库文件。\n3. 删除旧的 `database_tuning_record.json` 和 `database_workload.json` 文件，避免读取过时数据。","https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fissues\u002F40",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},43480,"在 Windows 或 Android 上运行时提示 'maxStorageBufferBindingSize exceeds limit' 错误怎么办？","该错误表示请求的存储缓冲区大小（默认 1024MB）超过了浏览器或驱动的限制（如 128MB）。解决方法：\n1. 目前 WebGPU 在某些平台（如 Windows Chrome Canary 或部分 Android 设备）上对大内存支持有限。\n2. 尝试启动浏览器时添加参数 `--enable-dawn-features=disable_robustness`（虽然部分用户反馈无效，但仍值得尝试）。\n3. 等待浏览器驱动更新以支持更大的 `maxStorageBufferBindingSize`，或在代码中修改模型配置以减少显存需求（如果项目支持量化或切片加载）。\n4. 考虑在其他支持更好显存管理的设备（如 macOS Metal 或 Linux + NVIDIA）上运行。","https:\u002F\u002Fgithub.com\u002Fmlc-ai\u002Fweb-stable-diffusion\u002Fissues\u002F35",{"id":153,"question_zh":154,"answer_zh":155,"source_url":146},43481,"如何在移动设备（如手机）上部署和自动调优 Stable Diffusion v1.5 模型？","要在移动设备上部署，需针对特定后端进行自动调优：\n1. 参考 Issue #39 中的指南，使用 `ms.relax_integration.tune_relax` 针对目标设备（如 Vulkan 或 Metal）生成调优记录。\n2. 设置合适的 `target` 参数，例如针对 Android 可使用 `llvm -device=mali` 或 `vulkan`。\n3. 将生成的 `database_tuning_record.json` 和模型权重文件部署到移动端。\n4. 注意移动端显存限制，可能需要启用模型量化或使用更小的变体（如 SD-Turbo）。\n维护者建议在真机上测试构建后的版本以确保兼容性。",[]]