Skip to content

Fix (graph/hadamard): remove matmul_hadUt_cuda, which raises TypeError on every call - #1604

Open
Anai-Guo wants to merge 1 commit into
Xilinx:masterfrom
Anai-Guo:drop-dead-matmul-hadut-cuda
Open

Anai-Guo wants to merge 1 commit into
Xilinx:masterfrom
Anai-Guo:drop-dead-matmul-hadut-cuda

Conversation

@Anai-Guo

Copy link
Copy Markdown

Problem

matmul_hadUt_cuda cannot be called — it forwards a transpose keyword that
matmul_hadU_cuda does not accept:

def matmul_hadU_cuda(X, hadK, K):          # L144 — no `transpose` parameter
    n = X.shape[-1]
    if K == 1:
        return fast_hadamard_transform.hadamard_transform(...)
    # if transpose:
    #     hadK = hadK.T.contiguous()
    ...

def matmul_hadUt_cuda(X, hadK, K):         # L158
    return matmul_hadU_cuda(X, hadK, K, transpose=True)   # L159

Any call raises:

TypeError: matmul_hadU_cuda() got an unexpected keyword argument 'transpose'

The commented-out # if transpose: block directly above is the residue: transpose
support was dropped from matmul_hadU_cuda, but this wrapper was never updated.

Why removal rather than restoring transpose

  • matmul_hadUt_cuda has no call sites anywhere in the repo (grep over src/,
    tests/, brevitas_examples/). Only matmul_hadU_cuda is imported and used —
    in graph/equalize.py:1527, nn/equalized_layer.py:110,128, and
    graph/hadamard.py:178,181.
  • Re-adding the parameter would mean re-enabling the commented-out transpose branch,
    i.e. resurrecting behaviour that was deliberately disabled. That's a semantic decision
    for maintainers, not a bug fix.
  • Because the function has never been callable, deleting it cannot break any working
    caller, in-tree or out.

The CPU counterpart is unaffected and keeps working, since matmul_hadU does take
transpose:

def matmul_hadU(X, transpose=False): ...   # L107
def matmul_hadUt(X):                       # L131
    return matmul_hadU(X, transpose=True)  # L132  <-- binds fine

Verification

Binding each wrapper's call against its callee's real signature, with the working CPU
pair as a control:

matmul_hadU_cuda(X, hadK, K)          <- matmul_hadUt_cuda passes (X, hadK, K, transpose=True)
   TypeError: got an unexpected keyword argument 'transpose'

matmul_hadU(X, transpose=False)       <- matmul_hadUt passes (X, transpose=True)
   bound OK        <-- control

Change

Deletes the four lines of the dead wrapper. No other behaviour touched.


🤖 Generated with Claude Code

matmul_hadUt_cuda passes transpose=True to matmul_hadU_cuda, which has
no such parameter, so every call raises TypeError. The function has no
call sites. Its CPU counterpart matmul_hadUt still works because
matmul_hadU does take transpose.

Signed-off-by: Anai-Guo <antai12232931@outlook.com>

This branch has not been deployed

No deployments
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.

1 participant