SlideShare a Scribd company logo
Go Conference 2019 Autumn
c-bata c_bata_
Distributed Bayesian Optimization Framework
Goptuna
CyberAgent AI Lab
Masashi SHIBATA
c-bata c_bata_
Python
go-prompt, kube-prompt
https://github.com/c-bata
1
2
3
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
y = f(x)x y
y x
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
my.cnf
nginx.conf


y
x
2
innodb_buffer_pool_size
80%
FFM 0.02
0.00001
15
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Grid Search / Random Search
[Eric et al., 2010]
[Eric et al., 2010]
• : 

• : 

• :


( )
[Eric et al., 2010]




( )
[Eric et al., 2010]




( )
[Eric et al., 2010]
L-BFGS
[Eric et al., 2010]
[Eric et al., 2010]
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
package main
import (
"log"
"math"
bayesopt "github.com/d4l3k/go-bayesopt"
)
var (
px1 = bayesopt.UniformParam{Name: "X1", Max: 10, Min: -10}
px2 = bayesopt.UniformParam{Name: "X2", Max: 10, Min: -10}
searchSpace = []bayesopt.Param{px1, px2}
)
func objective(params map[bayesopt.Param]float64) float64 {
x1 := params[px1]
x2 := params[px2]
return math.Pow(x1-1, 2) + math.Pow(x2-2, 2)
}
func main() {
o := bayesopt.New(
searchSpace,
bayesopt.WithRandomRounds(10),
bayesopt.WithRounds(100),
bayesopt.WithMinimize(true))
x, y, err := o.Optimize(objective)
if err != nil { ... }
log.Printf(...)
}
x1
x2

 

Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn


$ go get github.com/c-bata/goptuna
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
goptuna.Trial
float64 error
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
(x1, x2) = (2, -5)
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
SuggestUniform SuggestLogUniform
SuggestInt SuggestCategorical
x1 x2
[-10, 10]
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
$ go run _examples/simple_tpe/main.go
2019/10/28 01:55:34 [INFO] Trial finished: trialID=0 state=Complete evaluation=47.674293
2019/10/28 01:55:34 [INFO] Trial finished: trialID=1 state=Complete evaluation=16.564975
2019/10/28 01:55:34 [INFO] Trial finished: trialID=2 state=Complete evaluation=22.229764
2019/10/28 01:55:34 [INFO] Trial finished: trialID=3 state=Complete evaluation=132.160176
2019/10/28 01:55:34 [INFO] Trial finished: trialID=4 state=Complete evaluation=38.056051
:
2019/10/28 01:55:34 Best evaluation=0.038327 (x1=2.181604, x2=-4.926880)
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
package main
import (
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/rdb"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
func main() {
db, err := gorm.Open("sqlite3", "db.sqlite3")
if err != nil { ... }
defer db.Close()
db.DB().SetMaxOpenConns(1)
rdb.RunAutoMigrate(db)
storage := rdb.NewStorage(db)
study, _ := goptuna.LoadStudy(
"study-name",
goptuna.StudyOptionStorage(storage))
...
}
$ pip install optuna bokeh mysqlclient
$ optuna dashboard 
> --storage mysql+mysqldb://
goptuna:password@127.0.0.1:3306/yourdb 
> -—study yourstudy
import ...
func main() {
db, _ := gorm.Open(“mysql",
“user:pass@tcp(localhost:3306)/yourdb" +
”?parseTime=true”)
storage := rdb.NewStorage(db)
defer db.Close()
study, _ := goptuna.LoadStudy(
“study-name",
goptuna.StudyOptionStorage(storage))
...
}
$ goptuna create-study 
> --storage mysql+mysqldb://
goptuna:password@127.0.0.1:3306/yourdb 
> -—study yourstudy
goputna.LoadStudy study
: _examples/concurrency
• optuna.visualization.plot_contour(st
udy)
• optuna.visualization.
plot_intermediate_values(study)
• optuna.visualization.plot_optimizati
on_history(study)
• optuna.visualization.plot_parallel_c
oordinate(study)
• optuna.visualization.plot_slice(stud
y)
package main
import (
"log"
"math"
bo "github.com/d4l3k/go-bayesopt"
)
var (
px1 = bo.UniformParam{Name: "X1", Max: 10, Min: -10}
px2 = bo.UniformParam{Name: "X2", Max: 10, Min: -10}
searchSpace = []bo.Param{px1, px2}
)
func objective(params map[bo.Param]float64) float64 {
x1 := params[px1]
x2 := params[px2]
return math.Pow(x1-1, 2) + math.Pow(x2-2, 2)
}
func main() {
o := bo.New(
searchSpace,
bo.WithRandomRounds(10),
bo.WithRounds(100),
bo.WithMinimize(true))
x, y, err := o.Optimize(objective)
if err != nil { ... }
log.Printf(...)
}
package main
import (
"log"
"math"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/tpe"
)
func objective(trial goptuna.Trial) (float64, error) {
x1, _ := trial.SuggestUniform("x1", -10, 10)
x2, _ := trial.SuggestUniform("x2", -10, 10)
return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}
func main() {
study, _ := goptuna.CreateStudy(
"goptuna-example",
goptuna.StudyOptionSampler(tpe.NewSampler()))
err = study.Optimize(objective, 100)
if err != nil { ... }
v, _ := study.GetBestValue()
params, _ := study.GetBestParams()
log.Printf(...)
}
Define-and-Run interface
go-bayesopt
Define-by-Run interface
Goptuna




10 epochs
trial #1
trial #2
trial #3
trial #4
trial #5
trial #6
trial #7
trial #8
trial #9
30 epochs 90 epochs
[Jamieson and Talwalkar, 2016] [Li et al., 2018]


Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
2,010
10,660
1 ISUCON Alibaba Cloud ecs.sn1ne.large (vCPUx2, Mem 4.0GiB) 3
2 ISUCON9 9560 9100
func objective(trial goptuna.Trial) (float64, error) {
// Go application
goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64)
goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64)
goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128)
goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096)
goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128)
campaign, _ := trial.SuggestInt("campaign", 0, 2)
// Nginx
nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16)
nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096)
nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100)
// MySQL
innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800)
innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit",
[]string{"0", "1", "2"})
innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{
"fsync",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
})
...
} https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
func objective(trial goptuna.Trial) (float64, error) {
// Go application
goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64)
goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64)
goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128)
goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096)
goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128)
campaign, _ := trial.SuggestInt("campaign", 0, 2)
// Nginx
nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16)
nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096)
nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100)
// MySQL
innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800)
innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit",
[]string{"0", "1", "2"})
innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{
"fsync",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
})
...
} https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
(database/sql).DB
func objective(trial goptuna.Trial) (float64, error) {
// Go application
goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64)
goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64)
goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128)
goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096)
goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128)
campaign, _ := trial.SuggestInt("campaign", 0, 2)
// Nginx
nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16)
nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096)
nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100)
// MySQL
innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800)
innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit",
[]string{"0", "1", "2"})
innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{
"fsync",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
})
...
} https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
API 

(net/http).Client
func objective(trial goptuna.Trial) (float64, error) {
// Go application
goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64)
goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64)
goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128)
goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096)
goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128)
campaign, _ := trial.SuggestInt("campaign", 0, 2)
// Nginx
nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16)
nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096)
nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100)
// MySQL
innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800)
innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit",
[]string{"0", "1", "2"})
innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{
"fsync",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
})
...
} https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
campaign: 

func objective(trial goptuna.Trial) (float64, error) {
// Go application
goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64)
goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64)
goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128)
goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096)
goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128)
campaign, _ := trial.SuggestInt("campaign", 0, 2)
// Nginx
nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16)
nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096)
nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100)
// MySQL
innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800)
innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit",
[]string{"0", "1", "2"})
innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{
"fsync",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
})
...
} https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
Nginx
suggest text/template
nginx.conf systemd
func objective(trial goptuna.Trial) (float64, error) {
// Go application
goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64)
goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64)
goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128)
goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096)
goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128)
campaign, _ := trial.SuggestInt("campaign", 0, 2)
// Nginx
nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16)
nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096)
nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100)
// MySQL
innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800)
innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit",
[]string{"0", "1", "2"})
innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{
"fsync",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
})
...
} https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
MySQL
Nginx
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Go MySQL client (net/http).Client Nginx MySQL
SetMaxOpen
Conns
SetMaxIdleC
onns
SetConnMax
Lifetime
DialContext.
Keepalive
MaxIdleConn
sPerHost
worker_proc
esses
worker_conn
ections
keep_alive_ti
meout
innodb_buffe
r_pool_size
innodb_flush
_log_at_trx_c
ommit
innodb_flush
_method
10660
11160

(+500)
200 37 53 77s 40s 709 11 367 74s 711M 0 fsync

 

Go MySQL client Nginx MySQL
SetMaxOpenCo
nns
SetMaxIdleConn
s
SetConnMaxLife
time
worker_connecti
ons
innodb_buffer_p
ool_size
innodb_flush_log
_at_trx_commit
innodb_log_buff
er_size
innodb_log_file_
size
2010
2310

(+300)
50 23 4 28s 5 210M 0 27M 341M
https://github.com/c-bata/goptuna-isucon9q/issues/2
https://github.com/c-bata/goptuna-isucon9q/issues/9
Optuna x.264
(by Takeru Ohta a.k.a. @sile)
x.264
https://gist.github.com/sile/8aa1ff7808dd55298f51dd70c8b83092
• Goptuna

LibFFM [Juan et al., 2016] 

• Optuna

RocsDB by @sile

• BoTorch/Ax (Facebook)

HHVM JIT Compiler 

Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
• [Eric et al., 2010] Eric Brochu, Vlad M. Cora, and Nando de Freitas. A tutorial on Bayesian optimization of expensive cost
functions, with application to active user modeling and hierarchical reinforcement learning. 2010. arXiv:1012.2599.

• [James et al., 2011] James S. Bergstra, Remi Bardenet, Yoshua Bengio, and Balázs Kégl. Algorithms for hyper-
parameter optimization. In Advances in Neural Information Processing Systems 25. 2011.

• [Akiba at el., 2019] Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, Masanori Koyama. 2019. Optuna: A
Next-generation Hyperparameter Optimization Framework. In The 25th ACM SIGKDD Conference on Knowledge
Discovery and Data Mining (KDD ’19), August 4–8, 2019.

• [Jamieson and Talwalkar, 2016] K. Jamieson and A. Talwalkar. Non-stochastic best arm identification and
hyperparameter optimization. In AISTATS, 2016.

• [Li et al., 2018] Liam Li, Kevin Jamieson, Afshin Rostamizadeh, Ekaterina Gonina, Moritz Hardt, Benjamin Recht, and
Ameet Talwalkar. Massively parallel hyperparameter tuning. arXiv preprint arXiv:1810.05934, 2018.

• [Eggensperger et al., 2013] Eggensperger, K., Feurer, M., Hutter, F., Bergstra, J., Snoek, J., Hoos, H., and Leyton-Brown,
K.: Towards an Empirical Foundation for Assessing Bayesian Optimization of Hyperparameters, in NeurIPS workshop on
Bayesian Optimization in Theory and Practice (2013).

• [Juan et al., 2016] Yu-Chin Juan, Yong Zhuang, Wei-Sheng Chin, and Chih-Jen Lin. Field-aware factorization machines
for CTR prediction. In RecSys, pages 43–50, 2016.
References
THANK YOU
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
https://speakerdeck.com/nmasahiro/ji-jie-xue-xi-niokeru-haihaharametazui-shi-hua-falseli-lun-toshi-jian?slide=52

More Related Content

PPTX
Python 내장 함수
PDF
Python profiling
PDF
Welcome to python
PDF
python高级内存管理
PDF
Python高级编程(二)
PDF
Becoming a better developer with EXPLAIN
PDF
The Ring programming language version 1.5.1 book - Part 44 of 180
PDF
Clustering com numpy e cython
Python 내장 함수
Python profiling
Welcome to python
python高级内存管理
Python高级编程(二)
Becoming a better developer with EXPLAIN
The Ring programming language version 1.5.1 book - Part 44 of 180
Clustering com numpy e cython

What's hot (20)

PDF
Python tour
PDF
Damn Fine CoffeeScript
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
PPTX
ES6 Overview
PDF
Google Guava - Core libraries for Java & Android
PDF
TDC2016SP - Código funcional em Java: superando o hype
PDF
The Ring programming language version 1.7 book - Part 16 of 196
PDF
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
PDF
Groovy collection api
PDF
Is HTML5 Ready? (workshop)
PPTX
Python basic
PDF
CoffeeScript
PDF
Introducción a Elixir
PDF
"PostgreSQL and Python" Lightning Talk @EuroPython2014
PDF
yt: An Analysis and Visualization System for Astrophysical Simulation Data
PDF
Statistical computing 01
PDF
Python postgre sql a wonderful wedding
PDF
Backbone.js: Run your Application Inside The Browser
PPTX
Unit testing pig
PDF
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Python tour
Damn Fine CoffeeScript
Building Real Time Systems on MongoDB Using the Oplog at Stripe
ES6 Overview
Google Guava - Core libraries for Java & Android
TDC2016SP - Código funcional em Java: superando o hype
The Ring programming language version 1.7 book - Part 16 of 196
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Groovy collection api
Is HTML5 Ready? (workshop)
Python basic
CoffeeScript
Introducción a Elixir
"PostgreSQL and Python" Lightning Talk @EuroPython2014
yt: An Analysis and Visualization System for Astrophysical Simulation Data
Statistical computing 01
Python postgre sql a wonderful wedding
Backbone.js: Run your Application Inside The Browser
Unit testing pig
Машинное обучение на JS. С чего начать и куда идти | Odessa Frontend Meetup #12
Ad

Similar to Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn (20)

PDF
PyCon KR 2019 sprint - RustPython by example
PDF
Java VS Python
PDF
Groovy kind of test
PDF
Groovy kind of test
PDF
Refactoring to Macros with Clojure
KEY
Testing My Patience
PDF
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
PDF
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
PDF
What's new in Python 3.11
KEY
Django Celery
PDF
The Ring programming language version 1.5.3 book - Part 10 of 184
KEY
Python Development (MongoSF)
PDF
Practical Google App Engine Applications In Py
PDF
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
PDF
Python utan-stodhjul-motorsag
PDF
MySQL in Go - Golang NE July 2015
PPTX
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
KEY
Gevent what's the point
PDF
Google App Engine Developer - Day3
PDF
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
PyCon KR 2019 sprint - RustPython by example
Java VS Python
Groovy kind of test
Groovy kind of test
Refactoring to Macros with Clojure
Testing My Patience
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
What's new in Python 3.11
Django Celery
The Ring programming language version 1.5.3 book - Part 10 of 184
Python Development (MongoSF)
Practical Google App Engine Applications In Py
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Python utan-stodhjul-motorsag
MySQL in Go - Golang NE July 2015
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Gevent what's the point
Google App Engine Developer - Day3
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Ad

More from Masashi Shibata (20)

PDF
MLOps Case Studies: Building fast, scalable, and high-accuracy ML systems at ...
PDF
実践Djangoの読み方 - みんなのPython勉強会 #72
PDF
CMA-ESサンプラーによるハイパーパラメータ最適化 at Optuna Meetup #1
PDF
サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23
PDF
Implementing sobol's quasirandom sequence generator
PDF
DARTS: Differentiable Architecture Search at 社内論文読み会
PDF
PythonとAutoML at PyConJP 2019
PDF
Djangoアプリのデプロイに関するプラクティス / Deploy django application
PDF
Django REST Framework における API 実装プラクティス | PyCon JP 2018
PDF
Django の認証処理実装パターン / Django Authentication Patterns
PDF
RTMPのはなし - RTMP1.0の仕様とコンセプト / Concepts and Specification of RTMP
PDF
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
PDF
Golangにおける端末制御 リッチなターミナルUIの実現方法
PDF
How to develop a rich terminal UI application
PDF
Introduction of Feedy
PDF
Webフレームワークを作ってる話 #osakapy
PDF
Pythonのすすめ
PDF
pandasによるデータ加工時の注意点やライブラリの話
PDF
Pythonistaのためのデータ分析入門 - C4K Meetup #3
PDF
テスト駆動開発入門 - C4K Meetup#2
MLOps Case Studies: Building fast, scalable, and high-accuracy ML systems at ...
実践Djangoの読み方 - みんなのPython勉強会 #72
CMA-ESサンプラーによるハイパーパラメータ最適化 at Optuna Meetup #1
サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23
Implementing sobol's quasirandom sequence generator
DARTS: Differentiable Architecture Search at 社内論文読み会
PythonとAutoML at PyConJP 2019
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Django REST Framework における API 実装プラクティス | PyCon JP 2018
Django の認証処理実装パターン / Django Authentication Patterns
RTMPのはなし - RTMP1.0の仕様とコンセプト / Concepts and Specification of RTMP
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
Golangにおける端末制御 リッチなターミナルUIの実現方法
How to develop a rich terminal UI application
Introduction of Feedy
Webフレームワークを作ってる話 #osakapy
Pythonのすすめ
pandasによるデータ加工時の注意点やライブラリの話
Pythonistaのためのデータ分析入門 - C4K Meetup #3
テスト駆動開発入門 - C4K Meetup#2

Recently uploaded (20)

PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Cost to Outsource Software Development in 2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Transform Your Business with a Software ERP System
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Salesforce Agentforce AI Implementation.pdf
Patient Appointment Booking in Odoo with online payment
L1 - Introduction to python Backend.pptx
Why Generative AI is the Future of Content, Code & Creativity?
Cost to Outsource Software Development in 2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Autodesk AutoCAD Crack Free Download 2025
Odoo Companies in India – Driving Business Transformation.pdf
Reimagine Home Health with the Power of Agentic AI​
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
How to Choose the Right IT Partner for Your Business in Malaysia
Operating system designcfffgfgggggggvggggggggg
Transform Your Business with a Software ERP System
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Download FL Studio Crack Latest version 2025 ?
Salesforce Agentforce AI Implementation.pdf

Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn

  • 1. Go Conference 2019 Autumn c-bata c_bata_ Distributed Bayesian Optimization Framework Goptuna
  • 2. CyberAgent AI Lab Masashi SHIBATA c-bata c_bata_ Python go-prompt, kube-prompt
  • 6. y = f(x)x y y x
  • 11. Grid Search / Random Search
  • 12. [Eric et al., 2010]
  • 13. [Eric et al., 2010] • : • : • : 
 ( )
  • 14. [Eric et al., 2010] ( )
  • 15. [Eric et al., 2010] ( )
  • 16. [Eric et al., 2010] L-BFGS
  • 17. [Eric et al., 2010]
  • 18. [Eric et al., 2010]
  • 20. package main import ( "log" "math" bayesopt "github.com/d4l3k/go-bayesopt" ) var ( px1 = bayesopt.UniformParam{Name: "X1", Max: 10, Min: -10} px2 = bayesopt.UniformParam{Name: "X2", Max: 10, Min: -10} searchSpace = []bayesopt.Param{px1, px2} ) func objective(params map[bayesopt.Param]float64) float64 { x1 := params[px1] x2 := params[px2] return math.Pow(x1-1, 2) + math.Pow(x2-2, 2) } func main() { o := bayesopt.New( searchSpace, bayesopt.WithRandomRounds(10), bayesopt.WithRounds(100), bayesopt.WithMinimize(true)) x, y, err := o.Optimize(objective) if err != nil { ... } log.Printf(...) }
  • 23. 
 $ go get github.com/c-bata/goptuna
  • 24. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) }
  • 25. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) } goptuna.Trial float64 error
  • 26. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) } (x1, x2) = (2, -5)
  • 27. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) } SuggestUniform SuggestLogUniform SuggestInt SuggestCategorical x1 x2 [-10, 10]
  • 28. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) }
  • 29. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) }
  • 30. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) }
  • 31. package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) } $ go run _examples/simple_tpe/main.go 2019/10/28 01:55:34 [INFO] Trial finished: trialID=0 state=Complete evaluation=47.674293 2019/10/28 01:55:34 [INFO] Trial finished: trialID=1 state=Complete evaluation=16.564975 2019/10/28 01:55:34 [INFO] Trial finished: trialID=2 state=Complete evaluation=22.229764 2019/10/28 01:55:34 [INFO] Trial finished: trialID=3 state=Complete evaluation=132.160176 2019/10/28 01:55:34 [INFO] Trial finished: trialID=4 state=Complete evaluation=38.056051 : 2019/10/28 01:55:34 Best evaluation=0.038327 (x1=2.181604, x2=-4.926880)
  • 33. package main import ( "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/rdb" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" ) func main() { db, err := gorm.Open("sqlite3", "db.sqlite3") if err != nil { ... } defer db.Close() db.DB().SetMaxOpenConns(1) rdb.RunAutoMigrate(db) storage := rdb.NewStorage(db) study, _ := goptuna.LoadStudy( "study-name", goptuna.StudyOptionStorage(storage)) ... }
  • 34. $ pip install optuna bokeh mysqlclient $ optuna dashboard > --storage mysql+mysqldb:// goptuna:[email protected]:3306/yourdb > -—study yourstudy
  • 35. import ... func main() { db, _ := gorm.Open(“mysql", “user:pass@tcp(localhost:3306)/yourdb" + ”?parseTime=true”) storage := rdb.NewStorage(db) defer db.Close() study, _ := goptuna.LoadStudy( “study-name", goptuna.StudyOptionStorage(storage)) ... } $ goptuna create-study > --storage mysql+mysqldb:// goptuna:[email protected]:3306/yourdb > -—study yourstudy goputna.LoadStudy study : _examples/concurrency
  • 36. • optuna.visualization.plot_contour(st udy) • optuna.visualization. plot_intermediate_values(study) • optuna.visualization.plot_optimizati on_history(study) • optuna.visualization.plot_parallel_c oordinate(study) • optuna.visualization.plot_slice(stud y)
  • 37. package main import ( "log" "math" bo "github.com/d4l3k/go-bayesopt" ) var ( px1 = bo.UniformParam{Name: "X1", Max: 10, Min: -10} px2 = bo.UniformParam{Name: "X2", Max: 10, Min: -10} searchSpace = []bo.Param{px1, px2} ) func objective(params map[bo.Param]float64) float64 { x1 := params[px1] x2 := params[px2] return math.Pow(x1-1, 2) + math.Pow(x2-2, 2) } func main() { o := bo.New( searchSpace, bo.WithRandomRounds(10), bo.WithRounds(100), bo.WithMinimize(true)) x, y, err := o.Optimize(objective) if err != nil { ... } log.Printf(...) } package main import ( "log" "math" "github.com/c-bata/goptuna" "github.com/c-bata/goptuna/tpe" ) func objective(trial goptuna.Trial) (float64, error) { x1, _ := trial.SuggestUniform("x1", -10, 10) x2, _ := trial.SuggestUniform("x2", -10, 10) return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil } func main() { study, _ := goptuna.CreateStudy( "goptuna-example", goptuna.StudyOptionSampler(tpe.NewSampler())) err = study.Optimize(objective, 100) if err != nil { ... } v, _ := study.GetBestValue() params, _ := study.GetBestParams() log.Printf(...) } Define-and-Run interface go-bayesopt Define-by-Run interface Goptuna
  • 38. 
 
 10 epochs trial #1 trial #2 trial #3 trial #4 trial #5 trial #6 trial #7 trial #8 trial #9 30 epochs 90 epochs [Jamieson and Talwalkar, 2016] [Li et al., 2018] 

  • 41. 2,010 10,660 1 ISUCON Alibaba Cloud ecs.sn1ne.large (vCPUx2, Mem 4.0GiB) 3 2 ISUCON9 9560 9100
  • 42. func objective(trial goptuna.Trial) (float64, error) { // Go application goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64) goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64) goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128) goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096) goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128) campaign, _ := trial.SuggestInt("campaign", 0, 2) // Nginx nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16) nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096) nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100) // MySQL innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800) innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit", []string{"0", "1", "2"}) innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{ "fsync", "littlesync", "nosync", "O_DIRECT", "O_DIRECT_NO_FSYNC", }) ... } https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go
  • 43. func objective(trial goptuna.Trial) (float64, error) { // Go application goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64) goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64) goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128) goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096) goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128) campaign, _ := trial.SuggestInt("campaign", 0, 2) // Nginx nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16) nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096) nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100) // MySQL innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800) innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit", []string{"0", "1", "2"}) innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{ "fsync", "littlesync", "nosync", "O_DIRECT", "O_DIRECT_NO_FSYNC", }) ... } https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go (database/sql).DB
  • 44. func objective(trial goptuna.Trial) (float64, error) { // Go application goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64) goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64) goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128) goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096) goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128) campaign, _ := trial.SuggestInt("campaign", 0, 2) // Nginx nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16) nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096) nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100) // MySQL innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800) innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit", []string{"0", "1", "2"}) innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{ "fsync", "littlesync", "nosync", "O_DIRECT", "O_DIRECT_NO_FSYNC", }) ... } https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go API 
 (net/http).Client
  • 45. func objective(trial goptuna.Trial) (float64, error) { // Go application goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64) goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64) goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128) goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096) goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128) campaign, _ := trial.SuggestInt("campaign", 0, 2) // Nginx nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16) nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096) nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100) // MySQL innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800) innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit", []string{"0", "1", "2"}) innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{ "fsync", "littlesync", "nosync", "O_DIRECT", "O_DIRECT_NO_FSYNC", }) ... } https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go campaign: 

  • 46. func objective(trial goptuna.Trial) (float64, error) { // Go application goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64) goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64) goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128) goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096) goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128) campaign, _ := trial.SuggestInt("campaign", 0, 2) // Nginx nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16) nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096) nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100) // MySQL innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800) innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit", []string{"0", "1", "2"}) innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{ "fsync", "littlesync", "nosync", "O_DIRECT", "O_DIRECT_NO_FSYNC", }) ... } https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go Nginx suggest text/template nginx.conf systemd
  • 47. func objective(trial goptuna.Trial) (float64, error) { // Go application goMySQLOpenConns, _ := trial.SuggestInt("mysql_client_open_conns", 1, 64) goMySQLIdleConns, _ := trial.SuggestInt("mysql_client_idle_conns", 1, 64) goMySQLMaxLifetime, _ := trial.SuggestInt("mysql_client_max_lifetime", 1, 128) goHttpIdleConnsPerHost, _ := trial.SuggestInt("http_max_idle_conns_per_host", 1, 4096) goHttpKeepAlive, _ := trial.SuggestInt("http_keep_alive_timeout", 1, 128) campaign, _ := trial.SuggestInt("campaign", 0, 2) // Nginx nginxWorkerProcesses, _ := trial.SuggestInt("nginx_worker_processes", 1, 16) nginxWorkerConns, _ := trial.SuggestInt("nginx_worker_connections", 1, 4096) nginxKeepAliveTimeout, _ := trial.SuggestInt("nginx_keep_alive_timeout", 1, 100) // MySQL innoDBBufferPoolSize, _ := trial.SuggestInt("innodb_buffer_pool_size", 10, 3800) innoDBFlushLogAtTRXCommit, _ := trial.SuggestCategorical(“innodb_flush_log_at_trx_commit", []string{"0", "1", "2"}) innodbFlushMethod, _ := trial.SuggestCategorical("innodb_flush_method", []string{ "fsync", "littlesync", "nosync", "O_DIRECT", "O_DIRECT_NO_FSYNC", }) ... } https://github.com/c-bata/goptuna-isucon9q/blob/master/optimizer/main.go MySQL Nginx
  • 49. Go MySQL client (net/http).Client Nginx MySQL SetMaxOpen Conns SetMaxIdleC onns SetConnMax Lifetime DialContext. Keepalive MaxIdleConn sPerHost worker_proc esses worker_conn ections keep_alive_ti meout innodb_buffe r_pool_size innodb_flush _log_at_trx_c ommit innodb_flush _method 10660 11160 (+500) 200 37 53 77s 40s 709 11 367 74s 711M 0 fsync Go MySQL client Nginx MySQL SetMaxOpenCo nns SetMaxIdleConn s SetConnMaxLife time worker_connecti ons innodb_buffer_p ool_size innodb_flush_log _at_trx_commit innodb_log_buff er_size innodb_log_file_ size 2010 2310 (+300) 50 23 4 28s 5 210M 0 27M 341M https://github.com/c-bata/goptuna-isucon9q/issues/2 https://github.com/c-bata/goptuna-isucon9q/issues/9
  • 50. Optuna x.264 (by Takeru Ohta a.k.a. @sile)
  • 52. • Goptuna LibFFM [Juan et al., 2016] 
 • Optuna RocsDB by @sile
 • BoTorch/Ax (Facebook) HHVM JIT Compiler 

  • 54. • [Eric et al., 2010] Eric Brochu, Vlad M. Cora, and Nando de Freitas. A tutorial on Bayesian optimization of expensive cost functions, with application to active user modeling and hierarchical reinforcement learning. 2010. arXiv:1012.2599. • [James et al., 2011] James S. Bergstra, Remi Bardenet, Yoshua Bengio, and Balázs Kégl. Algorithms for hyper- parameter optimization. In Advances in Neural Information Processing Systems 25. 2011. • [Akiba at el., 2019] Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, Masanori Koyama. 2019. Optuna: A Next-generation Hyperparameter Optimization Framework. In The 25th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD ’19), August 4–8, 2019. • [Jamieson and Talwalkar, 2016] K. Jamieson and A. Talwalkar. Non-stochastic best arm identification and hyperparameter optimization. In AISTATS, 2016. • [Li et al., 2018] Liam Li, Kevin Jamieson, Afshin Rostamizadeh, Ekaterina Gonina, Moritz Hardt, Benjamin Recht, and Ameet Talwalkar. Massively parallel hyperparameter tuning. arXiv preprint arXiv:1810.05934, 2018. • [Eggensperger et al., 2013] Eggensperger, K., Feurer, M., Hutter, F., Bergstra, J., Snoek, J., Hoos, H., and Leyton-Brown, K.: Towards an Empirical Foundation for Assessing Bayesian Optimization of Hyperparameters, in NeurIPS workshop on Bayesian Optimization in Theory and Practice (2013). • [Juan et al., 2016] Yu-Chin Juan, Yong Zhuang, Wei-Sheng Chin, and Chih-Jen Lin. Field-aware factorization machines for CTR prediction. In RecSys, pages 43–50, 2016. References