Add N-tier cascade architecture (default N=2)#60
Merged
Conversation
- nadirclaw/tier_config/: YAML schema, hot-reload loader, tier selector, score adapter. Continuous-score classifier output -> configurable cutoffs. - Two bundled profiles: n2_default (cheap+strong) and n3_legacy (3-tier back-compat). - NTierCascade class with verifier-gated cascade (tau=0.80 default, adjacent escalation). Legacy Cascade class untouched. - wide_deep_asym_v3 weights work for any N via score adapter, no retraining. - 34 new tests; full suite 764/764 passing including e2e. Empirically validated on RouterArena: N=2 beats N=3 (arena_F 0.7358 vs 0.7136); see https://getnadir.com for results. Repo: https://github.com/NadirRouter/NadirClaw Contact: info@getnadir.com
c46e3bc to
6b74ba0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for configurable N-tier routing in NadirClaw. The router can now
operate as a 2-tier, 3-tier, 5-tier, 7-tier, or flat-arm cascade via YAML
config without code changes or classifier retraining.
The new default profile is N=2 (cheap + strong), based on empirical
RouterArena results showing N=2 beats N=3 on arena_F (0.7358 vs 0.7136).
What's new
nadirclaw/tier_config/: YAML schema (Pydantic), hot-reload loader,tier selector, classifier score adapter.
nadirclaw/tier_config/profiles/n2_default.yaml: 4-model cheap pool(gpt-4o-mini, qwen3-235b, deepseek-v3.2, claude-3-haiku) + 5-model strong
pool (gpt-5-mini, deepseek-reasoner, deepseek-v4-flash, grok-4-1-fast,
claude-sonnet-4). Verifier-gated cascade at tau=0.80, adjacent escalation.
nadirclaw/tier_config/profiles/n3_legacy.yaml: 3-tier legacy back-compatfor existing users.
NTierCascadeclass: new entry point that consumes a tier profile. LegacyCascadeclass untouched.wide_deep_asym_v3classifier extended with a continuousscorefield(expectation over class probabilities), enabling any N value without
retraining.
Why N=2
The 3-tier cascade's medium tier dilutes routing: medium-pool models
(claude-haiku, deepseek-v3.2, etc.) are roughly as expensive as the cheap
tier but less accurate on average. N=2 collapses the classifier's decision to
one boundary, lets the verifier handle the rest. RouterArena bake-off shows
N=3 at 0.7136 vs N=2 at 0.7358 on the official scorer.
Backward compatibility
NADIRCLAW_TIERS_PROFILEunset (default) -> no auto-loading at import,legacy
Cascadesemantics preserved.scorefield onClassificationResultis additive.Tests
tests/test_tier_config.pycovering schema validation,hot-reload, tier selection (cutoff + Pareto flat-arm), score adapter,
env-var resolution, fail-closed fallback, backward-compat parity.
Migration
Existing users: no action required. Default behavior unchanged.
To opt in to N=2:
```bash
export NADIRCLAW_TIERS_PROFILE=n2_default
```
Or to a custom YAML file:
```bash
export NADIRCLAW_TIERS_PROFILE=/path/to/your_profile.yaml
```
Related
Add Nadir router (verifier-gated cascade + cost-min baseline) RouteWorks/RouterArena#112
Contact: info@getnadir.com