GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: matvec(A, b, out=b) zeros out b · Issue #31144 · numpy/numpy

BUG: matvec(A, b, out=b) zeros out b #31144

New issue
Copy link
New issue
Copy link
Closed
#31150
Closed
BUG: matvec(A, b, out=b) zeros out b#31144
#31150
Copy link
Labels
00 - Bug
Milestone
2.4.5 release

Description

@misho88
misho88
opened on Apr 4, 2026
Issue body actions

Describe the issue:

I expected np.matvec(A, b, out=b) to behave more or less like np.einsum('...ij,...j', A, b, out=b), but instead b is set to all zeros

It seems to work fine if the output vector is not the same as the input vector.

Reproduce the code example:

>>> import numpy as np
>>> M, N = 100000, 10
... A = np.random.normal(size=(M, N, N))
... b = np.random.normal(size=(M, N))
>>> np.matvec(A, b, out=b)
array([[0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       ...,
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.]], shape=(100000, 10))

Error message:

Python and NumPy Versions:

2.4.4
3.14.3 (main, Feb 15 2026, 00:49:34) [GCC 15.2.1 20260209]

Runtime Environment:

[{'numpy_version': '2.4.4',
'python': '3.14.3 (main, Feb 15 2026, 00:49:34) [GCC 15.2.1 20260209]',
'uname': uname_result(system='Linux', node='...', release='6.19.10-artix1-1', version='#1 SMP PREEMPT_DYNAMIC Thu, 26 Mar 2026 22:46:44 +0000', machine='x86_64')},
{'simd_extensions': {'baseline': [],
'found': ['X86_V2', 'X86_V3'],
'not_found': ['X86_V4', 'AVX512_ICL', 'AVX512_SPR']}},
{'ignore_floating_point_errors_in_matmul': False},
{'filepath': '/usr/lib/libgomp.so.1.0.0',
'internal_api': 'openmp',
'num_threads': 12,
'prefix': 'libgomp',
'user_api': 'openmp',
'version': None}]

How does this issue affect you or how did you find it:

I needed to apply a linear transformation to many vectors in-place, and it didn't work.

Activity

  1. misho88
    added
    00 - Bug
    on Apr 4, 2026
  2. Ijtihed
    added a commit that references this issue on Apr 4, 2026

    BUG: fix matvec/vecmat in-place aliasing (out=input produces zeros)

    This issue will close once commit 89f6cd0 is merged into the 'main' branch.
    89f6cd0
  3. Ijtihed commented on Apr 4, 2026

    @Ijtihed
    Ijtihed
    on Apr 4, 2026
    Contributor
    More actions

    I believe matvec and vecmat are missing the same overlap-handling flag that matmul already has so when out aliases an inputt, BLAS zeros the buffer before reading it. we can fix it if we clear OVERLAP_ASSUME_ELEMENTWISE on their output operand like matmul does it

    #31150

  4. tylerjereddy commented on Apr 4, 2026

    @tylerjereddy
    tylerjereddy
    on Apr 4, 2026
    Contributor
    More actions

    I can't reproduce the original problem locally on latest main branch on ARM Mac. Maybe I'll try on x86_64 Linux next just in case...

    >>> import numpy as np
    >>> M, N = 100000, 10
    >>> A = np.random.normal(size=(M, N, N))
    >>> b = np.random.normal(size=(M, N))
    >>> np.matvec(A, b, out=b)
    array([[-4.27910098,  0.72496376, -4.57306406, ..., -3.30022262,
            -6.61555153, -7.48743835],
           [ 2.71045097, -2.0806753 , -5.4879226 , ..., -2.09790416,
            -2.90238571, -1.60047482],
           [ 0.50323991,  2.6632049 ,  2.08760249, ..., -1.03016698,
             1.8176871 , -1.77353083],
           ...,
           [-0.91260162,  4.44175049, -0.76366474, ...,  1.16549763,
            -3.66365006,  3.03244982],
           [-1.96788363, -2.14235089,  2.93116224, ..., -0.24430625,
             0.80722965,  4.79238694],
           [-3.64083547,  1.32681639, -0.32963045, ...,  0.29729222,
            -0.81767494, -0.90006859]], shape=(100000, 10))
  5. tylerjereddy commented on Apr 4, 2026

    @tylerjereddy
    tylerjereddy
    on Apr 4, 2026
    Contributor
    More actions

    I can reproduce on x86_64 Linux with Python 3.14.0 (and presumably OpenBLAS vs. Accelerate if that matters).

  6. charris
    added this to the 2.4.5 release milestone on Apr 5, 2026
  7. seberg
    closed this as completedin #31150on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bug

    Type

    No type

    Projects

    No projects

      Milestone

      • 2.4.5 release

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.