Using runtime policies
Use this page to learn how to use the ST4SD runtime policies, for example to execute parameterised packages that contain surrogate models.
- What is a runtime policy?
- How to use a runtime policy?
- Policy: prefer-surrogate
- Policy: random-canary-surrogate
What is a runtime policy?
Runtime policies are algorithms which modify the default behaviour of ST4SD when its asked to run a parameterised package.
How to use a runtime policy?
You can use a runtime policy by configuring the runtimePolicy
field of the api_experiment_start()
payload.
Example
from __future__ import typingimport jsondef experiment_start(api: experiment.service.db.ExperimentRestAPI) -> str:"""Start an experiment that uses the prefer-surrogate runtime policyArguments:api: An instance of ExperimentRestAPI that has connected to yourprivate ST4SD registry
Policy: prefer-surrogate
The algorithm of the policy is:
- Find a suitable surrogate package of the requested parameterised package in the
api_experiment_start()
payload- Find parameterised packages that are the result of synthesizing a transformation relationship, AND
- The outputGraph of the associated
transformation relationship
matches a subGraph of the requested parameterised package.
- If there is a suitable surrogate parameterised package then start it and return the UID of the resulting run.
- Otherwise, start and return the UID of the requested parameterised packages.
The schema of the runtimePolicy
field in the api_experiment_start()
payload (in YAML
format) is:
runtimePolicy:name: prefer-surrogate
Policy: random-canary-surrogate
In a future version the runtime system will automatically invoke this runtime-policy. However, users can also switch it on manually for their virtual experiment runs.
The algorithm of the policy is:
- Toss a weighted coin which shows heads with probability
probabilitySurrogate
. If the coin shows heads when it lands then attempt to start 2 virtual experiment instances. The requested one AND a surrogate of the requested one (if available).- If coin shows
heads
: then attempt to start 2 virtual experiment instances. An instance using the requested parameterised package from theapi_experiment_start()
payload and a second one of a suitable surrogate parameterised package (if present). If there is no suitable surrogate parameterised package then start just one run of the requested parameterised package. - Use the same logic as the “prefer-surrogate” to identify one surrogate parameterised package.
- If coin shows
- If the coin shows
tails
then start just the requested parameterised package - Return the UID of the instance for the parameterised package.
The schema of the runtimePolicy
field in the api_experiment_start()
payload (in YAML
format) is:
runtimePolicy:name: random-canary-surrogateconfig: # optionalprobabilitySurrogate: float from 0.0 to 1.0 (optional, default is 0.5)