Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText. - #5072
Open
copybara-service[bot] wants to merge 1 commit into
Open
Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText.#5072copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
parambole,
richjames0,
shralex,
shuningjin,
vipannalla and
xibinliu
as code owners
August 31, 2026 16:10
copybara-service
Bot
force-pushed
the
test_972617925
branch
2 times, most recently
from
September 2, 2026 20:51
ccea51d to
03b1b53
Compare
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
copybara-service
Bot
force-pushed
the
test_972617925
branch
from
September 2, 2026 20:59
03b1b53 to
8e937d9
Compare
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.
Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText.
Refactors the MaxText Lineage integration to use Lineage's high-level
dsv3.pyentry point as the unified integration point for DeepSeek-V3 execution (dense layers followed by sparse layers).Lineage Changes:
learning/performance/lineage/BUILDto grant package visibility to//third_party/py/maxtext:__subpackages__.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 (DSv3WeightsPytreecontaining 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 todsv3.dsv3.LineageAdapter(run_lineage_dsv3) into LinenDecoderandNNXDecoderto execute the full DeepSeek-V3 layer stack whenuse_lineage=true.lineage_sparse_adapter.py,use_lineage_sparse_layersflag, and early-return branching indeepseek.py). Removed all defensive fallback branches to maintain a lean, canonical integration.deepseek3-671b-lineage.yml,base.yml, andtypes.pywithuse_lineageand related Lineage flags.copy.bara.skyto excludelineage_adapter.py,deepseek3-671b-lineage.yml, and Lineage tests from open-source export.lineage_adapter_test.pyandlineage_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 oflineage_adapter_tpu_test, and XManager training runs xid/285946702