Skip to content

SGLang paged allocator free path should move indices to CPU before torch.unique #382

Description

@shipiyouniao

Problem

ElasticPagedTokenToKVPoolAllocator.free() computes page ids from free_index and then converts the result to Python indices for kvcached_allocator.free().

When free_index is a GPU tensor, doing the unique/conversion path directly can couple allocator free bookkeeping to CUDA device execution and synchronization behavior. This is fragile for high-concurrency SGLang serving paths.

Expected behavior

Move the free index tensor to CPU before deriving unique page ids and converting them to Python indices. The allocator backend only needs page id integers for bookkeeping, so the Python conversion should happen from CPU data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions