Skip to content

Commit f60ea00

Browse files
committed
Add histogram visualization for positive metrics
1 parent 2a72f64 commit f60ea00

File tree

8 files changed

+327
-309
lines changed

8 files changed

+327
-309
lines changed

notebooks/Analysis/No VRAM Use Analysis.ipynb

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
"\n",
9696
"from src.analysis import efficiency_analysis as ea\n",
9797
"from src.visualization import JobsWithMetricsVisualizer, UsersWithMetricsVisualizer\n",
98-
"from src.config.enum_constants import MetricsDataFrameNameEnum"
98+
"from src.config.enum_constants import MetricsDataFrameNameEnum\n",
99+
"from src.config.paths import USERS_VISUALIZATION_DATA_DIR"
99100
]
100101
},
101102
{
@@ -284,33 +285,10 @@
284285
"metadata": {},
285286
"outputs": [],
286287
"source": [
287-
"x_focus = inefficient_users_vram_hours[\"vram_hours\"]\n",
288-
"\n",
289-
"# Log-spaced bins inside the focus window to handle several orders of magnitude\n",
290-
"n_bins = 50\n",
291-
"# bins = np.logspace(np.log10(x_focus.min()), np.log10(x_focus.max()), n_bins)\n",
292-
"\n",
293-
"# Histogram with logarithmic x-axis (focused range only)\n",
294-
"ax = sns.histplot(x_focus, bins=10**4, color=\"#1f77b4\")\n",
295-
"ax.set_xscale(\"log\")\n",
296-
"ax.set_xlabel(\"VRAM-Hours (log scale)\")\n",
297-
"ax.set_ylabel(\"Count\")\n",
298-
"ax.set_title(\"VRAM-Hours Distribution\")\n",
299-
"\n",
300-
"total_count = x_focus.sum()\n",
301-
"ax.text(\n",
302-
" 0.98,\n",
303-
" 0.95,\n",
304-
" f\"Total VRAM_Hours\\n{total_count:,.2f}\",\n",
305-
" transform=ax.transAxes,\n",
306-
" ha=\"right\",\n",
307-
" va=\"top\",\n",
308-
" fontsize=10,\n",
309-
" bbox=dict(boxstyle=\"round,pad=0.3\", fc=\"white\", ec=\"gray\", alpha=0.9),\n",
310-
")\n",
311-
"\n",
312-
"plt.tight_layout()\n",
313-
"plt.show()"
288+
"distro_visualizer = UsersWithMetricsVisualizer(inefficient_users_vram_hours)\n",
289+
"distro_visualizer.visualize_metric_distribution(\n",
290+
" output_dir_path=USERS_VISUALIZATION_DATA_DIR, column=\"vram_hours\", figsize=(10, 6)\n",
291+
")"
314292
]
315293
},
316294
{

notebooks/Analysis/Requested and Used VRAM.ipynb

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,38 @@
415415
]
416416
},
417417
{
418-
"cell_type": "markdown",
418+
"cell_type": "code",
419+
"execution_count": null,
419420
"id": "29",
420421
"metadata": {},
422+
"outputs": [],
423+
"source": [
424+
"inefficient_users_ev_req_vram_eff = analyzer.sort_and_filter_records_with_metrics(\n",
425+
" metrics_df_name_enum=ResourceHoardingDataFrameNameEnum.USERS,\n",
426+
" sorting_key=\"expected_value_requested_vram_efficiency\",\n",
427+
" ascending=True, # Sort by expected_value_requested_vram_efficiency in ascending order\n",
428+
" filter_criteria={\n",
429+
" \"job_count\": {\"min\": 5, \"inclusive\": True}, # minimum job count threshold\n",
430+
" },\n",
431+
")\n",
432+
"users_with_metrics_ev_visualizer = UsersWithMetricsVisualizer(inefficient_users_ev_req_vram_eff)\n",
433+
"users_with_metrics_ev_visualizer.visualize_metric_distribution(\n",
434+
" output_dir_path=USERS_VISUALIZATION_DATA_DIR, column=\"expected_value_requested_vram_efficiency\", figsize=(8, 5)\n",
435+
")"
436+
]
437+
},
438+
{
439+
"cell_type": "markdown",
440+
"id": "30",
441+
"metadata": {},
421442
"source": [
422443
"### <a id='toc1_6_2_'></a>[Generate all hoarding analysis metrics for users:](#toc0_)"
423444
]
424445
},
425446
{
426447
"cell_type": "code",
427448
"execution_count": null,
428-
"id": "30",
449+
"id": "31",
429450
"metadata": {},
430451
"outputs": [],
431452
"source": [
@@ -435,7 +456,7 @@
435456
},
436457
{
437458
"cell_type": "markdown",
438-
"id": "31",
459+
"id": "32",
439460
"metadata": {},
440461
"source": [
441462
"#### <a id='toc1_6_2_1_'></a>[Find most inefficient users hoarding node RAM based on `expected_value_ram_hoarding_fraction_diff`](#toc0_)"
@@ -444,7 +465,7 @@
444465
{
445466
"cell_type": "code",
446467
"execution_count": null,
447-
"id": "32",
468+
"id": "33",
448469
"metadata": {},
449470
"outputs": [],
450471
"source": [
@@ -472,7 +493,7 @@
472493
},
473494
{
474495
"cell_type": "markdown",
475-
"id": "33",
496+
"id": "34",
476497
"metadata": {},
477498
"source": [
478499
"#### <a id='toc1_6_2_2_'></a>[Find most inefficient users hoarding CPU cores based on `expected_value_core_hoarding_fraction_diff`](#toc0_)"
@@ -481,7 +502,7 @@
481502
{
482503
"cell_type": "code",
483504
"execution_count": null,
484-
"id": "34",
505+
"id": "35",
485506
"metadata": {},
486507
"outputs": [],
487508
"source": [
@@ -509,7 +530,7 @@
509530
},
510531
{
511532
"cell_type": "markdown",
512-
"id": "35",
533+
"id": "36",
513534
"metadata": {},
514535
"source": [
515536
"## <a id='toc1_7_'></a>[PI Group Analysis](#toc0_)"
@@ -518,7 +539,7 @@
518539
{
519540
"cell_type": "code",
520541
"execution_count": null,
521-
"id": "36",
542+
"id": "37",
522543
"metadata": {},
523544
"outputs": [],
524545
"source": [
@@ -527,7 +548,7 @@
527548
},
528549
{
529550
"cell_type": "markdown",
530-
"id": "37",
551+
"id": "38",
531552
"metadata": {},
532553
"source": [
533554
"#### <a id='toc1_7_1_1_'></a>[Find Inefficient PIs based on `avg_requested_vram_efficiency_score`](#toc0_)"
@@ -536,7 +557,7 @@
536557
{
537558
"cell_type": "code",
538559
"execution_count": null,
539-
"id": "38",
560+
"id": "39",
540561
"metadata": {},
541562
"outputs": [],
542563
"source": [

notebooks/analysis/No VRAM Use Analysis.ipynb

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
"\n",
9696
"from src.analysis import efficiency_analysis as ea\n",
9797
"from src.visualization import JobsWithMetricsVisualizer, UsersWithMetricsVisualizer\n",
98-
"from src.config.enum_constants import MetricsDataFrameNameEnum"
98+
"from src.config.enum_constants import MetricsDataFrameNameEnum\n",
99+
"from src.config.paths import USERS_VISUALIZATION_DATA_DIR"
99100
]
100101
},
101102
{
@@ -284,33 +285,10 @@
284285
"metadata": {},
285286
"outputs": [],
286287
"source": [
287-
"x_focus = inefficient_users_vram_hours[\"vram_hours\"]\n",
288-
"\n",
289-
"# Log-spaced bins inside the focus window to handle several orders of magnitude\n",
290-
"n_bins = 50\n",
291-
"# bins = np.logspace(np.log10(x_focus.min()), np.log10(x_focus.max()), n_bins)\n",
292-
"\n",
293-
"# Histogram with logarithmic x-axis (focused range only)\n",
294-
"ax = sns.histplot(x_focus, bins=10**4, color=\"#1f77b4\")\n",
295-
"ax.set_xscale(\"log\")\n",
296-
"ax.set_xlabel(\"VRAM-Hours (log scale)\")\n",
297-
"ax.set_ylabel(\"Count\")\n",
298-
"ax.set_title(\"VRAM-Hours Distribution\")\n",
299-
"\n",
300-
"total_count = x_focus.sum()\n",
301-
"ax.text(\n",
302-
" 0.98,\n",
303-
" 0.95,\n",
304-
" f\"Total VRAM_Hours\\n{total_count:,.2f}\",\n",
305-
" transform=ax.transAxes,\n",
306-
" ha=\"right\",\n",
307-
" va=\"top\",\n",
308-
" fontsize=10,\n",
309-
" bbox=dict(boxstyle=\"round,pad=0.3\", fc=\"white\", ec=\"gray\", alpha=0.9),\n",
310-
")\n",
311-
"\n",
312-
"plt.tight_layout()\n",
313-
"plt.show()"
288+
"distro_visualizer = UsersWithMetricsVisualizer(inefficient_users_vram_hours)\n",
289+
"distro_visualizer.visualize_metric_distribution(\n",
290+
" output_dir_path=USERS_VISUALIZATION_DATA_DIR, column=\"vram_hours\", figsize=(10, 6)\n",
291+
")"
314292
]
315293
},
316294
{

notebooks/analysis/Requested and Used VRAM.ipynb

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,38 @@
415415
]
416416
},
417417
{
418-
"cell_type": "markdown",
418+
"cell_type": "code",
419+
"execution_count": null,
419420
"id": "29",
420421
"metadata": {},
422+
"outputs": [],
423+
"source": [
424+
"inefficient_users_ev_req_vram_eff = analyzer.sort_and_filter_records_with_metrics(\n",
425+
" metrics_df_name_enum=ResourceHoardingDataFrameNameEnum.USERS,\n",
426+
" sorting_key=\"expected_value_requested_vram_efficiency\",\n",
427+
" ascending=True, # Sort by expected_value_requested_vram_efficiency in ascending order\n",
428+
" filter_criteria={\n",
429+
" \"job_count\": {\"min\": 5, \"inclusive\": True}, # minimum job count threshold\n",
430+
" },\n",
431+
")\n",
432+
"users_with_metrics_ev_visualizer = UsersWithMetricsVisualizer(inefficient_users_ev_req_vram_eff)\n",
433+
"users_with_metrics_ev_visualizer.visualize_metric_distribution(\n",
434+
" output_dir_path=USERS_VISUALIZATION_DATA_DIR, column=\"expected_value_requested_vram_efficiency\", figsize=(8, 5)\n",
435+
")"
436+
]
437+
},
438+
{
439+
"cell_type": "markdown",
440+
"id": "30",
441+
"metadata": {},
421442
"source": [
422443
"### <a id='toc1_6_2_'></a>[Generate all hoarding analysis metrics for users:](#toc0_)"
423444
]
424445
},
425446
{
426447
"cell_type": "code",
427448
"execution_count": null,
428-
"id": "30",
449+
"id": "31",
429450
"metadata": {},
430451
"outputs": [],
431452
"source": [
@@ -435,7 +456,7 @@
435456
},
436457
{
437458
"cell_type": "markdown",
438-
"id": "31",
459+
"id": "32",
439460
"metadata": {},
440461
"source": [
441462
"#### <a id='toc1_6_2_1_'></a>[Find most inefficient users hoarding node RAM based on `expected_value_ram_hoarding_fraction_diff`](#toc0_)"
@@ -444,7 +465,7 @@
444465
{
445466
"cell_type": "code",
446467
"execution_count": null,
447-
"id": "32",
468+
"id": "33",
448469
"metadata": {},
449470
"outputs": [],
450471
"source": [
@@ -472,7 +493,7 @@
472493
},
473494
{
474495
"cell_type": "markdown",
475-
"id": "33",
496+
"id": "34",
476497
"metadata": {},
477498
"source": [
478499
"#### <a id='toc1_6_2_2_'></a>[Find most inefficient users hoarding CPU cores based on `expected_value_core_hoarding_fraction_diff`](#toc0_)"
@@ -481,7 +502,7 @@
481502
{
482503
"cell_type": "code",
483504
"execution_count": null,
484-
"id": "34",
505+
"id": "35",
485506
"metadata": {},
486507
"outputs": [],
487508
"source": [
@@ -509,7 +530,7 @@
509530
},
510531
{
511532
"cell_type": "markdown",
512-
"id": "35",
533+
"id": "36",
513534
"metadata": {},
514535
"source": [
515536
"## <a id='toc1_7_'></a>[PI Group Analysis](#toc0_)"
@@ -518,7 +539,7 @@
518539
{
519540
"cell_type": "code",
520541
"execution_count": null,
521-
"id": "36",
542+
"id": "37",
522543
"metadata": {},
523544
"outputs": [],
524545
"source": [
@@ -527,7 +548,7 @@
527548
},
528549
{
529550
"cell_type": "markdown",
530-
"id": "37",
551+
"id": "38",
531552
"metadata": {},
532553
"source": [
533554
"#### <a id='toc1_7_1_1_'></a>[Find Inefficient PIs based on `avg_requested_vram_efficiency_score`](#toc0_)"
@@ -536,7 +557,7 @@
536557
{
537558
"cell_type": "code",
538559
"execution_count": null,
539-
"id": "38",
560+
"id": "39",
540561
"metadata": {},
541562
"outputs": [],
542563
"source": [

0 commit comments

Comments
 (0)