psiddh's picture
Add ExecuTorch WebGPU program for qwen3-0.6b
65fa8ec verified
|
Raw History Blame Contribute Delete
4.45 kB
---
license: apache-2.0
base_model:
- Qwen/Qwen3-0.6B
base_model_relation: quantized
library_name: executorch
pipeline_tag: text-generation
inference: false
tags:
- executorch
- webgpu
- on-device
- browser
---
# Qwen3 0.6B for ExecuTorch WebGPU
This repository contains an [ExecuTorch](https://github.com/pytorch/executorch) conversion of
[Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) for the ExecuTorch **WebGPU** backend, so the model runs entirely in a web browser on
the visitor's GPU. It powers the corresponding demo in the ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)).
- **Base model:** [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B)
- **Format:** ExecuTorch `.pte` programs delegated to the WebGPU backend
- **Quantization:** 4-bit groupwise weights (q4gsw), fp16 KV cache
- **Total size:** 397.1 MB
## About the original model
A 0.6B-parameter dense causal language model from the Qwen3 family, with a thinking mode for multi-step reasoning and a non-thinking mode for fast chat.
- **Developed by:** Qwen Team, Alibaba Cloud
- **Paper:** [Qwen3 Technical Report](https://arxiv.org/abs/2505.09388)
- 0.6B parameters, 28 layers
- Context length 32,768 tokens
- Supports 100+ languages and dialects
For training data, evaluation results and full details, see the original model card: [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B).
## Intended use and limitations
General chat, instruction following and multilingual text generation.
Small language models can state false information confidently, repeat themselves, and reflect biases in their training data. Check important outputs. See the upstream card for best-practice sampling settings.
## What changed in this conversion
- Weights quantized to 4-bit groupwise (q4gsw); the KV cache is fp16
- Context capped at 8,960 tokens (upstream: 32,768)
- The playground uses non-thinking mode by default
## Inputs and outputs
- `forward(tokens int64 [1, 1..512], input_pos int64 [1]) -> logits float32 [1, 151936]` (last position only)
- The KV cache lives inside the program; call it with up to 512 new tokens at a time, then one token per step
- Tokenize with the files in `tokenizer/` (the upstream Qwen3 tokenizer) and the Qwen3 chat template
## Files
| File | Size | SHA-256 |
|---|---|---|
| `qwen3_0_6b_q4gsw.pte` | 382.0 MB | `057af5734a6ce17c…` |
| `tokenizer/config.json` | 726 B | `660db3b73d788119…` |
| `tokenizer/generation_config.json` | 239 B | `2325da0f15bb848e…` |
| `tokenizer/merges.txt` | 1.6 MB | `8831e4f1a0444713…` |
| `tokenizer/tokenizer.json` | 10.9 MB | `aeb13307a71acd8f…` |
| `tokenizer/tokenizer_config.json` | 9.5 KB | `d5d09f07b48c3086…` |
| `tokenizer/vocab.json` | 2.6 MB | `ca10d7e9fb3ed185…` |
Full checksums are in `manifest.json`. The playground verifies them after download.
## Running it
These programs were exported with the ExecuTorch WebGPU backend
([backends/webgpu](https://github.com/pytorch/executorch/tree/main/backends/webgpu)) and validated with the
WebAssembly runtime build used by the ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)). That runtime build is not published yet; until it is,
the playground is the supported way to run them. It downloads these files once, caches them in the browser,
and runs everything locally.
Requirements: a browser with WebGPU enabled. The language models use the `shader-f16` GPU feature when available and fall back to fp32 math without it.
## Provenance
- **Upstream:** `Qwen/Qwen3-0.6B` at revision `c1899de289a04d12100db370d81485cdf75e47ca` (official)
- **Exported with:** executorch 1.5.1+cpu, torch 2.14.1+cpu, torchao 0.18.0+cpu, transformers 5.19.0 (executorch git `3b6068392324`)
- **Reproduce:** `python recipes/qwen3-0.6b.py --out out/qwen3-0.6b` (recipe in `export/`)
- Re-running the recipe produces byte-identical files.
## Citation
If you use this model, please cite the original work:
```bibtex
@misc{qwen3technicalreport,
title={Qwen3 Technical Report},
author={Qwen Team},
year={2025},
eprint={2505.09388},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2505.09388}
}
```
## License
This is a derivative of the upstream model and is distributed under the same terms
(`apache-2.0`); see `LICENSE`.
Modifications (conversion to the ExecuTorch format and quantization) by Meta Platforms, Inc.