Skip to content

fix(detector): detect functools.partial bound-state replay#44

Closed
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:prasannakotyal/kg-blue-77-partial-bound-state-replay
Closed

fix(detector): detect functools.partial bound-state replay#44
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:prasannakotyal/kg-blue-77-partial-bound-state-replay

Conversation

@prasannakotyal

Copy link
Copy Markdown

Summary

Targets KG red #77, where custom_kernel = functools.partial(_impl, {}) hides replay state as a bound mutable argument. The helper fills that bound state from the input and later returns it on an input-independent fast path.

This adds a narrow PARTIAL_BOUND_STATE_REPLAY detector. It requires:

  • a top-level custom_kernel assignment using functools.partial or imported partial
  • a concrete helper function as the first partial argument
  • at least one bound helper parameter acting as state
  • mutation of that bound state from input-derived values
  • a call-free early return from that same state under a guard that does not reference input parameters

Legitimate partial use for constants, callable caches, and workspace buffers stays out of scope.

KernelGuard-Red-Submission: 77

Local verification

  • red_03_partial_replay -> PARTIAL_BOUND_STATE_REPLAY, should_filter=True
  • clean_partial_scalar -> stays valid
  • clean_partial_cached_fn -> stays valid
  • clean_partial_workspace -> stays valid
  • python -m py_compile kernelguard.py

@prasannakotyal prasannakotyal temporarily deployed to kernelguard-api-control-plane May 1, 2026 18:42 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

KernelGuard Blue Evaluation

@SinatrasC

Copy link
Copy Markdown
Collaborator

Thanks for the KernelGuard Flywheel Campaign contribution. We are not merging this narrow variant separately because the consolidated rule-family implementation in #273 is the merge path for this detector area.

@SinatrasC SinatrasC closed this Jun 20, 2026
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