Skip to main content

Utilities for ML models targeting hardware triggers

Project description

Machine Learning for Hardware Triggers

triggerflow provides a set of utilities for Machine Learning models targeting FPGA deployment. The TriggerModel class consolidates several Machine Learning frontends and compiler backends to construct a "trigger model". MLflow utilities are for logging, versioning, and loading of trigger models.

Installation

pip install triggerflow

Usage

from triggerflow.core import TriggerModel

triggerflow = TriggerModel(name="my-trigger-model", ml_backend="Keras", compiler="hls4ml", model, compiler_config or None)
triggerflow() # call the constructor

# then:
output_software = triggerflow.software_predict(input_data)
output_firmware = triggerflow.firmware_predict(input_data)
output_qonnx = triggerflow.qonnx_predict(input_data)

# save and load trigger models:
triggerflow.save("triggerflow.tar.xz")

# in a separate session:
from triggerflow.core import TriggerModel
triggerflow = TriggerModel.load("triggerflow.tar.xz")

Logging with MLflow

# logging with MLFlow:
import mlflow
from triggerflow.mlflow_wrapper import log_model

mlflow.set_tracking_uri("https://ngt.cern.ch/models")
experiment_id = mlflow.create_experiment("example-experiment")

with mlflow.start_run(run_name="trial-v1", experiment_id=experiment_id):
    log_model(triggerflow, registered_model_name="TriggerModel")

Note: This package doesn't install dependencies so it won't disrupt specific training environments or custom compilers. For a reference environment, see environment.yml.

Creating a kedro pipeline

This repository also comes with a default pipeline for trigger models based on kedro. One can create a new pipeline via:

NOTE: no "-" and upper cases!

# Create a conda environment & activate it
conda create -n triggerflow python=3.11
conda activate triggerflow

# install triggerflow
pip install triggerflow

# Create a pipeline
triggerflow new demo_pipeline

# NOTE: since we dont install dependency one has to create a
# conda env based on the environment.yml file of the pipeline
# this file can be changed to the needs of the indiviual project
cd demo_pipeline
conda env update -n triggerflow --file environment.yml

# Run Kedro
kedro run

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

triggerflow-0.2.1.tar.gz (42.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

triggerflow-0.2.1-py3-none-any.whl (69.6 kB view details)

Uploaded Python 3

File details

Details for the file triggerflow-0.2.1.tar.gz.

File metadata

  • Download URL: triggerflow-0.2.1.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for triggerflow-0.2.1.tar.gz
Algorithm Hash digest
SHA256 68992a47db72eb6ee542ba2073daaa68d084f19c11942c542b8e04078aa50f27
MD5 c22ddc34a0410221fd2cfdbf4c5331fa
BLAKE2b-256 d058dbd1425b120774b8532d6395306896a038b5fb9d080554ce50cd0a0dd66f

See more details on using hashes here.

File details

Details for the file triggerflow-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: triggerflow-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 69.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for triggerflow-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9edb3e04c95ca69c34fff39b6d587aa5abfc26dc2c85a29dae3ad39e2cb8cffb
MD5 e14f4565a57d5e2f9eefcb6c17a4a270
BLAKE2b-256 5c6592fc78d8edcf88c3b92f8e5150e2fb8fb7a1f9c443d17489da1fc1ea4fe1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page