@@ -25,44 +25,24 @@ def test_budget_only():
2525 """Setting only budget is valid."""
2626 config = TriAttentionConfig (budget = 2048 )
2727 assert config .budget == 2048
28- assert config .target_sparsity_ratio is None
2928
3029
31- def test_target_sparsity_only ():
32- """Setting only target_sparsity_ratio is valid."""
33- config = TriAttentionConfig (target_sparsity_ratio = 0.7 )
34- assert config .budget is None
35- assert config .target_sparsity_ratio == 0.7
36-
37-
38- def test_both_budget_and_sparsity_raises ():
39- """Setting both budget and target_sparsity_ratio raises."""
40- with pytest .raises (ValidationError , match = "Cannot set both" ):
30+ def test_target_sparsity_ratio_is_not_supported ():
31+ """Ratio-based eviction is not part of the TriAttention API."""
32+ with pytest .raises (ValidationError ):
4133 TriAttentionConfig (budget = 2048 , target_sparsity_ratio = 0.7 )
4234
4335
44- def test_neither_budget_nor_sparsity_raises ():
45- """Setting neither budget nor target_sparsity_ratio raises ."""
46- with pytest .raises (ValidationError , match = "Must set exactly one " ):
36+ def test_missing_budget_raises ():
37+ """TriAttention requires an explicit budget ."""
38+ with pytest .raises (ValidationError , match = "requires 'budget' " ):
4739 TriAttentionConfig ()
4840
4941
50- def test_target_sparsity_out_of_range_low ():
51- """target_sparsity_ratio <= 0 raises."""
52- with pytest .raises (ValidationError , match = "must be in" ):
53- TriAttentionConfig (target_sparsity_ratio = 0.0 )
54-
55-
56- def test_target_sparsity_out_of_range_high ():
57- """target_sparsity_ratio >= 1 raises."""
58- with pytest .raises (ValidationError , match = "must be in" ):
59- TriAttentionConfig (target_sparsity_ratio = 1.0 )
60-
61-
62- def test_target_sparsity_negative ():
63- """Negative target_sparsity_ratio raises."""
64- with pytest .raises (ValidationError ):
65- TriAttentionConfig (target_sparsity_ratio = - 0.1 )
42+ def test_non_positive_budget_raises ():
43+ """Budget must be positive."""
44+ with pytest .raises (ValidationError , match = "budget must be positive" ):
45+ TriAttentionConfig (budget = 0 )
6646
6747
6848def test_config_custom_values ():
@@ -91,17 +71,6 @@ def test_config_serialization_roundtrip_budget():
9171 data = config .model_dump ()
9272 restored = TriAttentionConfig (** data )
9373 assert restored .budget == 1024
94- assert restored .target_sparsity_ratio is None
95- assert restored .prune_interval == 64
96-
97-
98- def test_config_serialization_roundtrip_sparsity ():
99- """Config with target_sparsity_ratio survives serialization roundtrip."""
100- config = TriAttentionConfig (target_sparsity_ratio = 0.5 , prune_interval = 64 )
101- data = config .model_dump ()
102- restored = TriAttentionConfig (** data )
103- assert restored .budget is None
104- assert restored .target_sparsity_ratio == 0.5
10574 assert restored .prune_interval == 64
10675
10776
0 commit comments