Skip to main content

Model conversion and quantization

Create hardware-specific variants and validate compatibility and quality.

Import this workflow from AkôFlow Hub

Open the public README and measured execution results. The Hub includes the execution capture, activity metrics, logs and version history. Reading public results does not require an account.

In Desktop, choose Create workflow → Import from Hub and paste this version-specific URI:

akoflow://hub/publications/0b26ad29-87a9-457e-bc7c-d81ae79d451f/versions/1

Download the exact workflow YAML (v1). Configure the runtime prerequisites below before planning and executing it.

Run this example locally

Export a learned affine model as real ONNX and TorchScript files, generate int8 and IEEE float16 coefficient representations in parallel, reload both executable formats, and compare their numeric outputs against the original model. The float16 branch runs on CPU and does not build or claim a TensorRT engine.

Install Go and Python 3.12 or newer.

git clone https://github.com/UFFeScience/akoflow-examples.git &&
cd akoflow-examples &&
git checkout --detach d890c3171e3661890305b763b8fc3ede48bb61b4 &&
cd machine-learning/model-conversion &&
./prepare.sh &&
./run.sh

Run the block from the directory where you keep your repositories. If you already cloned the repository, enter this example's directory and run ./prepare.sh && ./run.sh.

Preparation downloads the Go module and any declared Python packages once. The workload then runs locally with offline input data. Every meaningful step is a separate process; independent activities run in parallel after their dependencies complete.

This example installs its Python packages in a dedicated .venv: numpy==2.5.4, onnx==1.23.2, torch==2.14.1.

Read outputs/manifest.json for the generated artifacts, outputs/dag-validation.json for dependency waves, and outputs/stage-<activity>.json for each activity's observed result. A failed stage stops the run and prevents a successful final manifest.

Expected outputs: model.onnx, model.torchscript.pt, model-int8.json, model-fp16.bin, validation.json.

Run the same activities in Desktop

Start your local AkôFlow daemon with Docker available and configure AKOFLOW_API_TOKEN in your shell. From this example's directory, run:

go run ../../tools/daemon-local -root ../.. -example machine-learning/model-conversion

This command validates the daemon connection, builds the declared image, registers the local environment and workflow, and submits a real run. The daemon owns execution and file transfers. Open the printed run ID in Desktop to inspect each activity.

Model conversion and quantization. Nodes in the same column can run in parallel once their dependencies complete.

Activity responsibilities

ActivityResponsibility
load-modelExecute the load-model stage and publish its declared outputs for downstream activities.
export-onnxExecute the export-onnx stage and publish its declared outputs for downstream activities.
export-torchscriptExecute the export-torchscript stage and publish its declared outputs for downstream activities.
quantize-cpuExecute the quantize-cpu stage and publish its declared outputs for downstream activities.
quantize-gpuExecute the quantize-gpu stage and publish its declared outputs for downstream activities.
validate-outputsExecute the validate-outputs stage and publish its declared outputs for downstream activities.
publish-variantsExecute the publish-variants stage and publish its declared outputs for downstream activities.

Inputs

  • Canonical model
  • Target formats
  • Tolerance policy

Outputs

  • model.onnx
  • model.torchscript.pt
  • model-int8.json
  • model-fp16.bin
  • validation.json

Provenance to preserve

  • Converter versions
  • Calibration data
  • Target hardware

Source bundle

The executable workflow and its implementation files are maintained in the separate AkôFlow examples repository. The documentation intentionally keeps code, container recipes, generators, and validation scripts out of the narrative page.

Open the complete source bundle ↗

Execution evidence

Verified on local Docker: 7/7 activities completed. These captures belong to run showcase-model-conversion-local-f22e706408-run-20261020t191128.224915000.

Read the daemon execution record · Local output manifest

Open full resolution ↗Model conversion and quantization: observed activity DAG
The observed activity graph. Click to see the complete capture.

Each stage also ran through the standalone local command. Read the dependency and artifact validation.

load-model

After: workflow start.

Open full resolution ↗Execution record for activity load-model

Read the measured local activity result

export-onnx

After: load-model.

Open full resolution ↗Execution record for activity export-onnx

Read the measured local activity result

export-torchscript

After: load-model.

Open full resolution ↗Execution record for activity export-torchscript

Read the measured local activity result

quantize-cpu

After: export-onnx, export-torchscript.

Open full resolution ↗Execution record for activity quantize-cpu

Read the measured local activity result

quantize-gpu

After: export-onnx, export-torchscript.

Open full resolution ↗Execution record for activity quantize-gpu

Read the measured local activity result

validate-outputs

After: quantize-cpu, quantize-gpu.

Open full resolution ↗Execution record for activity validate-outputs

Read the measured local activity result

publish-variants

After: validate-outputs.

Open full resolution ↗Execution record for activity publish-variants

Read the measured local activity result

Execution considerations

Conversion branches can use different images. Validate optimized artifacts on representative target hardware before publication.

AkôFlow boundary: the engine schedules, deploys, executes, transfers data, and records evidence. The ML or agent framework remains an implementation choice inside each activity.