@@ -50,7 +50,7 @@ func TestPrefixPlugin(t *testing.T) {
50
50
}
51
51
cycleState1 := types .NewCycleState ()
52
52
scores := plugin .Score (context .Background (), cycleState1 , req1 , pods )
53
- state , err := plugin . getPrefixState (cycleState1 )
53
+ state , err := types . ReadCycleStateKey [ * SchedulingContextState ] (cycleState1 , PrefixCachePluginType )
54
54
assert .NoError (t , err )
55
55
t .Logf ("Hashes %+v, cached servers: %+v" , state .PrefixHashes , state .PrefixCacheServers )
56
56
// Input size is 6, hash block size is 4, the last 2 characters are ignored.
@@ -71,7 +71,7 @@ func TestPrefixPlugin(t *testing.T) {
71
71
}
72
72
cycleState2 := types .NewCycleState ()
73
73
scores = plugin .Score (context .Background (), cycleState2 , req2 , pods )
74
- state , err = plugin . getPrefixState (cycleState2 )
74
+ state , err = types . ReadCycleStateKey [ * SchedulingContextState ] (cycleState2 , PrefixCachePluginType )
75
75
assert .NoError (t , err )
76
76
t .Logf ("Hashes %+v, cached servers: %+v" , state .PrefixHashes , state .PrefixCacheServers )
77
77
// Input size is 6, hash block size is 4, the last 2 characters are ignored.
@@ -91,7 +91,7 @@ func TestPrefixPlugin(t *testing.T) {
91
91
}
92
92
cycleState3 := types .NewCycleState ()
93
93
scores = plugin .Score (context .Background (), cycleState3 , req3 , pods )
94
- state , err = plugin . getPrefixState (cycleState3 )
94
+ state , err = types . ReadCycleStateKey [ * SchedulingContextState ] (cycleState3 , PrefixCachePluginType )
95
95
assert .NoError (t , err )
96
96
t .Logf ("Hashes %+v, cached servers: %+v" , state .PrefixHashes , state .PrefixCacheServers )
97
97
// Input size is 8, hash block size is 4, so 2 hashes will be calculated.
@@ -110,7 +110,7 @@ func TestPrefixPlugin(t *testing.T) {
110
110
}
111
111
cycleState4 := types .NewCycleState ()
112
112
scores = plugin .Score (context .Background (), cycleState4 , req4 , pods )
113
- state , err = plugin . getPrefixState (cycleState4 )
113
+ state , err = types . ReadCycleStateKey [ * SchedulingContextState ] (cycleState4 , PrefixCachePluginType )
114
114
assert .NoError (t , err )
115
115
t .Logf ("Hashes %+v, cached servers: %+v" , state .PrefixHashes , state .PrefixCacheServers )
116
116
// Input size is 8, hash block size is 4, so 2 hashes will be calculated.
@@ -129,7 +129,7 @@ func TestPrefixPlugin(t *testing.T) {
129
129
}
130
130
cycleState5 := types .NewCycleState ()
131
131
scores = plugin .Score (context .Background (), cycleState5 , req5 , pods )
132
- state , err = plugin . getPrefixState (cycleState5 )
132
+ state , err = types . ReadCycleStateKey [ * SchedulingContextState ] (cycleState5 , PrefixCachePluginType )
133
133
assert .NoError (t , err )
134
134
t .Logf ("Hashes %+v, cached servers: %+v" , state .PrefixHashes , state .PrefixCacheServers )
135
135
// Input size is 12, hash block size is 4, so 3 hashes will be calculated.
@@ -183,7 +183,7 @@ func BenchmarkPrefixPluginStress(b *testing.B) {
183
183
plugin .PostCycle (context .Background (), cycleState , & types.ProfileRunResult {TargetPod : pod })
184
184
185
185
// Second cycle: validate internal state
186
- state , err := plugin . getPrefixState (cycleState )
186
+ state , err := types . ReadCycleStateKey [ * SchedulingContextState ] (cycleState , PrefixCachePluginType )
187
187
assert .NoError (b , err )
188
188
expectedHashes := int (math .Min (float64 (maxPrefixBlocks + 1 ), float64 (len (req .Prompt )/ blockSize + 1 ))) // the extra one is for the model.
189
189
assert .Equal (b , expectedHashes , len (state .PrefixHashes ), "number of hashes is incorrect" )
0 commit comments