Git Product home page Git Product logo

google / vizier Goto Github PK

View Code? Open in Web Editor NEW
1.2K 20.0 70.0 4.07 MB

Python-based research interface for blackbox and hyperparameter optimization, based on the internal Google Vizier Service.

Home Page: https://oss-vizier.readthedocs.io

License: Apache License 2.0

Shell 0.14% Python 99.86%
vizier hyperparameter-optimization tuning tuning-parameters blackbox-optimization hyperparameter-tuning bayesian-optimization evolutionary-algorithms distributed-systems distributed-computing

vizier's Introduction

Open Source Vizier: Reliable and Flexible Black-Box Optimization.

PyPI version Continuous Integration Docs

Google AI Blog | Getting Started | Documentation | Installation | Citing and Highlights

What is Open Source (OSS) Vizier?

OSS Vizier is a Python-based service for black-box optimization and research, based on Google Vizier, one of the first hyperparameter tuning services designed to work at scale.


OSS Vizier's distributed client-server system. Animation by Tom Small.

Getting Started

As a basic example for users, below shows how to tune a simple objective using all flat search space types:

from vizier.service import clients
from vizier.service import pyvizier as vz

# Objective function to maximize.
def evaluate(w: float, x: int, y: float, z: str) -> float:
  return w**2 - y**2 + x * ord(z)

# Algorithm, search space, and metrics.
study_config = vz.StudyConfig(algorithm='DEFAULT')
study_config.search_space.root.add_float_param('w', 0.0, 5.0)
study_config.search_space.root.add_int_param('x', -2, 2)
study_config.search_space.root.add_discrete_param('y', [0.3, 7.2])
study_config.search_space.root.add_categorical_param('z', ['a', 'g', 'k'])
study_config.metric_information.append(vz.MetricInformation('metric_name', goal=vz.ObjectiveMetricGoal.MAXIMIZE))

# Setup client and begin optimization. Vizier Service will be implicitly created.
study = clients.Study.from_study_config(study_config, owner='my_name', study_id='example')
for i in range(10):
  suggestions = study.suggest(count=2)
  for suggestion in suggestions:
    params = suggestion.parameters
    objective = evaluate(params['w'], params['x'], params['y'], params['z'])
    suggestion.complete(vz.Measurement({'metric_name': objective}))

Documentation

OSS Vizier's interface consists of three main APIs:

  • User API: Allows a user to optimize their blackbox objective and optionally setup a server for distributed multi-client settings.
  • Developer API: Defines abstractions and utilities for implementing new optimization algorithms for research and to be hosted in the service.
  • Benchmarking API: A wide collection of objective functions and methods to benchmark and compare algorithms.

Additionally, it contains advanced API for:

  • Tensorflow Probability: For writing Bayesian Optimization algorithms using Tensorflow Probability and Flax.
  • PyGlove: For large-scale evolutionary experimentation and program search using OSS Vizier as a distributed backend.

Please see OSS Vizier's ReadTheDocs documentation for detailed information.

Installation

Quick start: For tuning objectives using our state-of-the-art JAX-based Bayesian Optimizer, run:

pip install google-vizier[jax]

Advanced Installation

Minimal version: To install only the core service and client APIs from requirements.txt, run:

pip install google-vizier

Full installation: To support all algorithms and benchmarks, run:

pip install google-vizier[all]

Specific installation: If you only need a specific part "X" of OSS Vizier, run:

pip install google-vizier[X]

which installs add-ons from requirements-X.txt. Possible options:

  • requirements-jax.txt: Jax libraries shared by both algorithms and benchmarks.
  • requirements-tf.txt: Tensorflow libraries used by benchmarks.
  • requirements-algorithms.txt: Additional repositories (e.g. EvoJAX) for algorithms.
  • requirements-benchmarks.txt: Additional repositories (e.g. NASBENCH-201) for benchmarks.
  • requirements-test.txt: Libraries needed for testing code.

Check if all unit tests work by running run_tests.sh after a full installation. OSS Vizier requires Python 3.10+, while client-only packages require Python 3.8+.

Citing and Highlights

Citing Vizier: If you found this code useful, please consider citing the OSS Vizier paper as well as the Google Vizier paper.

Highlights: We track notable users and media attention - let us know if OSS Vizier was helpful for your work.

Thanks!

@inproceedings{oss_vizier,
  author    = {Xingyou Song and
               Sagi Perel and
               Chansoo Lee and
               Greg Kochanski and
               Daniel Golovin},
  title     = {Open Source Vizier: Distributed Infrastructure and API for Reliable and Flexible Black-box Optimization},
  booktitle = {Automated Machine Learning Conference, Systems Track (AutoML-Conf Systems)},
  year      = {2022},
}
@inproceedings{google_vizier,
  author    = {Daniel Golovin and
               Benjamin Solnik and
               Subhodeep Moitra and
               Greg Kochanski and
               John Karro and
               D. Sculley},
  title     = {Google Vizier: {A} Service for Black-Box Optimization},
  booktitle = {Proceedings of the 23rd {ACM} {SIGKDD} International Conference on
               Knowledge Discovery and Data Mining, Halifax, NS, Canada, August 13
               - 17, 2017},
  pages     = {1487--1495},
  publisher = {{ACM}},
  year      = {2017},
  url       = {https://doi.org/10.1145/3097983.3098043},
  doi       = {10.1145/3097983.3098043},
}

vizier's People

Contributors

ark-kun avatar belenkil avatar chansoo-google avatar daiyip avatar dzelle avatar eglanz avatar emilyfertig avatar hawkinsp avatar levskaya avatar michaelreneer avatar mihirparadkar avatar qiuyiz avatar rchen152 avatar sagipe avatar setarehar avatar sinopalnikov avatar srvasude avatar superbobry avatar xingyousong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vizier's Issues

Desktop responsiveness

Hello at this moment there is a problem with desktop responsiveness there right hand side too much space which not look good so may it required to fix you can assign me I will fix it

Getting `UnparsedFlagAccessError` with example code

Hi there,

I'm trying to run the demo code from the README, but am getting an UnparsedFlagAccessError error.

Code:

from vizier.service import clients
from vizier.service import pyvizier as vz

# Objective function to maximize.
def evaluate(w: float, x: int, y: float, z: str) -> float:
    return w**2 - y**2 + x * ord(z)

# Algorithm, search space, and metrics.
study_config = vz.StudyConfig(algorithm='GAUSSIAN_PROCESS_BANDIT')
study_config.search_space.root.add_float_param('w', 0.0, 5.0)
study_config.search_space.root.add_int_param('x', -2, 2)
study_config.search_space.root.add_discrete_param('y', [0.3, 7.2])
study_config.search_space.root.add_categorical_param('z', ['a', 'g', 'k'])
study_config.metric_information.append(vz.MetricInformation('metric_name', goal=vz.ObjectiveMetricGoal.MAXIMIZE))

# Setup client and begin optimization. Vizier Service will be implicitly created.
study = clients.Study.from_study_config(study_config, owner='my_name', study_id='example')
for i in range(10):
    suggestions = study.suggest(count=1)
    for suggestion in suggestions:
        params = suggestion.parameters
        objective = evaluate(params['w'], params['x'], params['y'], params['z'])
        suggestion.complete(vz.Measurement({'metric_name': objective}))

Error:

---------------------------------------------------------------------------
UnparsedFlagAccessError                   Traceback (most recent call last)
Cell In[21], line 20
     18 study = clients.Study.from_study_config(study_config, owner='my_name', study_id='example')
     19 for i in range(10):
---> 20     suggestions = study.suggest(count=1)
     21     for suggestion in suggestions:
     22         params = suggestion.parameters

File ~/Projects/cppflow/venv/lib/python3.8/site-packages/vizier/_src/service/clients.py:143, in Study.suggest(self, count, client_id)
    138 def suggest(
    139     self, *, count: Optional[int] = None, client_id: str = 'default_client_id'
    140 ) -> List[Trial]:
    141   return [
    142       self._trial_client(t)
--> 143       for t in self._client.get_suggestions(
    144           count, client_id_override=client_id
    145       )
    146   ]

File ~/Projects/cppflow/venv/lib/python3.8/site-packages/vizier/_src/service/vizier_client.py:168, in VizierClient.get_suggestions(self, suggestion_count, client_id_override)
    165 num_attempts = 0
    166 while not operation.done:
    167   sleep_time = PollingDelay(
--> 168       num_attempts, FLAGS.vizier_new_suggestion_polling_secs
    169   )
    170   num_attempts += 1
    171   logging.info(
    172       'Waiting for operation with name %s to be done', operation.name
    173   )

File ~/Projects/cppflow/venv/lib/python3.8/site-packages/absl/flags/_flagvalues.py:481, in FlagValues.__getattr__(self, name)
    479   return fl[name].value
    480 else:
--> 481   raise _exceptions.UnparsedFlagAccessError(
    482       'Trying to access flag --%s before flags were parsed.' % name)

UnparsedFlagAccessError: Trying to access flag --vizier_new_suggestion_polling_secs before flags were parsed.

Specs:

  • Ubuntu 20, python3.8, google-vizier=0.1.5

Any ideas on how to fix this? I looked around online but didn't find anything helpful.

Thanks,
Jeremy

PyGlove interface errors with google-vizier 0.1.13

There was an error in backend.py causing the library imports to fail, some extra text that needed to be deleted.

Then in core.py, there is an attempted import from vizier.google of "metadata_to_user" which breaks the import of that file.

Looking at this repo, it seems these were already addressed at some point, but perhaps not pushed to the pip repository.

Where is the code implementation for the search algorithms?

In the study config file, there are multiple search algorithms like:

ALGORITHM_UNSPECIFIED = study_pb2.StudySpec.Algorithm.ALGORITHM_UNSPECIFIED
GAUSSIAN_PROCESS_BANDIT = study_pb2.StudySpec.Algorithm.GAUSSIAN_PROCESS_BANDIT
GRID_SEARCH = study_pb2.StudySpec.Algorithm.GRID_SEARCH
RANDOM_SEARCH = study_pb2.StudySpec.Algorithm.RANDOM_SEARCH
NSGA2 = study_pb2.StudySpec.Algorithm.NSGA2
EMUKIT_GP_EI = study_pb2.StudySpec.Algorithm.EMUKIT_GP_EI

wondering where is the implementation of each algorithm? are they currently not open-sourced?

Can't finish the run_test.sh flow

I want to install vizier on my own server, when I finish runing the install.sh. I meet error at running run_test.sh, with error:
No module named 'dopamine'
So I execute pip install dopamine and meet error ModuleNotFoundError: No module named 'dopaminekit'
and I execute pip install dopaminekit
and I meet E ImportError: cannot import name 'DopamineKit' from partially initialized module 'dopaminekit' (most likely due to a circular import) (/opt/ygh/envs/wxz1/lib/python3.9/site-packages/dopaminekit/__init__.py)
I search it on stack overflow got this answer
Which said: dopaminekit is a completely different thing that also happens to use the name "dopamine". Also, even with dopaminekit, that dopaminekit folder should not exist, so it looks like you may have screwed up your environment further.
So, How can I solve this dependency problem to avoid this error.

QUASI_RANDOM_SEARCH no work

I try to quasi random search points in the range [0.0001, 0.1]. I try for 25 trials but I found the points are in the range [0.01,0.013]. the server and the client code is as the appendix.
code.zip

How to get Gaussian Process?

I have installed, the extra version (pip install google-vizier[extra]), but get the error: Exception calling application: Algorithm GAUSSIAN_PROCESS_BANDIT is not registered.

Using example code, only with algorithm changed:

from scipy.optimize import rosen
from vizier.service import clients
from vizier.service import pyvizier as vz
from vizier.service import vizier_service

problem = vz.ProblemStatement()
problem.search_space.root.add_float_param("x", -5, 5)
problem.search_space.root.add_float_param("y", -5, 5)
problem.metric_information.append(
    vz.MetricInformation(name="maximize_metric", goal=vz.ObjectiveMetricGoal.MINIMIZE)
)


def evaluate(x: float, y: float) -> float:
    return rosen([x, y])


study_config = vz.StudyConfig.from_problem(problem)
study_config.algorithm = vz.Algorithm.GAUSSIAN_PROCESS_BANDIT

service = vizier_service.DefaultVizierService()

clients.environment_variables.service_endpoint = service.endpoint  # Server address.
study_client = clients.Study.from_study_config(study_config, owner="owner", study_id="example_study_id")

suggestions = study_client.suggest(count=5)
for suggestion in suggestions:
    x = suggestion.parameters["x"]
    y = suggestion.parameters["y"]
    print("Suggested Parameters (x,y):", x, y)
    final_measurement = vz.Measurement({"maximize_metric": evaluate(x, y)})
    suggestion.complete(final_measurement)

for optimal_trial in study_client.optimal_trials():
    optimal_trial = optimal_trial.materialize()
    print(
        "Optimal Trial Suggestion and Objective:", optimal_trial.parameters, optimal_trial.final_measurement
    )

Database locked

HI,
I keep getting the below error -

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked [SQL: INSERT INTO owners (owner_name) VALUES (?)]

I get this error in every run.
I am not doing anything out of ordinary to the best of my knowledge.
I have tried setting busy timeout and lock timeout but neither has helped.

Can you please help with what I am doing wrong here and how I can solve this ? Thanks

Currently NSGA2 is broken when using SQL datastore

Sorry for asking, I deployed oss vizier on my server. And sucessfully run the run_vizier_server.py. However when I run the run_vizier_client.py I got such error log on server:

E0708 13:08:56.978154 140386903254784 _server.py:445] Exception calling application: Currently NSGA2 is broken when using SQL datastore, due to needed metadata update changes.
Traceback (most recent call last):
  File "/root/anaconda3/envs/vizier/lib/python3.9/site-packages/grpc/_server.py", line 435, in _call_behavior
    response_or_iterator = behavior(argument, context)
  File "/home/wxz/project/vizier/vizier/service/vizier_server.py", line 291, in SuggestTrials
    pythia_policy = policy_creator(study.study_spec.algorithm,
  File "/home/wxz/project/vizier/vizier/service/vizier_server.py", line 45, in policy_creator
    raise ValueError(
ValueError: Currently NSGA2 is broken when using SQL datastore, due to needed metadata update changes.

and the client error log like this,

I0708 13:08:56.962552 139991912334144 vizier_client.py:51] Securing channel to localhost:24956.
I0708 13:08:56.967267 139991912334144 vizier_client.py:55] Secured channel to localhost:24956.
I0708 13:08:56.973042 139991912334144 run_vizier_client.py:94] Client created with study name: owners/my_name/studies/cifar10
Traceback (most recent call last):
  File "/home/wxz/project/vizier/demos/run_vizier_client.py", line 117, in <module>
    app.run(main)
  File "/root/anaconda3/envs/vizier/lib/python3.9/site-packages/absl/app.py", line 312, in run
    _run_main(main, args)
  File "/root/anaconda3/envs/vizier/lib/python3.9/site-packages/absl/app.py", line 258, in _run_main
    sys.exit(main(argv))
  File "/home/wxz/project/vizier/demos/run_vizier_client.py", line 98, in main
    suggestions = client.get_suggestions(
  File "/home/wxz/project/vizier/vizier/service/vizier_client.py", line 150, in get_suggestions
    operation = future.result()
  File "/root/anaconda3/envs/vizier/lib/python3.9/site-packages/grpc/_channel.py", line 722, in result
    raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Exception calling application: Currently NSGA2 is broken when using SQL datastore, due to needed metadata update changes."
        debug_error_string = "{"created":"@1657256936.978906103","description":"Error received from peer ipv4:127.0.0.1:24956","file":"src/core/lib/surface/call.cc","file_line":1067,"grpc_message":"Exception calling application: Currently NSGA2 is broken when using SQL datastore, due to needed metadata update changes.","grpc_status":2}"
>

Please give me some advice how can I sovle this.

Add weight to MetricInformation

Hi, from the documentation I understand that Vizier is able to optimize multiple objectives at the same time (is that correct?), but is it possible to assign the objectives different weights?

e.g.

problem.metric_information.append(pyvizier.MetricInformation(name="y1", weight=4.0, goal=pyvizier.ObjectiveMetricGoal.MAXIMIZE))
problem.metric_information.append(pyvizier.MetricInformation(name="y2", weight=1.0, goal=pyvizier.ObjectiveMetricGoal.MAXIMIZE))

And then the tool would understand that the result of [y1=11, y2=10] is better than [y1=10, y2=13] (although y2 is 30% better, y1 is 9.1% worse, which multiplied by the weight gives 36.4% reduction).
Is this supported/planned?
Thanks

SQLAlchemy maximum precludes using Pandas

sqlalchemy>=1.4,<=1.4.20 from requirements.txt conflicts with Modern Pandas. Here is the error when trying to use them together.

ImportError: Unable to find a usable engine; tried using: 'sqlalchemy'.
A suitable version of sqlalchemy is required for sql I/O support.
Trying to import the above resulted in these errors:
 - Pandas requires version '1.4.36' or newer of 'sqlalchemy' (version '1.4.20' currently installed).

This makes it pretty hard to work with many modern data science algorithms. Ideally, you should support the latest SQLAlchemy and Pandas.

Please advise on how to proceed.

Can't finish the run_test.sh flow

I want to install vizier on my own server, when I finish runing the install.sh. I meet error at running run_test.sh, with error:
No module named 'dopamine'
So I execute pip install dopamine and meet error ModuleNotFoundError: No module named 'dopaminekit'
and I execute pip install dopaminekit
and I meet E ImportError: cannot import name 'DopamineKit' from partially initialized module 'dopaminekit' (most likely due to a circular import) (/opt/ygh/envs/wxz1/lib/python3.9/site-packages/dopaminekit/__init__.py)
I search it on stack overflow got this answer
Which said: dopaminekit is a completely different thing that also happens to use the name "dopamine". Also, even with dopaminekit, that dopaminekit folder should not exist, so it looks like you may have screwed up your environment further.
So, How can I solve this dependency problem to avoid this error.

pip install google-vizier[jax] failed

here's the error info:
C:\Users\xxxx>python -V
Python 3.10.9

C:\Users\xxxx>pip install google-vizier[jax]
Collecting google-vizier[jax]
Using cached google_vizier-0.1.1-py3-none-any.whl (529 kB)
Collecting grpcio-tools<=1.48.2,>=1.35.0
Using cached grpcio_tools-1.48.2-cp310-cp310-win_amd64.whl (1.9 MB)
Collecting googleapis-common-protos>=1.56.4
Using cached googleapis_common_protos-1.58.0-py2.py3-none-any.whl (223 kB)
Requirement already satisfied: numpy>=1.21.5 in d:\miniforge3\lib\site-packages (from google-vizier[jax]) (1.24.2)
Collecting absl-py>=1.0.0
Using cached absl_py-1.4.0-py3-none-any.whl (126 kB)
Collecting portpicker>=1.3.1
Using cached portpicker-1.5.2-py3-none-any.whl (14 kB)
Collecting attrs==21.4.0
Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting protobuf<4.0,>=3.6
Using cached protobuf-3.20.3-cp310-cp310-win_amd64.whl (904 kB)
Collecting grpcio<=1.48.2,>=1.35.0
Using cached grpcio-1.48.2-cp310-cp310-win_amd64.whl (3.6 MB)
Collecting sqlalchemy==1.4
Using cached SQLAlchemy-1.4.0.tar.gz (7.4 MB)
Preparing metadata (setup.py) ... done
Collecting flax>=0.6.4
Using cached flax-0.6.5-py3-none-any.whl (209 kB)
Collecting jax>=0.4.2
Using cached jax-0.4.3.tar.gz (1.2 MB)
Preparing metadata (setup.py) ... done
Collecting google-vizier[jax]
Using cached google_vizier-0.1.0-py3-none-any.whl (529 kB)
Using cached google_vizier-0.0.20-py3-none-any.whl (482 kB)
Using cached google_vizier-0.0.19-py3-none-any.whl (440 kB)
Using cached google_vizier-0.0.18-py3-none-any.whl (436 kB)
Collecting coverage<=6.4.2,>=4.5
Using cached coverage-6.4.2-cp310-cp310-win_amd64.whl (187 kB)
Collecting google-api-python-client>=2.65.0
Using cached google_api_python_client-2.77.0-py2.py3-none-any.whl (11.0 MB)
Collecting mock<=4.0.3,>=3.0
Using cached mock-4.0.3-py3-none-any.whl (28 kB)
Collecting pytest
Using cached pytest-7.2.1-py3-none-any.whl (317 kB)
Collecting pytype>=2022.10.26
Using cached pytype-2023.2.9.tar.gz (2.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting google-vizier[jax]
Using cached google_vizier-0.0.17-py3-none-any.whl (432 kB)
Using cached google_vizier-0.0.16-py3-none-any.whl (421 kB)
Using cached google_vizier-0.0.15-py3-none-any.whl (419 kB)
Using cached google_vizier-0.0.14-py3-none-any.whl (418 kB)
Using cached google_vizier-0.0.13-py3-none-any.whl (390 kB)
Using cached google_vizier-0.0.12-py3-none-any.whl (390 kB)
Using cached google_vizier-0.0.11-py3-none-any.whl (388 kB)
Collecting grpcio<=1.47.0,>=1.35.0
Using cached grpcio-1.47.0-cp310-cp310-win_amd64.whl (3.5 MB)
Collecting googleapis-common-protos==1.56.0
Using cached googleapis_common_protos-1.56.0-py2.py3-none-any.whl (241 kB)
Collecting portpicker==1.3.1
Using cached portpicker-1.3.1.tar.gz (18 kB)
Preparing metadata (setup.py) ... done
Collecting grpcio-tools<=1.47.0,>=1.35.0
Using cached grpcio_tools-1.47.0-cp310-cp310-win_amd64.whl (1.9 MB)
Collecting pytype<=2022.4.22,>=2022.3.8
Using cached pytype-2022.4.22.tar.gz (1.8 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting google-api-python-client==1.12.8
Using cached google_api_python_client-1.12.8-py2.py3-none-any.whl (61 kB)
Collecting google-vizier[jax]
Using cached google_vizier-0.0.10-py3-none-any.whl (303 kB)
Collecting numpy==1.21.5
Using cached numpy-1.21.5-cp310-cp310-win_amd64.whl (14.0 MB)
Collecting absl-py<1.0,>=0.7
Using cached absl_py-0.15.0-py3-none-any.whl (132 kB)
Collecting typing
Using cached typing-3.7.4.3.tar.gz (78 kB)
Preparing metadata (setup.py) ... done
Collecting google-vizier[jax]
Using cached google_vizier-0.0.6-py3-none-any.whl (285 kB)
Using cached google_vizier-0.0.5-py3-none-any.whl (272 kB)
Using cached google_vizier-0.0.4-py3-none-any.whl (246 kB)
ERROR: Cannot install google-vizier[jax]==0.0.10, google-vizier[jax]==0.0.11, google-vizier[jax]==0.0.12, google-vizier[jax]==0.0.13, google-vizier[jax]==0.0.14, google-vizier[jax]==0.0.15, google-vizier[jax]==0.0.16, google-vizier[jax]==0.0.17, google-vizier[jax]==0.0.18, google-vizier[jax]==0.0.19, google-vizier[jax]==0.0.20, google-vizier[jax]==0.0.4, google-vizier[jax]==0.0.5, google-vizier[jax]==0.0.6, google-vizier[jax]==0.1.0 and google-vizier[jax]==0.1.1 because these package versions have conflicting dependencies.

The conflict is caused by:
google-vizier[jax] 0.1.1 depends on jaxlib>=0.4.2; extra == "jax"
google-vizier[jax] 0.1.0 depends on jaxlib>=0.4.2; extra == "jax"
google-vizier[jax] 0.0.20 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.19 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.18 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.17 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.16 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.15 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.14 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.13 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.12 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.11 depends on jaxlib>=0.3.15; extra == "jax"
google-vizier[jax] 0.0.10 depends on jaxlib==0.3.15; extra == "jax"
google-vizier[jax] 0.0.6 depends on jaxlib==0.3.15; extra == "jax"
google-vizier[jax] 0.0.5 depends on jaxlib==0.3.15; extra == "jax"
google-vizier[jax] 0.0.4 depends on jaxlib==0.3.15; extra == "jax"

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Getting started example error

Hi, I'm using Python 3.9.18 and wanted to test the given getting-started example
when I run the code below, I get the following error:
TypeError: field() got an unexpected keyword argument 'kw_only'

What could be the issue here?

from vizier.service import pyvizier as vz

# Objective function to maximize.
def evaluate(w: float, x: int, y: float, z: str) -> float:
  return w**2 - y**2 + x * ord(z)

# Algorithm, search space, and metrics.
study_config = vz.StudyConfig(algorithm='GAUSSIAN_PROCESS_BANDIT')
study_config.search_space.root.add_float_param('w', 0.0, 5.0)
study_config.search_space.root.add_int_param('x', -2, 2)
study_config.search_space.root.add_discrete_param('y', [0.3, 7.2])
study_config.search_space.root.add_categorical_param('z', ['a', 'g', 'k'])
study_config.metric_information.append(vz.MetricInformation('metric_name', goal=vz.ObjectiveMetricGoal.MAXIMIZE))

# Setup client and begin optimization. Vizier Service will be implicitly created.
study = clients.Study.from_study_config(study_config, owner='my_name', study_id='example')
for i in range(10):
  suggestions = study.suggest(count=1)
  for suggestion in suggestions:
    params = suggestion.parameters
    objective = evaluate(params['w'], params['x'], params['y'], params['z'])
    suggestion.complete(vz.Measurement({'metric_name': objective})) 

Seeding the Random Number Generators?

Currently, in the documentation, it's unclear whether it's possible to control the RNGs' seeding, and if that's possible, where (server, client, problem, study, sampling?) and how to perform that seeding.

sqlalchemy requeriment is too strict

I'm installing Vizier via pip, but I'm facing an issue with the required version of the sqlalchemy package. Vizier specifically demands sqlalchemy==1.4, while other packages in my environment need sqlalchemy>=1.4.1. Furthermore, using sqlalchemy version 1.4.1 with Vizier works fine. Could the dependency be made more flexible (e.g., sqalchemy>=1.4.1)?

How to run "evaluate" function offline ?

Hi,

In my code my "evaluate" function is not runnable with new suggestion automatically in python code.
I need to go to a C++ file, look for #defines under #defines under #ifdefs etc, update the define values per the suggestion, run my code and then I get the result of the "evaluate" function. So far, I do not know a way to automate or script it. I run it offline.
How can I handle this ?
Basically what I need is -

  1. I provide the range of valid values for parameters (+ some results from previous runs) and run vizier
  2. vizier makes a suggestion and updates it's database
  3. I use the suggestion, run my test with it offline, get the evaluate value and provide it to vizier.
  4. Then I rerun vizier which uses the updated database/ latest result to make a next suggestion.and so on.

Is this possible to do or is there a better way to accomplish this ? Thanks

Typing module considered unnecessary

As written in setup.py, google-vizier requires Python 3.9 or higher:

requires_python='>=3.9',

On the other hand, requirements.txt requires the installation of the typing module:

typing # version dependent on Python version.

Since the typing module is a backport of the standard library typing module to Python versions older than 3.5, it is not considered necessary to install it. Indeed, this usually does not cause problems since the modules in the standard library take precedence when there is a module with the same name. However, there is no reason to keep unnecessary dependencies, so I'd suggest removing dependency on the typing module:

diff --git a/requirements.txt b/requirements.txt
index 95e07c3..a659286 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,7 +5,6 @@ coverage>=4.5,<=6.4.2
 protobuf>=3.6,<4.0
 mock>=3.0,<=4.0.3
 pytype>=2022.3.8,<=2022.4.22
-typing  # version dependent on Python version.
 grpcio>=1.35.0,<=1.47.0
 portpicker==1.3.1
 pytest  # Use the latest version to match github workflow.

How much (continous) variables can the optimizer handle in practice

Is there an estimation how many variables the optimizer can handle in practice ?

I am especially interested in floating-point variables with a value range [0, 1].

For my application, I would need the optimizer to be able to support a few hundreds of such variables.
Do you think the optimizer can handle that ?

Test from README fails

Hi,
I am using Python 3.10.12 in Ubuntu 22.04.
I pip installed the default jax version (also tried with all).
I run the test code given in the README -

from vizier.service import clients
from vizier.service import pyvizier as vz

# Objective function to maximize.
def evaluate(w: float, x: int, y: float, z: str) -> float:
  return w**2 - y**2 + x * ord(z)

# Algorithm, search space, and metrics.
study_config = vz.StudyConfig(algorithm='GAUSSIAN_PROCESS_BANDIT')
study_config.search_space.root.add_float_param('w', 0.0, 5.0)
study_config.search_space.root.add_int_param('x', -2, 2)
study_config.search_space.root.add_discrete_param('y', [0.3, 7.2])
study_config.search_space.root.add_categorical_param('z', ['a', 'g', 'k'])
study_config.metric_information.append(vz.MetricInformation('metric_name', goal=vz.ObjectiveMetricGoal.MAXIMIZE))

# Setup client and begin optimization. Vizier Service will be implicitly created.
study = clients.Study.from_study_config(study_config, owner='my_name', study_id='example')
for i in range(10):
  suggestions = study.suggest(count=1)
  for suggestion in suggestions:
    params = suggestion.parameters
    objective = evaluate(params['w'], params['x'], params['y'], params['z'])
    suggestion.complete(vz.Measurement({'metric_name': objective}))

I get the below error -

/vizier/vizier/_src/service/stubs_util.py", line 24, in <module>
    from vizier._src.service import pythia_service_pb2_grpc
ImportError: cannot import name 'pythia_service_pb2_grpc' from 'vizier._src.service' (unknown location)

Is there any PATH requirement that I missed ? I tried checking but could not find anything.
Can you please help ?
Thanks

Issue running notebook

After installing via pip install google-vizier and then cloning this repo to obtain the running_vizier.ipynb notebook, I ran the first cell and had the following error:

File ~/miniconda3/lib/python3.8/site-packages/vizier/_src/pyvizier/oss/metadata_util.py:6, in <module>
      3 from typing import Tuple, Union, Optional, TypeVar, Type, Literal
      5 from vizier._src.pyvizier.shared import trial
----> 6 from vizier.service import key_value_pb2
      7 from vizier.service import study_pb2
      8 from vizier.service import vizier_service_pb2

ImportError: cannot import name 'key_value_pb2' from 'vizier.service' (/home/.../miniconda3/lib/python3.8/site-packages/vizier/service/__init__.py)

Have other folks ran into this when trying to run the notebook and have any solutions?

Get suggestions based on existing measurements

What is the easiest way to get Vizier suggestions based on existing measurements? I believe that somewhere inside Vizier there is a something that would let me do this without much overhead or boilerplate.

pyglove/backend.py: possible dependency on internal google vizier module?

While trying to use Vizier with PyGlove (and running into #1029 and #1030), I also noticed

from vizier.google import metadata_to_user

which causes my script to fail with a ModuleNotFoundError:

Traceback (most recent call last):
  File "/Users/connorbaker/Packages/ghc_hyperopt/./ghc_hyperopt/__main__.py", line 4, in <module>
    from vizier import pyglove as pg_vizier
  File "/Users/connorbaker/micromamba/envs/ghc_hyperopt/lib/python3.11/site-packages/vizier/pyglove/__init__.py", line 20, in <module>
    from vizier._src.pyglove.oss_vizier import init
  File "/Users/connorbaker/micromamba/envs/ghc_hyperopt/lib/python3.11/site-packages/vizier/_src/pyglove/oss_vizier.py", line 32, in <module>
    from vizier._src.pyglove import backend
  File "/Users/connorbaker/micromamba/envs/ghc_hyperopt/lib/python3.11/site-packages/vizier/_src/pyglove/backend.py", line 31, in <module>
    from vizier._src.pyglove import client
  File "/Users/connorbaker/micromamba/envs/ghc_hyperopt/lib/python3.11/site-packages/vizier/_src/pyglove/client.py", line 28, in <module>
    from vizier._src.pyglove import pythia as pg_pythia
  File "/Users/connorbaker/micromamba/envs/ghc_hyperopt/lib/python3.11/site-packages/vizier/_src/pyglove/pythia.py", line 29, in <module>
    from vizier._src.pyglove import core
  File "/Users/connorbaker/micromamba/envs/ghc_hyperopt/lib/python3.11/site-packages/vizier/_src/pyglove/core.py", line 32, in <module>
    from vizier.google import metadata_to_user
ModuleNotFoundError: No module named 'vizier.google'

The dependency was introduced as part of bf576cd, but I can't find it anywhere in the source tree.

Any suggestions?

[Bug] suggest() of EagleStrategyDesigner will raise AttributeError: 'float' object has no attribute 'flatten'

My search space has two float parameters. When I use suggest() of EagleStrategyDesigner, I receive an AttributeError: 'float' object has no attribute 'flatten'. The full error log is as follows:

Traceback (most recent call last):
  File "test.py", line 54, in <module>
    suggestion = designer.suggest(count=1)[0]
  File "anaconda3/lib/python3.10/site-packages/vizier/_src/algorithms/designers/eagle_strategy/eagle_strategy.py", line 209, in suggest
    return self._scaler.unmap(scaled_suggestions)
  File "anaconda3/lib/python3.10/site-packages/vizier/pyvizier/converters/embedder.py", line 151, in unmap
    parameters[name] = param_converter.to_parameter_values(value)[0]
  File "anaconda3/lib/python3.10/site-packages/vizier/pyvizier/converters/core.py", line 697, in to_parameter_values
    return [self._to_parameter_value(v) for v in list(array.flatten())]
AttributeError: 'float' object has no attribute 'flatten'

I think it is because value parameter is considered as ndarray type, as annotated in to_parameter_values function in line 692 of vizier/pyvizier/converters /core.py. But the value of the parameter is actually a float.

Python 3.8: field() got an unexpected keyword argument 'kw_only'

google-vizier-0.1.6

When installing from PIP using Python3.8 and then running, this is the error:

  File "/home/../.local/lib/python3.8/site-packages/vizier/_src/jax/models/tuned_gp_models.py", line 79, in VizierGaussianProcess
    _use_retrying_cholesky: bool = struct.field(
  File "/home/../.local/lib/python3.8/site-packages/flax/struct.py", line 31, in field
    return dataclasses.field(metadata={'pytree_node': pytree_node}, **kwargs)
TypeError: field() got an unexpected keyword argument 'kw_only'

It looks like the kw_only flag is available in 3.10, but not 3.8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.