Skip to content

Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText. - #5072

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_972617925
Open

Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText.#5072
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_972617925

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText.

Refactors the MaxText Lineage integration to use Lineage's high-level dsv3.py entry point as the unified integration point for DeepSeek-V3 execution (dense layers followed by sparse layers).

Lineage Changes:

  • Visibility: Updated learning/performance/lineage/BUILD to grant package visibility to //third_party/py/maxtext:__subpackages__.
  • Launcher: Added learning/performance/lineage/scripts/launch_dsv3_batchsplit_maxtext.sh (XManager launch script for 512-core Ghostfish TPU v7x).

MaxText Changes:

  • lineage_adapter.py: Translates MaxText parameter structures into Lineage's typed dataclasses (DSv3WeightsPytree containing both dense MLA/MLP weights and sparse MoE weights). Manages physical mesh axis mappings, YaRN RoPE frequencies, Splash Attention kernel initialization, and delegates execution directly to dsv3.dsv3.
  • Decoders: Integrated LineageAdapter (run_lineage_dsv3) into Linen Decoder and NNXDecoder to execute the full DeepSeek-V3 layer stack when use_lineage=true.
  • Cleanup: Removed vestigial remnants of the previous sparse-only integration (lineage_sparse_adapter.py, use_lineage_sparse_layers flag, and early-return branching in deepseek.py). Removed all defensive fallback branches to maintain a lean, canonical integration.
  • Configs: Updated deepseek3-671b-lineage.yml, base.yml, and types.py with use_lineage and related Lineage flags.
  • Export: Updated copy.bara.sky to exclude lineage_adapter.py, deepseek3-671b-lineage.yml, and Lineage tests from open-source export.
  • Tests: Added unit and TPU tests in lineage_adapter_test.py and lineage_adapter_tpu_test.py; updated existing MaxText test suites (batchsplit_google_test, train_compile_google_test).

Tested:
Verified via unit test suites (lineage_adapter_test, batchsplit_google_test, train_compile_google_test), compilation of lineage_adapter_tpu_test, and XManager training runs xid/285946702

@copybara-service
copybara-service Bot force-pushed the test_972617925 branch 2 times, most recently from ccea51d to 03b1b53 Compare September 2, 2026 20:51
@copybara-service copybara-service Bot changed the title Integrate Lineage DeepSeek-V3 58 sparse layer scan into MaxText. Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText. Sep 2, 2026
Refactors the MaxText Lineage integration to use Lineage's high-level `dsv3.py` entry point as the unified integration point for DeepSeek-V3 execution (dense layers followed by sparse layers).

Lineage Changes:
* Visibility: Updated `learning/performance/lineage/BUILD` to grant package visibility to `//third_party/py/maxtext:__subpackages__`.
* Launcher: Added `learning/performance/lineage/scripts/launch_dsv3_batchsplit_maxtext.sh` (XManager launch script for 512-core Ghostfish TPU v7x).

MaxText Changes:
* `lineage_adapter.py`: Translates MaxText parameter structures into Lineage's typed dataclasses (`DSv3WeightsPytree` containing both dense MLA/MLP weights and sparse MoE weights). Manages physical mesh axis mappings, YaRN RoPE frequencies, Splash Attention kernel initialization, and delegates execution directly to `dsv3.dsv3`.
* Decoders: Integrated `LineageAdapter` (`run_lineage_dsv3`) into Linen `Decoder` and `NNXDecoder` to execute the full DeepSeek-V3 layer stack when `use_lineage=true`.
* Cleanup: Removed vestigial remnants of the previous sparse-only integration (`lineage_sparse_adapter.py`, `use_lineage_sparse_layers` flag, and early-return branching in `deepseek.py`). Removed all defensive fallback branches to maintain a lean, canonical integration.
* Configs: Updated `deepseek3-671b-lineage.yml`, `base.yml`, and `types.py` with `use_lineage` and related Lineage flags.
* Export: Updated `copy.bara.sky` to exclude `lineage_adapter.py`, `deepseek3-671b-lineage.yml`, and Lineage tests from open-source export.
* Tests: Added unit and TPU tests in `lineage_adapter_test.py` and `lineage_adapter_tpu_test.py`; updated existing MaxText test suites (`batchsplit_google_test`, `train_compile_google_test`).

Tested:
Verified via unit test suites (`lineage_adapter_test`, `batchsplit_google_test`, `train_compile_google_test`), compilation of `lineage_adapter_tpu_test`, and XManager training runs xid/285946702
PiperOrigin-RevId: 972617925
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