Skip to content

feat: Add docstrings; Add Support for UserDict in _transfer_to_device#19

Open
proshian wants to merge 2 commits intoalstonlo:mainfrom
proshian:main
Open

feat: Add docstrings; Add Support for UserDict in _transfer_to_device#19
proshian wants to merge 2 commits intoalstonlo:mainfrom
proshian:main

Conversation

@proshian
Copy link
Copy Markdown

This PR

  • Docstrings: Adds docstring to undocumented methods in base.py
  • torch-influence & transformers: Updates the _transfer_to_device method to support UserDict instances. The Hugging Face BatchEncoding class, which is a common otype for a batch in the library, inherits from UserDict but not from dict. This change ensures that _transfer_to_device correctly handles these batch types, fixing error-raising in _transfer_to_device that prevented torch-influence from working seamlessly with the transformers library.

@proshian proshian closed this Aug 10, 2025
Add and update docstrings for methods:
* train_outputs
* _model_params
* _model_make_functional
* _model_reinsert_params
* _loader_wrapper
* _loss_grad_loader_wrapper
* _hvp_at_batch
@proshian proshian reopened this Aug 10, 2025
@proshian proshian changed the title Add docstrings; Add Support for UserDict in _transfer_to_device feat: Add docstrings; Add Support for UserDict in _transfer_to_device Aug 10, 2025
When using huggingface transformers library,
it's common for the batch to be of type
BatchEncoding which is a subtype of UserDict,
but is NOT a subtype of dict. This update
fixes the issue by adding support for UserDict.
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