Skip to content

fix(checkpoint): match device_map keys by dotted path - #46

Draft
lslusarczyk wants to merge 2 commits into
intel:mainfrom
lslusarczyk:fix/device-map-dotted-paths
Draft

lslusarczyk wants to merge 2 commits into
intel:mainfrom
lslusarczyk:fix/device-map-dotted-paths

Conversation

@lslusarczyk

Copy link
Copy Markdown
Contributor

load now matches device_map keys of nested tuned modules by dotted path.

load looked up a nested tuned module by its attribute name alone.
For model.inner.linear1 the key was linear1.
Two tuned modules named linear1 in different submodules shared one entry.

The key is now the dotted path, e.g. inner.linear1.
A direct submodule keeps its key, so linear1 still matches model.linear1.
Only modules nested two or more levels deep change their key.

The new tests tune a model nested two levels deep on XPU.
They fail without the fix.

Depends on #44, which changes the same recursion.
The first commit belongs to #44.

… state_dict

`load` handed each child a filtered copy of the state_dict.
The entry of a nested tuned module was removed from that copy only.
It stayed in the state_dict that `load_state_dict(strict=False)` receives, which ignored it.
The `if state_dict` skip for a fully tuned module never applied below the top level.

Children now share the same state_dict, which also drops one copy per module.

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>
`load` looked up a nested tuned module in `device_map` by its attribute name.
Two tuned modules named `linear1` in different submodules shared one entry.

The key is now the dotted path, e.g. `inner.linear1`.
A direct submodule keeps its key, so `linear1` still matches `model.linear1`.

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>

This branch has not been deployed

No deployments
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