[NIXL] Add CacheLayout meta-tensor abstraction for descriptor generation#44362
Draft
ZhanqiuHu wants to merge 13 commits into
Draft
[NIXL] Add CacheLayout meta-tensor abstraction for descriptor generation#44362ZhanqiuHu wants to merge 13 commits into
ZhanqiuHu wants to merge 13 commits into
Conversation
Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Introduce CacheLayout, a meta-tensor-based abstraction that encodes KV cache memory layout (shape, strides, shard_axis) and generates NIXL descriptors without manual byte arithmetic. - layout.py: CacheLayout with narrow(), sub_block(), descriptors(), from_tensor() (local path), from_physical() (remote path), and build_attn_layout() factory for attention regions. - worker.py: Wire CacheLayout into _build_fa_local (uses stored _region_layouts) and _build_fa_remote (uses build_attn_layout + TPTransferSlice.narrow() for TP head slicing). Mamba regions get CacheLayout with shard_axis=1; remote Mamba path unchanged. Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Replace the single `shard_axis` int and `virtually_split_kv` boolean with two explicit tuple annotations: - `iter_axes`: ordered dim indices that descriptors() iterates over (outer→inner), e.g. K/V split and blocks - `shard_axes`: dim indices sliced for TP sharding This makes the K/V split a proper axis in the layout shape rather than a boolean flag, inspired by TVM's named axis types. Signed-off-by: ZhanqiuHu <zhu@redhat.com>
Contributor
Author
|
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CacheLayout, a meta-tensor-based abstraction that encodes KV cache memory layout (shape, strides,shard_axis) and generates NIXL descriptors without manual byte arithmetic.CacheLayoutinto_build_fa_localand_build_fa_remote, replacing manualif is_blocks_first/ K-V split / TP head slicing logic withdescriptors(),sub_block(), andnarrow().TPTransferSlice/get_tp_transfer_slices).Key changes
layout.py(new file):CacheLayoutdataclass withmeta(PyTorch meta tensor) andshard_axisfrom_tensor()— local path, captures actual tensor's shape/stridesfrom_physical()— remote path, builds from raw shape/stridesnarrow(),select(),sub_block(),descriptors()— TP slicing, block splitting, and descriptor generationbuild_attn_layout()— factory for attention region layoutsworker.py(modified):_region_layouts: list[CacheLayout]built inregister_kv_caches(one per NIXL region,shard_axis=1for Mamba,shard_axis=2for blocks-first attention,shard_axis=1for non-blocks-first)_build_fa_local: iterates_region_layouts, callssub_block()+descriptors()_build_fa_remote: usesbuild_attn_layout()+TPTransferSlice.remote_read_offsetvianarrow()for TP head slicing, hoisted outside loop since block_lens are uniform for non-MLATest plan
test_nixl_connector.py)