<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mlops on Letters From The Wild Side</title><link>/tags/mlops/</link><description>Recent content in Mlops on Letters From The Wild Side</description><generator>Hugo -- gohugo.io</generator><language>en-uk</language><lastBuildDate>Sun, 29 Aug 2021 00:00:00 +0000</lastBuildDate><atom:link href="/tags/mlops/index.xml" rel="self" type="application/rss+xml"/><item><title>Flutter and Microservices</title><link>/p/flutter-and-microservices/</link><pubDate>Sun, 29 Aug 2021 00:00:00 +0000</pubDate><guid>/p/flutter-and-microservices/</guid><description>&lt;p&gt;Last modified: May-29-2022, 02:40PM +08&lt;/p&gt;
&lt;h1 id="flutter-web-and-microservices"&gt;Flutter Web and Microservices
&lt;/h1&gt;&lt;p&gt;If one ever needs to deploy neural-based services that can scale to zero, one of the best
options include a client-server architecture that is based on microservices. This is not
a comparison between software architecture design patterns, but rather an evaluation
on the feasibility of flutter and microservices.&lt;/p&gt;
&lt;p&gt;In most web applications, there is a common process which involves data aggregation
and processing for downstream tasks. Some of those tasks include analytics, error reporting
and threat monitoring. These tasks often come from different domains of data science, cybersecurity,
cryptography, database, networking and distributed computing. It would be infeasible and
impractical to expect any single programming language to cater to each and every domain.
Not forgetting users of every level, ranging from novices to experts and public to
enterprise.&lt;/p&gt;
&lt;p&gt;The natural and intuitive solution to this hard requirement of cross-domain resources
quickly points to a modularity of recomposing units with service granularity. Individual services
can be improved incrementally, agnostic of language and platform. Communication can be
independent or inter-dependent between separate components hosted on the same server.
Seamless integration allows monolithic legacy and modern subsystems to be fully integrated.&lt;/p&gt;
&lt;p&gt;Flexible integration with third-party resources such as autocomplete search engines, databases and
object-stores are fully swappable for new frameworks and technologies in the future to
prevent vendor lock-in.&lt;/p&gt;
&lt;p&gt;Most managed backend solutions on the market today fully supports encrypted traffic with
HTTPS. There is little reason not to secure and safeguard the user&amp;rsquo;s data and privacy
against malicious actors looking to exploit zero-day vulnerabilities. There is a global
community effort in developing and maintaining security standards and protocols which
serve the needs of billions of users on the internet. These open-source cryptographic libraries
form a critical part of the arsenal available to developers, without resource-stricken proprietary
libraries exposing the attack surface.&lt;/p&gt;
&lt;p&gt;The microservice developer also has access to open-source and efficient media codecs for
both transmission and storage. Attributes of a microservice architecture are well suited for a rapid
evolving technology that is seeking regional and global reach.&lt;/p&gt;
&lt;h2 id="development"&gt;Development
&lt;/h2&gt;&lt;p&gt;Common message formats include &lt;a class="link" href="https://developer.mozilla.org/en-US/docs/Web/HTTP" target="_blank" rel="noopener"
 &gt;HTTP&lt;/a&gt;, &lt;a class="link" href="https://grpc.io/" target="_blank" rel="noopener"
 &gt;gRPC&lt;/a&gt;, &lt;a class="link" href="https://graphql.org/" target="_blank" rel="noopener"
 &gt;GraphQL&lt;/a&gt; and &lt;a class="link" href="https://en.wikipedia.org/wiki/WebSocket" target="_blank" rel="noopener"
 &gt;WebSocket&lt;/a&gt; providing
uni/bidirectional communication channel depending on the application. Maturity of these
standards and protocols allow them to be widely implemented in languages popular with web
development. With the advent of microservices in the early 2010s, &lt;a class="link" href="https://www.docker.com/," title="Docker"
 target="_blank" rel="noopener"
 &gt;Docker&lt;/a&gt; remains
a popular tool for local development of containers.&lt;/p&gt;
&lt;p&gt;There has been ongoing work on porting docker to Internet-of-Things(IoT), mobile and GPU
platforms. The same codebase for any particular microservice can be easily adapted to
target a diversity of platforms during expansion into surrounding markets. This is
evident in the growing number of cross-platform web applications. The targeting platform
can be expanded to include x86, ARM, RISC-V, NVPTX or AMD ISA, not excluding FPGAs and
ASICs.&lt;/p&gt;
&lt;p&gt;Service endpoints comprise of IoT, dedicated servers and public cloud for both internal
and public facing APIs. To efficiently scale to millions of users, a container orchestration
tool such as &lt;a class="link" href="https://kubernetes.io/" target="_blank" rel="noopener"
 &gt;Kubernetes&lt;/a&gt; should be utilized to manage network traffic
and computing resources.&lt;/p&gt;
&lt;p&gt;Driven by open-source momentum, a healthy and growing ecosystem of developer tools is the
end result of that collective effort. There is no lack of options targeting different
niches of the technology stack required to bring a minimal viable product(MVP) to satisfy
early adopters, which in turn provide valuable feedback for the next product iteration.&lt;/p&gt;
&lt;p&gt;The adoption of continuous integration and continuous deployment(CI/CD) best practices
simplifies testing and deployment of microservices. This strategy enables the timely
delivery of new features on budget.&lt;/p&gt;
&lt;h2 id="deployment"&gt;Deployment
&lt;/h2&gt;&lt;p&gt;Once a microservice is deployed, its API will accept authenticated requests for identity
authentication and access-control of resources. Further restrictions on CPU, memory or
GPU are enforced through configurations flags. Resource requirements can be
forecasted based on usage patterns during off-peak and peak periods. Service granularity
allows real time procurement of additional resources before spikes in traffic and also scaling
to zero for deprecated services.&lt;/p&gt;
&lt;p&gt;Containers by default have restricted access to host resources and they run in isolation
with regards to other processes on the host system. A microservice being self-contained
and coupled with its dependencies can be deployed in parallel with version control.
As user base grows, vertical and horizontal scaling of these containers is what allow
microservice to be scalable across different regions via cloud.&lt;/p&gt;
&lt;p&gt;The high development cost is compensated by low cost of entry and low running costs
with generous credits from public clouds. Network latency is offset with load-balancing proxies,
CDNs and regional deployment with redundancies to ensure high availability to users.&lt;/p&gt;
&lt;p&gt;Fine-grained handling and securing of network traffic is done using a service mesh such
as &lt;a class="link" href="https://istio.io/" target="_blank" rel="noopener"
 &gt;Istio&lt;/a&gt;, &lt;a class="link" href="https://traefik.io/" target="_blank" rel="noopener"
 &gt;Traefik&lt;/a&gt; or in-house solution. API
security is enforced through threat and error monitoring with logging/tracing. To ensure
high availability, periodic health checks are conducted on endpoints. In the event of
a disruption, the operations team will be notified within seconds while an automated
rollback or spinning of new instances during surges will take place simultaneously.&lt;/p&gt;
&lt;p&gt;This composition of behaviors ensure the microservice stays fault-tolerant.&lt;/p&gt;
&lt;h2 id="security"&gt;Security
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;OAuth2&lt;/li&gt;
&lt;li&gt;SAML&lt;/li&gt;
&lt;li&gt;JWT&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="future-applications"&gt;Future Applications
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Self-driving vehicles and autopilot UI&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Self-planning residential and industrial robots with remote human intervention&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Self-organizing behavior in drone swarms at scale with mining and agriculture industries&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implementation of the first distributed superintelligence with a brain-computer
interface&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A bundle of artificial intelligence(AI) tools with the analogy of the Swiss army knife&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="whats-next"&gt;What&amp;rsquo;s Next?
&lt;/h2&gt;&lt;p&gt;Experimentation of running neural-based eBPF programs as microservices with flutter.&lt;/p&gt;
&lt;h2 id="summary"&gt;Summary
&lt;/h2&gt;&lt;p&gt;Attributes of a microservice architecture are well suited for a rapid evolving technology
that is seeking regional and global reach.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;healthy, growing ecosystem of developer tools and CI/CD best practices ensures timely
delivery of new features on budget.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;composition of service granularity, identity and access control of resources ensures
the microservice to remain fault-tolerant and highly available.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;API security&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;future applications&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;</description></item><item><title>ML Engineering</title><link>/p/ml-engineering/</link><pubDate>Tue, 08 Jun 2021 00:00:00 +0000</pubDate><guid>/p/ml-engineering/</guid><description>&lt;p&gt;Last modified: Dec-14-2021, 10:35PM +08&lt;/p&gt;
&lt;h1 id="from-manual-to-semi-automatic"&gt;From Manual To Semi-Automatic
&lt;/h1&gt;&lt;p&gt;Before the advent of the concept &amp;ldquo;MLOps&amp;rdquo;, getting a single machine learning(ML) model to
production was tedious and belaboring. Every single detail pertaining to the inputs,
model server, training and inference have to be defined explicitly. This is to ensure the
input tensors follow a strict requirement for them to be processed by user defined
functions.&lt;/p&gt;
&lt;p&gt;To serve a single model, these predefined configurations have to be under version
control as the ML field and software ecosystem is accelerating at near exponential
speeds. In addition to the model, version control has to be applied to the training data
as well as the software infrastructure that is used to host the model. A working
production pipeline is like a moving train loading and offloading compartments to keep up
with cutting-edge development.&lt;/p&gt;
&lt;p&gt;After the release of &lt;a class="link" href="https://ieeexplore.ieee.org/abstract/document/5206848" title="ImageNet"
 target="_blank" rel="noopener"
 &gt;ImageNet&lt;/a&gt; dataset,
there was tremendous effort poured into surpassing the human baseline. In the early
2010s, that
&lt;a class="link" href="https://kr.nvidia.com/content/tesla/pdf/machine-learning/imagenet-classification-with-deep-convolutional-nn.pdf" title="baseline"
 target="_blank" rel="noopener"
 &gt;baseline&lt;/a&gt; was exceeded with the combination of readily available data, open-source frameworks and modern computing
resources that can be bought off the shelf. However, being proficient in these resources was restricted to experts
and those within the technical community. Developer sanity was largely dependant on up-to-date documentation
or comments within the source where documentation was absent.&lt;/p&gt;
&lt;p&gt;In the mid 2010s, a number of Deep Learning(DL) frameworks were designed to unify the
common primitives in building these DL models. These include
&lt;a class="link" href="https://www.tensorflow.org/" title="TensorFlow"
 target="_blank" rel="noopener"
 &gt;TensorFlow&lt;/a&gt;, &lt;a class="link" href="https://keras.io/" title="Keras"
 target="_blank" rel="noopener"
 &gt;Keras&lt;/a&gt;,
&lt;a class="link" href="https://pytorch.org/" title="PyTorch"
 target="_blank" rel="noopener"
 &gt;Pytorch&lt;/a&gt;, &lt;a class="link" href="https://mxnet.apache.org/versions/1.8.0/" title="mxnet"
 target="_blank" rel="noopener"
 &gt;Apache MXNet&lt;/a&gt; and many others.&lt;/p&gt;
&lt;p&gt;To tackle the problem of productionizing models, one of the solutions explored was the usage
of &lt;a class="link" href="https://www.docker.com/" title="Docker"
 target="_blank" rel="noopener"
 &gt;Docker&lt;/a&gt; containers, to package both the dependencies and the actual model as lightweight
components that can be easily shared through a public repository. This approach greatly
democratize the deployment of DL models to common hosting providers like the public clouds
or in-house servers.&lt;/p&gt;
&lt;p&gt;The natural progression in using Docker containers meant the inclusion of shell scripts,
cron jobs and triggers that allow the automation of the entire ML pipeline. Docker-based
workflows gave developers access to version controlled resources locally on their laptops
and globally across different time zones.&lt;/p&gt;
&lt;h2 id="components-based-workflow"&gt;Components-Based Workflow
&lt;/h2&gt;&lt;p&gt;For organizations that need to scale to millions of containers in production, the
de facto solution include container orchestration platforms such as
&lt;a class="link" href="https://kubernetes.io/" title="Kubernetes"
 target="_blank" rel="noopener"
 &gt;Kubernetes&lt;/a&gt;. The platform allows hundreds and
thousands of engineers to collaborate on different levels of a complex ML system. This
ranges from low level implementation of hardware drivers to the high level design of
user-interfaces such as click-and-drag block diagrams.&lt;/p&gt;
&lt;p&gt;The low-code or no-code approach is an industry effort to lower the cognitive strain
in designing complex ML models. The design and implementation of mission-critical models
requires non-trivial engineering efforts, so why should their deployment be unnecessarily complex?&lt;/p&gt;
&lt;p&gt;Behind the scenes of the components-based workflow lies Kubernetes applications such as
&lt;a class="link" href="https://argoproj.github.io/argo-workflows/" title="Argo Workflows"
 target="_blank" rel="noopener"
 &gt;Argo Workflows&lt;/a&gt;,
&lt;a class="link" href="https://tekton.dev/" title="Tekton"
 target="_blank" rel="noopener"
 &gt;Tekton&lt;/a&gt; as well as many others. These applications specify
steps in a ML pipeline as containers that can spun up sequentially or in parallel. These
steps can be expressed as a directed acyclic graph(DAG), which can be version controlled
and compiled for export to different hardware architectures.&lt;/p&gt;
&lt;p&gt;Initially, we had manual design, hand-tuned and hand-crafted models without A/B testing
because deployment of new models simply could not keep up with the development of a core
application(4~6 weeks cycle). Now we can churn dozens of models daily in parallel, set to trigger on
arrival of new data or based on adjacent/over-lapping time windows. The models that
passed evaluation are then uploaded to a model repository for further downstream
processes.&lt;/p&gt;
&lt;h2 id="cautionary-tales"&gt;Cautionary Tales
&lt;/h2&gt;&lt;p&gt;A majority of kubernetes applications are rather new to the scene, many more are emerging
to solve critical issues pertaining to storage, security, networking and other
peripherals. Choosing the right software stack requires an in-depth technical review of
existing solutions with respect to dimensions of correctness, latency and costs.&lt;/p&gt;
&lt;p&gt;At the SME scale, one single competent ML engineer is the bare requirement for a
sufficiently complex ML system, serving requests up to the number of CPU cores procured with
default settings.&lt;/p&gt;
&lt;p&gt;At the enterprise scale, ML engineering is not well suited to be an one-man job, but
rather spread across different teams with each being a subject matter expert on their domains.&lt;/p&gt;
&lt;h2 id="whats-next"&gt;What&amp;rsquo;s Next
&lt;/h2&gt;&lt;p&gt;Currently working on a regression pipeline, targeting TensorFlow.js models to be deployed
in a Flutter application, hosted by Firebase. The pipeline is designed to be agnostic to
regression problem domains. Future regression tasks include cryptocurrency market size,
health monitoring, renewable energy forecasts and EV tank-to-wheel
efficiency(70~90%).&lt;/p&gt;
&lt;p&gt;Other pipelines include tasks under the pillars of ML:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;classification&lt;/li&gt;
&lt;li&gt;density-estimation&lt;/li&gt;
&lt;li&gt;dimensionality-reduction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pipelines for generative models are in the roadmap as well.&lt;/p&gt;
&lt;p&gt;Incorporating accelerators such as GPUs or TPUs into pipeline to further parallelize existing
workflows.&lt;/p&gt;
&lt;hr&gt;</description></item></channel></rss>