Diff Coverage

Diff: origin/master...HEAD, staged and unstaged changes

Source File Diff Coverage (%) Missing Lines
hyper_parallel/compile/compiler.py 25.0% 143-144,201-202,270,431
hyper_parallel/compile/compiler.py
139
140
141
142
143
144
145
146
147
148
        self._parameter_groups = {}
        self._parameter_shapes = {}
        self._parameter_layouts = None
        self._layout_signature = None
        self._compile_started = False
        self.device = device or torch.device(get_device_type())

        self.pass_config.validate()

        self._joint_graph = None
197
198
199
200
201
202
203
204
205
206
        Args:
            **inputs: Model inputs, forwarded to ``train_fn`` as keyword
                arguments and used to trace the joint graph
        """
        if self._compile_started:
            raise RuntimeError(
                "GraphCompiler.compile() may only be called once: the "
                "partitioning passes mutate the live model in place, so "
                "re-compiling (even after a failed attempt) would trace an "
                "already-partitioned model"
266
267
268
269
270
271
272
273
274

        # Passes mutate ``graph_module`` in place and return it, so the
        # transformed graph lives on ``joint_graph`` for ``forward_backward``.
        # Only the mutating passes make a retry unsafe, so guard from here.
        self._compile_started = True
        pipeline.run(joint_graph.graph_module, **pass_kwargs)

        if joint_graph.input_guards is not None:
            joint_graph.input_guards.refresh()
427
428
429
430
431
432
433
434
            self._parameter_groups[name] = (registered[ranks], shard.size())

    def _mesh_device_type(self) -> str:
        """Return the backend of the self-built mesh, honoring ``device``."""
        return torch.device(self.device).type

    def _init_device_mesh(self, mesh_context: Optional[Any] = None):
        """Initialize the DP process group(s) for the configured ``dp_mode``.