On Wed, Jan 25, 2023 at 7:50 PM Thomas Monjalon <tho...@monjalon.net> wrote: > > 14/11/2022 13:02, jer...@marvell.com: > > From: Jerin Jacob <jer...@marvell.com> > > > > Machine learning inference library > > ================================== > > > > Definition of machine learning inference > > ---------------------------------------- > > Inference in machine learning is the process of making an output prediction > > based on new input data using a pre-trained machine learning model. > > > > The scope of the RFC would include only inferencing with pre-trained > > machine learning models, > > training and building/compiling the ML models is out of scope for this RFC > > or > > DPDK mldev API. Use existing machine learning compiler frameworks for model > > creation. > > > > Motivation for the new library > > ------------------------------ > > Multiple semiconductor vendors are offering accelerator products such as DPU > > (often called Smart-NIC), FPGA, GPU, etc., which have ML inferencing > > capabilities > > integrated as part of the product. Use of ML inferencing is increasing in > > the domain > > of packet processing for flow classification, intrusion, malware and > > anomaly detection. > > > > Lack of inferencing support through DPDK APIs will involve complexities and > > increased latency from moving data across frameworks (i.e, dataplane to > > non dataplane ML frameworks and vice-versa). Having a standardized DPDK > > APIs for ML > > inferencing would enable the dataplane solutions to harness the benefit of > > inline > > inferencing supported by the hardware. > > > > Contents > > --------------- > > > > A) API specification for: > > > > 1) Discovery of ML capabilities (e.g., device specific features) in a vendor > > independent fashion > > 2) Definition of functions to handle ML devices, which includes probing, > > initialization and termination of the devices. > > 3) Definition of functions to handle ML models used to perform inference > > operations. > > 4) Definition of function to handle quantize and dequantize operations > > > > B) Common code for above specification
Thanks for the review. > > Can we compare this library with WinML? > https://learn.microsoft.com/en-us/windows/ai/windows-ml/api-reference Proposed DPDK library supports only inferencing with pre-trained models. > Is there things we can learn from it? Comparing to winML, API provide functionality similar to "LearningModel*" classes provides. Support related to handling custom operators and Native APIs like winML is provided through this API. There may more features which we can add where there are drivers which supports it. > > > > ML Model: An ML model is an algorithm trained over a dataset. A model > > consists of > > procedure/algorithm and data/pattern required to make predictions on live > > data. > > Once the model is created and trained outside of the DPDK scope, the model > > can be loaded > > via rte_ml_model_load() and then start it using rte_ml_model_start() API. > > The rte_ml_model_params_update() can be used to update the model parameters > > such as weight > > and bias without unloading the model using rte_ml_model_unload(). > > The fact that the model is prepared outside means the model format is free > and probably different per mldev driver. > I think it is OK but it requires a lot of documentation effort to explain > how to bind the model and its parameters with the DPDK API. > Also we may need to pass some metadata from the model builder > to the inference engine in order to enable optimizations prepared in the > model. > And the other way, we may need inference capabilities in order to generate > an optimized model which can run in the inference engine. The base API specification kept absolute minimum. Currently, weight and biases parameters updated through rte_ml_model_params_update(). It can be extended when there are drivers supports it or if you have any specific parameter you would like to add it in rte_ml_model_params_update(). Other metadata data like batch, shapes, formats queried using rte_ml_io_info(). > > > [...] > > Typical application utilisation of the ML API will follow the following > > programming flow. > > > > - rte_ml_dev_configure() > > - rte_ml_dev_queue_pair_setup() > > - rte_ml_model_load() > > - rte_ml_model_start() > > - rte_ml_model_info() > > - rte_ml_dev_start() > > - rte_ml_enqueue_burst() > > - rte_ml_dequeue_burst() > > - rte_ml_model_stop() > > - rte_ml_model_unload() > > - rte_ml_dev_stop() > > - rte_ml_dev_close() > > Where is parameters update in this flow? Added the mandatory APIs in the top level flow doc. rte_ml_model_params_update() used to update the parameters. > Should we update all parameters at once or can it be done more fine-grain? Currently, rte_ml_model_params_update() can be used to update weight and bias via buffer when device is in stop state and without unloading the model. > > > Question about the memory used by mldev: > Can we manage where the memory is allocated (host, device, mix, etc)? Just passing buffer pointers now like other subsystem. Other EAL infra service can take care of the locality of memory as it is not specific to ML dev. +/** ML operation's input and output buffer representation as scatter gather list + */ +struct rte_ml_buff_seg { + rte_iova_t iova_addr; + /**< IOVA address of segment buffer. */ + void *addr; + /**< Virtual address of segment buffer. */ + uint32_t length; + /**< Segment length. */ + uint32_t reserved; + /**< Reserved for future use. */ + struct rte_ml_buff_seg *next; + /**< Points to next segment. Value NULL represents the last segment. */ +}; > >