What's New
Four RoPE-scaling additions that close the long-context gap with Unsloth and LlamaFactory — YaRN, Dynamic NTK hardening, LongLoRA S² shifted-sparse attention (schema-only), and full Llama 3.1 NTK-aware scaling.
- YaRN RoPE scaling. New
training.rope_scaling_type: yarnwith explicit tunablesyarn_factor/yarn_attn_factor/yarn_beta_fast/yarn_beta_slow. Pure-Python kernels (yarn_find_correction_dim,yarn_find_correction_range,yarn_linear_ramp_mask,yarn_get_mscale) mirror the YaRN paper §3.4/§3.5 withbool/ NaN / Inf rejection on every numeric input. The range helper auto-disambiguateshigh <= lowso the ramp-mask denominator is non-zero on adversarial inputs. - Llama 3.1 NTK-aware (full impl). New
training.rope_scaling_type: llama3emits the canonical{factor, original_max_position_embeddings, low_freq_factor=1.0, high_freq_factor=4.0}block.scale_inv_freq_llama3classifies each frequency by its wavelength relative toold_context_len=8192.detect_llama3_rope_in_configreads HF model configs and accepts bothrope_scaling.typeandrope_scaling.rope_typekeys. - LongLoRA S² shifted-sparse attention (schema gate). New
training.use_longlora: truerequirestask=sft,backend=transformers, a Llama-family base, anduse_ring_attention=false. Schema gate ships now so misconfigured runs fail fast; live forward override deferred to v0.49.1. - Dynamic NTK hardened. Existing path verified;
get_rope_scaling_config('dynamic', ...)accepts both absolute target lengths and scaling factors. - Public-API hardening.
get_rope_scaling_configvalidatestarget_length/original_length/yarn_factorforbool/ NaN / Inf / non-positive at the public boundary — prevents direct callers from emitting{factor: NaN}into HF model configs even when bypassing the Pydantic schema.
Install / Upgrade
pip install --upgrade soup-cli
# or
pip install soup-cli==0.49.0Security
- Public-boundary input validation on
soup_cli/utils/long_context.py::get_rope_scaling_config—target_length/original_length/yarn_factorrejectbool/ NaN / Inf / non-positive (matches v0.30.0Candidate/ v0.34.0estimate_run_cost_usd/ v0.41.0 Part Blr_groupspolicy). scale_inv_freq_llama3rejectsboolon every numeric parameter (inv_freq,scale_factor,low_freq_factor,high_freq_factor,old_context_len).yarn_get_mscaleraises on non-finite input rather than silently clamping to identity.detect_llama3_rope_in_configuses explicitis Noneinstead oforidiom — falsy-but-set values cannot silently fall through (matches v0.40.6 review-fix policy).is_llama_modeluses a word-boundary regex with null-byte rejection + 512-char cap — substring"llama"inside an unrelated identifier does NOT match (mirrors v0.39.0is_gemma4_model/ v0.44.0is_llama4_modelpolicy). ReDoS-bounded by the size cap and the absence of nested quantifiers.validate_longlora_compatemits distinct error messages per failure mode (mlx vs other non-transformers backends) per v0.34.0 review-fix policy.
Known Limitations
- LongLoRA live
LlamaAttention.forwardoverride deferred to v0.49.1 —apply_longlora_forward_overrideraisesNotImplementedErrorwith the v0.49.1 marker; the schema gate ships now so misconfigured runs cannot reach trainer construction. Mirrors v0.27.0 MII / v0.37.0 multipack / v0.41.0 LLaMA Pro stub-then-live pattern. - LongLoRA architecture allowlist is Llama 1/2/3.x + CodeLlama only — Mistral / Qwen / Phi expansion tracked for v0.49.1+.
- Llama 3.1 NTK auto-detect helper ships but is not yet wired into
apply_long_context_config—detect_llama3_rope_in_configis exposed so trainer wiring can pick it up when needed. - YaRN math kernels are reference / config-emit — the actual RoPE rotation runs inside HF Transformers'
_compute_yarn_parameters. The pure-Python kernels are exposed for testing and direct config emission.
+80 net new tests (6410 → 6490). Full suite green on ubuntu / windows / macOS × Python 3.9 / 3.11 / 3.12.