feat(config): v4 rope_scaling, per-layer-type rope, and layer_types #115
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/config-rope-scaling-layer-types"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
config.Loadhad two gaps in how it reads rope settings, both silent:rope_scalingwas ignored. transformers v4 checkpoints carry their rope scaling there, with theta at the top level. A YaRN checkpoint written that way got plain rope and no error.allenai/Olmo-3-7B-Thinkis one.rope_parameterskeyed by layer type ({"sliding_attention": {...}, "full_attention": {...}}). The flat decode reads that shape as all zeros, and a zero theta produces NaN logits.What changes
rope_scalingis folded into the v5 fields byfoldRopeScaling, following transformers' per-model conversion:RopeParameters, with the top-level theta;full_attentionentry ofRopeByLayerType, with plain rope forsliding_attention(as inOlmo3Config.convert_rope_params_to_dict).The old
typekey is accepted forrope_type.Nested
rope_parameters(keyed by layer type) are recognized from the raw JSON intoRopeByLayerType, at the top level and undertext_config.layer_typesis read, and Load rejects a list whose length differs fromnum_hidden_layers.Accessors for models:
RopeFreqsForLayer(l, headDim)returns layerl's rope, falling back toRopeFreqswhen layers share one.SlidingWindowFor(l)windows onlysliding_attentionlayers whenlayer_typesis present. Without it,sliding_windowapplies to every layer, as Mistral 7B v0.1 used it. 0 means unlimited.layer_types' vocabulary differs by family (GLM uses it for its own attention kinds), so only these accessors interpret it.AGENTS.md describes the three spellings and the per-model fold.
No model reads the new accessors yet;
mistral.gostill rejectssliding_window. They are for the OLMo 3 architecture, which follows. No checkpoint gllm serves today usesrope_scalingor sliding layer types, so their rope is unchanged.Verification
go build ./...,go vet ./...,go test ./...pass; gofmt is clean.TestOlmo3RopeByLayerTypeloads OLMo 3's config in both spellings, v4rope_scalingas published and v5 keyedrope_parameters. It checks inv_freq at six pairs and the attention scaling for sliding and full layers against transformers 5.14.1'sOlmo3RotaryEmbeddingon the real checkpoint: plain rope with scaling 1, and YaRN with 1.2079441541679836.TestRopeScalingLegacy: arope_scalingwith the oldtypekey on a single-rope model yields YaRNRopeParameterswith the top-level theta.TestSlidingWindowFor: per-layer windows fromlayer_types, a window on every layer without it, and none withoutsliding_window.TestLayerTypesLength: a mismatchedlayer_typeslength is rejected.🤖 Generated with Claude Code
Automated review by pr-reviewer v0.54.0 | Safety Check | Nemotron 3 Nano | tracking id
r-c1ee4f-77606cThis is an AI-generated review and may contain mistakes.
Status: ❌ Failed
Review failed. Tracking id
r-c1ee4f-77606c— see logs for details.Comment
@pr-reviewer-bot retryto try again.