Skip to content

Commit 43aea48

Browse files
committed
refactor(sidecar): name request-field constants after their wire keys
The requestFieldP2P* constants held remote_* wire keys, so the names no longer described the values. Naming them for their values matches the sibling request-field constants and leaves P2P to name only the OffloadingConnector tier and its protocol functions. Also sweeps test comments and one spec title that still named the sub-dicts by the old decode/prefill/p2p keys. Signed-off-by: nilig <nili.ifergan@gmail.com>
1 parent 9cac78f commit 43aea48

5 files changed

Lines changed: 32 additions & 31 deletions

File tree

pkg/sidecar/proxy/connector_nixlv2_p2p_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var _ = Describe("NIXL Connector with P2P pull", func() {
104104
Expect(kv).To(HaveKeyWithValue(requestFieldDoRemoteDecode, true))
105105
Expect(kv).To(HaveKeyWithValue(requestFieldDoRemotePrefill, false))
106106
// The remote_kv_source block drives the OffloadingConnector's cached-prefix pull.
107-
p2p, ok := kv[requestFieldP2PParams].(map[string]any)
107+
p2p, ok := kv[requestFieldRemoteKVSource].(map[string]any)
108108
Expect(ok).To(BeTrue())
109109
Expect(p2p[requestFieldKVRequestID]).ToNot(BeEmpty())
110110
Expect(p2p[requestFieldRemoteHost]).To(Equal("10.9.9.9"))
@@ -120,7 +120,7 @@ var _ = Describe("NIXL Connector with P2P pull", func() {
120120
routing.KVCacheSourceHeader: kvCacheSource,
121121
})
122122

123-
Expect(prefillKV()).ToNot(HaveKey(requestFieldP2PParams))
123+
Expect(prefillKV()).ToNot(HaveKey(requestFieldRemoteKVSource))
124124
})
125125

126126
It("does not compose a p2p pull when the source is the prefiller itself", func() {
@@ -133,7 +133,7 @@ var _ = Describe("NIXL Connector with P2P pull", func() {
133133
routing.KVCacheSourceHeader: prefillHostPort,
134134
})
135135

136-
Expect(prefillKV()).ToNot(HaveKey(requestFieldP2PParams))
136+
Expect(prefillKV()).ToNot(HaveKey(requestFieldRemoteKVSource))
137137
})
138138

139139
// The parallel-dispatch (MoRI-IO WRITE) path builds the prefill leg in a
@@ -160,7 +160,7 @@ var _ = Describe("NIXL Connector with P2P pull", func() {
160160
// Prefill leg keeps the NIXL WRITE fields and gains the composed remote_kv_source block.
161161
pkv := kvParams(env.prefillHandler, 0)
162162
Expect(pkv).To(HaveKeyWithValue(requestFieldDoRemoteDecode, true))
163-
p2p, ok := pkv[requestFieldP2PParams].(map[string]any)
163+
p2p, ok := pkv[requestFieldRemoteKVSource].(map[string]any)
164164
Expect(ok).To(BeTrue())
165165
Expect(p2p[requestFieldRemoteHost]).To(Equal("10.9.9.9"))
166166
Expect(p2p[requestFieldRemotePort]).To(BeNumerically("==", p2pConnectorPort))

pkg/sidecar/proxy/connector_p2p.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (s *Server) handleP2P(w http.ResponseWriter, r *http.Request, prefillPodHos
6969
prefillData[k] = v
7070
}
7171
prefillKVParams := map[string]any{
72-
requestFieldP2PDecodeParams: map[string]any{
72+
requestFieldRemoteDecoder: map[string]any{
7373
requestFieldKVRequestID: kvRequestID,
7474
},
7575
}
@@ -95,7 +95,7 @@ func (s *Server) handleP2P(w http.ResponseWriter, r *http.Request, prefillPodHos
9595
decodeData[k] = v
9696
}
9797
decodeData[requestFieldKVTransferParams] = map[string]any{
98-
requestFieldP2PPrefillParams: map[string]any{
98+
requestFieldRemotePrefiller: map[string]any{
9999
requestFieldKVRequestID: kvRequestID,
100100
requestFieldRemoteHost: extractHost(prefillPodHostPort),
101101
requestFieldRemotePort: s.config.P2PConnectorPort,
@@ -229,7 +229,7 @@ func (s *Server) p2pPullAvailable() bool {
229229
// NixlConnector.
230230
func (s *Server) addP2PPullToPrefill(prefillKVParams map[string]any, kvCacheSource, prefillPodHostPort string) {
231231
if kvCacheSource != "" && extractHost(kvCacheSource) != extractHost(prefillPodHostPort) {
232-
prefillKVParams[requestFieldP2PParams] = s.p2pSourceParams(kvCacheSource)
232+
prefillKVParams[requestFieldRemoteKVSource] = s.p2pSourceParams(kvCacheSource)
233233
}
234234
}
235235

@@ -267,7 +267,7 @@ func (s *Server) decodeWithP2PSource(w http.ResponseWriter, r *http.Request, sou
267267
p2pParams := s.p2pSourceParams(sourceHostPort)
268268
// Rebuild kv_transfer_params from scratch: the sidecar owns this field, so
269269
// client-supplied keys are dropped rather than forwarded to vLLM.
270-
requestData[requestFieldKVTransferParams] = map[string]any{requestFieldP2PParams: p2pParams}
270+
requestData[requestFieldKVTransferParams] = map[string]any{requestFieldRemoteKVSource: p2pParams}
271271

272272
s.logger.Info("running P2P source protocol",
273273
"source_host", extractHost(sourceHostPort),

pkg/sidecar/proxy/connector_p2p_source_test.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ var _ = Describe("P2P KV cache source header", func() {
8484

8585
kvParams, ok := dreq[requestFieldKVTransferParams].(map[string]any)
8686
Expect(ok).To(BeTrue())
87-
Expect(kvParams).ToNot(HaveKey(requestFieldP2PDecodeParams))
88-
Expect(kvParams).ToNot(HaveKey(requestFieldP2PPrefillParams))
89-
p2p, ok := kvParams[requestFieldP2PParams].(map[string]any)
87+
Expect(kvParams).ToNot(HaveKey(requestFieldRemoteDecoder))
88+
Expect(kvParams).ToNot(HaveKey(requestFieldRemotePrefiller))
89+
p2p, ok := kvParams[requestFieldRemoteKVSource].(map[string]any)
9090
Expect(ok).To(BeTrue())
9191
Expect(p2p[requestFieldKVRequestID]).ToNot(BeEmpty())
9292
Expect(p2p[requestFieldRemoteHost]).To(Equal("10.9.9.9"))
@@ -112,37 +112,38 @@ var _ = Describe("P2P KV cache source header", func() {
112112
return len(testInfo.prefillHandler.GetCompletionRequests())
113113
}).Should(Equal(1))
114114

115-
// Prefill leg: decode + p2p, each with its own kv_request_id.
115+
// Prefill leg: remote_decoder + remote_kv_source, each with its own
116+
// kv_request_id.
116117
preq := testInfo.prefillHandler.GetCompletionRequests()[0]
117118
prefillKVParams, ok := preq[requestFieldKVTransferParams].(map[string]any)
118119
Expect(ok).To(BeTrue())
119-
decodeParams, ok := prefillKVParams[requestFieldP2PDecodeParams].(map[string]any)
120+
decodeParams, ok := prefillKVParams[requestFieldRemoteDecoder].(map[string]any)
120121
Expect(ok).To(BeTrue())
121-
p2p, ok := prefillKVParams[requestFieldP2PParams].(map[string]any)
122+
p2p, ok := prefillKVParams[requestFieldRemoteKVSource].(map[string]any)
122123
Expect(ok).To(BeTrue())
123124
Expect(p2p[requestFieldKVRequestID]).ToNot(BeEmpty())
124125
Expect(p2p[requestFieldKVRequestID]).ToNot(Equal(decodeParams[requestFieldKVRequestID]))
125126
Expect(p2p[requestFieldRemoteHost]).To(Equal("10.9.9.9"))
126127
Expect(p2p[requestFieldRemotePort]).To(BeNumerically("==", p2pConnectorPort))
127128

128-
// Decode leg: prefill only, never prefill + p2p.
129+
// Decode leg: remote_prefiller only, never remote_kv_source.
129130
decodeReqs := testInfo.decodeHandler.GetCompletionRequests()
130131
Expect(decodeReqs).To(HaveLen(1))
131132
decodeKVParams, ok := decodeReqs[0][requestFieldKVTransferParams].(map[string]any)
132133
Expect(ok).To(BeTrue())
133-
Expect(decodeKVParams).To(HaveKey(requestFieldP2PPrefillParams))
134-
Expect(decodeKVParams).ToNot(HaveKey(requestFieldP2PParams))
134+
Expect(decodeKVParams).To(HaveKey(requestFieldRemotePrefiller))
135+
Expect(decodeKVParams).ToNot(HaveKey(requestFieldRemoteKVSource))
135136

136137
testInfo.cancelFn()
137138
<-testInfo.stoppedCh
138139
})
139140

140-
It("should not add p2p to the prefill leg when the source is the prefiller itself", func() {
141+
It("should not add remote_kv_source params to the prefill leg when the source is the prefiller itself", func() {
141142
proxyBaseAddr := testInfo.startProxy()
142143

143144
prefillHostPort := testInfo.prefillBackend.URL[len("http://"):]
144145
// The source resolves to the selected prefiller - there is nothing to
145-
// pull from itself, so the prefill leg carries decode only.
146+
// pull from itself, so the prefill leg carries remote_decoder only.
146147
sendRequest(proxyBaseAddr, map[string]string{
147148
routing.PrefillEndpointHeader: prefillHostPort,
148149
routing.KVCacheSourceHeader: prefillHostPort,
@@ -155,8 +156,8 @@ var _ = Describe("P2P KV cache source header", func() {
155156
preq := testInfo.prefillHandler.GetCompletionRequests()[0]
156157
prefillKVParams, ok := preq[requestFieldKVTransferParams].(map[string]any)
157158
Expect(ok).To(BeTrue())
158-
Expect(prefillKVParams).To(HaveKey(requestFieldP2PDecodeParams))
159-
Expect(prefillKVParams).ToNot(HaveKey(requestFieldP2PParams))
159+
Expect(prefillKVParams).To(HaveKey(requestFieldRemoteDecoder))
160+
Expect(prefillKVParams).ToNot(HaveKey(requestFieldRemoteKVSource))
160161

161162
testInfo.cancelFn()
162163
<-testInfo.stoppedCh
@@ -200,7 +201,7 @@ var _ = Describe("P2P KV cache source header", func() {
200201
Expect(ok).To(BeTrue())
201202
// Only the sidecar-owned remote_kv_source key survives; the client's keys are gone.
202203
Expect(kvParams).To(HaveLen(1))
203-
p2p, ok := kvParams[requestFieldP2PParams].(map[string]any)
204+
p2p, ok := kvParams[requestFieldRemoteKVSource].(map[string]any)
204205
Expect(ok).To(BeTrue())
205206
Expect(p2p[requestFieldRemoteHost]).To(Equal("10.9.9.9"))
206207

@@ -247,7 +248,7 @@ var _ = Describe("P2P KV cache source header", func() {
247248
for _, dreq := range decodeReqs {
248249
kvParams, ok := dreq[requestFieldKVTransferParams].(map[string]any)
249250
Expect(ok).To(BeTrue())
250-
p2p, ok := kvParams[requestFieldP2PParams].(map[string]any)
251+
p2p, ok := kvParams[requestFieldRemoteKVSource].(map[string]any)
251252
Expect(ok).To(BeTrue())
252253
ids = append(ids, p2p[requestFieldKVRequestID])
253254
}

pkg/sidecar/proxy/connector_p2p_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ var _ = Describe("P2P Connector", func() {
6969
Expect(preq).To(HaveKey(requestFieldKVTransferParams))
7070
prefillKVParams, ok := preq[requestFieldKVTransferParams].(map[string]any)
7171
Expect(ok).To(BeTrue())
72-
Expect(prefillKVParams).ToNot(HaveKey(requestFieldP2PPrefillParams))
73-
prefillDecode, ok := prefillKVParams[requestFieldP2PDecodeParams].(map[string]any)
72+
Expect(prefillKVParams).ToNot(HaveKey(requestFieldRemotePrefiller))
73+
prefillDecode, ok := prefillKVParams[requestFieldRemoteDecoder].(map[string]any)
7474
Expect(ok).To(BeTrue())
7575
prefillKVRequestID := prefillDecode[requestFieldKVRequestID]
7676
Expect(prefillKVRequestID).ToNot(BeEmpty())
@@ -92,8 +92,8 @@ var _ = Describe("P2P Connector", func() {
9292
Expect(dreq).To(HaveKey(requestFieldKVTransferParams))
9393
decodeKVParams, ok := dreq[requestFieldKVTransferParams].(map[string]any)
9494
Expect(ok).To(BeTrue())
95-
Expect(decodeKVParams).ToNot(HaveKey(requestFieldP2PDecodeParams))
96-
decodePrefill, ok := decodeKVParams[requestFieldP2PPrefillParams].(map[string]any)
95+
Expect(decodeKVParams).ToNot(HaveKey(requestFieldRemoteDecoder))
96+
decodePrefill, ok := decodeKVParams[requestFieldRemotePrefiller].(map[string]any)
9797
Expect(ok).To(BeTrue())
9898
Expect(decodePrefill[requestFieldKVRequestID]).To(Equal(prefillKVRequestID))
9999
Expect(decodePrefill[requestFieldRemoteHost]).To(Equal(extractHost(prefillHostPort)))

pkg/sidecar/proxy/proxy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ const (
9595
// nesting key, named for the remote party it describes: "remote_decoder" on
9696
// the prefiller leg, "remote_prefiller" on the decoder leg, "remote_kv_source"
9797
// for a symmetric cached-prefix pull.
98-
requestFieldP2PDecodeParams = "remote_decoder"
99-
requestFieldP2PPrefillParams = "remote_prefiller"
100-
requestFieldP2PParams = "remote_kv_source"
101-
requestFieldKVRequestID = "kv_request_id"
98+
requestFieldRemoteDecoder = "remote_decoder"
99+
requestFieldRemotePrefiller = "remote_prefiller"
100+
requestFieldRemoteKVSource = "remote_kv_source"
101+
requestFieldKVRequestID = "kv_request_id"
102102

103103
KVConnectorNIXLV2 = constants.KVConnectorNIXLV2
104104
KVConnectorSharedStorage = constants.KVConnectorSharedStorage

0 commit comments

Comments
 (0)