feat(rosetta): FamilyRegistry::detect_from_config_str + register_alias#1562
Conversation
Lifts the cookbook's architecture-demos detector primitive upstream as a
public FamilyRegistry method, plus adds an HF-pattern alias mechanism
that unblocks derived models (codellama→llama, etc.) without requiring
new loader implementations.
detect_from_config_str(body: &str) -> Option<&'static str>:
Discriminator-field-based dispatch from raw config.json body to family
name. Order-sensitive: more-specific discriminators first (qwen3_5
before qwen3 before qwen2; mistral before llama catch-all). Recognizes
18 families (16 in-progress text + whisper + moonshine).
register_alias(hf_pattern, parent_family) -> Result<(), String>:
Aliases an HF repo glob pattern to an existing parent family. e.g.
registry.register_alias("codellama/*", "llama") lets codellama
checkpoints dispatch through the llama loader. Errors if parent_family
is not registered.
resolve_alias(hf_repo) -> Option<&str>:
Resolves a concrete HF repo identifier through the registered aliases.
supported_families() -> Vec<&'static str>:
Exposes the discriminator-dispatch list (18 families) for downstream
consumers (e.g., apr-cookbook's architecture-demos detector recipe).
This implements the upstream side of apr-cookbook's PMAT-309 detector
recipe — the cookbook's reverse-engineered discriminator catalog now has
an authoritative home in aprender-core.
Tests: 9 detector_tests + 5 alias_tests = 14 new unit tests, all pass.
No regressions in existing aprender-core test suite.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cookbook side is consumer-readyJust landed paiml/apr-cookbook#421 which ships the consumer-side composed pipeline that this PR's
Also shipped Unblock impact when this mergesMerging #1562 unblocks:
Status check
The cookbook side is committed to consuming this verbatim once shipped. Happy to help land — what's the gating constraint? Test failures, review feedback, or just queue depth? |
Upstream contribution from apr-cookbook architecture-demos campaign. Lifts the cookbook's PMAT-309 cross-family detector primitive into
aprender-coreas a public API.What's added
detect_from_config_str(body: &str) -> Option<&'static str>Discriminator-field-based dispatch from raw config.json body to family name. Order-sensitive priority list:
tie_word_embeddings + head_dim + qwen3_5) → before Qwen3head_dim + qwen3, NOTqwen3_5) → before Qwen2qwen2 + rope_theta)qkv_proj_fused)query_pre_attn_scalar)use_parallel_residual)do_layer_norm_before)"n_embd")ffn_multipliers + num_query_heads)n_routed_experts)mamba_d_state + mamba_expand + falcon_h1)time_mix_extra_dim)state_size + conv_kernel, NOTnum_attention_heads)type_vocab_size)sliding_window + MistralForCausalLM) → before LlamaWhisperForConditionalGeneration)MoonshineForConditionalGeneration)LlamaForCausalLM) — catch-all, checked LASTAlias mechanism (unblocks 11+ blocked families)
Unblocks the 11 alias entries from apr-cookbook's
architecture-demos/manifest.yaml: codellama, dolphin, hermes, openchat, smollm, smollm2, tinyllama, vicuna, wizardcoder, yi, zephyr — all derive from llama or mistral and just needed pattern aliasing.Tests
detector_tests— one per supported family + edge cases (priority order, unknown configs, determinism)alias_tests— glob matching, exact matching, parent-validation, count, resolutionAll 14 pass; no regressions in existing aprender-core suite.
Why upstream
apr-cookbook's PMAT-309
inference_arch_detectorrecipe was effectively a reverse-engineered discriminator catalog living in cookbook code. Lifting it here:contracts/model-families/upstream)aprender::FamilyRegistry::detect_from_config_strinstead of a parallel implementationstatus: blockedentries in the manifest)Follow-up PR will update apr-cookbook to consume this API.
🤖 Generated with Claude Code