Repository navigation
feat(models): add Arcee AFM-4.5B (arcee) dense support - #3270
Merged
Merged
Conversation
Member
Author
Implementation Review SummaryIntent
Findings AddressedNone needed fixing at CRITICAL or HIGH. The YaRN screening matches transformers 5.24 Remaining Items
Verification
|
inureyes
added a commit
that referenced
this pull request
Nov 22, 2026
Bilingual technical report for the Arcee AFM dense support PR.
Adds the dense Arcee family (model_type arcee, ArceeForCausalLM). The decoder reuses the shared llama3 attention, including YaRN, and adds a gate-free squared-ReLU MLP. The config translation refuses activations, RoPE types and YaRN settings the shared path would decode differently from transformers. Parity reference is Hugging Face transformers ArceeForCausalLM 5.24.0 (maintainer decision), scored by the new scripts/arcee_oracle_trace.py with relu and no-yarn negative arms. On AFM-4.5B the teacher-forced trace has no decided-position disagreement over 2048 and 8192 positions. Closes #1719
Move the YaRN truncate screen into the ArceeConfig Deserialize impl so the adapter route refuses it too, and refuse partial_rotary_factor other than 1, a conflicting top-level original_max_position_embeddings, a type / rope_type conflict, an inverted beta pair and factorless linear or llama3 blocks. Name Arcee in the fused_add_rms_norm, forward_split_attention and RoPE-override rosters, and record the measured commit in the benchmark row.
A top-level original_max_position_embeddings is now compared with the context the shared YaRN path would actually use, including the max_position_embeddings fallback when the RoPE block omits it. The transformers oracle loads safetensors only.
Bilingual technical report for the Arcee AFM dense support PR.
inureyes
force-pushed
the
feature/1719-arcee-afm-4.5b
branch
from
November 22, 2026 21:41
9fc870b to
156792e
Compare
inureyes
marked this pull request as ready for review
November 22, 2026 21:47
inureyes
added a commit
that referenced
this pull request
Nov 22, 2026
The branch was rebuilt on current main (f315dc2) to clear the CHANGELOG.md and docs/supported-models.md conflicts with #3270, #3275 and #3276. This merge records the previously pushed commit 2642118 as a parent so the update is a fast-forward of the remote branch; the tree is the rebuilt branch's, which already carries every change of that commit. Refs #2354
inureyes
added a commit
that referenced
this pull request
Nov 23, 2026
…#3293) The model library catalog tests used `arcee` as their example of an unsupported dense model. Arcee AFM became a supported family in #3270, so `server::webui::catalog::tests::incomplete_index_and_unsupported_dense_variant_stay_inspectable` fails on main: the entry now resolves an architecture. The embedding contract test in `catalog_contract_tests.rs` used the same model type and kept passing only because its config declares `BertModel`. Both tests now use the synthetic model type `unported_dense_fixture`, which no detection arm will claim, so a future model port cannot silently change what they cover. Test-only change. Found by the full serial lib suite on main after the auto-impl run (12583 passed, this one failed); `server::webui::catalog` now passes all 43 tests.
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
Adds the dense Arcee family (
model_type: arcee,ArceeForCausalLM,arcee-ai/AFM-4.5B). Before this,mlxcel generateexited withUnsupported model type: arcee. This is not AFMoE (afmoe) and not Apple's AFM-7 (afm7).src/models/arcee.rs: the decoder reuses the sharedllama3::Attention(fused QKV, GQA, YaRN frequency table and magnitude, cache-owned attention dispatch, split-attention batched decode) and adds only the block and the gate-free MLP,down_proj(relu(up_proj(x))^2)throughmlxcel_core::utils::relu_squared. The model implementslast_row_logits, native batched decode, batched and maskless padded prefill, and the paged decode backend, asLlama3Modeldoes.ArceeConfigtranslatesconfig.json(including a transformers 5rope_parametersblock, through the shared lift) intollama3::ModelArgswith a full struct literal.validate()refuses, naming the field: ahidden_actother thanrelu2, a RoPE type other thandefault/linear/llama3/yarn(the shared path would otherwise fall back to the unscaled rotation with only a warning), alinear/llama3/yarnblock without a positivefactor, a non-positivebeta_fast/beta_slow/original_max_position_embeddingsorbeta_fast < beta_slow, YaRNtruncate: false, a YaRN magnitude that differs from the one transformers'_compute_yarn_parametersderives (for example a declaredattention_factorother than the derived one, or a non-unitmscalewithoutmscale_all_dim, which transformers ignores; AFM-4.5B's ownmscale: 1.0gives the same 1.299573 on both sides), apartial_rotary_factorother than 1, a top-leveloriginal_max_position_embeddingsthat differs from the block's, atype/rope_typepair that disagree, and geometry beyond fixed ceilings or not fitting in i32. The RoPE keys outsideRopeScalingare captured inArceeConfig's ownDeserialize(on top of the sharedrope_parameterslift), so the adapter route screens them as the directory loader does. Agate_projtensor in an MLP is refused at load.model_metadata.rs),LoadedModel, the registry andmlxcel arch(listed under the Arcee heading next to AFMoE), the memory estimator id, and the tensor-parallel dispatch table, where it is not shardable (the TP runtime would build a SwiGLU Llama MLP).scripts/arcee_oracle_trace.py: the transformers reference arm forexamples/logit_trace, reusing the chunk-plan transcription inlaguna_oracle_trace.py. It has two negative arms,--arm relu(plain ReLU in every MLP) and--arm no-yarn(rope_parametersreset to the default rotation), plus--dtype bfloat16and--report-range.relu_squaredgains a/// Used by:annotation (Arcee is its sixth caller file); thefused_add_rms_norm,forward_split_attentionand RoPE-override rosters name Arcee.docs/supported-models.md,CHANGELOG.md, and an M3 Ultra benchmark row forafm-4.5b(benchmarks/metal_m3ultra_2026-11-23_afm-4.5b.csv).Parity reference
Hugging Face transformers
ArceeForCausalLM(src/transformers/models/arcee/modeling_arcee.py), PyPI transformers 5.24.0 with torch 2.15.0 and tokenizers 0.23.3, run on CPU in float32 (bf16 weights widened, which is exact) viauv run --python 3.12 --with torch --with transformers --with safetensors. The maintainer accepted this reference on 2026-11-23 because neither mlx-lm nor mlx-vlm hasarcee. transformers resolves AFM-4.5B's YaRN block to attention scaling 1.299573 (0.1 * ln(20) + 1) andinv_freq[-1] = 5.77391e-06; the shared YaRN path applies the same values, which a unit test pins.Validation
Real checkpoint
models/afm-4.5b(bf16 on disk, run with mlxcel's usual bf16 to f16 load cast), M3 Ultra. The reference's peak squared-ReLU activation is 165 and its peak residual 363 on the short corpus (158 and 330 on the long one), far inside the f16 range.compare_logit_traces.py --decided 2:docs/architecture.md 256 8 8architecture.md + benchmarks.md 2048 4 8 6144MLXCEL_TRACE_BATCH_ROWS=1(width-one decode)256 8 8MLXCEL_TRACE_BATCH_ROWS=4256 8 8256 8 8256 8 8--arm reluvs mlxcel256 8 8--arm no-yarnvs mlxcel256 8 8--arm no-yarnvs mlxcel, long2048 4 8 6144Every disagreement in the positive arms sits where the reference's top-two gap is below 0.5 and lands on the reference's rank 2. The YaRN negative arm also fails on the short plan, because YaRN changes the interpolated low frequencies and the attention magnitude at every position, not only past 4096.
mlxcel generate -m models/afm-4.5b -p "Hello" -n 50 --temp 0: "Hello! It's nice to meet you. How are you doing today?", stopping on<|im_end|>after 15 tokens. "What is the capital of France? Answer in one sentence." gives "The capital of France is Paris." A 200-token paragraph on the printing press is coherent at 60.4 tok/s.mlxcel generate -p "Hello, how are you today?" -n 128 --profile, the prompt text of the oldFAIL:unsupported_arch_arcee_denserow, run by hand through the chat template rather than the sweep's pp512 shape, soprompt_target_lenis empty): 195 prompt tokens, prefill 1557 tok/s, decode 63.0 tok/s, 51 tokens before EOS. The failing row inbenchmarks/metal_m5max_2026-09-09.csvwas measured on an M5 Max, which this host is not, so the new row is a separate M3 Ultra file.mlxcel-server: two concurrent/v1/chat/completionsrequests (199 and 196 prompt tokens, batched decode at batch 2) finished withstopafter 68 tokens ("The sky appears blue because of a phenomenon called Rayleigh scattering...") andlengthat 120 tokens (a worked 17 x 23 multiplication); a streaming request returned 60 chunks ending inlength.models::arcee, 16, plusmodels::detection_tests::arcee_dense_model_type_is_detected): config translation, the transformers attention-factor resolution and YaRN table, therope_parameterslift, each refusal, the MLP against hand-computed squared-ReLU values (plain ReLU would give a different vector), thegate_projrefusal, the shared last-row harness and native batched decode against sequential decode.coverage_tests, clippy-D warningson lib and tests, fmt, and thescripts/cicontract checks pass.Changes during review
truncatescreen moved fromparse_configintoArceeConfig'sDeserializeso the adapter (LoRA) route refuses it too, and the partial-rotary, top-level original context,type/rope_typeconflict, inverted beta and factorlesslinear/llama3refusals were added, each with a unit test. The benchmark row'smlxcel_commitnow names this PR's first commit.use_safetensors=True), and a top-leveloriginal_max_position_embeddingsis compared with the context the shared YaRN path would really use, including itsmax_position_embeddingsfallback when the RoPE block omits the key.TECHNICAL_REPORTS/3270-arcee-afm-dense-support-20261123.{en,ko}.md.Not validated
UnifiedLinear/FusedQKVLinearloading.Closes #1719