Skip to content

RWKV-v7/rwkv_v7_numpy.py fails on NumPy <2.0 (.mT attribute) #343

Description

@chirag127

Problem

RWKV-v7/rwkv_v7_numpy.py uses the ndarray.mT attribute, which was introduced in NumPy 2.0. On NumPy 1.x it raises AttributeError.

Steps

  1. pip install numpy==1.26.4 torch rwkv
  2. cd RWKV-v7 && python rwkv_v7_numpy.py

Expected

Script runs and prints deviation vs reference rwkv package.

Actual

AttributeError: 'numpy.ndarray' object has no attribute 'mT'

Triggered at RWKV-v7/rwkv_v7_numpy.py:39:

S = S * w.mT - S @ kk * (kk*a).mT + v * k.mT

(also used on nothing else, only line 39). Per NumPy 2.0 release notes, ndarray.mT is New in version 2.0.

Environment

  • NumPy 1.26.4 (still widely paired with PyTorch 2.4/2.5)
  • Python 3.10
  • Repo has no requirements.txt at root or under RWKV-v7/ pinning numpy>=2.0.

Fix options: replace .mT with np.swapaxes(x,-1,-2), or add a header comment / RWKV-v7/requirements.txt requiring numpy>=2.0.

Thanks for maintaining BlinkDL/RWKV-LM!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions