metaseq icon indicating copy to clipboard operation
metaseq copied to clipboard

Unify model and task registries with... everything else.

Open suchenzang opened this issue 2 years ago • 0 comments

From looking at the merge_with_parent method, we see:

(base) √ fairseq-big-internal % ag merge_with_parent
fairseq/tasks/__init__.py
12:from fairseq.dataclass.utils import merge_with_parent, populate_dataclass
39:            cfg = merge_with_parent(dc(), cfg)

fairseq/registry.py
10:from fairseq.dataclass.utils import populate_dataclass, merge_with_parent
40:                cfg = merge_with_parent(dc(), cfg)

fairseq/models/__init__.py
12:from fairseq.dataclass.utils import merge_with_parent, populate_dataclass
81:            cfg = merge_with_parent(dc(), cfg)

fairseq/dataclass/utils.py
463:def merge_with_parent(dc: FairseqDataclass, cfg: FairseqDataclass):

What is notable here is that models and tasks are the only two modules that doesn't call on the fairseq/registry.py shared file. Meanwhile:

(base) √ fairseq-big-internal % ag setup_registry
fairseq/registry.py
17:def setup_registry(registry_name: str, base_class=None, default=None, required=False):

fairseq/optim/lr_scheduler/__init__.py
23:) = registry.setup_registry(

fairseq/optim/__init__.py
31:) = registry.setup_registry("--optimizer", base_class=FairseqOptimizer, required=True)

fairseq/data/encoders/__init__.py
13:build_tokenizer, register_tokenizer, TOKENIZER_REGISTRY, _ = registry.setup_registry(
19:build_bpe, register_bpe, BPE_REGISTRY, _ = registry.setup_registry(

fairseq/criterions/__init__.py
23:) = registry.setup_registry(

use registry to setup configurations.

Figure out how to unify these (or what a good reason for leaving model/task untouched would be).

suchenzang avatar Mar 19 '22 22:03 suchenzang