apple envy moe implementation - #4645
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
🤖 I'm sorry @RissyRan, but I was unable to process your request. Please see the logs for more details. |
JamesDeng42
left a comment
There was a problem hiding this comment.
left some comments, otherwise, it looks good to me.
d4cb0d7 to
9194371
Compare
|
🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
This Pull Request successfully implements the Apple Envy MoE model (specifically supporting the Switch-Base, Switch-Large, and Switch-XXL models) in MaxText. The alternating inhomogeneous dense and sparse layers, RMSNorm configurations, and parameters are precisely matched (reaching an exact 100% parameter count match of 22.07B parameters for Switch-Base). The changes are exceptionally well-structured, follow existing design conventions, and are verified by unit tests.
🔍 General Feedback
- Rigorous Validation: The detailed parameter equivalence report comparing AXLearn and MaxText structure and shape mappings is exemplary and ensures high correctness.
- Clean Architectural Integration: Adding Envy as an inhomogeneous decoder block option integrates perfectly across Linen (
decoders.py) and NNX (nnx_decoders.py) layer builders. - Comprehensive Test Coverage: The unit test
tests/unit/envy_test.pycovers the compilation, initialization, and training forward pass.
RissyRan
left a comment
There was a problem hiding this comment.
LGTM at high level. Will you test logits alignment in next PR for the model?
9194371 to
0b37548
Compare
RissyRan
left a comment
There was a problem hiding this comment.
LGTM! Are you planning to test logits alignment?
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'MaxText Test Execution Times'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.15.
| Benchmark suite | Current: cb4b671 | Previous: c78ebcf | Ratio |
|---|---|---|---|
Total CPU-POST-TRAINING-UNIT Tests Duration |
365.5109999999999 sec |
312.1020000000001 sec |
1.17 |
Total TPU-POST-TRAINING-UNIT Tests Duration |
91.48300000000003 sec |
76.93599999999999 sec |
1.19 |
This comment was automatically generated by workflow using github-action-benchmark.
cb4b671 to
e11be1e
Compare
e11be1e to
e468ac5
Compare
|
Closing and using different PR: #4695 |
Description
Implements Apple Envy MoE model as described here
Tests
Envy MoE Parameter Equivalence Report
This report compares the parameter structures of Apple's Envy Switch-Base model between AXLearn and MaxText to verify architectural correctness.
1. Parameter Shape Mapping
Here is the direct mapping of parameter tensors for the 12-layer Switch-Base model (6 repeat blocks of Alternating Dense and Sparse MoE layers):
decoder/emb/token_emb/weight[32768, 1536]token_embedder/embedding(32768, 1536)logits_via_embedding: true)decoder/output_norm/scale[1536]decoder_norm/scale(1536,)self_attention/norm/scale(6, 1536)pre_self_attention_layer_norm/scale(1536, 6)self_attention/attention/i_proj/i_proj/qkv_proj/weight(6, 1536, 36, 128)-
query/kernel(1536, 6, 12, 128)-
key/kernel(1536, 6, 12, 128)-
value/kernel(1536, 6, 12, 128)AXLearn groups QKV along the projection axis:
attention/scale_query/norm/scale(6, 128)attention/scale_key/norm/scale(6, 128)query_norm/scale(128, 6)key_norm/scale(128, 6)self_attention/attention/o_proj/weight(6, 1536, 12, 128)out/kernel(12, 6, 128, 1536)feed_forward/prenorm/scale(6, 1536)post_self_attention_layer_norm/scale(1536, 6)feed_forward/postnorm/scale(6, 1536)post_ffw_norm/scale(1536, 6)use_post_ffw_norm: true)feed_forward/linear1_0/weight(6, 1536, 6144)feed_forward/linear1_1/weight(6, 1536, 6144)feed_forward/linear2/weight(6, 6144, 1536)wi_0/kernel(1536, 6, 6144)wi_1/kernel(1536, 6, 6144)wo/kernel(6144, 6, 1536)feed_forward/prenorm/scale(6, 1536)post_self_attention_layer_norm/scale(1536, 6)feed_forward/postnorm/scale(6, 1536)post_ffw_norm/scale(1536, 6)use_post_ffw_norm: true)feed_forward/gate_weight(6, 1536, 128)MoeBlock_0/gate/kernel(1536, 6, 128)feed_forward/wi_0_weight(6, 128, 1536, 6144)feed_forward/wi_1_weight(6, 128, 1536, 6144)feed_forward/wo_weight(6, 128, 6144, 1536)MoeBlock_0/wi_0(128, 6, 1536, 6144)MoeBlock_0/wi_1(128, 6, 1536, 6144)MoeBlock_0/wo(128, 6, 6144, 1536)2. Parameter Counts Analysis
22,077,958,656(22.07B)22,077,958,656(22.07B)0parameters (100% exact match)Key Configurations Enabled:
logits_via_embedding: true: Shares the token embedding parameters with the output logits projection.use_post_ffw_norm: true: Activates the post-FFN normalization layer (post_ffw_normin MaxText, mapping topostnormin AXLearn'shybridnormFFN structure).Ran test:
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.