Skip to Content
DocsWriting ScriptsParameter Handling

How Job Parameters Flow to Workflows

When a job is submitted through the Marqov platform, it includes a params dict containing backend configuration, device ARN, S3 settings, and any custom parameters. This guide explains how those parameters reach your workflow code.

The params Dict

The job parameters dict typically contains:

{ "backend": "sv1", "device_arn": "arn:aws:braket:::device/quantum-simulator/amazon/sv1", "s3_bucket": "amazon-braket-marqov-dev", "s3_prefix": "jobs/abc123", "shots": 1000, # ... any custom params from the job submission form }

How the Executor Filters Parameters

The Temporal executor (temporal_executor.py) uses Python’s inspect.signature() to match parameters to your workflow function. The behavior depends on which entry point strategy you use.

Strategy 1: main(client, params)

With an explicit main(), the full params dict is passed as-is. No filtering occurs.

async def main(client, params): # params contains ALL job parameters print(params["backend"]) # "sv1" print(params["s3_bucket"]) # "amazon-braket-marqov-dev" print(params["shots"]) # 1000 dispatch = my_workflow(theta=0.5, config=params) return await dispatch.run(client)

Strategy 2: Single @workflow auto-detection

When the executor auto-detects a single @workflow function, it inspects the function signature and passes only the matching parameters.

@workflow def my_workflow(theta: float, shots: int): ...

Given params = {"theta": 0.5, "shots": 1000, "backend": "sv1", "s3_bucket": "..."}, the executor calls:

my_workflow(theta=0.5, shots=1000) # "backend" and "s3_bucket" are filtered out because they're not in the signature

Using **kwargs to Accept All Parameters

If your workflow signature includes **kwargs, the executor passes the entire params dict without filtering:

@workflow def my_workflow(theta: float, **kwargs): # theta is extracted from params # all remaining params are available in kwargs ...

Given params = {"theta": 0.5, "backend": "sv1", "shots": 1000}, the executor calls:

my_workflow(theta=0.5, backend="sv1", shots=1000)

Filtering Logic

Here is the exact filtering logic from the executor:

sig = inspect.signature(fn) accepts_kwargs = any( p.kind == inspect.Parameter.VAR_KEYWORD for p in sig.parameters.values() ) if accepts_kwargs: filtered_params = params else: filtered_params = { k: v for k, v in params.items() if k in sig.parameters } dispatch = fn(**filtered_params)

This means:

  1. If the function has **kwargs, all params are passed through
  2. Otherwise, only params whose names match function parameters are passed
  3. Extra params in the dict are silently dropped
  4. Missing params that have no default will cause a TypeError

Examples

Workflow that only needs theta

@workflow def optimize(theta: float): circuit = build_ansatz(theta) return measure(circuit.to_dict())

The executor extracts theta from params["theta"] and drops everything else.

Workflow that needs backend config

@workflow def experiment(theta: float, device_arn: str, s3_bucket: str, s3_prefix: str): config = { "device_arn": device_arn, "s3_bucket": s3_bucket, "s3_prefix": s3_prefix, } circuit = build_ansatz(theta) return measure(circuit.to_dict(), config)

The executor extracts all four named params from the dict.

Workflow with defaults for optional params

@workflow def experiment(theta: float, shots: int = 1000, backend: str = "local"): ...

If params contains shots or backend, those values override the defaults. If not, the defaults apply.

Using main() for full control

@workflow def vqe_step(theta: float, executor_config: dict): ... async def main(client, params): theta = params.get("theta", 0.5) executor_config = { "device_arn": params["device_arn"], "s3_bucket": params["s3_bucket"], "s3_prefix": params["s3_prefix"], "timeout_seconds": params.get("timeout", 300), } dispatch = vqe_step(theta, executor_config) result = await dispatch.run(client) return {"result": result}

This is the most flexible approach — you control exactly how params map to workflow arguments.

Common Pitfalls

Missing required parameter:

@workflow def my_workflow(theta: float, shots: int): ...

If params is {"theta": 0.5} (no shots), the executor raises:

TypeError: my_workflow() missing 1 required keyword-only argument: 'shots'

Fix: add a default value (shots: int = 1000) or ensure the param is always provided.

Type mismatches:

Parameters arrive as whatever type they were in the JSON. A "1000" string will not auto-convert to int. The job submission API typically handles this, but if you use custom params, be aware of types.

Last updated on