When MATLAB Algorithms Leave Their Development Environment - MATLAB
Video Player is loading.
Current Time 0:00
Duration 17:06
Loaded: 0.97%
Stream Type LIVE
Remaining Time 17:06
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 17:06

    When MATLAB Algorithms Leave Their Development Environment

    You’ve reached a significant milestone in your modeling work and have created an application or model that is ready to be shared with others, deliver results as part of an automated process, or be scaled up using larger compute power. In any case, your code will no longer be executed on your (local) development environment—it will be deployed on a server that is potentially hosted on the cloud.

    The execution platform you choose depends on your use case and whether you want to access a remote compute cluster with many CPUs, access a powerful graphics card for computationally intense calculations, or provide a point-and-click interface to let your users focus on problem-solving, not the algorithm. Alternatively, your code could be executed upon specific calls by other software, as a part of a larger production system, or a mix of all. MathWorks provides a set of tools with various options to facilitate these deployment workflows.

    Published: 27 Feb 2023

    Hello. And thanks for joining us today. I'm Stuart Theakston, Industry Marketing Manager for Financial Services here at MathWorks in Europe. I'm standing in for my colleague, Alex, today. I'm sorry if you were expecting him and now you've got me. But I've got some great stuff to show you, all about the options for getting projects, that you've developed in MATLAB, out into the world, scaling them, deploying them, sharing them, accessing them as web apps, and creating microservices.

    This is just a quick introduction. We've got deeper dive webinars on each of these topics coming up in the next couple of months. I'll come back to those at the end. Please feel free to put your questions in the chat or Q&A box. We'll answer some of them there. Or at the end, I'm going to have a quick chat with my colleague Eddie, who's our technical expert to answer any other questions.

    So let's get started. Here's a bit of a road map of what we're going to talk about today. A very simplified picture of where MATLAB algorithms or models sit in an enterprise. People develop models using data. And then they need to deploy them for other people or processes to use. Sometimes this is called "model execution."

    And we might need to scale those models of both the development stage, or after they've been deployed. And all these processes can live on someone's desktop. But even in the smallest enterprises, it's probably best that they don't. Let's start with half a step back and quickly talk about scaling before your code has left the development environment, while you're still building it and you need something more than a desktop set up.

    We're all very familiar with the MATLAB 101 workflow. You download some data onto your machine. You fire up MATLAB. And you write some code that uses that data. And that's fine as far as it goes. But there's a point at which it simply doesn't scale. Sometimes the data is too large, or you're doing something that's better suited to running on a big GPU, like training a deep learning network.

    And however much you've played around with the profiler, been really careful about your vectorization, just takes too long to run. And a lot of code, particularly at the exploratory analysis development stage, gets written by iteration. Code. Run. Look at the results. Code. Run. Look at the results. And you can only do this as fast as your code takes to run.

    And sure, you can buy a bigger desktop machine. But one, that involves spending money. And two, it's just wasteful buying big PCs for everyone when half the time they're just replying to emails on them, especially when MATLAB scales into the cloud and modern data science environments seamlessly.

    You can run as big a machine instance as you want on AWS, or Azure, or wherever. With big GPUs, if need be, remote into it. And run full desktop MATLAB. MATLAB now sits alongside languages like Python, as having a fully supported Jupyter kernel, as well as prebuilt Docker images with the full desktop MATLAB in them for easy management.

    So you can take advantage of centrally managed, cloud-based, big data environments utilizing pretty much unlimited storage or compute during your development cycle, or at least the limits your AWS will, I guess. So one of the enterprise solutions here is our MATLAB Online Server. Your organization can provide the MATLAB desktop experience to their staff in a browser from a single powerful machine, set of machines, or a cluster.

    If you have used our MATLAB Online, this is like having your own instance of that. It's hosted, managed, and controlled by your organization. User sign in with a corporate credentials and all of the MATLAB licensing options are available as the advantages of being able to bring compute to where the data is.

    And all the functionality that's available on the desktop is available here. Hardware resources are managed by your IT team. And physically, this hardware can be on prem, in your center, or in your organization's infrastructure. And it runs on Kubernetes for scaling.

    Now there's a lot of reasons why users might prefer this. They basically get to run MATLAB a massively grunting machine. But for the enterprise, the significant efficiencies in centrally managed services, over supporting loads of individual user desktop installs-- MATLAB Online Server can be better, more powerful, simpler, and less expensive to run.

    Now I'm going to talk about parallel scaling during the development process a little bit later. But once we've developed our model, whether we did it on our desktop MATLAB or did it in the cloud, we now need to operationalize it. We'll deploy it. We'll distribute it, depending on the use case. But really, this means getting it to people or machines who are going to use that model to make some sort of business decision, rather than those of us who are writing the code.

    And I always like to think that the deployment journey starts when the person sitting next to you turns to you and says, can you run that thing for me?

    How far you need to go, and what tools you use to get there, depend on the use case. Fundamentally, what we want is our business logic that we've coded in MATLAB to get into the hands of some person or process-- doesn't use MATLAB, doesn't care that we did use MATLAB, and doesn't have a MATLAB license. They just want to run our stuff and use the results.

    And we support pretty much every imaginable way in which you might want to do that, starting with MATLAB Compiler, which along with a MATLAB Runtime Library, allows you to package up your code to generate compiled artifacts for each of many common languages, like Java, Python .NET. You can create an Excel add-in. Can deploy queries to the web.

    And for enterprise scaling solutions, you can create Docker containers. You can use MATLAB Production Server. And you can compile artifacts for using MapReduce or frameworks, like Apache spark. Another option, for the sake of completeness, is MATLAB Coder. --enables you to generate C code that you can compile directly into your applications without any runtime.

    This isn't actually that common to use in finance. It's mostly used for embedded code in hardware devices. But we do have some customers in finance using this for high performance applications, like market making.

    So now let's talk about what we can do with those things that we've compiled. Very common easy start is we've got an app that's got a GUI. And we want other people to use it. This could be that person who's sitting next to me always bugging me to rerun stuff. Or it could be someone on the other side of the world on the public internet.

    I'd like to get them using this thing without needing to deploy anything to them. They don't need to install anything. They can just use it, pretty much how they use everything else nowadays, as a web page. For that, I need MATLAB Web App Server. Build my app and App Designer. I package it up with MATLAB Compiler. I deploy it to our web app server. It's as simple as just uploading the CTF file to the web server-- can be.

    And now anyone can point their web browser at it and use it, as long as I've permissioned them to. It comes with all of the security and authentication integrations that you'd expect. The end-user doesn't need a MATLAB license, doesn't need to deploy or run any special software. They don't need admin access to their machine, which is actually quite important in the enterprise.

    And they don't even need to know that they're using MATLAB. Best of all, as the person who wrote the app, I don't need to have that person even talk to me. They just fire up their browser and they get going. What do we get? We get something that looks like this. It's a MATLAB app running in a browser.

    And to get you started, there's even a lightweight version of the web app server shipped with the MATLAB Compiler that you can use just to test this process on your LAN.

    Now let's look at microservices. So there are two options here are essentially, compiling into Docker containers, and using MATLAB Production Server. First, let's look at containerization with Docker. It's very well suited to batch-like workflows, or for microservices on a rest end point.

    And you can use all of your cloud providers container management systems, just like you would for any other Docker container. And you generate Docker images directly from MATLAB Compiler. They contain your code, a runtime, everything you need to execute.

    And then, deploy them into your cloud environment using your normal container deployment tools. If your organization already has an infrastructure for doing this, for scheduling scaling and managing containers, then this is a great option to take advantage of that existing capability.

    But if it doesn't, and you don't particularly want to learn to do all that stuff, then we can do it for you with MATLAB Production Server, which supports as many services as you want, provides that same rest end point, but comes with all the management of security, load balancing, persistence, scheduling. All that's built in.

    And it's as simple as compiling a CTF artifact in MATLAB Compiler, and deploying it to that server. It even supports hot deployment. And firms with a large MATLAB infrastructure often use Production Server to turn their MATLAB analytics into services that can be leveraged from the rest of the enterprise.

    So let's just bring these things together. Because a question people deploying interactive applications often ask me is, when should I use Web App server versus Microservices or a Production Server, sort of restful interface? And it really depends what you're doing. Web app server has everything encapsulated for you, don't need to run anything else.

    So for quick and dirty, getting an app with a GUI out there to others, it's very efficient. It's a great solution for a single developer who's a quant and not a web developer. But it produces something that looks like a MATLAB app. And whilst that's great as far as we're concerned, it's not necessarily what everyone wants.

    Using Production Server or Microservices as the back-end is a more institutional-grade infrastructure. It enables that machine to machine integration of those MATLAB analytics with your enterprise systems, like your enterprise reporting system, for example, and more scaling options.

    And if you're developing a web app on top of that, you have the choice of using whatever web development framework you might prefer. Yes, you need some web development and some infrastructure skills, or a team of people who do, if you're going to go that route.

    So Web Apps, great for prototyping, getting the job done quickly, and a services based approach more appropriate for larger longer lived more complex projects, or where you want to use a particular web development framework. Now let's dig into that scaling layer we've been mentioning.

    We might use this during the development stage or from production applications deployed in any of the ways that I've talked about already.

    Read a code or get your head around any complex distributed computing paradigms. And this code is identical, whether you're prototyping in your machine, to when you scale it up to a full distributed cluster, running MATLAB Parallel Server, which provides cloud or data center based infrastructure for parallelizing beyond the desktop.

    It provides scaling as vast as your hardware will allow, or you can afford, and supports batch jobs, interactive parallel computations, and distributed computations with large matrices. And this is great for the sort of work that I used to do as a hedge fund quant, which was run massive parameter scans across lots of investment strategies looking for stuff that worked. --well, at least worked in sample.

    And the real power here is the flexibility. Because Parallel Server can autoscale based on workloads, a very normal use case would be needing thousands of parallel workers for just a few minutes, US. And you just pay for what you use. And with our Cloud Center, you can do this with zero knowledge of what's going on the underlying machine instances of hardware, or managing any of that. --does it all for you.

    The last thing you want is to have got your code working, only to discover that you have to spend ages massively re-engineering it by hand. Because as soon as you run it on a decent sized data set, it grinds to a halt. Let's be honest, we've all been there. But here, once you're set up, it can be as simple as one click.

    Right. That's pretty much it for a whistle stop tour. I just want to briefly mention Modelscape Deploy, which is part of Modelscape, an enterprise solution for managing the full model lifecycle. Modelscape Deploy is for those organizations with large model estates, coded in multiple languages, particularly in regulated entities like banks.

    Other Modelscape solutions include capabilities for model monitoring and model governance, in line with rules like SR 11-7 and CP 6/22. So that's it. We've covered, very quickly, the whole range of options for when MATLAB algorithms leave their development environment. Starting even before they have, looking at scaling the development process with MATLAB Online Server, Jupyter, and prebuilt Docker containers with a full MATLAB in them.

    We looked at deployment options, including packaging up to run in another language with a runtime, using Web App server, Docker containers, Microservices, and MATLAB Production Server. We talked about massively scaling computations, at any stage of the workflow, using MATLAB Parallel Server. We briefly talked about Modelscape, MathWorks' full enterprise--