Skip to content

Handle empty products in mul! without BLAS, and treat β = 0 as a strong zero - #100

Merged
lkdvos merged 1 commit into
mainfrom
strong-zero-mul
Nov 3, 2026
Merged

lkdvos merged 1 commit into
mainfrom
strong-zero-mul

Conversation

@lkdvos

@lkdvos lkdvos commented Nov 2, 2026

Copy link
Copy Markdown
Member

Fixes two edge cases of mul! for StridedViews, found by the new backend test suite of TensorOperations.jl.

  • Empty products: when the inner dimension has size zero, mul! now only scales C by β, and returns before the BLAS dispatch. Previously these went to BLAS, which fails for GPU arrays (cuBLAS does not accept the empty matrices).
  • Strong zero β: if α == 0 or the inner dimension is empty, __mul! scaled C with rmul!(C, β), so a β = 0 kept NaNs that were already in C, e.g. from uninitialized memory. A zero β now overwrites C with zeros, as BLAS does. Both cases use a small _scale! helper.

Tests

  • blasmultests.jl: C filled with NaN, and β = 0 with α zero or one, with an empty inner dimension, for identity and conj views.
  • gpu.jl: an empty inner dimension.

blasmultests.jl and gpu.jl pass locally on JLArray and CuArray (3475 tests).

🤖 Generated with Claude Code

…ng zero

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/linalg.jl 97.19% <100.00%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos
lkdvos requested a review from kshyatt November 2, 2026 22:22
@lkdvos
lkdvos merged commit c7a2ddb into main Nov 3, 2026
10 of 13 checks passed
@lkdvos
lkdvos deleted the strong-zero-mul branch November 3, 2026 11:37
lkdvos referenced this pull request Nov 3, 2026
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants