From 2607dbca4b643b79c66b245152d491e4afee0327 Mon Sep 17 00:00:00 2001 From: Wenyu Date: Thu, 11 Aug 2022 17:05:50 +0800 Subject: [PATCH] recompute flag (#6628) --- configs/vitdet/cascade_rcnn_vit_large_hrfpn_cae_1x_coco.yml | 2 ++ ppdet/modeling/backbones/vision_transformer.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/vitdet/cascade_rcnn_vit_large_hrfpn_cae_1x_coco.yml b/configs/vitdet/cascade_rcnn_vit_large_hrfpn_cae_1x_coco.yml index 5f5bbfb46..3bd443ef3 100644 --- a/configs/vitdet/cascade_rcnn_vit_large_hrfpn_cae_1x_coco.yml +++ b/configs/vitdet/cascade_rcnn_vit_large_hrfpn_cae_1x_coco.yml @@ -7,6 +7,7 @@ weights: output/cascade_rcnn_vit_large_hrfpn_cae_1x_coco/model_final depth: &depth 24 dim: &dim 1024 +use_fused_allreduce_gradients: &use_checkpoint True VisionTransformer: img_size: [800, 1344] @@ -15,6 +16,7 @@ VisionTransformer: num_heads: 16 drop_path_rate: 0.25 out_indices: [7, 11, 15, 23] + use_checkpoint: *use_checkpoint pretrained: https://bj.bcebos.com/v1/paddledet/models/pretrained/vit_large_cae_pretrained.pdparams HRFPN: diff --git a/ppdet/modeling/backbones/vision_transformer.py b/ppdet/modeling/backbones/vision_transformer.py index 798ea3768..26e6ff2a0 100644 --- a/ppdet/modeling/backbones/vision_transformer.py +++ b/ppdet/modeling/backbones/vision_transformer.py @@ -596,7 +596,7 @@ class VisionTransformer(nn.Layer): feats = [] for idx, blk in enumerate(self.blocks): - if self.use_checkpoint: + if self.use_checkpoint and self.training: x = paddle.distributed.fleet.utils.recompute( blk, x, rel_pos_bias, **{"preserve_rng_state": True}) else: -- GitLab