Skip to content

Add N-tier cascade architecture (default N=2)#60

Merged
doramirdor merged 1 commit into
mainfrom
feature/n-tier-cascade
May 29, 2026
Merged

Add N-tier cascade architecture (default N=2)#60
doramirdor merged 1 commit into
mainfrom
feature/n-tier-cascade

Conversation

@doramirdor
Copy link
Copy Markdown
Collaborator

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-compat
    for existing users.
  • NTierCascade class: new entry point that consumes a tier profile. Legacy
    Cascade class untouched.
  • wide_deep_asym_v3 classifier extended with a continuous score field
    (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_PROFILE unset (default) -> no auto-loading at import,
    legacy Cascade semantics preserved.
  • 730 pre-existing tests pass unmodified.
  • New optional score field on ClassificationResult is additive.

Tests

  • 34 new tests in tests/test_tier_config.py covering schema validation,
    hot-reload, tier selection (cutoff + Pareto flat-arm), score adapter,
    env-var resolution, fail-closed fallback, backward-compat parity.
  • Full suite: 764 passed, 0 failed.

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

Contact: info@getnadir.com

- 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
@doramirdor doramirdor force-pushed the feature/n-tier-cascade branch from c46e3bc to 6b74ba0 Compare May 29, 2026 01:38
@doramirdor doramirdor merged commit 2bd2380 into main May 29, 2026
3 checks passed
@doramirdor doramirdor deleted the feature/n-tier-cascade branch May 29, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant