nvidia-nat 1.4.0a20251030__py3-none-any.whl → 1.4.0a20251101__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nat/observability/exporter/span_exporter.py +8 -0
- nat/profiler/parameter_optimization/parameter_optimizer.py +12 -2
- nat/profiler/parameter_optimization/pareto_visualizer.py +67 -2
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/METADATA +1 -1
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/RECORD +10 -10
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/WHEEL +0 -0
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/entry_points.txt +0 -0
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/top_level.txt +0 -0
|
@@ -196,6 +196,14 @@ class SpanExporter(ProcessingExporter[InputSpanT, OutputSpanT], SerializeMixin):
|
|
|
196
196
|
span_kind = event_type_to_span_kind(event.event_type)
|
|
197
197
|
sub_span.set_attribute(f"{self._span_prefix}.span.kind", span_kind.value)
|
|
198
198
|
|
|
199
|
+
# Enable session grouping by setting session.id from conversation_id
|
|
200
|
+
try:
|
|
201
|
+
conversation_id = self._context_state.conversation_id.get()
|
|
202
|
+
if conversation_id:
|
|
203
|
+
sub_span.set_attribute("session.id", conversation_id)
|
|
204
|
+
except (AttributeError, LookupError):
|
|
205
|
+
pass
|
|
206
|
+
|
|
199
207
|
if event.payload.data and event.payload.data.input:
|
|
200
208
|
match = re.search(r"Human:\s*Question:\s*(.*)", str(event.payload.data.input))
|
|
201
209
|
if match:
|
|
@@ -111,7 +111,10 @@ def optimize_parameters(
|
|
|
111
111
|
tasks = [_single_eval(i) for i in range(reps)]
|
|
112
112
|
return await asyncio.gather(*tasks)
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
# Calculate padding width based on total number of trials
|
|
115
|
+
trial_id_width = len(str(max(0, optimizer_config.numeric.n_trials - 1)))
|
|
116
|
+
trial_id_padded = f"{trial.number:0{trial_id_width}d}"
|
|
117
|
+
with (out_dir / f"config_numeric_trial_{trial_id_padded}.yml").open("w") as fh:
|
|
115
118
|
yaml.dump(cfg_trial.model_dump(), fh)
|
|
116
119
|
|
|
117
120
|
all_scores = asyncio.run(_run_all_evals())
|
|
@@ -132,7 +135,7 @@ def optimize_parameters(
|
|
|
132
135
|
|
|
133
136
|
# Save final results (out_dir already created and defined above)
|
|
134
137
|
with (out_dir / "optimized_config.yml").open("w") as fh:
|
|
135
|
-
yaml.dump(tuned_cfg.model_dump(), fh)
|
|
138
|
+
yaml.dump(tuned_cfg.model_dump(mode='json'), fh)
|
|
136
139
|
with (out_dir / "trials_dataframe_params.csv").open("w") as fh:
|
|
137
140
|
# Export full trials DataFrame (values, params, timings, etc.).
|
|
138
141
|
df = study.trials_dataframe()
|
|
@@ -154,6 +157,13 @@ def optimize_parameters(
|
|
|
154
157
|
# Some Optuna versions return a dict in a single user_attrs column.
|
|
155
158
|
df["rep_scores"] = df["user_attrs"].apply(lambda d: d.get("rep_scores") if isinstance(d, dict) else None)
|
|
156
159
|
df = df.drop(columns=["user_attrs"])
|
|
160
|
+
|
|
161
|
+
# Get Pareto optimal trial numbers from Optuna study
|
|
162
|
+
pareto_trials = study.best_trials
|
|
163
|
+
pareto_trial_numbers = {trial.number for trial in pareto_trials}
|
|
164
|
+
# Add boolean column indicating if trial is Pareto optimal
|
|
165
|
+
df["pareto_optimal"] = df["number"].isin(pareto_trial_numbers)
|
|
166
|
+
|
|
157
167
|
df.to_csv(fh, index=False)
|
|
158
168
|
|
|
159
169
|
# Generate Pareto front visualizations
|
|
@@ -21,6 +21,8 @@ import matplotlib.pyplot as plt
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
import optuna
|
|
23
23
|
import pandas as pd
|
|
24
|
+
from matplotlib.lines import Line2D
|
|
25
|
+
from matplotlib.patches import Patch
|
|
24
26
|
|
|
25
27
|
logger = logging.getLogger(__name__)
|
|
26
28
|
|
|
@@ -79,6 +81,19 @@ class ParetoVisualizer:
|
|
|
79
81
|
linewidths=1.5,
|
|
80
82
|
marker='*')
|
|
81
83
|
|
|
84
|
+
# Add trial number labels to Pareto optimal points
|
|
85
|
+
for idx in range(len(pareto_trials_df)):
|
|
86
|
+
trial_number = pareto_trials_df.iloc[idx]['number'] \
|
|
87
|
+
if 'number' in pareto_trials_df.columns else pareto_trials_df.index[idx]
|
|
88
|
+
ax.annotate(f'{int(trial_number)}',
|
|
89
|
+
xy=(pareto_x[idx], pareto_y[idx]),
|
|
90
|
+
xytext=(8, 8),
|
|
91
|
+
textcoords='offset points',
|
|
92
|
+
fontsize=9,
|
|
93
|
+
fontweight='bold',
|
|
94
|
+
color='darkred',
|
|
95
|
+
bbox=dict(boxstyle='round,pad=0.3', facecolor='white', edgecolor='red', alpha=0.9))
|
|
96
|
+
|
|
82
97
|
# Draw Pareto front line (only for 2D)
|
|
83
98
|
if len(pareto_x) > 1:
|
|
84
99
|
# Sort points for line drawing based on first objective
|
|
@@ -182,6 +197,18 @@ class ParetoVisualizer:
|
|
|
182
197
|
trial_values = [normalized_values[j][idx] for j in range(n_metrics)]
|
|
183
198
|
ax.plot(x_positions, trial_values, 'r-', alpha=0.8, linewidth=3)
|
|
184
199
|
|
|
200
|
+
# Add trial number label at the rightmost point
|
|
201
|
+
trial_number = trials_df.iloc[idx]['number'] if 'number' in trials_df.columns else idx
|
|
202
|
+
# Position label slightly to the right and above the last point
|
|
203
|
+
ax.annotate(f'{int(trial_number)}',
|
|
204
|
+
xy=(x_positions[-1], trial_values[-1]),
|
|
205
|
+
xytext=(5, 5),
|
|
206
|
+
textcoords='offset points',
|
|
207
|
+
fontsize=9,
|
|
208
|
+
fontweight='bold',
|
|
209
|
+
color='darkred',
|
|
210
|
+
bbox=dict(boxstyle='round,pad=0.3', facecolor='white', edgecolor='red', alpha=0.8))
|
|
211
|
+
|
|
185
212
|
# Customize plot
|
|
186
213
|
ax.set_xticks(x_positions)
|
|
187
214
|
ax.set_xticklabels([f"{name}\n({direction})" for name, direction in zip(self.metric_names, self.directions)])
|
|
@@ -191,10 +218,10 @@ class ParetoVisualizer:
|
|
|
191
218
|
ax.grid(True, alpha=0.3)
|
|
192
219
|
|
|
193
220
|
# Add legend
|
|
194
|
-
from matplotlib.lines import Line2D
|
|
195
221
|
legend_elements = [
|
|
196
222
|
Line2D([0], [0], color='blue', alpha=0.3, linewidth=2, label='All Trials'),
|
|
197
|
-
Line2D([0], [0], color='red', alpha=0.8, linewidth=3, label='Pareto Optimal')
|
|
223
|
+
Line2D([0], [0], color='red', alpha=0.8, linewidth=3, label='Pareto Optimal'),
|
|
224
|
+
Patch(facecolor='white', edgecolor='red', label='[n]: trial number')
|
|
198
225
|
]
|
|
199
226
|
ax.legend(handles=legend_elements, loc='best')
|
|
200
227
|
|
|
@@ -262,11 +289,49 @@ class ParetoVisualizer:
|
|
|
262
289
|
linewidths=1,
|
|
263
290
|
marker='*')
|
|
264
291
|
|
|
292
|
+
# Add trial number labels to Pareto optimal points
|
|
293
|
+
for idx in range(len(pareto_trials_df)):
|
|
294
|
+
trial_number = pareto_trials_df.iloc[idx]['number'] \
|
|
295
|
+
if 'number' in pareto_trials_df.columns else pareto_trials_df.index[idx]
|
|
296
|
+
ax.annotate(f'{int(trial_number)}',
|
|
297
|
+
xy=(pareto_x[idx], pareto_y[idx]),
|
|
298
|
+
xytext=(6, 6),
|
|
299
|
+
textcoords='offset points',
|
|
300
|
+
fontsize=8,
|
|
301
|
+
fontweight='bold',
|
|
302
|
+
color='darkred',
|
|
303
|
+
bbox=dict(boxstyle='round,pad=0.2',
|
|
304
|
+
facecolor='white',
|
|
305
|
+
edgecolor='red',
|
|
306
|
+
alpha=0.8))
|
|
307
|
+
|
|
265
308
|
ax.set_xlabel(f"{self.metric_names[j]} ({self.directions[j]})")
|
|
266
309
|
ax.set_ylabel(f"{self.metric_names[i]} ({self.directions[i]})")
|
|
267
310
|
|
|
268
311
|
ax.grid(True, alpha=0.3)
|
|
269
312
|
|
|
313
|
+
# Add legend to the figure
|
|
314
|
+
legend_elements = [
|
|
315
|
+
Line2D([0], [0],
|
|
316
|
+
marker='o',
|
|
317
|
+
color='w',
|
|
318
|
+
markerfacecolor='lightblue',
|
|
319
|
+
markeredgecolor='navy',
|
|
320
|
+
markersize=8,
|
|
321
|
+
alpha=0.6,
|
|
322
|
+
label='All Trials'),
|
|
323
|
+
Line2D([0], [0],
|
|
324
|
+
marker='*',
|
|
325
|
+
color='w',
|
|
326
|
+
markerfacecolor='red',
|
|
327
|
+
markeredgecolor='darkred',
|
|
328
|
+
markersize=10,
|
|
329
|
+
alpha=0.9,
|
|
330
|
+
label='Pareto Optimal'),
|
|
331
|
+
Patch(facecolor='white', edgecolor='red', label='[n]: trial number')
|
|
332
|
+
]
|
|
333
|
+
fig.legend(handles=legend_elements, loc='upper right', bbox_to_anchor=(0.98, 0.98), framealpha=0.9, fontsize=10)
|
|
334
|
+
|
|
270
335
|
plt.tight_layout()
|
|
271
336
|
|
|
272
337
|
if save_path:
|
|
@@ -299,7 +299,7 @@ nat/observability/exporter/exporter.py,sha256=fqF0GYuhZRQEq0skq_FK2nlnsaUAzLpQi-
|
|
|
299
299
|
nat/observability/exporter/file_exporter.py,sha256=XYsFjF8ob4Ag-SyGtKEh6wRU9lBx3lbdu7Uo85NvVyo,1465
|
|
300
300
|
nat/observability/exporter/processing_exporter.py,sha256=U_VE1VZZ2giGE-OUGH4pnHTYW2Nwcwfx4bFLL7_iu9M,25044
|
|
301
301
|
nat/observability/exporter/raw_exporter.py,sha256=0ROEd-DlLP6pIxl4u2zJ6PMVrDrQa0DMHFDRsdGQMIk,1859
|
|
302
|
-
nat/observability/exporter/span_exporter.py,sha256=
|
|
302
|
+
nat/observability/exporter/span_exporter.py,sha256=1TOx2bGzxRQ4XPolrhNHU2zpmjfeEwtYld-GudeLz14,14422
|
|
303
303
|
nat/observability/mixin/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
|
|
304
304
|
nat/observability/mixin/batch_config_mixin.py,sha256=DixQq-jRhBFJvpOX-gq7GvPmZCPOXQdacylyEuhZ6y0,1399
|
|
305
305
|
nat/observability/mixin/collector_config_mixin.py,sha256=3iptkRH9N6JgcsPq7GyjjJVAoxjd-l42UKE7iSF4Hq8,1087
|
|
@@ -371,9 +371,9 @@ nat/profiler/inference_optimization/experimental/prefix_span_analysis.py,sha256=
|
|
|
371
371
|
nat/profiler/parameter_optimization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
372
372
|
nat/profiler/parameter_optimization/optimizable_utils.py,sha256=93Pl8A14Zq_f3XsxSH-yFnEJ6B7W5hp7doPnPoLlRB4,3714
|
|
373
373
|
nat/profiler/parameter_optimization/optimizer_runtime.py,sha256=rXmCOq81o7ZorQOUYociVjuO3NO9CIjFBbwql2u_4H4,2715
|
|
374
|
-
nat/profiler/parameter_optimization/parameter_optimizer.py,sha256=
|
|
374
|
+
nat/profiler/parameter_optimization/parameter_optimizer.py,sha256=xKqKLOJaOi3EVZjT95zwKwHdX3AyYmMfxDxyhwtHal4,8256
|
|
375
375
|
nat/profiler/parameter_optimization/parameter_selection.py,sha256=pfnNQIx1evNICgChsOJXIFQHoL1R_kmh_vNDsVMC9kg,3982
|
|
376
|
-
nat/profiler/parameter_optimization/pareto_visualizer.py,sha256=
|
|
376
|
+
nat/profiler/parameter_optimization/pareto_visualizer.py,sha256=mE4Az9G_hw4CsAP8jgNl9H5L9KQjq82bxmIPEr63nEg,20537
|
|
377
377
|
nat/profiler/parameter_optimization/prompt_optimizer.py,sha256=_AmdeB1jRamd93qR5UqRy5LweYR3bjnD7zoLxzXYE0k,17658
|
|
378
378
|
nat/profiler/parameter_optimization/update_helpers.py,sha256=NxWhrGVchbjws85pPd-jS-C14_l70QvVSvEfENndVcY,2339
|
|
379
379
|
nat/registry_handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -475,10 +475,10 @@ nat/utils/reactive/base/observer_base.py,sha256=6BiQfx26EMumotJ3KoVcdmFBYR_fnAss
|
|
|
475
475
|
nat/utils/reactive/base/subject_base.py,sha256=UQOxlkZTIeeyYmG5qLtDpNf_63Y7p-doEeUA08_R8ME,2521
|
|
476
476
|
nat/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
477
477
|
nat/utils/settings/global_settings.py,sha256=9JaO6pxKT_Pjw6rxJRsRlFCXdVKCl_xUKU2QHZQWWNM,7294
|
|
478
|
-
nvidia_nat-1.4.
|
|
479
|
-
nvidia_nat-1.4.
|
|
480
|
-
nvidia_nat-1.4.
|
|
481
|
-
nvidia_nat-1.4.
|
|
482
|
-
nvidia_nat-1.4.
|
|
483
|
-
nvidia_nat-1.4.
|
|
484
|
-
nvidia_nat-1.4.
|
|
478
|
+
nvidia_nat-1.4.0a20251101.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
479
|
+
nvidia_nat-1.4.0a20251101.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
480
|
+
nvidia_nat-1.4.0a20251101.dist-info/METADATA,sha256=78C7pN8jbZ_1VQERKvTOUZu-ynlnlpC_dKu3iBkgGAM,10248
|
|
481
|
+
nvidia_nat-1.4.0a20251101.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
482
|
+
nvidia_nat-1.4.0a20251101.dist-info/entry_points.txt,sha256=4jCqjyETMpyoWbCBf4GalZU8I_wbstpzwQNezdAVbbo,698
|
|
483
|
+
nvidia_nat-1.4.0a20251101.dist-info/top_level.txt,sha256=lgJWLkigiVZuZ_O1nxVnD_ziYBwgpE2OStdaCduMEGc,8
|
|
484
|
+
nvidia_nat-1.4.0a20251101.dist-info/RECORD,,
|
|
File without changes
|
{nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{nvidia_nat-1.4.0a20251030.dist-info → nvidia_nat-1.4.0a20251101.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|