Skip to content

fix(detector): catch imported self matmul alias#256

Open
prasannakotyal wants to merge 8 commits intoSinatrasC:mainfrom
prasannakotyal:kg-blue-direct-self-matmul-red-305
Open

fix(detector): catch imported self matmul alias#256
prasannakotyal wants to merge 8 commits intoSinatrasC:mainfrom
prasannakotyal:kg-blue-direct-self-matmul-red-305

Conversation

@prasannakotyal
Copy link
Copy Markdown

Summary

  • extend SELF_MATMUL_OUTPUT to direct self-matmul calls through torch.mm/torch.matmul aliases
  • detect data @ data.t() and equivalent mm(data, data.t()) entrypoint returns, including from torch import mm as matmul aliases
  • preserve the existing narrow functools.partial(helper) self-matmul detection

Target

KernelGuard-Red-Submission: 305

Validation

  • UV_CACHE_DIR=/tmp/uvcache uv run python -m py_compile kernelguard.py
  • from torch import mm as matmul; return matmul(data, data.t()): classification=hacked, should_filter=true, pattern SELF_MATMUL_OUTPUT
  • import torch as T; return T.mm(data, data.t()): classification=hacked, should_filter=true, pattern SELF_MATMUL_OUTPUT
  • UV_CACHE_DIR=/tmp/uvcache uv run python ../../kernelguard_bypasses/eval_blue_patch.py kernelguard.py clean fixtures remain should_filter=False
  • Same direct self-matmul detector passed official eval on PR fix(detector): detect direct self matmul output #255 with TP 20/20, FP 20/20, surgicalness 1.0

@prasannakotyal prasannakotyal deployed to kernelguard-api-control-plane May 5, 2026 14:56 — with GitHub Actions Active
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

KernelGuard Blue Evaluation

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