fix(core): validate scales and biases rows in QuantizedEmbedding loading
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- backend, machine-learning
Hướng nghiên cứu
Bắt đầu tại src/lib/mlxcel-core/src/layers.rs, ở QuantizedEmbedding::from_weights_with_mode, rồi so sánh phần xác thực của nó với UnifiedLinear::from_weights_with_mode. Thêm các trường hợp Scales và Biases quá ngắn vào src/lib/mlxcel-core/src/layers_scales_axes_tests.rs, bao gồm đường đi UnifiedEmbedding::from_weights và trường hợp hợp lệ affine_plane(64). Cập nhật chú thích tài liệu “Used by”, rồi chạy ba lệnh xác minh được liệt kê trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
QuantizedEmbedding::from_weights_with_mode (src/lib/mlxcel-core/src/layers.rs:375-436) accepts a scales or biases plane with fewer rows than weight. Safetensors files are untrusted input, and with a short plane the lookup reads past the buffer: quantized_embedding (src/lib/mlxcel-core/cpp/mlx_cxx_bridge.cpp:4023-4028) runs take(scales, ids, 0) and take(biases, ids, 0) with token ids bounded only by the weight's row count, and the tied head (as_linear) indexes scales by output row in qmv. The loader only calls reconcile_quantization_layout_logged, which looks at the last axis alone.
Current Behavior
UnifiedLinear::from_weights_with_mode (layers.rs:2912) already calls check_scales_leading_axes (issue #3457), so quantized linears are covered. The embedding loader was missed. PR #3542 patched this only for Lille, in src/models/lille_130m_shapes.rs:109-116 (check_packing). Other families get the check only if they call validate_embedding_table (BailingMoe, Gpt2, GptBigCode, GptNeoX, Mamba, Mamba2, Florence2). Every other UnifiedEmbedding::from_weights caller is unprotected.
Proposed Solution
In QuantizedEmbedding::from_weights_with_mode, call check_scales_leading_axes(prefix, &w_shape, &s_shape, b_shape.as_deref())? before reconciliation, the same way UnifiedLinear does. That covers from_weights and UnifiedEmbedding::from_weights too. Keep Lille's check_packing, which also validates the column count.
Out of scope: QuantizedWeight::new (layers.rs:106) is infallible and its callers build planes by hand; file a follow-up if an audit finds an unchecked caller.
Acceptance Criteria
- New failing test in
src/lib/mlxcel-core/src/layers_scales_axes_tests.rs:QuantizedEmbedding::from_weights_with_mode(&affine_plane(32), "p", 64, 4, "affine")returns anErrthat namesp.scales,[32, 1]and[64, 8]. Add the same check throughUnifiedEmbedding::from_weights, plus a case where onlybiasesis short.affine_plane(64)still loads - The existing Lille and
validate_embedding_tabletests still pass - Doc comment on
check_scales_leading_axeslistsQuantizedEmbedding::from_weights_with_modeunder "Used by"
Verification
cargo test -p mlxcel-core --lib layers::scales_axes_tests
cargo test --lib lille_130m
cargo clippy --all-targets -- -D warnings
- 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
-
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
-
area:models platform:linux priority:medium status:ready type:bug
Độ 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
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