Repository navigation
Add SenseNova-Loop-9B (looped transformer + mHC routing) - #2079
Open
yunlistener wants to merge 1 commit into
Open
yunlistener wants to merge 1 commit into
yunlistener wants to merge 1 commit into
Conversation
## Requirements - ☑️ I understand it is strictly prohibited to use AI to write PR description - AI usage disclosure: (fill in before marking ready for review) ## Model information - Name: SenseNova-Loop-9B - Homepage: https://huggingface.co/sensenova/SenseNova-Loop-9B - Reference implementation: https://huggingface.co/sensenova/SenseNova-Loop-9B/blob/main/modeling_sensenova_loop.py (published by the model authors as remote code; not in transformers upstream) ## Supported checkpoints - https://huggingface.co/sensenova/SenseNova-Loop-9B (BF16 reference) - https://huggingface.co/listener8341/SenseNova-Loop-9B-MLX-6bit (MLX 6-bit, produced by this model file with `mlx_lm.convert`) ## Verification Run mlx-lm command: ```console mlx_lm.generate --model SenseNova-Loop-9B-6bit -p "The secret to baking a good cake is" -m 300 ``` Output: ``` The secret to baking a good cake is a combination of several key factors: **Precision & Measurement** - Use a kitchen scale for accuracy. Baking is chemistry, and even small imprecisions can throw off the balance. - Measure ingredients by weight rather than volume when possible. **Room-Temperature Ingredients** - Let butter, eggs, and milk come to room temperature. This helps with emulsification and even mixing. **Fresh Leavening** - Use fresh baking powder, baking soda, or yeast. Old leavening agents won't activate properly. **Don't Overmix** - Mix just until combined. Overmixing develops gluten, leading to a tough, dense crumb. **Patience** - Bake at the right temperature. Too hot can cause cracking or a gummy center. - Test doneness with a toothpick rather than relying solely on time. **Quality Ingredients** - Use good butter Prompt: 18 tokens, 57.528 tokens-per-sec Generation: 300 tokens, 14.706 tokens-per-sec Peak memory: 7.382 GB ``` ## Numerical agreement with the reference implementation Compared against the HF `modeling_sensenova_loop.py` on an 11-token probe: per-position logit cosine 0.9999+, argmax agreement 11/11, and repeated forwards are bit-identical. ## Notes for reviewers - **The cache is sized by the execution plan, not by the physical layer count.** `loop_settings` expands `[0..3] + [4..27] x2 + [28..31]` = 56 visits, so `make_cache()` returns 56 slots. This is the same convention the existing `iquestloopcoder` model uses (`2 * num_layers` for a full-depth loop); SenseNova generalises "all layers twice" to "an interval N times", which is why `len(plan)` is used instead of a constant multiplier. - **The mHC tensors must stay fp32.** `quant_predicate` / `cast_predicate` keep the mHC weights and biases, the GDN `A_log`/`dt_bias` and every RMSNorm weight out of quantization and out of dtype casting. The 20-iteration Sinkhorn is numerically sensitive and bf16 there silently produces garbage. - Text tower only: the visual encoder, the MTP head and the loop gate are not implemented. - Pre-existing test failures: a full `unittest discover tests/` run reports 23 failures on this machine (numerically sensitive batch / cache / ssm tests), and a clean checkout of `main` produces an identical failure set. `test_all_models` passes with the new config.
This branch has not been deployed
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.
Requirements
Model information
Supported checkpoints
mlx_lm.convert)Verification
Run mlx-lm command:
mlx_lm.generate --model SenseNova-Loop-9B-6bit -p "The secret to baking a good cake is" -m 300Output:
Numerical agreement with the reference implementation
Compared against the HF
modeling_sensenova_loop.pyon an 11-token probe: per-position logit cosine 0.9999+, argmax agreement 11/11, and repeated forwards are bit-identical.Notes for reviewers
loop_settingsexpands[0..3] + [4..27] x2 + [28..31]= 56 visits, somake_cache()returns 56 slots. This is the same convention the existingiquestloopcodermodel uses (2 * num_layersfor a full-depth loop); SenseNova generalises "all layers twice" to "an interval N times", which is whylen(plan)is used instead of a constant multiplier.quant_predicate/cast_predicatekeep the mHC weights and biases, the GDNA_log/dt_biasand every RMSNorm weight out of quantization and out of dtype casting. The 20-iteration Sinkhorn is numerically sensitive and bf16 there silently produces garbage.unittest discover tests/run reports 23 failures on this machine (numerically sensitive batch / cache / ssm tests), and a clean checkout ofmainproduces an identical failure set.test_all_modelspasses with the new config.