fix(perf): skip solar-open layer eval during decode#22
Merged
Conversation
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.
Summary
SolarOpenModel::forwardwas callingmlxcel_core::eval_allon the hidden state after every transformer layer to keep the MoE compute graph bounded (128 experts × ~50 ops/layer). That guard is needed for multi-token prefill — without it, the graph grows quadratically withseq_len × n_layers— but it's pure overhead on single-token decode, where the final-logits evaluation flushes the graph once anyway. The per-layer flush was costing ~48 GPU synchronizations per generated token.Cherry-picked from
mlxcel-internalcommitc5e88612(the internaldocs/model_tests_m5max.mdupdate was intentionally excluded, same as #20 — it references an internal-only baseline doc that was never in the public repo).What changed
src/models/solar_open.rs— gates the per-layereval_allon prefill only:should_eval_layer_outputsis a 3-line helper that checksinput_ids.shape.last() != Some(1), plus a unit test that pins the decode-vs-prefill behaviour.Verification
make verify-fmt— cleanmake verify-clippy(CI-faithful:--all-targets --features metal,accelerate -- -D warnings) — clean in 22s (warm cache)make verify-testskipped (15–30 min release-mode run); the upstream commit is already validated inmlxcel-internalagainst the M5 Max sweep.