@@ -19,9 +19,7 @@ package llmdinferencesim
1919import  (
2020	"context" 
2121	"errors" 
22- 	"fmt" 
2322	"io" 
24- 	"math" 
2523	"net/http" 
2624	"os" 
2725	"reflect" 
@@ -662,9 +660,6 @@ var _ = Describe("Simulator metrics", Ordered, func() {
662660			ctx  :=  context .TODO ()
663661			args  :=  []string {"cmd" , "--model" , model , "--mode" , common .ModeRandom ,
664662				"--fake-metrics" ,
665- << << << <  HEAD 
666- 				"{\" running-requests\" :10,\" waiting-requests\" :30,\" kv-cache-usage\" :0.4,\" loras\" :[{\" running\" :\" lora4,lora2\" ,\" waiting\" :\" lora3\" ,\" timestamp\" :1257894567},{\" running\" :\" lora4,lora3\" ,\" waiting\" :\" \" ,\" timestamp\" :1257894569}],\" ttft-buckets-values\" :[1, 2, 3],\" tpot-buckets-values\" : [0, 0, 1, 2, 3]}" ,
667- == == == = 
668663				`{`  + 
669664					`"running-requests":10,`  + 
670665					`"waiting-requests":30,`  + 
@@ -678,6 +673,8 @@ var _ = Describe("Simulator metrics", Ordered, func() {
678673					`"request-prompt-tokens":[10,20,30],`  + 
679674					`"request-generation-tokens":[10,20,30],`  + 
680675					`"request-params-max-tokens":[10,20,30],`  + 
676+ 					`"ttft-buckets-values":[1,2,3],`  + 
677+ 					`"tpot-buckets-values":[0,0,1,2,3],`  + 
681678					`"loras":[`  + 
682679					`{`  + 
683680					`"running":"lora4,lora2",`  + 
@@ -691,7 +688,6 @@ var _ = Describe("Simulator metrics", Ordered, func() {
691688					`}`  + 
692689					`]`  + 
693690					`}` ,
694- >> >> >> >  02 bc5c3  (fix  review  comment )
695691			}
696692
697693			client , err  :=  startServerWithArgs (ctx , common .ModeRandom , args , nil )
@@ -710,7 +706,6 @@ var _ = Describe("Simulator metrics", Ordered, func() {
710706			Expect (metrics ).To (ContainSubstring ("vllm:lora_requests_info{max_lora=\" 1\" ,running_lora_adapters=\" lora4,lora2\" ,waiting_lora_adapters=\" lora3\" } 1.257894567e+09" ))
711707			Expect (metrics ).To (ContainSubstring ("vllm:lora_requests_info{max_lora=\" 1\" ,running_lora_adapters=\" lora4,lora3\" ,waiting_lora_adapters=\" \" } 1.257894569e+09" ))
712708
713- << << << <  HEAD 
714709			Expect (metrics ).To (ContainSubstring ("vllm:time_to_first_token_seconds_bucket{model_name=\" my_model\" ,le=\" 0.001\" } 1" ))
715710			Expect (metrics ).To (ContainSubstring ("vllm:time_to_first_token_seconds_bucket{model_name=\" my_model\" ,le=\" 0.005\" } 3" ))
716711			Expect (metrics ).To (ContainSubstring ("vllm:time_to_first_token_seconds_bucket{model_name=\" my_model\" ,le=\" 0.01\" } 6" ))
@@ -767,7 +762,7 @@ var _ = Describe("Simulator metrics", Ordered, func() {
767762			Expect (metrics ).To (ContainSubstring ("vllm:time_to_first_token_seconds_bucket{model_name=\" my_model\" ,le=\" 640\" } 0" ))
768763			Expect (metrics ).To (ContainSubstring ("vllm:time_to_first_token_seconds_bucket{model_name=\" my_model\" ,le=\" 2560\" } 0" ))
769764			Expect (metrics ).To (ContainSubstring ("vllm:time_to_first_token_seconds_bucket{model_name=\" my_model\" ,le=\" +Inf\" } 1" ))
770- == == == = 
765+ 
771766			Expect (metrics ).To (ContainSubstring (`vllm:request_generation_tokens_bucket{model_name="my_model",le="1"} 10` ))
772767			Expect (metrics ).To (ContainSubstring (`vllm:request_generation_tokens_bucket{model_name="my_model",le="2"} 30` ))
773768			Expect (metrics ).To (ContainSubstring (`vllm:request_generation_tokens_bucket{model_name="my_model",le="5"} 60` ))
@@ -808,8 +803,6 @@ var _ = Describe("Simulator metrics", Ordered, func() {
808803			Expect (metrics ).To (ContainSubstring (`vllm:request_success_total{finish_reason="remote_decode",model_name="my_model"} 0` ))
809804			Expect (metrics ).To (ContainSubstring (`vllm:request_success_total{finish_reason="stop",model_name="my_model"} 20` ))
810805			Expect (metrics ).To (ContainSubstring (`vllm:request_success_total{finish_reason="tool_calls",model_name="my_model"} 0` ))
811- 
812- >> >> >> >  02 bc5c3  (fix  review  comment )
813806		})
814807	})
815808})
@@ -993,104 +986,3 @@ func TestBuild125Buckets(t *testing.T) {
993986		})
994987	}
995988}
996- 
997- func  validateSamplesInBuckets (t  * testing.T , samples  []float64 , boundaries  []float64 , counts  []float64 ) {
998- 	fullCounts  :=  padCountsToFull (boundaries , counts )
999- 	// Now validate using fullCounts 
1000- 	sortedSamples  :=  make ([]float64 , len (samples ))
1001- 	copy (sortedSamples , samples )
1002- 	sort .Float64s (sortedSamples )
1003- 
1004- 	actualCounts  :=  make ([]int , len (fullCounts ))
1005- 	sampleIndex  :=  0 
1006- 
1007- 	for  bucketIndex  :=  range  fullCounts  {
1008- 		var  upperBound  float64 
1009- 		if  bucketIndex  ==  len (boundaries ) {
1010- 			upperBound  =  math .Inf (+ 1 )
1011- 		} else  {
1012- 			upperBound  =  boundaries [bucketIndex ]
1013- 		}
1014- 
1015- 		for  sampleIndex  <  len (sortedSamples ) &&  sortedSamples [sampleIndex ] <=  upperBound  {
1016- 			actualCounts [bucketIndex ]++ 
1017- 			sampleIndex ++ 
1018- 		}
1019- 	}
1020- 
1021- 	// Verify each bucket 
1022- 	for  i , want  :=  range  fullCounts  {
1023- 		if  actualCounts [i ] !=  int (want ) {
1024- 			var  lowerStr , upperStr  string 
1025- 			if  i  ==  0  {
1026- 				lowerStr  =  "-Inf" 
1027- 			} else  {
1028- 				lowerStr  =  fmt .Sprintf ("%.3f" , boundaries [i - 1 ])
1029- 			}
1030- 			if  i  ==  len (boundaries ) {
1031- 				upperStr  =  "+Inf" 
1032- 			} else  {
1033- 				upperStr  =  fmt .Sprintf ("%.3f" , boundaries [i ])
1034- 			}
1035- 			t .Errorf ("bucket[%d] (%s, %s]: want %d, got %d" ,
1036- 				i , lowerStr , upperStr , int (want ), actualCounts [i ])
1037- 		}
1038- 	}
1039- 
1040- 	totalExpected  :=  0 
1041- 	for  _ , c  :=  range  fullCounts  {
1042- 		totalExpected  +=  int (c )
1043- 	}
1044- 	if  len (samples ) !=  totalExpected  {
1045- 		t .Errorf ("total samples: want %d, got %d" , totalExpected , len (samples ))
1046- 	}
1047- }
1048- 
1049- func  TestGenerateSamplesFromBuckets (t  * testing.T ) {
1050- 	tests  :=  []struct  {
1051- 		name             string 
1052- 		boundaries       []float64 
1053- 		counts           []float64 
1054- 		expectedSamples  int 
1055- 	}{
1056- 		{
1057- 			name :            "short counts with non-zero in middle" ,
1058- 			boundaries :      []float64 {1 , 2 , 5 , 10 , 20 , 50 , 100 , 200 , 500 , 1000 },
1059- 			counts :          []float64 {0 , 0 , 0 , 5 , 0 , 5 },
1060- 			expectedSamples : 10 ,
1061- 		},
1062- 		{
1063- 			name :            "empty boundaries → 1 bucket" ,
1064- 			boundaries :      []float64 {},
1065- 			counts :          []float64 {7 },
1066- 			expectedSamples : 7 ,
1067- 		},
1068- 		{
1069- 			name :            "single boundary → 2 buckets, short counts" ,
1070- 			boundaries :      []float64 {10.0 },
1071- 			counts :          []float64 {3 },
1072- 			expectedSamples : 3 ,
1073- 		},
1074- 		{
1075- 			name :            "full counts provided" ,
1076- 			boundaries :      []float64 {1 , 2 , 5 },
1077- 			counts :          []float64 {1 , 0 , 2 , 1 },
1078- 			expectedSamples : 4 ,
1079- 		},
1080- 		{
1081- 			name :            "all zeros (short)" ,
1082- 			boundaries :      []float64 {1 , 2 , 5 },
1083- 			counts :          []float64 {},
1084- 			expectedSamples : 0 ,
1085- 		},
1086- 	}
1087- 	for  _ , tt  :=  range  tests  {
1088- 		t .Run (tt .name , func (t  * testing.T ) {
1089- 			samples  :=  generateSamplesFromBuckets (tt .boundaries , tt .counts )
1090- 			if  len (samples ) !=  tt .expectedSamples  {
1091- 				t .Fatalf ("sample count mismatch: want %d, got %d" , tt .expectedSamples , len (samples ))
1092- 			}
1093- 			validateSamplesInBuckets (t , samples , tt .boundaries , tt .counts )
1094- 		})
1095- 	}
1096- }
0 commit comments