1313# limitations under the License.
1414
1515"""
16- DAG to verify tpu-info streaming rate functionality on TPU v6e slices.
16+ DAG to validate the 'tpu-info' streaming refresh rate by calculating the time interval
17+ between consecutive hardware telemetry updates on TPU v6e slices.
1718"""
1819
1920import datetime
@@ -40,7 +41,7 @@ class TPUPerformanceAnalyzer:
4041
4142 def __init__ (self , target_rate : float = 0.1 ):
4243 """
43- Initialize the analyzer with a target sampling rate.
44+ Initialize the analyzer with a target refresh rate.
4445 :param target_rate: The expected update interval in seconds (default 0.1s).
4546 """
4647 self .target_rate = target_rate
@@ -125,11 +126,11 @@ def filter_update_events(self):
125126
126127 def validate_rate_match (self ) -> bool :
127128 """
128- Validates if the hardware update frequency aligns with the target rate.
129+ Validates if the hardware update frequency aligns with the target refresh rate.
129130
130131 Logic Rationale:
131132 1. Eager Hardware Output: To ensure monitoring data does not lag behind the
132- specified sampling frequency (Target Rate), the hardware driver implements
133+ specified refresh frequency (Target Refresh Rate e.g., 0.1s ), the hardware driver implements
133134 an eager refresh strategy. This often results in intervals slightly below
134135 or exactly at the target (e.g., 0.08s - 0.10s).
135136 2. Jitter Tolerance: A +/- 20% buffer (0.08s to 0.12s) is established to
@@ -200,7 +201,9 @@ def generate_report(self) -> str:
200201 is_matched = self .validate_rate_match ()
201202 output .append ("-" * 210 )
202203 output .append (
203- f"Average Interval (Stable Phase): { avg_intv :.3f} s | Target Rate Match: { is_matched } "
204+ f"Average Interval (Stable Phase): { avg_intv :.3f} s\n "
205+ f"Target Rate Match: { is_matched } \n "
206+ f"(Verified: Streaming data updated within the target refresh rate window)"
204207 )
205208
206209 return "\n " .join (output )
@@ -237,14 +240,15 @@ def validate_streaming_rate_iterations(
237240 rate : float ,
238241 iteration_count : int = 40 ,
239242 duration : int = 30 ,
243+ pass_threshold_percent : float = 0.5 ,
240244) -> str :
241245 """
242246 Performs 40 iterations of 30s tests.
243247 The task succeeds if at least 50% of the iterations are valid.
244248 """
245249 analyzer = TPUPerformanceAnalyzer (target_rate = rate )
246250 success_count = 0
247- pass_threshold = iteration_count / 2 # 50% threshold
251+ pass_threshold = iteration_count * pass_threshold_percent
248252
249253 for i in range (1 , iteration_count + 1 ):
250254 # Precise command with Perl microsecond timestamping and terminal line export
@@ -302,15 +306,20 @@ def validate_streaming_rate_iterations(
302306 "streaming-rate" ,
303307 ],
304308 description = (
305- "Automated validation of the tpu-info CLI's --rate parameter, "
306- "ensuring accurate metric streaming frequencies on TPU v6e-16 slices."
309+ "Validates the tpu-info refresh rate by "
310+ "calculating the time interval "
311+ "between consecutive hardware telemetry updates on TPU v6e-16 slices."
307312 ),
308313 doc_md = """
309- ## TPU Info Streaming Rate Verification DAG
314+ ## TPU Info Streaming Refresh Rate Verification DAG
310315
311- This DAG automates the functional testing of the `tpu-info` CLI tool, specifically focusing on the
312- `--streaming` and `--rate` flags. It verifies that the tool correctly honors requested update
313- intervals within a Kubernetes-managed TPU environment.
316+ This DAG automates the functional testing of the `tpu-info` CLI tool, specifically
317+ validating the accuracy of the streaming **refresh rate**.
318+
319+ The core verification logic calculates the precise time delta between
320+ consecutive hardware data frames. It ensures that the actual refresh frequency
321+ matches the requested `--rate` parameter within a defined jitter tolerance,
322+ confirming that the system delivers real-time hardware metrics without stale data.
314323 """ ,
315324) as dag :
316325 for machine in MachineConfigMap :
@@ -362,6 +371,8 @@ def generate_second_node_pool_name(
362371 node_pool_name = generate_second_node_pool_name (cluster_info ),
363372 )
364373
374+ # Keyword arguments are generated dynamically at runtime (pylint does not
375+ # know this signature).
365376 with TaskGroup ( # pylint: disable=unexpected-keyword-arg
366377 group_id = "create_node_pool"
367378 ) as create_node_pool :
@@ -398,7 +409,7 @@ def generate_second_node_pool_name(
398409 # Keyword arguments are generated dynamically at runtime (pylint does not
399410 # know this signature).
400411 with TaskGroup ( # pylint: disable=unexpected-keyword-arg
401- group_id = "tpu_streaming_rate_verification "
412+ group_id = "streaming_rate_verification "
402413 ) as rate_verification_group :
403414 test_rates = [0.1 , 0.5 , 1.0 , 5.0 ]
404415
@@ -418,6 +429,7 @@ def generate_second_node_pool_name(
418429 info = cluster_info ,
419430 rate = rate ,
420431 iteration_count = 40 ,
432+ pass_threshold_percent = 0.5 , # At least 50% must pass
421433 ).expand (
422434 pod_name = pod_names
423435 )
0 commit comments