Skip to content

Commit 0073643

Browse files
authored
Hparams plugin: Retrieve and render only first 1000 hparams. (#6807)
We limit the number of hparams retrieved and rendered in the Hparams plugin. Otherwise the plugin can become very slow and even crash. Unlike #6780, we do not provide an option for loading more in the Hparams plugin. We may provide this option later if there is demand. But generally we think 1000 should be enough, especially if the underlying hparams provider is sorting the results with "differs" fields first. ![image](https://github.com/tensorflow/tensorboard/assets/17152369/da1f2c26-3804-4faf-be4a-03bb8aaa178d)
1 parent b1402dc commit 0073643

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tensorboard/plugins/hparams/tf_hparams_query_pane/tf-hparams-query-pane.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ interface ColumnHparam {
3333
filterInterval?: MinMax | null;
3434
filterRegexp?: string;
3535
order?: string;
36+
includeInResult: boolean;
3637
}
3738

3839
interface ColumnMetric {
3940
metric: string;
4041
filterInterval?: MinMax | null;
4142
order?: string;
43+
includeInResult: boolean;
4244
}
4345

4446
const MAX_DOMAIN_DISCRETE_LIST_LEN = 10;
@@ -56,6 +58,12 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
5658
<hparams-split-layout orientation="vertical">
5759
<div slot="content" class="section hyperparameters">
5860
<div class="section-title">Hyperparameters</div>
61+
<template is="dom-if" if="[[_TooManyHparams]]">
62+
<div class="too-many-hparams">
63+
Warning: There were too many hparams to load all of them
64+
efficiently. Only [[_maxNumHparamsToLoad]] were loaded.
65+
</div>
66+
</template>
5967
<template is="dom-repeat" items="{{_hparams}}" as="hparam">
6068
<div class="hparam">
6169
<paper-checkbox
@@ -271,6 +279,12 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
271279
text-decoration: underline;
272280
margin-bottom: 7px;
273281
}
282+
.too-many-hparams {
283+
color: var(--tb-orange-dark);
284+
font-size: 13px;
285+
font-style: italic;
286+
margin: 12px 0;
287+
}
274288
.discrete-value-checkbox,
275289
.metric-checkbox,
276290
.hparam-checkbox {
@@ -432,6 +446,12 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
432446
// 'regexp' string field containing the filtering regexp.
433447
@property({type: Array})
434448
_hparams: any[];
449+
// The limit to the number of hparams we will load. Loading too many will slow
450+
// down the UI noticeably and possibly crash it.
451+
@property({type: Number}) _maxNumHparamsToLoad: number = 1000;
452+
// Tracks whether we loaded the maximum number of allowed hparams as defined
453+
// by _maxNumHparamsToLoad.
454+
@property({type: Boolean}) _tooManyHparams: boolean = false;
435455
// An array of objects--each storing information about the user
436456
// setting for a single metric. Each object has the following fields:
437457
// info: The MetricInfo object returned by the backend in the
@@ -545,6 +565,7 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
545565
}
546566
const experimentRequest = {
547567
experimentName: this.experimentName,
568+
hparamsLimit: this._maxNumHparamsToLoad,
548569
};
549570
this.backend
550571
.getExperiment(experimentRequest)
@@ -636,6 +657,7 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
636657
result[i].displayed = true;
637658
}
638659
this.set('_hparams', result);
660+
this.set('_TooManyHparams', result.length >= this._maxNumHparamsToLoad);
639661
}
640662
// Updates the _metrics property from the _experiment property.
641663
_computeMetrics() {
@@ -851,7 +873,10 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
851873
let colParams: (ColumnHparam | ColumnMetric)[] = [];
852874
// Build the hparams filters in the request.
853875
this._hparams.forEach((hparam, index) => {
854-
let colParam: ColumnHparam = {hparam: hparam.info.name};
876+
let colParam: ColumnHparam = {
877+
hparam: hparam.info.name,
878+
includeInResult: true,
879+
};
855880
if (hparam.filter.domainDiscrete) {
856881
const allChecked = hparam.filter.domainDiscrete.every(
857882
(filterVal) => filterVal.checked
@@ -880,6 +905,7 @@ class TfHparamsQueryPane extends LegacyElementMixin(PolymerElement) {
880905
this._metrics.forEach((metric, index) => {
881906
let colParam: ColumnMetric = {
882907
metric: metric.info.name,
908+
includeInResult: true,
883909
};
884910
if (isIntervalSet(metric.filter.interval)) {
885911
colParam.filterInterval = parseInputInterval(

0 commit comments

Comments
 (0)