Skip to main content

Let people tune from the web app

With a few settings, anyone on your project can run a commit's code on other tests, or with other parameters, from the commit page's Run Tests / Tuning form, without a terminal. This page is how a project enables it.

Looking for how to start runs?

See Running from the web app in the user guide.

A grid of 2 score thresholds by 2 NMS IoUs on 2 tests: Start 8 runs, then compare the runs in the Tuning Analysis.

On the inference gateway, a performance engineer swept the batching settings this way: 3 maximum batch sizes by 4 maximum delays. The Tuning Analysis view plotted each configuration's CPU per request against its p99 latency, and the settings on that frontier became the new defaults.

The trade-offs of the tune-batching sweep: one point per configuration of max batch and max delay, CPU per request against p99, the best trade-offs highlighted and joined by a dotted line. The hovered point, max batch 16 and max delay 250 µs, is one of them.The trade-offs of the tune-batching sweep: one point per configuration of max batch and max delay, CPU per request against p99, the best trade-offs highlighted and joined by a dotted line. The hovered point, max batch 16 and max delay 250 µs, is one of them.
Each configuration's CPU per request against its p99: the defaults picked, max batch 16 and 250 µs of delay, are on the frontier.

Enable it​

  1. Save the build in the CI. Runs started from the web app use the commit's artifacts: the files your code needs to run, like a build, saved by qa save-artifacts (see CI integration). qaboard.yaml, qa/ and the batches files are always saved.
  2. Choose where the runs execute. The runs go to your project's runner, runners.default in qaboard.yaml (see Choose where runs execute). The server starts the qa batch command where its admins chose: in a Kubernetes pod, in an LSF job, or in the server's own container. Until they choose, it starts none (it may still redo runs, on LSF). See Run batches from the web app.
  3. Log in. Starting runs needs a logged-in user, and runs are started as that user. See user management.
  4. (Optional) Emails. If the server can send emails, people get one when the batches they start end: see Emails.

To check: open a commit of your CI on its commit page, then Run Tests / Tuning. Tick your CI batch, add no parameter, and start. The batch's runs start, and the Logs view lists the batch under "Started from QA-Board", with the qa batch command QA-Board ran and its log.

The Logs view of the tune-batching sweep: under "Commands", the qa batch command kaito's tuning request ran, from QA-Board, with Run again, the batches it ran, its grid of max batch and max delay and the end of its log; then the two runs left by the filter.The Logs view of the tune-batching sweep: under "Commands", the qa batch command kaito's tuning request ran, from QA-Board, with Run again, the batches it ran, its grid of max batch and max delay and the end of its log; then the two runs left by the filter.
A sweep started from the web app: the Logs view shows the qa batch command QA-Board ran, its log, and its runs.

How the batch starts​

For each request, the server writes a script in the batch's directory and runs it with the chosen runner. The script:

  • goes to the commit's artifacts folder, and sources the .envrc files of that folder and of its parents: activate your environment there (a virtualenv, modules...), it's saved with the artifacts;
  • sets CI=true, GIT_COMMIT to the commit, QA_USER to the user who started it, and QABOARD_TUNING=true;
  • runs qa --label <label> batch --batches-file <the batches> --batch <the batch> --tuning-search ..., or qa optimize for automated tuning.

<the batches> is batches.yaml, next to the script: the batches that run, as they are defined when you start, with only them and the aliases that reach them, from the commit's inputs.batches, the shared and private batches and the files you send. It is what ran, even after the files change, and how to run it again.

When the batch doesn't start, the Logs view says why, with the end of that script's log: a ModuleNotFoundError points to the environment, an LSF report to the cluster. See Logs and failed runs.

Start them from a terminal or a script​

Scripts, CI jobs and coding agents can start the same batches with --commit: QA-Board runs them exactly as when someone clicks Start in the web app, from the commit's artifacts, and the results show on that commit's page. Nothing runs on your machine, and your local changes don't matter.

qa --label nms-sweep batch --commit 3f2a91c ci --tuning-search-file nms-sweep.yaml
qa --label int8-auto optimize --commit my-branch --batch quant-search --config-file int8-search.yaml

--label is required, like the name in the web app's form: without it, the runs would go with the commit's CI results. qa checks the request with the server, starts the batch, prints the batch's page and returns: it doesn't wait for the runs. Read the results later with qa runs, or check them with qa gate --label nms-sweep. To only check the request, add --dryrun.

The batches are the commit's, like in the web app: the files in its inputs.batches, then your shared and private batches from Available Tests. To try batches you didn't commit, send them with --batches-file local.yaml. Unlike qa batch --batches-file without --commit, which replaces inputs.batches, the files you send are read after the commit's: they win over its batches with the same name. qa says where each batch is defined, and warns when a local file listed in inputs.batches differs from the commit's, since the commit's is used.

What --commit accepts, and when it refuses to start
  • The commit: an id, a branch or a tag, found with your local git: run git fetch first. qa warns when the commit isn't on a remote branch you fetched, or when your branch and its upstream differ.
  • Options: --label, --platform and --dryrun; for qa batch the batches, --batches-file, --tuning-search(-file), --action-on-existing run|sync (by default existing runs are kept, like in the web app) and --no-wait; for qa optimize, --batch, --batches-file and --config-file. Other options on the command line, like --runner or --offline, are refused: the server's settings decide where runs execute. QA_LABEL and QA_PLATFORM are used; other options set in QA_* variables, e.g. in an .envrc, are ignored.
  • The commit must be known to QA-Board, with its artifacts saved: right after a push, wait for the CI job that runs qa save-artifacts. If the artifacts were deleted, qa doesn't start, unless the project lets QA-Board recreate them: it then asks your CI, and you try again once it's done.
  • Exit codes: 0 when the batch started, 1 when it didn't (the message says why), 2 when the artifacts are being recreated: try again later.
  • Signing in: like in the web app, with your account (qa auth login). In CI, use a token with the act scope, of an account with the developer role on the project: stored, or exchanged by a trusted CI job.
  • No emails when the runs end.

How parameters reach your code​

Tuning parameters are merged into context.params, and appended to context.configs as a dict: in most cases you have nothing to do. The detector's run() lets them override its defaults and the flags each commit builds with:

qa/main.py
def read_flags(params):
flags = dict(DEFAULT_FLAGS)
path = ROOT / 'build' / 'flags.json'
if path.exists():
flags.update({k: v for k, v in json.loads(path.read_text()).items() if v is not None})
flags.update({k: v for k, v in params.items() if k in DEFAULT_FLAGS}) # tuning parameters
return flags

The same parameters work from a terminal, with --tuning for one set of values:

qa --label int8-nms --tuning '{"score_threshold": 0.3, "nms_iou": 0.5}' batch quant-search

Settings in qaboard.yaml​

qaboard.yaml
inputs:
# Let users choose a platform, passed to `qa --platform`. By default runs use "linux".
platforms:
- name: linux
label: Linux
- name: hw-model
label: Fixed-point model

tuning:
# If your CI only saves artifacts on some branches, list them (globs, "*" matches "/" too):
# on the commits of other branches, the tuning form warns that tuning may not work, and how to save the artifacts.
# In monorepos, {subproject} is the project's folder in the repository and {subproject.name} its last part.
branches:
- main
- '*/*{subproject.name}*' # e.g. alice/denoise-v2 for the project in isp/denoise

People choose the tests from the batches files of the commit, and can add their own in the Available Tests view (see the user guide). For the batches' syntax, see Batches of inputs.

Shortcuts for people who tune
  • To start from an existing run's parameters, hover its configuration tags and choose Copy as a tuning search space, then paste it in the editor under Choose the values.
  • Pasting lines of key=value in that editor converts them to the tuning format: block.threshold=10 becomes "block.threshold": [10], and space-separated matrices like [1 2 3] become JSON arrays.
  • In the Available Tests view, Ctrl+S (or Cmd+S) saves the batches file you are editing.
  • Once runs are done, the Tuning Analysis view says which parameter set is best, how much each parameter matters, where the best set loses test by test, and the trade-off between two metrics, with every set in parallel coordinates. See the user guide. For an automated tuning, it reports what the search found and what to do next: see Read the results.
  • Runs without metrics can be scored afterwards: Tuning Analysis gives people a script to start from, which adds a metric to each run with run.log_metrics() (Add metrics to runs).

Other tuning workflows​

Tuning from the web app runs the code of a commit. Depending on where you are in your work, other workflows fit better:

  • Locally, with your own tools: if you already have good development and debugging tools (an IDE, tensorboard for neural networks, one-off scripts...), keep using them. It's still worth having them call your code through qa, so that runs behave the same everywhere: see debugging with IDEs.
  • Your local code, results in QA-Board: tweak, compile and run your code, then compare the results across runs in the web app. Runs started from a computer appear in a batch named after you, with a warning that they may not match the committed code:
    qa run --input slices/small-objects
    qa --label testing-some-logic-tweaks batch quant-search
  • Commit, CI, QA-Board: to change configuration files that live in your repository, commit and push the changes, and look at the results of the CI runs.
  • Automated tuning: let qa optimize search the parameters for you, from the web app or the CLI. See Find the best parameters automatically to start one and read its results, and Automated tuning with qa optimize for every setting.