From 401cfa4ee06b89b7da9e72bb11ce7308d5015719 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 24 Oct 2024 17:53:16 -0400 Subject: [PATCH] add developing doc Signed-off-by: Jinzhe Zeng --- doc/development/create-a-model-pt.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/development/create-a-model-pt.md b/doc/development/create-a-model-pt.md index 257dd8a25d..9a34affc5b 100644 --- a/doc/development/create-a-model-pt.md +++ b/doc/development/create-a-model-pt.md @@ -137,6 +137,15 @@ class SomeAtomicModel(BaseAtomicModel, torch.nn.Module): pass ``` +### Floating-point precision + +When creating a new component, the floating-point precision should obey the [Floating-point precision of the model](../model/precision.md) section. +In implementation, the component should + +- store parameters in the component precision, except those for input and output normalization; +- store normalization parameters in {py:data}`deepmd.pt.utils.env.GLOBAL_PT_FLOAT_PRECISION`; +- after input normalization, cast the input tensor to the component precision; before output normalization, cast the output tensor to the {py:data}`deepmd.pt.utils.env.GLOBAL_PT_FLOAT_PRECISION`. + ## Register new arguments To let someone uses your new component in their input file, you need to create a new method that returns some `Argument` of your new component, and then register new arguments. For example, the code below