perf(metal): extend mlxcel_affine_qmm_t_rows to 4-row verify blocks on gen 13/14

Đang mở
#3,401 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
20/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cmake, cpp, rust

Hướng nghiên cứu

Read TECHNICAL_REPORTS/3400-qmv-wide-force-diagnostic-20261124.en.md, then dispatch_qmm_t in src/lib/mlxcelverse/overlays/metal/mlx/backend/metal/quantized.cpp:2349 and the use_mlxcel_qmm_rows gate at :622. Run the exactness probe in src/models/speculative_exactness.rs:311 with MLXCEL_QMV_WIDE=1, then benchmark interleaved verify ms and decode tok/s per docs/benchmarks.md. Done means byte-identical 4-row products reach mlxcel_affine_qmm_t_rows, faster verify, and updated src/lib/mlxcelverse/overlays/metal/README.md and src/lib/mlxcelverse/CMakeLists.txt if kept.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

platform:macos priority:low status:backlog type:performance

Problem

On Apple GPU generations 13 and 14 a block-4 MTP verify runs one qmv per row. In dispatch_qmm_t (src/lib/mlxcelverse/overlays/metal/mlx/backend/metal/quantized.cpp:2349), qmv_mma is disabled on Ultra parts, use_mlxcel_qmm_rows (:622) admits only M >= 5 && M <= 8, and affine qmv_wide is gen 15+. On an M1 Ultra with mlx-community/gemma-4-12b-it-4bit (revision 73bcf09) and mlx-community/gemma-4-12B-it-assistant-bf16, block 4, temperature 0, a verify round costs about 68 ms, about three classic steps (classic decode is about 43 tok/s). MTP reaches 50 tok/s on an enumeration prompt (acceptance 0.997) but 33 tok/s on prose (acceptance 0.52), slower than classic. See TECHNICAL_REPORTS/3400-qmv-wide-force-diagnostic-20261124.en.md.

Proposal

Lower the row floor of use_mlxcel_qmm_rows to 4 (try 2 and 3 if cheap), then measure. The comment at :622 records that the kernel beats qmv at 4 rows only for gate_up and from 6 rows for smaller projections, so a per-shape gate is an acceptable outcome.

Exactness risk: the overlay header says mlxcel_affine_qmm_t_rows reduces in a different order than qmv and shares the MLXCEL_QMV_WIDE switch for that reason. With the variable unset, a failing probe makes retry_without_qmv_wide (src/models/speculative_exactness.rs:311) pin the process narrow. That turns the rows kernel off, so the probe passes on per-row qmv with no speedup, and the 5-to-8-row batched decode kernel is lost for the process. If the probe fails, do not keep the range change alone. Either make the 4-row path order-preserving relative to qmv (see #1289), or close this issue with the numbers.

Acceptance Criteria

  • The exactness probe passes with MLXCEL_QMV_WIDE=1 (this skips the retry, so the new branch must itself be byte-identical), and the 4-row products are shown to reach mlxcel_affine_qmm_t_rows.
  • Verify ms per round and decode tok/s for unset vs changed, on enumeration and prose prompts, from interleaved runs.
  • A teacher-forced logit trace per docs/benchmarks.md ("Judging a change that moves the numbers"), including the reverted arm.
  • The change is kept only if the verify round gets faster.
  • A kept change is documented in the overlay header, src/lib/mlxcelverse/overlays/metal/README.md, and the overlay note in src/lib/mlxcelverse/CMakeLists.txt.

Refs #3398, #3400.

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lablup/mlxcel

Tất cả issue của lablup/mlxcel

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.