[Frontend][RL] Track HTTP weight operation outcomes and concurrency (#55781)
Signed-off-by: Ronald1995 <ronaldautomobile@163.com> Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: aoshen02 <aoshen@inferact.ai>
This commit is contained in:
co-authored by
aoshen02
Claude Opus 5.5
aoshen02
parent
ae66f9a97c
commit
713ec07655
@@ -6723,6 +6723,7 @@ async fn weight_transfer_routes_support_the_http_training_lifecycle() {
|
||||
})
|
||||
})
|
||||
.await;
|
||||
let metrics_before = METRICS.render().unwrap();
|
||||
|
||||
let mut responses = Vec::new();
|
||||
for (method, path, body) in [
|
||||
@@ -6785,6 +6786,26 @@ async fn weight_transfer_routes_support_the_http_training_lifecycle() {
|
||||
);
|
||||
}
|
||||
engine_task.await.expect("mock engine task");
|
||||
let metrics_after = METRICS.render().unwrap();
|
||||
for operation in ["update", "finish"] {
|
||||
assert_eq!(
|
||||
metric_delta(
|
||||
&metrics_before,
|
||||
&metrics_after,
|
||||
"vllm:rl_weight_update_operation_duration_seconds_count",
|
||||
Some(&format!("operation=\"{operation}\"")),
|
||||
),
|
||||
2.0
|
||||
);
|
||||
assert_eq!(
|
||||
metric_value(
|
||||
&metrics_after,
|
||||
"vllm:rl_weight_update_operations_in_flight",
|
||||
Some(&format!("operation=\"{operation}\"")),
|
||||
),
|
||||
Some(0.0)
|
||||
);
|
||||
}
|
||||
expect_test::expect![[r#"
|
||||
[
|
||||
"{\"message\":\"Weight transfer initialized\"}",
|
||||
@@ -6811,6 +6832,7 @@ async fn weight_transfer_routes_reject_invalid_payloads_before_engine_calls() {
|
||||
})
|
||||
})
|
||||
.await;
|
||||
let metrics_before = METRICS.render().unwrap();
|
||||
|
||||
for (path, body) in [
|
||||
("/init_weight_transfer_engine", "{"),
|
||||
@@ -6840,6 +6862,18 @@ async fn weight_transfer_routes_reject_invalid_payloads_before_engine_calls() {
|
||||
.expect("call app");
|
||||
assert_eq!(response.status(), StatusCode::BAD_REQUEST, "{path}: {body}");
|
||||
}
|
||||
let metrics_after = METRICS.render().unwrap();
|
||||
for operation in ["init", "update", "finish"] {
|
||||
assert_eq!(
|
||||
metric_delta(
|
||||
&metrics_before,
|
||||
&metrics_after,
|
||||
"vllm:rl_weight_update_operation_duration_seconds_count",
|
||||
Some(&format!("operation=\"{operation}\"")),
|
||||
),
|
||||
0.0
|
||||
);
|
||||
}
|
||||
engine_task.abort_and_join().await;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use axum::extract::State;
|
||||
use axum::extract::rejection::JsonRejection;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
use vllm_metrics::METRICS;
|
||||
|
||||
use crate::error::{ApiError, invalid_request};
|
||||
use crate::state::AppState;
|
||||
@@ -62,6 +63,7 @@ pub async fn init_weight_transfer_engine(
|
||||
)
|
||||
})?;
|
||||
|
||||
let _recorder = METRICS.api_server.record_weight_operation("init");
|
||||
state
|
||||
.engine_core_client()
|
||||
.init_weight_transfer_engine(init_info)
|
||||
@@ -77,6 +79,7 @@ pub async fn init_weight_transfer_engine(
|
||||
pub async fn start_weight_update(
|
||||
State(state): State<Arc<AppState>>,
|
||||
) -> Result<Json<MessageResponse>, ApiError> {
|
||||
let _recorder = METRICS.api_server.record_weight_operation("start");
|
||||
state
|
||||
.engine_core_client()
|
||||
.start_weight_update()
|
||||
@@ -92,6 +95,7 @@ pub async fn start_weight_update(
|
||||
pub async fn start_draft_weight_update(
|
||||
State(state): State<Arc<AppState>>,
|
||||
) -> Result<Json<MessageResponse>, ApiError> {
|
||||
let _recorder = METRICS.api_server.record_weight_operation("start_draft");
|
||||
state
|
||||
.engine_core_client()
|
||||
.start_draft_weight_update()
|
||||
@@ -122,6 +126,7 @@ pub async fn update_weights(
|
||||
)
|
||||
})?;
|
||||
|
||||
let _recorder = METRICS.api_server.record_weight_operation("update");
|
||||
state
|
||||
.engine_core_client()
|
||||
.update_weights(update_info)
|
||||
@@ -142,6 +147,7 @@ pub async fn finish_weight_update(
|
||||
let request = body?.map(|Json(request)| request).unwrap_or_default();
|
||||
|
||||
let client = state.engine_core_client();
|
||||
let _recorder = METRICS.api_server.record_weight_operation("finish");
|
||||
client
|
||||
.finish_weight_update()
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user