Diff Coverage

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

Source File Diff Coverage (%) Missing Lines
hyper_parallel/data/batching/get_batch.py 0.0% 93,120-122,124,127-128,130
hyper_parallel/distributed/encoder_parallel/contracts.py 100%  
hyper_parallel/distributed/encoder_parallel/runtime.py 100%  
hyper_parallel/distributed/encoder_parallel/transport.py 96.4% 47,64,78
hyper_parallel/trainer/vlm_trainer.py 50.0% 167
hyper_parallel/data/batching/get_batch.py
89
90
91
92
93
94
95
96
97
        self.sequence_parallel = bool(mesh_context.sequence_parallel)
        self.runtime_input_adapter = runtime_input_adapter
        self.cp_sharder = CPBatchSharder(self.parallel_context, token_fields=OMNI_CP_TOKEN_FIELDS)
        self.tp_broadcaster = TPBatchBroadcaster(self.parallel_context, device)
        self.batch_transport = None
        self._batch_index = 0

    def __call__(
            self,
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
                tuple(local_batch["input_ids"].shape), self.parallel_context.tp_world_size,
                self.parallel_context.cp_world_size, self.parallel_context.cp_rank, enabled=True,
            )

        transport_inputs = {}
        if self.batch_transport is None:
            device_batch = self.tp_broadcaster.broadcast(local_batch, broadcast_all_fields=True)
        else:
            device_batch, transport_inputs = self.batch_transport(local_batch, self.tp_broadcaster)
        runtime_inputs = self._build_runtime_inputs(device_batch)
        model_inputs, loss_inputs = self._split_model_and_loss_inputs(device_batch)
        if set(transport_inputs).intersection((*device_batch, *runtime_inputs)):
            raise ValueError("batch transport cannot replace Omni model or runtime inputs")
        model_inputs.update(runtime_inputs)
        model_inputs.update(transport_inputs)
        # Shapes are host metadata; inspecting device tensor values here can stall collectives.
        logger.debug(
            "Omni get_batch: batch=%d transport_ready fields=%s runtime_fields=%s",
            self._batch_index,
hyper_parallel/distributed/encoder_parallel/transport.py
43
44
45
46
47
48
49
50
51

    def __init__(self, *, runtime: EncoderParallelRuntime, chunk_bytes: int = _CHUNK_BYTES) -> None:
        """Set the runtime and maximum device staging size in bytes."""
        if isinstance(chunk_bytes, bool) or not isinstance(chunk_bytes, int) or chunk_bytes < 1:
            raise ValueError("encoder transport chunk_bytes must be a positive integer")
        self.runtime = runtime
        self.chunk_bytes = chunk_bytes

    def _prepare_source(self, batch: Mapping[str, Any]) -> dict[str, Any]:
60
61
62
63
64
65
66
67
68
                raise ValueError("encoder transport fields cannot be supplied by the DataLoader")
            for name in bridge.input_fields:
                value = batch.get(name)
                if torch.is_tensor(value) and value.device.type != "cpu":
                    raise ValueError(f"encoder source field {name} must remain on the CPU")
            items = bridge.parse_images(batch)
            pixels = batch.get(bridge.payload_field)
            if pixels is not None:
                dtype = pixels.dtype
74
75
76
77
78
79
80
81
82
    def _check_source_errors(self, error: str | None, device: Any) -> None:
        """Make all FSDP participants fail before plan or payload collectives."""
        invalid = torch.tensor(int(error is not None), device=device)
        if dist.is_initialized() and self.runtime.global_mesh.size() > 1:
            dist.all_reduce(invalid, op=dist.ReduceOp.MAX, group=self.runtime.global_mesh.get_group())
        if bool(invalid.item()):
            raise ValueError(f"invalid encoder CPU input: {error or 'another source rank rejected its batch'}")

    def __call__(self, batch: Mapping[str, Any] | None,
hyper_parallel/trainer/vlm_trainer.py
163
164
165
166
167
168
169
170
171
        )
        if encoder_runtime is not None:
            if not isinstance(get_batch, OmniParallelBatch):
                raise ValueError("encoder parallel requires OmniParallelBatch")
            get_batch.batch_transport = EncoderParallelBatchTransport(runtime=encoder_runtime)
        self.base.get_batch = get_batch

    @property
    def distributed_setup(self) -> Any: