Mobilint Model Zoo Transformers
SkillAI & modelsWork effectively on Mobilint Model Zoo Hugging Face Transformers integrations, tests, and benchmarks while respecting optional dependencies, NPU configuration, and download constraints.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Mobilint Model Zoo Transformers skill
What this skill tells your AI
The instructions your AI receives, as published by mobilint/mblt-model-zoo in .agents/skills/mblt-transformers/SKILL.md and read by ahel’s review.
Start Here
- Read
AGENTS.mdand the sharedmblt-model-zooskill. - Run
git status --shortbefore changing files. - Read
pyproject.toml,tests/transformers/TEST.md, andbenchmark/transformers/README.md.
Preserve Contracts
- Install the matching
transformersoptional extra before running integration tests. MobilintNPUBackendhostsNqbruntime.Modelslots;max_batch_sizeis the aggregate batch capacityN * K, whereKis the compiled MXQ batch axis probed from slot 0. The backend launchesN = ceil(max_batch_size / K)slots and distributes them round-robin across the unique devices referenced by the canonical target strings. A non-batch MXQ (K == 1) with logicalB > 1fans intoN = Bslots dispatched in parallel viaMobilintNPUBackend.infer_slot; a batched MXQ (K > 1) reuses hardware batching untilN * K >= max_batch_size. Beam search paths stayN = 1.dev_nois syntactic sugar for the device-prefix component of the canonical target strings. Scalar pins one device, a list expands to multiple devices. Read the canonical target lists (_target_cores_serialized/_target_clusters_serialized, or the public accessors) at dispatch time so multi-device backends behave correctly.- Backend target topology accumulates raw overrides in
NPUTargetSpecPendingonMobilintNPUBackend._pending; the lazy_specproperty callspending.finalize()once per epoch and caches onself._finalized. After each finalize,_pendingis promoted to a fresh baseline viaNPUTargetSpecPending.from_baseline(all intent flags cleared) so the next HF setter chain or standalone runtime mutation gets an isolated intent slate. The per-field setters (dev_no,core_mode,target_cores,target_clusters) only mutate_pendingand invalidate_finalized; setter order within one chain does not affect the resolved canonical spec.finalize()runs one ordered pipeline (legacy migration → sibling drop → grain unification → off-mode drop → device-set consistency →global8coverage) once every accumulated override is visible. Target-only override syncsdev_noto the target device set at finalize;dev_no-only override clears stale targets and re-expands sugar; both overridden → the device-set consistency check surfaces mismatches on the next canonical read (not on the setter).NPUTargetSpec.from_kwargsremains the config-layer (JSON load) entry point where eager normalization is unambiguous. - Canonical NPU target wire form is fully-qualified:
target_coresentries are"d:c:k"strings andtarget_clustersentries are"d:c"strings. Legacy 2-partc:kcores, bare integer clusters, andqbruntime.CoreId/Clusterobjects are silently migrated to the canonical form insidefinalize()(and its_normalize_npu_target_kwargsconfig- layer wrapper) usingdev_noas the fallback prefix.singlemode unfoldstarget_clustersinto every cluster core;multi/global4/global8foldtarget_coresup to their"d:c"cluster prefixes and warn when a partial cluster is rounded up.global8requires both clusters on every covered device. MobilintCache([m0, m1, ...], per_model_batch=K)dualizes KV state along(model_idx, cache_id)with capacityN * Krows. Rowimaps to(i // K, i % K); useslot_of,model_of, andgroup_by_modelfor dispatch routing.ensure_batch_sizebeyondN * Kis only allowed on the legacy single-Model hardware-batch path (N == 1).MobilintCache(model, batch_size=K)remains as a shim for the historicalN = 1, K = Kcase; do not pass bothper_model_batchandbatch_sizein the same call.MobilintBeamCacheenforcesN == 1— beam search bookkeeping tracks one active qbruntime cache and multi-Model construction raisesNotImplementedError. UseMobilintCachefor multi-Model dispatch.- On HBM
BadAllocduringcreateorlaunch,MobilintNPUBackenddisposes every previously loaded slot and re-raises the underlyingQbRuntimeErrorasMobilintBackendAllocErrorwithphase,slot,dev,succeeded_so_far,n_total,max_batch_size, andk_per_modelcontext. Callers should lowermax_batch_sizeor spread the workload across more devices viadev_no(or explicit fully-qualified target strings) rather than retrying on the same target set. - Reuse shared NPU options and
tests.npu_backend_options.build_vision_engine_kwargs()rather than introducing divergent hardware flags or engine keyword bundles. - Treat
mblt_model_zoo/cli/tps_table.pyas the source of truth for TPS printed rows, JSON keys, units, and run/aggregate/summary extraction. Update the focusedtests/transformers/cli_tpsschema and layer-consistency tests with any change. - Keep VLM non-batch tests under
tests/transformers/image_text_to_text/non_batch. Keep batch text-generation and image-text-to-text suites in theirbatchdirectories and route both through serial Phase B inscripts/test_transformers_matrix.py. - Qwen3-VL release contract:
MobilintQwen3VLConfig.dynamic_vision(top-level bool) pairs the vision MXQ, text MXQ, and processor as one release. A dynamic-vision release accepts video and per-prompt multi-image inputs. A static-vision release supports one image per prompt only and raisesNotImplementedErrorfromMobilintQwen3VLProcessor.__call__for video or per-prompt multi-image, with a message pointing the caller at a dynamic-vision release. Batched single-image prompts are always allowed.MobilintQwen3VLProcessor.from_pretrainedderives the flag fromconfig.dynamic_visionand syncs the video processor's mirror. CallMobilintQwen3VLProcessor.sync_dynamic_vision_from_model(model)only when a runtimevision_mxq_path=override diverges from the shipped config so the processor adopts the detectedvisual._uses_dynamic_visionvalue. - Qwen3-VL video decoding requires the
torchcodecdependency shipped with thetransformersextra; validate video paths only against a dynamic-vision release. - Preserve local style in
mblt_model_zoo/hf_transformers; it is excluded from repository-wide Ruff checks.
EAGLE-3 Workflow
- Load a release (for example
mobilint/EAGLE3-Qwen3-4B) throughAutoModelForCausalLM.from_pretrained(...); the wrapper binds the base MXQ, one-block draft MXQ, and FC stack as a single release. Qwen3 and Llama base families are supported throughmblt_model_zoo/hf_transformers/models/qwen3_eagle3/andmblt_model_zoo/hf_transformers/models/llama_eagle3/. Each ships aMobilintXxxEagle3Config/MobilintXxxEagle3ForCausalLMpair (MobilintQwen3Eagle3Config/MobilintQwen3Eagle3ForCausalLM,MobilintLlamaEagle3Config/MobilintLlamaEagle3ForCausalLM) that wiresMobilintEagle3FCProjector, the family-specific base backend, and the family-specific one-block draft backend on top of the sharedMobilintEagle3BaseModelMixin/MobilintEagle3DraftModelMixin. The mixins ownembed_tokensandrotary_embinitialization, so every concreteMobilintXxxEagle3ForCausalLM.__init__stays a thin wiring shim; register a new base family by subclassing the mixins rather than duplicating the init bodies. The presence ofeagle3_base_modelon the loaded model is how measurement paths detect EAGLE-3. - Tune the draft-tree budget through
GenerationConfig.num_assistant_tokens(default64inmblt_model_zoo/hf_transformers/utils/generation_utils.py). Qwen3-4B measures best in the25–30range: the Hugging Face default of49costs more iteration latency than its extra acceptance recovers. Override by editing the shippedgeneration_config.json, by settingmodel.generation_config.num_assistant_tokens = ...beforegenerate, or by passingnum_assistant_tokens=<value>directly togenerate(...)for a per-call override. - Mobilint EAGLE-3 releases train base and draft at a matched hidden size by policy; the
draft_emb.shape == target_emb.shapeassert inscripts/build_eagle3_safetensors.pyenforces it. TheMobilintEagle3DraftModelMixinhidden_states.shape[-1] != inputs_embeds.shape[-1]branch (callingMobilintEagle3FCProjector.project) is legacy / future-experiment scaffolding, not evidence that unequal base/draft widths are supported — do not use it to justify relaxing the packaging assert. mblt_model_zoo/hf_transformers/utils/eagle3/tree_decoding.py::softmax_topk_cpu_torchdispatches per call. Defaultauto: slice to the declaredTopKLogitsWarper's top-K first and apply the processor list on that slice (Hugging Face_get_logits_warperorder Temperature → TopK → TopP makes the slice mathematically identical to full-vocab softmax while skipping the full-vocabexp), except when boundary ties push part of the active support outside the slice — HF'sTopKLogitsWarperuses a strict-less-than filter and keeps every logit equal to the k-th threshold, whiletorch.topkdrops tied entries at the boundary, so the slice path checks(x >= threshold).sum(-1) > slice_sizeand falls back to the full-vocab helper on any tie; otherwise fall back to the full-vocab path so a bareTopPLogitsWarperstill determines its nucleus over the whole distribution.fullforces the full-vocab path as a manual override.slicedis a deprecated back-compat mode that unconditionally renormalizes over a top-max_return_kslice and emits a warning; retain it only for A/B reproducibility. Toggle at import throughMBLT_EAGLE3_SOFTMAX_TOPK_MODE=auto|full|sliced, or programmatically throughset_softmax_topk_mode(...). Themax_return_kargument (default10) is a return-slice size for downstream candidate matching, not the math slice. Keepprepare_logits_processorin HF order (RepetitionPenalty → Temperature → TopK → TopP) so the auto slice-by-TopK path stays HF-equivalent. The greedy path (temperature<=1e-5) never enters this function becauseprepare_logits_processorreturnsNone.- Keep the argmax-first shape in
evaluate_posteriorgreedy:argmax(logits)[safe_positions]avoids materializing the(n_cand, depth, vocab)fancy-index slice. - EAGLE-3 speculative-decode rows exposed by
mblt-model-zoo tps measureareaccept_steps,tokens_sum,tokens_per_step(=drafts_avg + 1, matchingaccept_length + 1in the referencespeculative_decoding/mxq_app/eagle3MXQ.py), anddraft_accept_ratio. Non-EAGLE-3 pipelines omit these rows automatically. The schema lives inmblt_model_zoo/cli/tps_table.py; update it and the focusedtests/transformers/cli_tpssuites together. tps measurealso exposes--print-output(prints the actually generated tokens for the last run, both preserving and stripping special tokens), mutually exclusive--enable-thinking/--disable-thinking(overrides the Qwen3 chat templateenable_thinkingflag), and--temperature FLOAT(0.0keeps greedy;>0enablesdo_sample=True). Chat templates apply to text prompts by default.tps sweepremains greedy so its numbers stay comparable.- On EAGLE-3 pipelines,
_apply_eagle3_gen_kwargsinmblt_model_zoo/hf_transformers/utils/benchmark_utils.pystripsmin_new_tokensandpad_token_idand setseos_token_id=None, sogeneratehonors the real EOS fromconfig.json.--decode Nbecomes an upper bound and the measurednum_decodereflects the tokens actually produced. Non-speculative pipelines keep exact-Nsemantics. - MXQ backends have known cross-process non-determinism. Reproduce and isolate with
scripts/probe_mxq_determinism.py,scripts/probe_generate_same_process.py, andscripts/probe_warmup_stabilization.py. Warmup does not stabilize outputs across processes (verified by the warmup probe). For stable measurements, run same-process--repeat N. - Note the definition drift versus the reference
speculative_decoding/mxq_appimplementation:accept_lengththere counts drafts accepted whiletokens_per_stephere countsdrafts + 1(the forced base root token per step). Usetokens_per_stepwhen comparing to paper-style acceptance numbers.
Validate Proportionately
- Start with the narrowest test file or documented
-kselection and use-xwhile iterating. - Run
pytest tests/transformers --full-matrixonly for release or pre-merge matrix validation. - Hardware, downloaded models, and external data may be unavailable. Run safe static or focused checks and report the limitation rather than broadening the test run.
Signals
- GitHub stars
- 24
- Forks
- 1
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
mblt-transformers- Source
- github.com/mobilint/mblt-model-zoo