Skip to content

Conversation

@ParagEkbote
Copy link
Contributor

@ParagEkbote ParagEkbote commented Dec 18, 2025

Fixes #248

Motivation

As described in the issue, this PR implements an TrackioCallback for optuna-integration. Currently, trackio has a min python version of 3.10 and since python 3.9 has reached EOL, we will be required to bump the min. version in this repo to ensure that CI will be green.

Description of the changes

The implementation of the callback is similar to the wandb callback, as the library is designed to be an open-source and offline alternative to wandb. The main difference between the wandb and trackio is that trackio does not rely on a global mutable state, each run is explicitly created and each run has a fixed lifetime. The API docs have also helped to define the scope of the callback.

The runs can be visualized as follows:

image

We can also display the results as an HF Space and an dataset. The example is as follows:

import optuna
import trackio

from optuna_integration.trackio import TrackioCallback


def main():
    callback = TrackioCallback(
        project="toy-optuna-trackio-multirun",
        metric_name="loss",
        as_multirun=True,
        resume="allow",


        dataset_id="AINovice2005/toy-optuna-hpo-dataset",
        space_id="AINovice2005/optuna-dashboard",
        private=False,  # set True if you want private
    )

    @callback.track_in_trackio()
    def objective(trial: optuna.trial.Trial) -> float:
        x = trial.suggest_float("x", -10.0, 10.0)
        loss = (x - 2.0) ** 2

        trackio.log(
            {
                "x": x,
                "loss_squared": loss,
            }
        )

        return loss

    study = optuna.create_study(direction="minimize")
    study.optimize(
        objective,
        n_trials=5,
        callbacks=[callback],
        n_jobs=1,
    )

    print("Done multi-run test.")


if __name__ == "__main__":
    main()

If the results are not synced, you can do so with the following command:

trackio sync \
  --project toy-optuna-trackio-multirun \
  --space-id AINovice2005/optuna-dashboard

Could you please review?

cc: @nzw0301

@ParagEkbote ParagEkbote marked this pull request as ready for review December 19, 2025 11:11
@not522 not522 assigned not522 and c-bata and unassigned not522 Dec 24, 2025
@c-bata
Copy link
Member

c-bata commented Dec 24, 2025

@ParagEkbote Thank you for your pull request. Could you fix the CI error? I think you can skip Python 3.9 test by specifying python_matrix like below:

python_matrix: "['3.9', '3.10', '3.11', '3.12', '3.13']"

@c-bata c-bata added the feature Change that does not break compatibility, but affects the public interfaces. label Dec 24, 2025
Copy link
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

Thank you the updates! I left an early feedback comment.

Due to the year-end and New Year holidays, my review may take a bit longer than usual. I’ll get back to you once I’m able to resume the review.

@ParagEkbote ParagEkbote requested a review from c-bata December 26, 2025 14:17
@github-actions
Copy link

github-actions bot commented Jan 4, 2026

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Jan 4, 2026
@c-bata c-bata removed the stale Exempt from stale bot labeling. label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Change that does not break compatibility, but affects the public interfaces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add trackio integration

3 participants