mudler / mudler/vllm.cpp

port(KERNEL-ATTN-MLA-SPARSE): MLA chunked context is the pre-b38e111d3e equal-share grid, not per-request packing

Open
#2,650 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
423
Forks
53
Avg merge
20h 26m
Merged PRs (30d)
310

Description

Row: KERNEL-ATTN-MLA-SPARSE

Found by #2647 (PORT-NOW wave
PORTQ-3, tranche 81-120). Nothing was executed: this is a static reading of the
tree at e24ec8bfd against upstream b38e111d3e (vllm#50613), read with
git show at that revision.

What is missing

Upstream b38e111d3e replaces MLA chunked-context planning. The old scheme gives
every with-context prefill an equal share of the workspace and lays chunks out on
a [num_chunks, num_prefills] grid, so a chunk can contain requests that
contribute zero tokens to it. The new plan_mla_context_chunks packs requests in
order and splits on an aligned boundary when the workspace fills, so a chunk
covers a contiguous run of requests and charges attention, up-projection and
merge only to them.

This tree carries the pre-commit scheme, line for line.
include/vllm/model_executor/layers/attention/mla_chunked_context.h:129-130:

int64_t max_context_chunk = workspace_size / num_prefills_with_context;
max_context_chunk = (max_context_chunk / page_size) * page_size;

That is the equal-share division the commit deletes. The header's own comment at
:35-40 records chunks containing zero-token requests as a live hazard, which is
exactly the condition upstream's packer removes by construction.

Size

Roughly 400-600 lines over 6-8 files: rewrite BuildMlaChunkedContext, change
the MlaChunkedContextMetadata / MlaChunkDeviceMetadata shape to carry a
request slice and a continuation flag, rework ComputeMlaPrefillContext
(mla_chunked_context.h:254-300) into a request-slice merge, update the three
call sites (src/vllm/model_executor/models/deepseek_v2.cpp:228,
minicpm3.cpp:119, kimi_linear_device.cpp:2028) and extend
tests/vt/test_ops_mla_chunked_context.cpp.

The DCP half of the upstream diff is inert here: dcp_world_size is 1 at
src/vllm/v1/core/sched/scheduler.cpp:280 and the header states it ports only
the non-DCP branch.

Expected observable effect

Workspace efficiency and chunk count, not tokens. Merging is order-associative
and vt::MergeAttnStates already handles the double -inf case, so token-exact
output is the expectation. That is an argument from the code, not a
measurement
— nothing was run for this issue, and whoever ports it owes the
differential against the pinned oracle.

Owner

KERNEL-ATTN-MLA-SPARSE (.agents/kernel-matrix.md:140, state PARTIAL, claim
CLAIM-MLA-DEEPSEEK) explicitly owns "the PREFILL PATH and CHUNKED-CONTEXT LOOP
(W5)", which is this code.

Not in scope here

This issue does not advance the parity pin. b38e111d3e is inside the
5559679229..e126687a9a window that #2611
owns.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing include/vllm/model_executor/layers/attention/mla_chunked_context.h with upstream b38e111d3e, focusing on BuildMlaChunkedContext and ComputeMlaPrefillContext. Then trace the call sites in deepseek_v2.cpp, minicpm3.cpp, and kimi_linear_device.cpp, and extend tests/vt/test_ops_mla_chunked_context.cpp; done means matching the pinned oracle's chunking while preserving token-exact output.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.