analytical-viz: add FFN-only scope + 3rd sweep button
Both auto tabs now offer three sweep scopes via three buttons instead
of two:
- Run sweep — Attention → include_attention=T, include_ffn=F
- Run sweep — FFN/MoE → include_attention=F, include_ffn=T
- Run sweep — Attn + FFN/MoE → include_attention=T, include_ffn=T
Each button caches its result under its own session_state key; the most
recently clicked button drives the display. All three caches persist so
users can flip between scopes without re-running.
Core changes:
auto_explore.py + auto_hardware.py:
- New include_attention: bool = True param alongside include_ffn
- _sum_visible_latency, _efficiency, score_config, run_auto_explore,
compute_parallelism_sensitivity, joint_explore, compute_sensitivity,
_best_parallelism_for_hw, _best_parallelism_two_stage all wired.
- Attention and FFN are additive with no overlap: measured 7.35 ms
(attn) + 5.50 ms (ffn) = 12.85 ms (full) for Llama 70B decode 128K.
Bug fix (drive-by): the display block in both tab render functions was
incorrectly nested inside the "cached ctx is stale" warning branch, so
metrics/scatter/table/sensitivity/load only rendered when the cache
was stale. Un-indented and removed the dead trailing else-info block.
Verified:
- 24 pytest tests pass (added 1 new for FFN-only scope invariants)
- Smoke: Llama 70B decode 128K all three scopes produce sensible Pareto:
* Attention only: 7.35 ms (14 pareto configs)
* FFN / MoE only: 5.50 ms (34 pareto configs)
* Attn + FFN/MoE: 12.85 ms (6 pareto configs)
Sums add up exactly, confirming no overlap in stage summation.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -183,11 +183,31 @@ def test_attention_only_pareto_non_empty():
|
||||
model = PRESETS["Llama 3.1 70B"].model
|
||||
machine = MachineParams()
|
||||
res = run_auto_explore(model, machine, s_kv=8192, mode="decode",
|
||||
include_ffn=False)
|
||||
include_attention=True, include_ffn=False)
|
||||
assert res.total_feasible > 0
|
||||
assert len(res.pareto_scores) > 0
|
||||
|
||||
|
||||
def test_ffn_only_latency_less_than_full_and_different_from_attn():
|
||||
"""FFN-only latency must be > 0, < full-model latency, and != attn-only."""
|
||||
model = PRESETS["Llama 3.1 70B"].model
|
||||
machine = MachineParams()
|
||||
r_full = run_auto_explore(model, machine, s_kv=8192, mode="decode",
|
||||
include_attention=True, include_ffn=True)
|
||||
r_attn = run_auto_explore(model, machine, s_kv=8192, mode="decode",
|
||||
include_attention=True, include_ffn=False)
|
||||
r_ffn = run_auto_explore(model, machine, s_kv=8192, mode="decode",
|
||||
include_attention=False, include_ffn=True)
|
||||
b_full = min(r_full.pareto_scores, key=lambda s: s.total_latency_ns)
|
||||
b_attn = min(r_attn.pareto_scores, key=lambda s: s.total_latency_ns)
|
||||
b_ffn = min(r_ffn.pareto_scores, key=lambda s: s.total_latency_ns)
|
||||
assert b_ffn.total_latency_ns > 0
|
||||
assert b_ffn.total_latency_ns < b_full.total_latency_ns
|
||||
assert abs(b_ffn.total_latency_ns - b_attn.total_latency_ns) > 1.0, (
|
||||
"FFN-only and attention-only latencies should not be identical"
|
||||
)
|
||||
|
||||
|
||||
def test_parallelism_sensitivity_includes_baseline_value():
|
||||
"""Each row's values contain the baseline_value."""
|
||||
from tests.analytical_visualization.auto_explore import (
|
||||
|
||||
Reference in New Issue
Block a user