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.tar.gz (42.0 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-py3-none-any.whl (69.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: triggerflow-0.2.tar.gz
  • Upload date:
  • Size: 42.0 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.tar.gz
Algorithm Hash digest
SHA256 a89ed757c738531d6bb9bdb36144758b09aa0f3cc213c2dcabe8fbcd4c7b6f0a
MD5 ccbb6634aa48a7171c79bd2bc1ef2ff3
BLAKE2b-256 0ea7b707540352a669b9e695532fcb64a5e2241668e61ea00e40b852aaf1585b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: triggerflow-0.2-py3-none-any.whl
  • Upload date:
  • Size: 69.1 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-py3-none-any.whl
Algorithm Hash digest
SHA256 87d35bada8debfc15bf47b367679fc253a6fdc41009c1c0aace87f016dc1786d
MD5 a77141971b1c40bfdefe4e3eb7696874
BLAKE2b-256 53e63f84b4926a1e96805f29c62243384c9f9b2f076f726d657deb673fba9ced

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