ndif-team / nnsight

The nnsight package enables interpreting and manipulating the internals of deep learned models.
https://nnsight.net/
MIT License
401 stars 38 forks source link

When scanning using 'meta' tensors, handle torch calls to allocate new data. #40

Closed JadenFiotto-Kaufman closed 8 months ago

JadenFiotto-Kaufman commented 10 months ago

Sometimes (in models like llama), running the model creates new tensors like torch.ones(...) or something. This creates a cpu tensor by default which can mess with meta tensors during scanning. Need to set default device in _scan like torch.set_default_device or use patching if need be.