Skip to content

Conversation

Zeyi-Lin
Copy link
Member

Description

Closes: #1113

import random
from ray import tune
from swanlab.integration.ray import SwanLabLoggerCallback

def train_func(config):
    offset = random.random() / 5
    for epoch in range(2, config["epochs"]):
        acc = 1 - (2 + config["lr"]) ** -epoch - random.random() / epoch - offset
        loss = (2 + config["lr"]) ** -epoch + random.random() / epoch + offset
        tune.report({"acc": acc, "loss": loss})


tuner = tune.Tuner(
    train_func,
    param_space={
        "lr": tune.grid_search([0.001, 0.01, 0.1, 1.0]),
        "epochs": 10,
    },
    run_config=tune.RunConfig(
        callbacks=[SwanLabLoggerCallback(project="Ray_Project")],
    ),
)
results = tuner.fit()

@Zeyi-Lin Zeyi-Lin requested a review from SAKURA-CAT June 19, 2025 18:01
@Zeyi-Lin Zeyi-Lin assigned SAKURA-CAT and Zeyi-Lin and unassigned SAKURA-CAT Jun 19, 2025
@Zeyi-Lin Zeyi-Lin added the 💪 enhancement New feature or request label Jun 19, 2025
@SAKURA-CAT SAKURA-CAT merged commit fa34721 into main Jun 20, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/integration-ray branch June 20, 2025 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQUEST] Ray SwanLabLoggerCallback
2 participants