Skip to content

Fix PAG int shorthand crash in LayerSkipConfig.indices#15

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-1463
Draft

Fix PAG int shorthand crash in LayerSkipConfig.indices#15
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-1463

Conversation

@cursor

@cursor cursor Bot commented Jun 25, 2026

Copy link
Copy Markdown

Bug and impact

PerturbedAttentionGuidance(perturbed_guidance_layers=7, ...) crashes during hook installation with TypeError when PAG is active. The documented int shorthand for layer selection is broken.

Root cause

The shorthand path passed a bare int to LayerSkipConfig.indices (typed as list[int]). _apply_layer_skip_hook calls len(config.indices), which fails on an int. SLG/AutoGuidance had the same bug (PR #10); PAG was missed because it builds a single config with all layer indices instead of one config per layer.

Fix

Wrap perturbed_guidance_layers int shorthand to [int] before constructing LayerSkipConfig, matching SLG/AutoGuidance behavior.

Validation

  • Added regression tests in tests/guiders/test_perturbed_attention_guidance.py
  • pytest tests/guiders/test_perturbed_attention_guidance.py — 2 passed
Open in Web View Automation 

When perturbed_guidance_layers is a single int, wrap it in a list before
building LayerSkipConfig so hook installation does not crash with TypeError.

Co-authored-by: Simon Lynch <srlynch1@users.noreply.github.com>
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