Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Use shared_dict for linear model #4412

Open
ChiahsinChu opened this issue Nov 24, 2024 · 1 comment
Open

[Feature Request] Use shared_dict for linear model #4412

ChiahsinChu opened this issue Nov 24, 2024 · 1 comment

Comments

@ChiahsinChu
Copy link
Contributor

Summary

Currently, the linear model is implemented to combine multiple frozen models. However, this architecture can be further used for models with more complicated combining rules. I wonder if it is possible to have the design similar to multi-task/model/shared_dict and make all submodels share (some of) their parameters.
I would like to know the comments/suggestions from developers about this feature and the relevant code implementation. I can implement it once we come to a conclusion.
Thanks.

Detailed Description

An example input expected:

"model": {
    "type": "custom_ener_model",
    "shared_dict": {
      "type_map_all": [
        "O",
        "H"
      ],
      "sea_descriptor_1": {
        "type": "se_e2_a",
        "sel": [
          46,
          92
        ],
        "rcut_smth": 0.50,
        "rcut": 6.00,
        "neuron": [
          25,
          50,
          100
        ],
        "resnet_dt": false,
        "axis_neuron": 16,
        "type_one_side": true,
        "seed": 1,
        "_comment": " that's all"
      },
      "_comment": "that's all"
    },
    "models": [
    {
        "type_map": "type_map_all",
        "descriptor": "sea_descriptor_1",
        "fitting_net" : {
	    "neuron":		[240, 240, 240],
	    "resnet_dt":	true,
	    "seed":		1
	}
    },
    {
        "type_map": "type_map_all",
        "descriptor": "sea_descriptor_1",
        "fitting_net" : {
            "type": "dipole",
	    "neuron":		[100, 100, 100],
	    "resnet_dt":	true,
	    "seed":		1
	}
    }
    ],
    "model_arg":{}
},

Further Information, Files, and Links

No response

@iProzd
Copy link
Collaborator

iProzd commented Nov 26, 2024

@ChiahsinChu LGTM to add a 'share_dict' param inside the linear_ener model. The code for preprocess input and sharing params can be found in https://github.com/deepmodeling/deepmd-kit/blob/devel/deepmd/pt/utils/multi_task.py#L14 and https://github.com/deepmodeling/deepmd-kit/blob/devel/deepmd/pt/train/wrapper.py#L62, respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants