Master-Shi commited on
Commit
d1fe397
·
verified ·
1 Parent(s): ff078d0

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--115--2d_none--0000_000.png +3 -0
  2. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--164--2d_none--0000_000.png +3 -0
  3. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--189--2d_none--0000_000.png +3 -0
  4. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--192--2d_none--0000_000.png +3 -0
  5. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--195--2d_none--0000_000.png +3 -0
  6. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--292--2d_none--0000_000.png +3 -0
  7. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--322--2d_none--0000_000.png +3 -0
  8. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--399--2d_none--0000_000.png +3 -0
  9. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--405--2d_none--0000_000.png +3 -0
  10. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--462--2d_none--0000_000.png +3 -0
  11. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--504--2d_none--0000_000.png +3 -0
  12. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--549--2d_none--0000_000.png +3 -0
  13. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--567--2d_none--0000_000.png +3 -0
  14. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju17r8il13910799dr2wme2e--2d_none--0000_000.png +3 -0
  15. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju45ty6zn9oz0850qy4qnck1--2d_none--0000_001.png +3 -0
  16. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju886ryxnsl50801r93jai7q--2d_none--0000_001.png +3 -0
  17. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju8b542nr81x0871uxnkm9ih--2d_none--0000_000.png +3 -0
  18. benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju8bj2ssrmlm0871gc2ug2rs--2d_none--0000_000.png +3 -0
  19. 之前的代码版本/注意力用于sam的prompt的版本/MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl/utils/fsdp_utils.py +140 -0
  20. 之前的代码版本/注意力用于sam的prompt的版本/MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl/utils/logger/logger.py +165 -0
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--115--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: f01c7480c8010820e58c6725d92b3703606c9c4b616dd88107146c8f323f4994
  • Pointer size: 129 Bytes
  • Size of remote file: 1.63 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--164--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 3fd1d6cf440cb13c44d541c07a47cfb3d1144af7eca385be606237f159316381
  • Pointer size: 128 Bytes
  • Size of remote file: 969 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--189--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 2d23c46f7e0a518dc1f5da3d974739b40b93a5f6494cb42b7d28b56000d418af
  • Pointer size: 128 Bytes
  • Size of remote file: 929 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--192--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 83e011a65e42290d7ae3a84a1b63f612d7baf3c33b768f0b72cb99ca5b33708b
  • Pointer size: 128 Bytes
  • Size of remote file: 775 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--195--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: b32d7813eefa2154cd40031cec9a445ed1078634344427bf055ba62e5a7e47bd
  • Pointer size: 128 Bytes
  • Size of remote file: 927 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--292--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 7811ab21ae56a4649e8a3e7473a32509e4ad749c61734fc79036b01a9cfadd30
  • Pointer size: 128 Bytes
  • Size of remote file: 801 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--322--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 95497e7f9ce0a06284b9cd98b3dee6e2cd822f1e662454d41dde8fcf688071c4
  • Pointer size: 128 Bytes
  • Size of remote file: 980 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--399--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: dfef8ac17b50f9d19972d3e8945f214be270b1aa85d79b744a9b6b83c6d74e5e
  • Pointer size: 129 Bytes
  • Size of remote file: 1.22 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--405--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: bc1af3503d46b6a293e56d62f21b159ef43cf83c9e231e8e1206e291b7a6fa63
  • Pointer size: 129 Bytes
  • Size of remote file: 1.15 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--462--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: ffb6006171408d24d62445806dc032493bb9e67c162a5cd01b4c5a5389b10f5f
  • Pointer size: 129 Bytes
  • Size of remote file: 1.02 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--504--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 13b7a83b794d85f5a53dd568d5ea970ba7d6bf27b2f28bb09fd4f60e7074cf65
  • Pointer size: 129 Bytes
  • Size of remote file: 1.13 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--549--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: c3ae588482d688788c7396fad51e2be8a3fc83355cf315d2b3734e706581c6dc
  • Pointer size: 128 Bytes
  • Size of remote file: 790 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--cvc_clinicdb--567--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 3a2fcfa3d99bc730684a155747f36ef9c43ced7f7bc9f47201ce4d3390dd4e92
  • Pointer size: 128 Bytes
  • Size of remote file: 755 Bytes
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju17r8il13910799dr2wme2e--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 08c5012e710d0160b2d36726217e88a9e9aa9aaea13db43ad2d0f3e7c92e02f1
  • Pointer size: 129 Bytes
  • Size of remote file: 1.84 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju45ty6zn9oz0850qy4qnck1--2d_none--0000_001.png ADDED

Git LFS Details

  • SHA256: 866766dbf021e725c42aed5ba53494a583ab7270300c90be510e349763c48f46
  • Pointer size: 129 Bytes
  • Size of remote file: 2.82 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju886ryxnsl50801r93jai7q--2d_none--0000_001.png ADDED

Git LFS Details

  • SHA256: e662c3d3e745cddfbd5797e684d782b25781db50fed60c48fac0b8493162bba9
  • Pointer size: 129 Bytes
  • Size of remote file: 3.1 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju8b542nr81x0871uxnkm9ih--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 30a4c0d215c0e67c0330c220c4bf5cbedc4f50f6fa7d5b7ca0aeab744d8e1dae
  • Pointer size: 129 Bytes
  • Size of remote file: 1.92 kB
benchmarks/VGMED/image_folder/SAMed2D_v1/endoscopy/masks/endoscopy_00--kvasir_seg--cju8bj2ssrmlm0871gc2ug2rs--2d_none--0000_000.png ADDED

Git LFS Details

  • SHA256: 524c3d700e17fcc34687646a9d63b5231b8e879324138a883670ca904530a9e4
  • Pointer size: 129 Bytes
  • Size of remote file: 1.22 kB
之前的代码版本/注意力用于sam的prompt的版本/MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl/utils/fsdp_utils.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import gc
16
+ from collections import defaultdict
17
+ from functools import partial
18
+ from typing import Callable, Union
19
+
20
+ import torch
21
+ from torch import nn
22
+ from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
23
+ from torch.distributed.fsdp._runtime_utils import _lazy_init
24
+ from torch.distributed.fsdp.wrap import transformer_auto_wrap_policy
25
+ from torch.optim import Optimizer
26
+ from transformers import PreTrainedModel
27
+ from transformers.trainer_pt_utils import get_module_class_from_name
28
+
29
+
30
+ def get_init_fn(model: nn.Module, device: Union[str, torch.device]) -> Callable[[nn.Module], None]:
31
+ param_occurrence = defaultdict(int)
32
+ for _, param in model.named_parameters(remove_duplicate=False):
33
+ param_occurrence[param] += 1
34
+
35
+ duplicated_params = {param for param in param_occurrence.keys() if param_occurrence[param] > 1}
36
+ materialized_params = {}
37
+
38
+ def init_fn(module: nn.Module):
39
+ for name, param in module.named_parameters(recurse=False):
40
+ if param in duplicated_params:
41
+ module._parameters[name] = materialized_params.setdefault(
42
+ param, nn.Parameter(torch.empty_like(param.data, device=device), requires_grad=param.requires_grad)
43
+ )
44
+ else:
45
+ module._parameters[name] = nn.Parameter(
46
+ torch.empty_like(param.data, device=device), requires_grad=param.requires_grad
47
+ )
48
+
49
+ return init_fn
50
+
51
+
52
+ def get_fsdp_wrap_policy(model: PreTrainedModel):
53
+ """Get FSDP wrap policy for the model.
54
+
55
+ Args:
56
+ module: The module to get wrap policy for
57
+ """
58
+ transformer_cls_to_wrap = set()
59
+ for module in model._no_split_modules:
60
+ transformer_cls = get_module_class_from_name(model, module)
61
+ if transformer_cls is None:
62
+ raise Exception(f"Cannot find {module} in pretrained model.")
63
+ else:
64
+ transformer_cls_to_wrap.add(transformer_cls)
65
+
66
+ return partial(transformer_auto_wrap_policy, transformer_layer_cls=transformer_cls_to_wrap)
67
+
68
+
69
+ @torch.no_grad()
70
+ def offload_fsdp_model(model: FSDP, empty_cache: bool = True):
71
+ # lazy init FSDP model
72
+ _lazy_init(model, model)
73
+ assert model._is_root, "Only support root model offloading to CPU"
74
+ for handle in model._all_handles:
75
+ if handle._offload_params:
76
+ continue
77
+
78
+ flat_param = handle.flat_param
79
+ assert (
80
+ flat_param.data.data_ptr() == flat_param._local_shard.data_ptr()
81
+ and id(flat_param.data) != id(flat_param._local_shard)
82
+ and flat_param.data.size() == flat_param._local_shard.size()
83
+ )
84
+ handle.flat_param_to("cpu", non_blocking=True)
85
+ # the following still keeps id(._local_shard) != id(.data)
86
+ flat_param._local_shard = flat_param.data
87
+ assert id(flat_param._local_shard) != id(flat_param.data)
88
+
89
+ if empty_cache:
90
+ torch.cuda.empty_cache()
91
+
92
+
93
+ @torch.no_grad()
94
+ def load_fsdp_model(model: FSDP, empty_cache: bool = True):
95
+ # lazy init FSDP model
96
+ _lazy_init(model, model)
97
+ assert model._is_root, "Only support root model loading to GPU"
98
+ for handle in model._all_handles:
99
+ if handle._offload_params:
100
+ continue
101
+
102
+ flat_param = handle.flat_param
103
+ handle.flat_param_to("cuda", non_blocking=True)
104
+ # the following still keeps id(._local_shard) != id(.data)
105
+ flat_param._local_shard = flat_param.data
106
+
107
+ if empty_cache:
108
+ gc.collect()
109
+
110
+
111
+ @torch.no_grad()
112
+ def offload_fsdp_optimizer(optimizer: Optimizer, empty_cache: bool = True):
113
+ if not optimizer.state:
114
+ return
115
+
116
+ for param_group in optimizer.param_groups:
117
+ for param in param_group["params"]:
118
+ state = optimizer.state[param]
119
+ for key, value in state.items():
120
+ if isinstance(value, torch.Tensor):
121
+ state[key] = value.to("cpu", non_blocking=True)
122
+
123
+ if empty_cache:
124
+ torch.cuda.empty_cache()
125
+
126
+
127
+ @torch.no_grad()
128
+ def load_fsdp_optimizer(optimizer: Optimizer, empty_cache: bool = True):
129
+ if not optimizer.state:
130
+ return
131
+
132
+ for param_group in optimizer.param_groups:
133
+ for param in param_group["params"]:
134
+ state = optimizer.state[param]
135
+ for key, value in state.items():
136
+ if isinstance(value, torch.Tensor):
137
+ state[key] = value.to("cuda", non_blocking=True)
138
+
139
+ if empty_cache:
140
+ gc.collect()
之前的代码版本/注意力用于sam的prompt的版本/MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl/utils/logger/logger.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """
15
+ A unified tracking interface that supports logging data to different backend
16
+ """
17
+
18
+ import os
19
+ from abc import ABC, abstractmethod
20
+ from typing import Any, Dict, List, Optional, Tuple, Union
21
+
22
+ import torch
23
+
24
+ from ..py_functional import convert_dict_to_str, flatten_dict, is_package_available, unflatten_dict
25
+ from .gen_logger import AggregateGenerationsLogger
26
+
27
+
28
+ if is_package_available("mlflow"):
29
+ import mlflow # type: ignore
30
+
31
+
32
+ if is_package_available("tensorboard"):
33
+ from torch.utils.tensorboard import SummaryWriter
34
+
35
+
36
+ if is_package_available("wandb"):
37
+ import wandb # type: ignore
38
+
39
+
40
+ if is_package_available("swanlab"):
41
+ import swanlab # type: ignore
42
+
43
+
44
+ class Logger(ABC):
45
+ @abstractmethod
46
+ def __init__(self, config: Dict[str, Any]) -> None: ...
47
+
48
+ @abstractmethod
49
+ def log(self, data: Dict[str, Any], step: int) -> None: ...
50
+
51
+ def finish(self) -> None:
52
+ pass
53
+
54
+
55
+ class ConsoleLogger(Logger):
56
+ def __init__(self, config: Dict[str, Any]) -> None:
57
+ print("Config\n" + convert_dict_to_str(config))
58
+
59
+ def log(self, data: Dict[str, Any], step: int) -> None:
60
+ print(f"Step {step}\n" + convert_dict_to_str(unflatten_dict(data)))
61
+
62
+
63
+ class MlflowLogger(Logger):
64
+ def __init__(self, config: Dict[str, Any]) -> None:
65
+ mlflow.start_run(run_name=config["trainer"]["experiment_name"])
66
+ mlflow.log_params(flatten_dict(config))
67
+
68
+ def log(self, data: Dict[str, Any], step: int) -> None:
69
+ mlflow.log_metrics(metrics=data, step=step)
70
+
71
+
72
+ class SwanlabLogger(Logger):
73
+ def __init__(self, config: Dict[str, Any]) -> None:
74
+ swanlab_key = os.getenv("SWANLAB_API_KEY")
75
+ swanlab_dir = os.getenv("SWANLAB_DIR", "swanlab_log")
76
+ swanlab_mode = os.getenv("SWANLAB_MODE", "cloud")
77
+ if swanlab_key:
78
+ swanlab.login(swanlab_key)
79
+
80
+ swanlab.init(
81
+ project=config["trainer"]["project_name"],
82
+ experiment_name=config["trainer"]["experiment_name"],
83
+ config={"UPPERFRAMEWORK": "EasyR1", "FRAMEWORK": "veRL", **config},
84
+ logdir=swanlab_dir,
85
+ mode=swanlab_mode,
86
+ )
87
+
88
+ def log(self, data: Dict[str, Any], step: int) -> None:
89
+ swanlab.log(data=data, step=step)
90
+
91
+ def finish(self) -> None:
92
+ swanlab.finish()
93
+
94
+
95
+ class TensorBoardLogger(Logger):
96
+ def __init__(self, config: Dict[str, Any]) -> None:
97
+ tensorboard_dir = os.getenv("TENSORBOARD_DIR", "tensorboard_log")
98
+ os.makedirs(tensorboard_dir, exist_ok=True)
99
+ print(f"Saving tensorboard log to {tensorboard_dir}.")
100
+ self.writer = SummaryWriter(tensorboard_dir)
101
+ config_dict = {}
102
+ for key, value in flatten_dict(config).items():
103
+ if isinstance(value, (int, float, str, bool, torch.Tensor)):
104
+ config_dict[key] = value
105
+ else:
106
+ config_dict[key] = str(value)
107
+
108
+ self.writer.add_hparams(hparam_dict=config_dict, metric_dict={"placeholder": 0})
109
+
110
+ def log(self, data: Dict[str, Any], step: int) -> None:
111
+ for key, value in data.items():
112
+ self.writer.add_scalar(key, value, step)
113
+
114
+ def finish(self):
115
+ self.writer.close()
116
+
117
+
118
+ class WandbLogger(Logger):
119
+ def __init__(self, config: Dict[str, Any]) -> None:
120
+ wandb.init(
121
+ project=config["trainer"]["project_name"],
122
+ name=config["trainer"]["experiment_name"],
123
+ config=config,
124
+ )
125
+
126
+ def log(self, data: Dict[str, Any], step: int) -> None:
127
+ wandb.log(data=data, step=step)
128
+
129
+ def finish(self) -> None:
130
+ wandb.finish()
131
+
132
+
133
+ LOGGERS = {
134
+ "console": ConsoleLogger,
135
+ "mlflow": MlflowLogger,
136
+ "swanlab": SwanlabLogger,
137
+ "tensorboard": TensorBoardLogger,
138
+ "wandb": WandbLogger,
139
+ }
140
+
141
+
142
+ class Tracker:
143
+ def __init__(self, loggers: Union[str, List[str]] = "console", config: Optional[Dict[str, Any]] = None):
144
+ if isinstance(loggers, str):
145
+ loggers = [loggers]
146
+
147
+ self.loggers: List[Logger] = []
148
+ for logger in loggers:
149
+ if logger not in LOGGERS:
150
+ raise ValueError(f"{logger} is not supported.")
151
+
152
+ self.loggers.append(LOGGERS[logger](config))
153
+
154
+ self.gen_logger = AggregateGenerationsLogger(loggers)
155
+
156
+ def log(self, data: Dict[str, Any], step: int) -> None:
157
+ for logger in self.loggers:
158
+ logger.log(data=data, step=step)
159
+
160
+ def log_generation(self, samples: List[Tuple[str, str, str, float]], step: int) -> None:
161
+ self.gen_logger.log(samples, step)
162
+
163
+ def __del__(self):
164
+ for logger in self.loggers:
165
+ logger.finish()