Set static graph for DDP. It is recommended to set static graph in the DDP constructor, which will call this private API internally.
(self)
| 2198 | self.reducer._set_ddp_runtime_logging_sample_rate(sample_rate) |
| 2199 | |
| 2200 | def _set_static_graph(self): |
| 2201 | """ |
| 2202 | Set static graph for DDP. |
| 2203 | |
| 2204 | It is recommended to set static graph in the DDP constructor, which will |
| 2205 | call this private API internally. |
| 2206 | """ |
| 2207 | # If self.static_graph has been set, no need to set it again |
| 2208 | if self.static_graph: |
| 2209 | warnings.warn( |
| 2210 | "You've set static_graph to be True, no need to set it again." |
| 2211 | ) |
| 2212 | return |
| 2213 | self.static_graph = True |
| 2214 | self._static_graph_delay_allreduce_enqueued = False |
| 2215 | self.reducer._set_static_graph() |
| 2216 | assert self.logger is not None |
| 2217 | self.logger._set_static_graph() |
| 2218 | if self.find_unused_parameters: |
| 2219 | warnings.warn( |
| 2220 | "You passed find_unused_parameters=true to DistributedDataParallel, " |
| 2221 | "`_set_static_graph` will detect unused parameters automatically, so " |
| 2222 | "you do not need to set find_unused_parameters=true, just be sure these " |
| 2223 | "unused parameters will not change during training loop while calling " |
| 2224 | "`_set_static_graph`." |
| 2225 | ) |
| 2226 | |
| 2227 | def _remove_autograd_hooks(self): |
| 2228 | """Remove autograd hooks registered by the reducer on the model parameters.""" |