nncf icon indicating copy to clipboard operation
nncf copied to clipboard

Use storage scopes when determining train-only modules

Open vshampor opened this issue 3 years ago • 3 comments

Changes

When replacing only non-train-only modules, check the scopes of the modules we iterate on against the scopes corresponding to the storage of the module, not the execution module call stack of the op.

Reason for changes

Some PT models may be written in such a fashion that a given submodule calls a certain other submodule in the model, but at the same time does not contain it in the storage hierarchy (see the test case in the PR for an explicit example of such a model). In this case the storage scope does not coincide with the execution scope of the operations; this also causes problems during module traversal in replace_modules.

Related tickets

75373

Tests

tests.torch.test_nncf_network.test_wrapping_of_indirect_module_operations

vshampor avatar Jan 20 '22 09:01 vshampor

I wonder how ignored_scope and target_scope will work in case of such model. Am I right, that everything will be in storage-mode now: scopes in original and compressed graphs, scopes in log? User will never know that there's execution-mode scope, will he?

ljaljushkin avatar Jan 20 '22 13:01 ljaljushkin

No, in fact, the storage scope comparisons are limited to determining the train-only modules and referencing their scopes against the storage scope that is being tracked during the one-time replacement process with NNCF-wrapped ones. The user would probably have to specify storage scope if they really want to not wrap a part of the model, but otherwise all the other ignored scopes and target scopes are still specified in terms of what is visible in the compressed_graph.dot, i.e. in terms of the execution scope.

vshampor avatar Jan 20 '22 15:01 vshampor

No, in fact, the storage scope comparisons are limited to determining the train-only modules and referencing their scopes against the storage scope that is being tracked during the one-time replacement process with NNCF-wrapped ones. The user would probably have to specify storage scope if they really want to not wrap a part of the model, but otherwise all the other ignored scopes and target scopes are still specified in terms of what is visible in the compressed_graph.dot, i.e. in terms of the execution scope.

It makes sense to document this, it can be not obvious even for developers after a while

ljaljushkin avatar Jan 20 '22 15:01 ljaljushkin

SOTA eval PT build 206 is OK

vshampor avatar Feb 15 '23 14:02 vshampor