Diff Coverage

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

Source File Diff Coverage (%) Missing Lines
hyper_parallel/compile/compiler.py 100%  
hyper_parallel/components/modules/engram/parallel_engram.py 12.5% 316,320,323-326,334
hyper_parallel/components/modules/engram/parallel_engram.py
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
            )
        num_local_rows = padded_num_embeddings // ep_size
        row_start = ep_rank * num_local_rows
        flat_ids = hash_ids.reshape(-1)
        torch._check_index(  # pylint: disable=protected-access
            ((flat_ids >= 0) & (flat_ids < padded_num_embeddings)).all().item(),
            lambda: "Engram hash requested a row outside the padded table",
        )
        owner = torch.div(flat_ids, num_local_rows, rounding_mode="floor").long()
        # A fixed-size histogram keeps the peer counts in the graph even when
        # an owner receives no rows. The exchange only needs one count per peer.
        local_counts = owner.new_zeros(ep_size).scatter_add_(0, owner, torch.ones_like(owner))
        received_counts = ep_exchange_counts(local_counts, ep_group)
        send_counts = ep_split_sizes(local_counts, flat_ids.numel())
        recv_counts = ep_split_sizes(received_counts)

        # Ascend ArgSort executes integer inputs on AiCPU. The owner range is
        # bounded by ep_size, so float32 preserves it exactly and stays on AiCore.
        sort_indices = torch.argsort(owner.float(), stable=True)
330
331
332
333
334
335
336
337
338
        sort_indices = torch.argsort(owner.float(), stable=True)
        sorted_ids = flat_ids.index_select(0, sort_indices)
        received_ids = ep_all_to_all(sorted_ids, send_counts, recv_counts, ep_group)
        local_ids = received_ids - row_start
        torch._check_index(  # pylint: disable=protected-access
            ((local_ids >= 0) & (local_ids < num_local_rows)).all().item(),
            lambda: "Engram EP routing delivered a row to the wrong owner",
        )
        # Call the child module instead of reading ``embedding.weight``