Skip to content

Support "Relative Step" in the X-axis - #7168

Open
vruotolo wants to merge 13 commits into
tensorflow:masterfrom
vruotolo:relative-steps-feature
Open

vruotolo wants to merge 13 commits into
tensorflow:masterfrom
vruotolo:relative-steps-feature

Conversation

@vruotolo

@vruotolo vruotolo commented Oct 29, 2026 •

Copy link
Copy Markdown

Motivation for features / changes

Fixes #6969 (http://b/261046163).

When comparing runs that start at different step offsets (for example, fine-tuning from a checkpoint vs. training from step 0, or comparing runs resumed at different steps), plotting by absolute Step makes side-by-side comparison difficult. Adding a Relative Step X-axis option normalizes each run (or partitioned pseudo-run) to start at step 0 (point.step - firstStep), similar to how Relative Time normalizes wallTime (point.wallTime - firstWallTime).

Additionally, renaming the display label of Relative to Relative Time (XAxisType.RELATIVE_TIME) clarifies the distinction between relative step count and relative wall time.

Technical description of changes

  • XAxisType enum (tensorboard/webapp/metrics/internal_types.ts):
    • Renamed XAxisType.RELATIVE to XAxisType.RELATIVE_TIME = 'relative_time'.
    • Added XAxisType.RELATIVE_STEP = 'relative_step'.
  • Settings Dropdown (settings_view_component.ts):
    • Updated XAxisTypeDropdownOptions to display Step, Relative Step, Wall, and Relative Time.
  • Scalar Card & Line Chart (scalar_card_types.ts, scalar_card_container.ts, scalar_card_component.ts, scalar_card_line_chart_component.ts, scalar_card_line_chart_container.ts):
    • Added optional relativeStep?: number to ScalarCardPoint.
    • Computed relativeStep: point.step - firstStep per partitioned series in ScalarCardContainer and mapped point.x = point.relativeStep when xAxisType === XAxisType.RELATIVE_STEP.
    • Configured XAxisType.RELATIVE_STEP to use ScaleType.LINEAR, siNumberFormatter, and step-based NaN/Infinity filtering (isStepBased).
  • Histogram Card (histogram_card_component.ts):
    • Mapped XAxisType.RELATIVE_STEP to TimeProperty.STEP and XAxisType.RELATIVE_TIME to TimeProperty.RELATIVE.
  • Unit Tests (scalar_card_test.ts, scalar_card_line_chart_test.ts, histogram_card_test.ts):
    • Updated existing XAxisType.RELATIVE references to XAxisType.RELATIVE_TIME and added unit tests covering XAxisType.RELATIVE_STEP point calculation, axis formatting, and histogram time property mapping.

Screenshots of UI changes (or N/A)

Screenshot From 2026-10-29 21-06-55

Detailed steps to verify changes work correctly (as executed by you)

  1. Built all webapp targets and executed the card_renderer unit tests (scalar_card_test, scalar_card_line_chart_test, histogram_card_test).
  2. Verified in the Time Series dashboard that selecting Relative Step under Horizontal Axis plots scalar series relative to each series' initial step (0, step - firstStep) and formats axis ticks with the SI number formatter.

Alternate designs / implementations considered (or N/A)

Considered computing point.step - series.points[0].step inline only when xAxisType === XAxisType.RELATIVE_STEP without storing relativeStep on ScalarCardPoint. Decided to store relativeStep?: number on ScalarCardPoint alongside relativeTimeInMs for consistency and to make the relative step value available on the point object.

@vruotolo vruotolo changed the title Support for "relative steps" in the x-axis Support "Relative Step" in the X-axis and rename "Relative" to "Relative Time" Oct 29, 2026
@vruotolo vruotolo changed the title Support "Relative Step" in the X-axis and rename "Relative" to "Relative Time" Support "Relative Step" in the X-axis Oct 29, 2026
@vruotolo
vruotolo marked this pull request as ready for review October 29, 2026 21:17
@cdavalos7
cdavalos7 self-requested a review October 29, 2026 21:20

@cdavalos7 cdavalos7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is so useful!

Tested locally with runs starting at steps 0, 5000 and 12000: the scalar curves align at 0 as expected.

One gap: in Relative Step mode the tooltip's "Step" column still shows the absolute step (5,980 / 12,980 / 980 at the same x), so the plotted value isn't visible anywhere. Could it show relativeStep in this mode? scalar_card_component.ng.html

pr7168-tooltip-relative-step

timeProperty(xAxisType: XAxisType) {
switch (xAxisType) {
case XAxisType.STEP:
case XAxisType.RELATIVE_STEP:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Relative Step selected, histograms still show the original steps (5200–6800 and 12200–13800 below) instead of starting from 0. Relative Time does make each run's histogram start from 0, so the two modes behave differently. Could we support relative steps here too, or add a note that Relative Step only applies to scalar charts?

pr7168-histogram-relative-step

}));

it('does not render fobs when axis type is RELATIVE', fakeAsync(() => {
it('does not render fobs when axis type is RELATIVE_TIME', fakeAsync(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relative Step disables linked time and the data table from settings because the existing checks compare === XAxisType.STEP. That seems right, since the selection is an absolute step, but it's implicit. Could you add RELATIVE_STEP cases here and in the does not render table... test?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 6238cf6

@vruotolo
vruotolo force-pushed the relative-steps-feature branch from f0c42a6 to 1087d0b Compare November 11, 2026 22:23
@vruotolo
vruotolo force-pushed the relative-steps-feature branch from a28e439 to ab9db69 Compare November 12, 2026 17:23
@vruotolo
vruotolo force-pushed the relative-steps-feature branch from 287c68b to a5bbb77 Compare November 12, 2026 18:30
@vruotolo
vruotolo force-pushed the relative-steps-feature branch from e04aca6 to b76c806 Compare November 13, 2026 18:49
@vruotolo
vruotolo requested a review from cdavalos7 November 17, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support "relative steps" in X-axis

2 participants