feat(model): OLMo 3 (Olmo3ForCausalLM) in the dense-transformer package #117
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/olmo3"
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?
Adds OLMo 3 (
Olmo3ForCausalLM, e.g.allenai/Olmo-3-7B-Thinkand its compressed-tensors NVFP4 quantization) tointernal/model/mistral.It builds on #114, #115 and #116 (generation-config stop ids, per-layer rope and
layer_types, sliding-window attention), all now on main.The architecture
OLMo 3 is the Llama block with its norms moved and two norms added. Its layers also differ in attention:
input_layernormpost_attention_layernormpost_attention_layernormpost_feedforward_layernormq_norm,k_norm: RMSNorm over the whole projection, before ropepost_attention_layernormnames a different position in each family.What changes
layercarries RMSNorm weights at four optional positions: each sublayer's input or its output.Forwardapplies whichever are non-nil, through anormhelper that passes the input through when there is no weight, soForwardhas no OLMo branch. The loader assigns tensor names by architecture (Mistral.postNorm).q_normandk_normare applied in place to the q and k projections before rope. RMSNorm is row-local on both backends, so in place is safe.layercarries its own rope table and window, fromconfig.Model.RopeFreqsForLayerandSlidingWindowFor, and passes the window toPagedAttention. For every other architecture these equal the old model-wide values with no window.mistral.Newno longer rejectssliding_window.The chat template is not part of this PR. Chat completions still return 501 until OLMo's think-only template has a renderer, which comes next.
Verification
go build ./...,go vet ./...,go test ./...pass; gofmt is clean.testdata/generate_olmo3.py, transformers 5.14.1):TestForwardOlmo3matches the logits at 1e-4 for prefill and for token-by-token decode. It loads the config both as saved (v5,rope_parameterskeyed by layer type) and respelled as the published checkpoints write it (v4,rope_scaling).TestOlmo3FeaturesAreLoadBearing: removing any one of seven pieces breaks the match with the goldens: the window, YaRN on the full layer, plain rope on the sliding layers,q_norm,k_norm,post_attention_layernorm,post_feedforward_layernorm.TestForwardOlmo3CUDA: the same goldens pass on the RTX PRO 6000 Blackwell and the RTX 3070. The wholemistralCUDA package passes on both (25 tests).finish_reason: stop🤖 Generated with Claude Code
Automated review by pr-reviewer v0.54.0 | Safety Check | Nemotron 3 Nano | tracking id
r-c1f10b-6f1e37This is an AI-generated review and may contain mistakes.
Status: ❌ Failed
Review failed. Tracking id
r-c1f10b-6f1e37— see logs for details.Comment
@pr-reviewer-bot retryto try again.