No SIMD emitted for typed-array dot-product / MAC loops (0 vector instructions in a 431 KB A64 binary)
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
- 25/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ệ
- typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
Read the compiler’s loop-vectorization and SLP paths, then inspect how bounds checks and ordering semantics affect the typed-array loops described here. Start by checking the issue’s asm-count evidence and the referenced #1126 work; the issue does not name source files or tests. Done means supported loops emit SIMD under a documented ordering policy or explicit opt-in, with tests showing the generated vector instructions.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
On scriptc 0.3.6 / AArch64 (Apple Silicon M4), a program dominated by typed-array arithmetic emits zero SIMD instructions anywhere in the binary. Even loops that are fully check-free after inlining (bounds hoisted, direct ldr sN element loads) run as chains of scalar fadd/fmul — roughly 25% of the CPU's vector FMA throughput. For numeric-kernel workloads that leaves ~4× (or more, with multiple FMA ports) of headroom unclaimed.
Evidence
Our engine (llama.scriptc — llama.cpp-parity LLM inference in scriptc): we searched 431 KB of --emit asm output for fmla / vector-register patterns — none emitted anywhere. The hottest loops are unit-stride, 4-way-unrolled f32 dot products over Float32Array weights (row-matvec [896×896], attention scores, lm_head [896→151936]) — textbook vectorization candidates.
Scalar rates on M4 for the same loop body:
- ~1.9 cycles per f32 MAC when bounds are hoisted (entry-inlined copy, 2.05 GMAC/s)
- ~3.8 cycles per MAC as a standalone function (1.06 GMAC/s) — per-access descriptor→length→icmp→br ladder; this part is PR #1126's target, and we've validated its mechanism from the outside (commented there with numbers + probes)
For comparison, llama.cpp's hand-written SIMD kernels run the same class of matvec at the effective equivalent of ~40–80 GMAC/s on the same CPU.
Ask
Once #1126 lands (bounds versioning + alias tags → hoisted pointers, pruned ladder), the main remaining blocker for auto-vectorization on these loops is ordering semantics, not structure. Two options that would unlock this workload class:
- Let
loop-vectorize/SLP fire on the versioned (proven-in-bounds) loops, with the f32-reorder caveat documented — numeric-kernel consumers already accept reorder noise (reference implementations like llama.cpp are SIMD themselves). - Or an explicit opt-in (
--vectorize, or a source-level annotation) that permits contracting the accumulation chains when directed.
Either way the win is large on existing source with no intrinsics: 4 f32 lanes per 128-bit FMA on A64 (same on x86-64 SSE/AVX), taking our hot loops from ~2 → ~8+ GMAC/s measured-equivalent, which for inference is the difference between 470 and well under 200 ms/token end to end.
Full evidence (asm counts, per-op rates, probes): secret gist — kernel-rate-investigation.md, probe_gap5, probe_gap9, probe_rowcliff, repro_matvec
- Ngôn ngữ chính
- TypeScript
- Star
- 6.7k
- Fork
- 229
- Merge trung bình
- 14 giờ 29 phút
- Pull request đã merge (30 ngày)
- 787
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 vercel-labs/scriptc
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
vercel-labs/scriptc#4865 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
vercel-labs/scriptc#4864 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows ARM64 as a cross-compile targetCó thể đã có người làm @hum-n đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
vercel-labs/scriptc#4858 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
post-merge-bisect-unresolved
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 43/100
vercel-labs/scriptc#4791 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
post-merge-bisect-unconfirmed
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
vercel-labs/scriptc#4755 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của vercel-labs/scriptc
Issue tương tự
-
bug data-types
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: middleware enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
agent/quality testing
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
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 92/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
juspay/agent-distro#203 ·
Maintainer thường phản hồi trong vòng 1 ngày