Skip to content

Instantly share code, notes, and snippets.

import ray
from ray import serve
import mlflow.pyfunc
class MLflowBackend:
def __init__(self, model_uri):
self.model = mlflow.pyfunc.load_model(model_uri=model_uri)
from ray.tune.integration.mlflow import mlflow_mixin
@mlflow_mixin
def train_fn(config):
mlflow.autolog()
xgboost_results = xgb.train(config, ...)
from ray.tune.integration.mlflow import mlflow_mixin
@mlflow_mixin
def train_fn(config):
...
mlflow.log_metric(...)
from ray.tune.integration.mlflow import MLflowLoggerCallback
tune.run(
train_fn,
config={
# define search space here
"parameter_1": tune.choice([1, 2, 3]),
"parameter_2": tune.choice([4, 5, 6]),
},
callbacks=[MLflowLoggerCallback(
experiment_name="experiment1",
{
"per_gpu_batch_size": (16, 64),
"weight_decay": (0, 0.3),
"learning_rate": (1e-5, 5e-5),
"warmup_steps": (0, 500),
"num_epochs": (2, 5)
}
{
"per_gpu_batch_size": [16, 32, 64],
"weight_decay": (0, 0.3),
"learning_rate": (1e-5, 5e-5),
"num_epochs": [2, 3, 4, 5]
}
@amogkam
amogkam / grid_search.py
Last active August 26, 2020 01:35
Huggingface Transformers Blog Post
{
"per_gpu_batch_size": [16, 32],
"learning_rate": [2e-5, 3e-5, 5e-5],
"num_epochs": [2, 3, 4]
}
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 8 columns, instead of 5 in line 3.
query_no,query,cardinality_predict,cardinality_true,q_error,latency_ms,generated_spn_calls,latency_generated_code
0,"SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.kind_id = 2 AND title.series_years >= 1340 AND title.production_year <= 2004.0;",24827,11637,2.1334536392541033,44.170667009893805,0,0.0
1,"SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.phonetic_code = 16773 AND title.kind_id = 1 AND movie_companies.company_type_id = 1 AND movie_info_idx.info_type_id = 101;",22,383,17.40909090909091,38.34984201239422,0,0.0
2,"SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.kind_id = 4 AND title.phonetic_code <= 16924 AND title.production_year >= 1987.0 AND movie_companies.company_type_id = 1;",44389,79017,1.7801031787154
query_no query cardinality_predict cardinality_true q_error latency_ms generated_spn_calls latency_generated_code
0 SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.kind_id = 2 AND title.series_years >= 1340 AND title.production_year <= 2004.0; 6750 11637 1.724 48.24709799140692 0 0.0
1 SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.phonetic_code = 16773 AND title.kind_id = 1 AND movie_companies.company_type_id = 1 AND movie_info_idx.info_type_id = 101; 20 383 19.15 39.38393101270776 0 0.0
2 SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.kind_id = 4 AND title.phonetic_code <= 16924 AND title.production_year >= 1987.0 AND movie_companies.company_type_id = 1; 43965 79017 1.7972705561241897 45.22453300887719 0 0.0
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 8 columns, instead of 5 in line 3.
query_no,query,cardinality_predict,cardinality_true,q_error,latency_ms,generated_spn_calls,latency_generated_code
0,"SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.kind_id = 2 AND title.series_years >= 1340 AND title.production_year <= 2004.0;",9892,11637,1.176405175899717,38.586937997024506,0,0.0
1,"SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.phonetic_code = 16773 AND title.kind_id = 1 AND movie_companies.company_type_id = 1 AND movie_info_idx.info_type_id = 101;",119,383,3.2184873949579833,32.95858099590987,0,0.0
2,"SELECT COUNT(*) FROM movie_companies, movie_info_idx, title WHERE title.id=movie_companies.movie_id AND title.id=movie_info_idx.movie_id AND title.kind_id = 4 AND title.phonetic_code <= 16924 AND title.production_year >= 1987.0 AND movie_companies.company_type_id = 1;",44853,79017,1.7616881813925