[Misc][Nixl] Unify _logical_to_remote_kernel_block_ids (#48717)
Signed-off-by: NickLucche <nicolo.lucchesi@mistral.ai>
This commit is contained in:
@@ -86,7 +86,9 @@ def test_logical_to_kernel_block_ids_with_hma():
|
||||
|
||||
# Test conversion: FA + SW group
|
||||
logical_block_ids = [[0, 1, 2], [3, 4]]
|
||||
kernel_block_ids = worker._logical_to_kernel_block_ids(logical_block_ids)
|
||||
kernel_block_ids = worker._logical_to_kernel_block_ids(
|
||||
logical_block_ids, worker._physical_blocks_per_logical_kv_block
|
||||
)
|
||||
|
||||
expected_kernel_block_ids = [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9]]
|
||||
assert kernel_block_ids == expected_kernel_block_ids, (
|
||||
@@ -179,7 +181,7 @@ def test_read_blocks_for_req_expands_remote_ids(
|
||||
"""_read_blocks_for_req must expand remote logical block IDs to kernel
|
||||
block IDs when kernel block size != logical block size.
|
||||
|
||||
The hot path always calls _logical_to_remote_kernel_block_ids with
|
||||
The hot path always calls _logical_to_kernel_block_ids with
|
||||
remote_info.remote_physical_blocks_per_logical (model-agnostic).
|
||||
"""
|
||||
from unittest.mock import MagicMock
|
||||
@@ -1140,7 +1142,7 @@ def test_derive_mamba_conv_split(
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_logical_to_remote_kernel_block_ids(
|
||||
def test_logical_to_kernel_block_ids_with_remote_ratio(
|
||||
mamba_enabled,
|
||||
swa_enabled,
|
||||
local_physical_per_logical,
|
||||
@@ -1148,7 +1150,7 @@ def test_logical_to_remote_kernel_block_ids(
|
||||
logical_block_ids,
|
||||
expected_kernel_block_ids,
|
||||
):
|
||||
"""Verify _logical_to_remote_kernel_block_ids uses the remote
|
||||
"""Verify _logical_to_kernel_block_ids uses the remote
|
||||
physical_per_logical for FA expansion, not the local one.
|
||||
|
||||
This was the root cause of silent accuracy corruption in Qwen3.5
|
||||
@@ -1169,7 +1171,7 @@ def test_logical_to_remote_kernel_block_ids(
|
||||
swa_enabled=swa_enabled,
|
||||
)
|
||||
|
||||
result = worker._logical_to_remote_kernel_block_ids(
|
||||
result = worker._logical_to_kernel_block_ids(
|
||||
logical_block_ids,
|
||||
remote_physical_per_logical,
|
||||
)
|
||||
|
||||
@@ -487,7 +487,7 @@ class TestPushWriterStartLoadKv:
|
||||
# path here.
|
||||
w._send_heartbeats = lambda metadata: None
|
||||
# Stub logical-to-kernel mapping used by reqs_to_recv.
|
||||
w._logical_to_kernel_block_ids = lambda x: x
|
||||
w._logical_to_kernel_block_ids = lambda x, ratio: x
|
||||
|
||||
meta = NixlConnectorMetadata()
|
||||
meta.push_registrations = {
|
||||
@@ -775,7 +775,7 @@ class TestPushWriterNegative:
|
||||
"""Empty metadata must not wake the writer or enqueue anything."""
|
||||
w = _StubWriterWorker.fresh()
|
||||
w._send_heartbeats = lambda metadata: None
|
||||
w._logical_to_kernel_block_ids = lambda x: x
|
||||
w._logical_to_kernel_block_ids = lambda x, ratio: x
|
||||
|
||||
meta = NixlConnectorMetadata()
|
||||
w.start_load_kv(meta)
|
||||
@@ -944,7 +944,7 @@ class TestPushWriterMlaReplication:
|
||||
rank_offset_factor=0,
|
||||
)
|
||||
}
|
||||
w._logical_to_remote_kernel_block_ids = lambda block_ids, ratio: block_ids
|
||||
w._logical_to_kernel_block_ids = lambda block_ids, ratio: block_ids
|
||||
w.dst_xfer_side_handles = {engine_id: {r: 1000 + r for r in d_ranks}}
|
||||
w.src_xfer_handles_by_block_size = {16: 2000}
|
||||
w._remote_agents = {engine_id: {(0, r): f"agent-{r}" for r in d_ranks}}
|
||||
|
||||
Reference in New Issue
Block a user