feat(xla): RWKV7 (WKV7 generalized delta kernel + token-shift state)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 8/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- pytorch, rust
- Lĩnh vực
- ai-infra-agents
Hướng nghiên cứu
Start with src/lib/mlxcel-xla/src/emitter/config.rs at from_json_str (around line 561), which currently rejects rwkv7, and the MLX reference src/models/rwkv7.rs. The WKV7 kernel goes in src/lib/mlxcel-xla/src/emitter/delta.rs or a new file, with state tensors wrapped in the existing threaded-state ABI. Done means the validate_arch.sh command on the 0.1B checkpoint exits 0 with CLI ids matching the MLX oracle, and goldens and lib tests pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Part of #564
Problem / Background
Epic #564 brings SSM / hybrid / recurrent architectures to the OpenXLA/IREE backend. Design record: spike/openxla/SSM_HYBRID_DESIGN.md (written 2026-07-01; most symbol locations it cites have moved, use the ones in this issue, which were re-located on main at 56bfb92a, and re-verify them before editing). The Stage 2a spike-first pattern this follows is in spike/openxla/STAGE2_DESIGN.md and spike/openxla/FINDINGS_phase2a.md.
RWKV7 is attention-free with its own WKV7 kernel (a generalized delta rule with a vector-valued in-context learning rate) and token-shift state for both the time-mix and channel-mix blocks. from_json_str (src/lib/mlxcel-xla/src/emitter/config.rs:561) rejects it. MLX reference: src/models/rwkv7.rs (loads model.layers.N.attn.x_r, the fla-hub HF layout).
Goal
RWKV7 generates and serves on hip, token-exact against the MLX eager oracle.
Scope
- Config
rwkv7withMixerKind::Rwkv7for every layer andhas_kv_cache() == false. - New WKV7 kernel (in
src/lib/mlxcel-xla/src/emitter/delta.rsor its own file) with step and chunked-prefill forms followingrwkv7.rs: per headS_t = S_{t-1} * diag(w_t) + (S_{t-1} a_t) b_t^T + v_t k_t^T,y_t = S_t r_t, in f32; padded rows leaveSand the shift states unchanged. - State tensors, in order:
wkv_s [L, H, hd, hd]F32,shift_attn [L, hidden]F32,shift_ffn [L, hidden]F32 (the previous token's normed input for each block). Prefill writes the shift states from rowreal_len - 1withdynamic_slice;real_len = 0leaves them at their inputs. - LoRA-style projections (
w,a,v,glow-rank),x_r/x_w/x_k/x_v/x_a/x_gmixing, group norm, value residual from layer 0, and channel-mix relu2 exactly asrwkv7.rs. - Weight names and
weight_specs_qin lock-step; goldens; synthetic tiny RWKV7 for an ignored test.
Threaded-state ABI (from #3338 / #3339 / #3340, unchanged): Config::state_tensors() lists StateTensorSpec { name, dims, elem }; prefill takes and returns them after the optional KV (absent here); single-sequence decode keeps them in util.globals seeded by @state_import; ragged decode takes and returns them at [B, ...]. The shim supports up to XLA_MAX_STATE = 8 tensors.
Acceptance Criteria
- Checkpoint: an fla-hub RWKV7 0.1B HF-format checkpoint (confirm the id) in
models/hf/rwkv7-0.1b. - Oracle: mlxcel MLX eager
rwkv7, greedy 40 tokens, in theoracle_continuation.pyJSON format. -
scripts/xla/validate_arch.sh --model models/hf/rwkv7-0.1b --device hip --oracle <json> --batch 4 --requests 8 --maxcap 24exits 0; CLI ids equal the oracle; server 4 concurrent completions equal their CLI outputs. - Goldens registered; previous goldens byte-identical; fmt, clippy, lib tests clean.
Host and environment
Host: ROCm gfx1151 (Strix Halo, 31 GiB unified memory), IREE hip and llvm-cpu / local-task. Every build and every GPU command runs under scripts/rocm_gpu_guard.sh --hold -- <cmd>.
eval "$(scripts/iree/setup-rocm.sh --env)"
export MLXCEL_XLA_DEVICE=hip MLXCEL_XLA_ROCM_TARGET=gfx1151
export OPENSSL_INCLUDE_DIR=/usr/include OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu CARGO_BUILD_JOBS=6
PY=spike/openxla/.venv/bin/python # or $MLXCEL_ORACLE_PYTHON
scripts/rocm_gpu_guard.sh --hold -- cargo build --release --features xla-iree --bin mlxcel --bin mlxcel-server
Dependencies
Blocked by #3340 (per-slot state carry). Blocks #3357, #3358.
Risks
validate_arch.shbuilds its oracle with HF; if--oracleis not honoured for skipping the HF step, add that in this PR.- WKV7 chunked prefill numerics; fall back to a smaller chunk if 5e-5 is not met.
User decisions that apply
- Downloads are allowed. If
spike/openxla/.venvis missing, create it withuv venv --python 3.12 spike/openxla/.venvand install CPU torch and transformers as pinned inspike/openxla/requirements.lock(torch==2.12.1+cpu from the PyTorch CPU wheel index, transformers==5.12.1). Small HF-format checkpoints go intomodels/hf/<name>; confirm the exact HF repo id on the model page before downloading. Gated-licence models are skipped and reported unless the licence is already accepted on this account. - Families whose HF modeling code cannot run on CPU (Kimi-Linear, RWKV7, and Plamo2 if its remote code needs
mamba_ssm/causal_conv1d) use mlxcel's own MLX eager model as the oracle, following the pattern of thexla-reference-diagnosticsfeature examples (Cargo.toml:125,:570-575): run the MLX model greedily at temperature 0 on the same prompt and record its token ids in theoracle_continuation.pyJSON format soxla_oracle_checkandxla_batch_benchconsume it unchanged. - Prefix-hash sharing: the recurrent state cannot be rebuilt from a token-prefix hash, so no recurrent model may use the prompt cache or APC on the XLA path. The guard and its test land in #3341; do not attach the prompt-cache store for a config whose
Config::has_recurrent_state()is true.
- Ngôn ngữ chính
- Rust
- Star
- 505
- Fork
- 81
- Merge trung bình
- 14 giờ 2 phút
- Pull request đã merge (30 ngày)
- 448
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của lablup/mlxcel
-
area:core priority:high status:ready type:security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:medium status:ready type:security
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:models modeltype:text priority:medium status:in-progress type:bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:models priority:low status:ready type:test
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:models modeltype:omni priority:medium status:ready type:bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của lablup/mlxcel
Issue tương tự
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Có thể đã có người làm @ealwanlee đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
psmux/psmux-plugins#47 ·
-
Link Checker ReportĐang mởautomated issue report
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
ratatui/awesome-ratatui#598 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
release
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
github/gh-aw-mcpg#17603 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
C-Bug S-Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bevyengine/bevy#26718 ·
Maintainer thường phản hồi trong vòng 2 ngày