Skip to content

Add flag-controlled sliced MLA projections - #4630

Open
dandragona wants to merge 4 commits into
mainfrom
sliced-mla-projections
Open

Add flag-controlled sliced MLA projections#4630
dandragona wants to merge 4 commits into
mainfrom
sliced-mla-projections

Conversation

@dandragona

@dandragona dandragona commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Performance optimizations that avoids an unnecessary split operation.

  • Add use_sliced_mla_projections flag to base.yml and types.py.
  • Support slice_bounds in DenseGeneral.call to slice projection weights/bias prior to contraction for unquantized paths.
  • Update mla_query_projection and mla_get_key_value in attention_mla.py to use sliced projections when enabled.
  • Add unit test coverage in linears_test.py.

Tests

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Port performance optimization from CL 947805696 into MaxText under a new configuration flag use_sliced_mla_projections (defaulting to False).

- Add use_sliced_mla_projections flag to base.yml and types.py.
- Support slice_bounds in DenseGeneral.__call__ to slice projection weights/bias prior to contraction for unquantized paths.
- Update mla_query_projection and mla_get_key_value in attention_mla.py to use sliced projections when enabled.
- Add unit test coverage in linears_test.py.

TAG=agy
CHANGE_STEWARD=true
Verify correctness of sliced MLA projections by comparing outputs against the default unsliced implementation in train, prefill, and autoregressive modes.

CHANGE_STEWARD=true
TAG=agy
CONV=86839aa9-de96-414b-b896-1ac9aeb38589
Add documentation for the new use_sliced_mla_projections performance optimization flag in the DeepSeek runner guide.

TAG=agy
CONV=a262e292-a0d4-49f9-ad26-f42e697a5979
CHANGE_STEWARD=true
Remove tpu_only decorator from test_sliced_mla_projections to run it on CPU. Add test_slice_bounds_with_quantization to cover assertion in DenseGeneral. Format with pyink and fix pylint warnings.

TAG=agy

CONV=e336d40c-d648-45cb-9abd-7b79a924be5e

CHANGE_STEWARD=true
@dandragona
dandragona force-pushed the sliced-mla-projections branch from 6bd7660 to 169107a Compare July 27, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant