You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a common pattern in resource estimation research - we would like to have one algorithm implementation but be able to optimize it for different metrics using different building blocks.
Describe the solution you'd like
All these can be addressed by having a configuration (dictionary keyed by strings) that will be available to Q# code.
function GetConfigInt(key: name): Int;
function GetConfigDouble(key: name): Double;
function GetConfigBool(key: name): Bool;
function GetConfigString(key: name): String;
And this can be used to know whether we are in resource estimator or not. We will introduce some "system configs" that are always available (and forbid users to override them). For example, "is_resource_estimating" will be bool config that will be set to true for RE backend and to False for other backends.
This can be implemented in Rust (in Interpreter or in each backend) by keeping map<String, Value> where Value is defined as enum Value {Int(i64), Float(f64), Bool(bool), String(String)}. If value is not set, default value is returned.
Describe alternatives you've considered
The alternative is to pass configuration as operation arguments: define struct Config and add all configuration there. Then pass it as first or last arguments from entry point to all methods that need this. This is somewhat ugly.
Is your feature request related to a problem? Please describe.
There are multiple cases when this would be helpful:
Describe the solution you'd like
All these can be addressed by having a configuration (dictionary keyed by strings) that will be available to Q# code.
Suggested Python syntax (for evaluate, run, logical_counts etc):
Suggested Q# intrinsics to access the config:
Then, for example, this code can be rewritten as:
And this can be used to know whether we are in resource estimator or not. We will introduce some "system configs" that are always available (and forbid users to override them). For example, "is_resource_estimating" will be bool config that will be set to true for RE backend and to False for other backends.
This can be implemented in Rust (in Interpreter or in each backend) by keeping
map<String, Value>where Value is defined asenum Value {Int(i64), Float(f64), Bool(bool), String(String)}. If value is not set, default value is returned.Describe alternatives you've considered
The alternative is to pass configuration as operation arguments: define
struct Configand add all configuration there. Then pass it as first or last arguments from entry point to all methods that need this. This is somewhat ugly.