Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
f1ac311
Declare and pin the dependencies: requirements files, VX_VERSION, z3
hiraditya Nov 20, 2026
708a3dd
THIRD_PARTY_NOTICES: the code that follows llama.cpp
hiraditya Nov 20, 2026
a27bafc
tests: broken copies of the decode attention parts, not to merge
hiraditya Nov 20, 2026
3657ac6
round: write the round attention parts in Vx, as the decode kernel is
hiraditya Nov 20, 2026
7780b4c
Merge pull request #85 from vx-lang/deps-notices
hiraditya Nov 20, 2026
5bc57df
Qwen3.6-35B-A3B: weight file version 2, converter, NumPy reference an…
hiraditya Nov 20, 2026
148546a
Qwen3.6-35B-A3B: load weight file version 2 into GPU memory
hiraditya Nov 20, 2026
2a21537
qwen app: the Gated DeltaNet of one token, for Qwen3.6 (#89)
hiraditya Nov 20, 2026
f4740e3
qwen app: the gated full attention of one token, for Qwen3.6 (#89)
hiraditya Nov 20, 2026
c183465
qwen app: conv of the DeltaNet as 4 taps for each channel in one row,…
hiraditya Nov 20, 2026
a86dc7e
qwen app: draft of the token loop of Qwen3.5/Qwen3.6, on the structs …
hiraditya Nov 20, 2026
63b1468
Merge pull request #90 from vx-lang/qwen36-reference
hiraditya Nov 20, 2026
55ee7c4
qwen app: run Qwen3.5 and Qwen3.6 models (arch 1 of weight file v2) e…
hiraditya Nov 20, 2026
45e71dc
qwen app: the prompt of Qwen3.5/Qwen3.6 in chunks (#89)
hiraditya Nov 20, 2026
27be85b
Merge pull request #91 from vx-lang/qwen36-loader
hiraditya Nov 20, 2026
8b12928
Merge pull request #92 from vx-lang/qwen36-deltanet
hiraditya Nov 20, 2026
be863cb
qwen app: flash attention for the prompt of Qwen3.5/Qwen3.6 (#89)
hiraditya Nov 20, 2026
6888edb
tokenizer: read the tokenizer of Qwen3.5 and Qwen3.6
hiraditya Nov 20, 2026
3dcbe09
tokenizer: refuse a Python with another Unicode version
hiraditya Nov 20, 2026
0f7c7ed
qwen app: the chat format of Qwen3.5/Qwen3.6, with --think (#89)
hiraditya Nov 20, 2026
8390803
qwen app: --draft for Qwen3.5/Qwen3.6 (#89)
hiraditya Nov 20, 2026
0ba9521
qwen app: run the app with vxc -O2
hiraditya Nov 20, 2026
98d32b6
qwen app: --prompt-runs and --ignore-eos for the benchmark runner (#89)
hiraditya Nov 20, 2026
3945b0a
Prefill products: skip the multiplies of a half tile of padding (#89)
hiraditya Nov 20, 2026
413e932
Prefill products: skip the multiplies of padding by 8 tokens (#89)
hiraditya Nov 20, 2026
3ee766d
Prefill of Qwen3.6: the router in the fast kernel, SiLU of live rows …
hiraditya Nov 20, 2026
3d56b14
Prefill of Qwen3.6: dense Q4_0 products in blocks of 64 tokens (#89)
hiraditya Nov 20, 2026
6992d3d
Merge pull request #93 from vx-lang/qwen36-tokenizer
hiraditya Nov 21, 2026
1f3cd29
ci: give the tests 60 minutes
hiraditya Nov 21, 2026
61a4635
Merge pull request #100 from vx-lang/ci-test-time-limit
hiraditya Nov 21, 2026
cbba4e5
ci: test again with the time limit of main
hiraditya Nov 21, 2026
86e7cb3
ci: test again with the time limit of main
hiraditya Nov 21, 2026
713f1e5
Merge pull request #95 from vx-lang/qwen36-flash-attention
hiraditya Nov 21, 2026
e078b81
Merge pull request #96 from vx-lang/vxc-o2
hiraditya Nov 21, 2026
8271f9e
ci: test again with the time limit of main
hiraditya Nov 21, 2026
f69f313
Merge pull request #97 from vx-lang/qwen36-bench-options
hiraditya Nov 21, 2026
f0b28dc
ci: test again with the time limit of main
hiraditya Nov 21, 2026
8ecf359
qwen app: compile the prompt kernels of Qwen3.6 before the first cloc…
hiraditya Nov 21, 2026
fa8bfcc
Merge pull request #98 from vx-lang/qwen36-experts
hiraditya Nov 21, 2026
7c4c9aa
benchmark: a runner for Qwen3.6 against llama.cpp, as the benchmarkin…
hiraditya Nov 20, 2026
04024cc
benchmark: check the text of every draft run, and drop llama-lookup
hiraditya Nov 20, 2026
5a9aadc
benchmark: date the folder of the Qwen3.6 benchmark
hiraditya Nov 21, 2026
8e0be8c
benchmark: let llama-speculative-simple read prompts of more than 2,0…
hiraditya Nov 21, 2026
9fde977
benchmark: count the llama.cpp runs with drafts whose text differs
hiraditya Nov 21, 2026
0be9d57
benchmark: show the speedup of the llama.cpp drafts in the summary
hiraditya Nov 21, 2026
eb3fa07
benchmark: check that the two weight files hold the same model
hiraditya Nov 21, 2026
7cf911a
benchmark: the results of Qwen3.6-35B-A3B against llama.cpp on an M4
hiraditya Nov 21, 2026
7bdae33
Merge pull request #102 from vx-lang/qwen36-benchmark
hiraditya Nov 21, 2026
c1b1a66
Merge pull request #104 from vx-lang/qwen36-warm-kernels
hiraditya Nov 21, 2026
5487a52
qwen app: a draft rule for Qwen3.5/Qwen3.6 (#89)
hiraditya Nov 21, 2026
99967df
qwen35: run the shared expert at the same time as the router
hiraditya Nov 22, 2026
fb030aa
convert: write the MTP layer of Qwen3.6-35B-A3B
hiraditya Nov 22, 2026
63e9ded
qwen app: drafts from the MTP layer of Qwen3.6 (--mtp K)
hiraditya Nov 22, 2026
fecb2e3
rounds: the attention of all positions of a round at once
hiraditya Nov 22, 2026
123478d
rounds: lm_head of 4 positions in each block
hiraditya Nov 22, 2026
a9ae809
rounds: lm_head of the rows that can be the greedy token
hiraditya Nov 23, 2026
9cf9895
docs/optimizations.md: entry 16, drafts from the MTP layer
hiraditya Nov 23, 2026
a87d35c
docs/optimizations.md: entry 17, the attention and lm_head of a round
hiraditya Nov 23, 2026
b14bd86
Merge qwen36-rows (docs entry 17) into qwen36-pick
hiraditya Nov 23, 2026
4c02a06
docs/optimizations.md: entry 18, the lm_head of a round
hiraditya Nov 23, 2026
90dfa78
Merge pull request #107 from vx-lang/qwen36-draft-rule
hiraditya Nov 23, 2026
c55e89b
Merge pull request #108 from vx-lang/qwen36-overlap
hiraditya Nov 23, 2026
af19315
Merge main (#107, #108) into this branch
hiraditya Nov 23, 2026
97ae9db
Merge main (#107, #108) into this branch
hiraditya Nov 23, 2026
1b87d8f
Merge qwen36-rows (main with #107, #108) into qwen36-pick
hiraditya Nov 23, 2026
9367319
Merge pull request #109 from vx-lang/qwen36-mtp
hiraditya Nov 23, 2026
abdd41e
Merge main (#109) into qwen36-rows
hiraditya Nov 23, 2026
2020fe9
Merge qwen36-rows (main with #109) into qwen36-pick
hiraditya Nov 23, 2026
09b01e4
Merge pull request #110 from vx-lang/qwen36-rows
hiraditya Nov 23, 2026
8494805
qwen app: the MTP rows after a round in one pass
hiraditya Nov 22, 2026
931b96e
qwen app: a second length of MTP drafts (--mtp K,L)
hiraditya Nov 23, 2026
9ac308b
docs/optimizations.md: entry 16, the MTP rows in one pass and --mtp K,L
hiraditya Nov 23, 2026
e91c157
Merge pull request #112 from vx-lang/qwen36-mtp-catchup
hiraditya Nov 23, 2026
99aaa08
Merge pull request #111 from vx-lang/qwen36-pick
hiraditya Nov 23, 2026
0c773e4
qwen app: drafts from the context in --mtp rounds (--draft D[,M] with…
hiraditya Nov 24, 2026
b7d48d6
qwen app: drafts from the context in --mtp rounds need a match of 16
hiraditya Nov 24, 2026
f33743d
docs: entry 19 and the README, drafts from the context with --mtp
hiraditya Nov 25, 2026
730f1b7
docs/optimizations.md: the PR number of entry 19
hiraditya Nov 25, 2026
4b92449
Give each function the level that its callers need, for the private f…
hiraditya Nov 25, 2026
473a0df
README: a short page, with the details in docs/
hiraditya Nov 26, 2026
44a5ba9
Benchmark of 2026-11-25: qwen-vx with MTP drafts against llama.cpp
hiraditya Nov 26, 2026
f8e0e9d
Merge pull request #115 from vx-lang/qwen36-readme
hiraditya Nov 26, 2026
6366da5
Merge pull request #116 from vx-lang/qwen36-benchmark-mtp
hiraditya Nov 26, 2026
dec965c
Merge pull request #113 from vx-lang/qwen36-mtp-context
hiraditya Nov 26, 2026
58c5887
Merge remote-tracking branch 'origin/main' into vx-rights
hiraditya Nov 27, 2026
341f91b
qwen app: main takes Root, and opens files and prints only with its r…
hiraditya Nov 27, 2026
792e64e
Test with Vx v0.0.6, which has private functions and pkg
hiraditya Nov 27, 2026
5c412d6
Merge branch 'vx-root-and-visibility' into vx-rights
hiraditya Nov 27, 2026
5f0e073
Merge vx-rights (#117) into vx-attention-merge-2, for Vx v0.0.6
hiraditya Nov 29, 2026
d8b7f20
Merge the #86 branch for Vx v0.0.6, and use the functions of src/simd.vx
hiraditya Nov 29, 2026
17380c7
tests: broken copies of the decode attention parts, not to merge
hiraditya Nov 29, 2026
49d2587
Keep the old #88 commit in the history, so that the branch moves on w…
hiraditya Nov 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ permissions:
jobs:
test:
runs-on: macos-15
# A run takes 5 to 8 minutes. A test that hangs stops here, not at the limit of 6 hours.
timeout-minutes: 30
env:
# The oldest release that has every std::nn kernel that the program calls.
VX_VERSION: v0.0.5
# With the tests of Qwen3.6, a run takes more than 30 minutes: a RUN line that compiles the app
# takes 90 to 115 s on this runner. A test that hangs stops here, not at the limit of 6 hours.
timeout-minutes: 60
steps:
- uses: actions/checkout@v7

# The file VX_VERSION names the Vx release that the program is tested with. The toolchain
# needs LLVM 22 and z3 on macOS.
- name: Install Vx
run: |
brew install --quiet llvm@22 z3
curl -fsSL https://vxlang.org/install.sh | VX_NO_MODIFY_PATH=1 sh
~/.vx/current/bin/vxc --version
version=$(cat VX_VERSION)
curl -fsSL https://vxlang.org/install.sh | VX_VERSION="$version" VX_NO_MODIFY_PATH=1 sh
~/.vx/current/bin/vxc --version | grep -F "vxc ${version#v} "

# The system Python of the runner takes no packages, so they go in a venv.
- name: Install the Python packages
run: |
python3 --version
python3 -m venv "$RUNNER_TEMP/venv"
"$RUNNER_TEMP/venv/bin/pip" install --quiet numpy ml_dtypes filecheck
"$RUNNER_TEMP/venv/bin/pip" install --quiet -r requirements-test.txt

- name: Test
run: PATH="$RUNNER_TEMP/venv/bin:$PATH" tests/run.sh
547 changes: 79 additions & 468 deletions README.md

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions THIRD_PARTY_NOTICES
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Third-party notices
===================

The code of this repository is under the Apache License v2.0 with LLVM Exceptions (LICENSE).
Some of it follows the design of code from other projects. This file lists each such piece, the
files that hold it, and the license of the project that it comes from.

The repository has no copy of another project's source files. The pieces below are written anew in
Vx, in MLIR that a script of this repository prints, or in Python, after the design of the named
upstream code. The upstream commit that each design was read from was not recorded.


1. llama.cpp (https://github.com/ggml-org/llama.cpp), MIT License
-----------------------------------------------------------------

| Files | Follows |
| --- | --- |
| src/attention.vx (vec_attention), scripts/mlir_kernels/decode_attention.py | kernel_flash_attn_ext_vec and kernel_flash_attn_ext_vec_reduce, in ggml/src/ggml-metal/ggml-metal.metal of older releases and ggml/src/ggml-metal/kernels/fa_vec_*.metal in v1.0.0 |
| src/round.vx (round_attention), scripts/mlir_kernels/round_attention.py | the same kernels, for several queries in a row |
| src/prefill.vx (the attention of the prompt), scripts/mlir_kernels/flash_attention.py | kernel_flash_attn_ext, ggml/src/ggml-metal/kernels/fa_common.metal |
| src/prefill.vx (pf_mm_q4_set), scripts/mlir_kernels/expert_product.py | kernel_mul_mm_id, ggml/src/ggml-metal/kernels/mul_mm.metal |
| src/products.vx | the shape of a block of kernel_mul_mv_q4_0_f32 (2 SIMD groups of 4 rows), ggml/src/ggml-metal/kernels/mul_mv.metal |
| scripts/qwen_weights.py (Q4_0 codes) | the rounding of quantize_row_q4_0_ref and the search of quantize_row_q4_0_impl, ggml/src/ggml-quants.c |

The Q4_0 format itself (a 4-bit code and an f16 scale for each 32 weights, a weight being
(code - 8) times the scale) is the Q4_0 of llama.cpp.

The license of llama.cpp:

MIT License

Copyright (c) 2023-2026 The ggml authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


2. Model weights and tokenizers
-------------------------------

The repository has no model weights and no tokenizer files. scripts/convert.py and
scripts/convert_tokenizer.py make the files that the program reads from a model of Hugging Face.
Each model has its own license, on its model card. The tests make tiny random models with
scripts/make_tiny_model.py and scripts/make_tiny_tokenizer.py.
1 change: 1 addition & 0 deletions VX_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.6
2 changes: 1 addition & 1 deletion decode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Qwen3-Coder-30B-A3B in Q4_0 on an M4 with 32 GB.
## Run them

```sh
vxc decode/profile_decode.vx --package qwen=src --host default \
vxc -O2 decode/profile_decode.vx --package qwen=src --host default \
--machine ~/.vx/current/fleet/m4-uma.vx -- qwen3-30b-q4.vxw

clang -O2 -fobjc-arc -framework Foundation -framework Metal decode/bandwidth.m -o bandwidth
Expand Down
8 changes: 5 additions & 3 deletions decode/profile_decode.vx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// out, after a warm-up. `skip` is a mask of the parts to leave out. The results of a run with a
// part left out are wrong, but its time shows the cost of that part. See README.md.
//
// vxc decode/profile_decode.vx --package qwen=src --host default \
// vxc -O2 decode/profile_decode.vx --package qwen=src --host default \
// --machine ~/.vx/current/fleet/m4-uma.vx -- qwen3-30b-q4.vxw
import core::convert;
import std::nn;
Expand All @@ -19,6 +19,8 @@ import qwen::attention;
import qwen::weights;
import qwen::model;
import qwen::prefill;
import std::root;
import std::string;

const NORMS : i32 = 1;
const QKV : i32 = 2;
Expand Down Expand Up @@ -148,8 +150,8 @@ fn print_part(m : i32, t : f64, part : f64) -> void {
return;
}

fn main(argc : i32, argv : *mut *mut i8) -> i32 {
let w = load_weights(unsafe { argv[1] });
fn main(root : Root, args : Vec<String>) -> i32 {
let w = load_weights(&root.files, args.get_ref(1));
assert(w.config.num_experts > 0 && w.layers[0].gate_up.dtype == U4, "give the Q4_0 file of the 30B MoE model");
let mut s = new_state(&w.config, 2048);
let mut next = transfer(Tensor<i32>([1]), Memory::HBM);
Expand Down
2 changes: 2 additions & 0 deletions docs/benchmarks/2026-11-20-qwen36-m4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
logs/
__pycache__/
Loading
Loading