Skip to content

Fix type of HookedTransformerConfig.device#1230

Open
brendanlong wants to merge 1 commit intoTransformerLensOrg:mainfrom
brendanlong:brendanlong/device-type
Open

Fix type of HookedTransformerConfig.device#1230
brendanlong wants to merge 1 commit intoTransformerLensOrg:mainfrom
brendanlong:brendanlong/device-type

Conversation

@brendanlong
Copy link
Copy Markdown
Contributor

@brendanlong brendanlong commented Apr 3, 2026

Description

This is typed as Optional[str] but sometimes returns torch.device.
Updated the code to just return the str instead of wrapping with a
device.

I'm not confident that every function which takes a device will
always be passed a string, so I didn't change functions like
warn_if_mps.

Found while working on #1219.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

@brendanlong brendanlong force-pushed the brendanlong/device-type branch from a36f23e to 7173dfa Compare April 4, 2026 19:42
This is typed as `Optional[str]` but sometimes returns `torch.device`.
Updated the code to just return the `str` instead of wrapping with a
device.

I'm not confident that every function which takes a device will
always be passed a string, so I didn't change functions like
warn_if_mps.

Found while working on TransformerLensOrg#1219
@brendanlong brendanlong force-pushed the brendanlong/device-type branch from 7173dfa to 560ec23 Compare April 4, 2026 19:45
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