Live data from Hacker News

Show HN: Carton – Run any ML model from any programming language

carton.run

1–10 of 59 posts

Show HN: Carton – Run any ML model from any programming language

#1
The goal of Carton is to let you use a single interface to run any machine learning model from any programming language.

It’s currently difficult to integrate models that use different technologies (e.g. TensorRT, Ludwig, TorchScript, JAX, GGML, etc) into your application, especially if you’re not using Python. Even if you learn the details of integrating each of these frameworks, running multiple frameworks in one process can cause hard-to-debug crashes.

Ideally, the ML framework a model was developed in should just be an implementation detail. Carton lets you decouple your application from specific ML frameworks so you can focus on the problem you actually want to solve.

At a high level, the way Carton works is by running models in their own processes and using an IPC system to communicate back and forth with low overhead. Carton is primarily implemented in Rust, with bindings to other languages. There are lots more details linked in the architecture doc below.

Importantly, Carton uses your model’s original underlying framework (e.g. PyTorch) under the hood to actually execute the model. This is meaningful because it makes Carton composable with other technologies. For example, it’s easy to use custom ops, TensorRT, etc without changes. This lets you keep up with cutting-edge advances, but decouples them from your application.

I’ve been working on Carton for almost a year now and I’m excited to open source it today!

Some useful links:

* Website, docs, quickstart - https://carton.run

* Explore existing models - https://carton.pub

* Repo - https://github.com/VivekPanyam/carton

* Architecture - https://github.com/VivekPanyam/carton/blob/main/ARCHITECTURE...

Please let me know what you think!

Show HN: Carton – Run any ML model from any programming language
carton.run

Re: Show HN: Carton – Run any ML model from any programming language

#3
post #2

So this means if I want to use a ML model I made in python, but don't want to code the rest of the application in python I can do that?

Yes, that's a use case Carton supports.

For exmaple, if your model contains arbitrary Python code, you'd pack it using [1] and then you could load it from another language using [2]. In this case, Carton transparently spins up an isolated Python interpreter under the hood to run your model (even if the rest of your application is in another language).

You can take it one step further if you're using certain DL frameworks. For example, you can create a TorchScript model in Python [3] and then use it from any programming language Carton supports without requiring python at runtime (i.e. your model runs completely in native code).

[1] https://carton.run/docs/packing/python

[2] https://carton.run/docs/loading

[3] https://carton.run/docs/packing/torchscript

Re: Show HN: Carton – Run any ML model from any programming language

#4
post #3
post #2

So this means if I want to use a ML model I made in python, but don't want to code the rest of the application in python I can do that?

Yes, that's a use case Carton supports. For exmaple, if your model contains arbitrary Python code, you'd pack it using [1] and then you could load it from another language using [2]. In this case, Carton transparently spins up an isolated Python interpreter under the hood to run your model (even if the rest of your application is in another language). You can take it one step further if you're using certain DL framew…

That’s awesome! Thanks for making this

Re: Show HN: Carton – Run any ML model from any programming language

#5
post #3
post #2

So this means if I want to use a ML model I made in python, but don't want to code the rest of the application in python I can do that?

Yes, that's a use case Carton supports. For exmaple, if your model contains arbitrary Python code, you'd pack it using [1] and then you could load it from another language using [2]. In this case, Carton transparently spins up an isolated Python interpreter under the hood to run your model (even if the rest of your application is in another language). You can take it one step further if you're using certain DL framew…

Seems almost too good to be true, but I really hope it's not. How does it handle things like CUDA dependencies? Can it somehow make those portable too? Or is GPU acceleration not quite there yet?

Re: Show HN: Carton – Run any ML model from any programming language

#8
post #3

Earlier quoted context omitted.

Yes, that's a use case Carton supports. For exmaple, if your model contains arbitrary Python code, you'd pack it using [1] and then you could load it from another language using [2]. In this case, Carton transparently spins up an isolated Python interpreter under the hood to run your model (even if the rest of your application is in another language). You can take it one step further if you're using certain DL framew…

Seems almost too good to be true, but I really hope it's not. How does it handle things like CUDA dependencies? Can it somehow make those portable too? Or is GPU acceleration not quite there yet?

Thanks :)

It uses the NVIDIA drivers on your system, but it should be possible to make the rest of CUDA somewhat portable. I have a few thoughts on how to do this, but haven't gotten around to it yet.

The current GPU enabled torch runners use a version of libtorch that's statically linked against the CUDA runtime libraries. So in theory, they just depend on your GPU drivers and not your CUDA installation. I haven't yet tested on a machine that has just the GPU drivers installed (i.e without CUDA), but if it doesn't already work, it should be very possible to make it work.

Re: Show HN: Carton – Run any ML model from any programming language

#9
post #6

> Carton wraps your model with some metadata and puts it in a zip file Why a zip file?

zip-file-as-a-container-format seems pragmatic: it's a way to bundle multiple files into one file (easier to manage than scattering multiple files), it avoids introducing a new proprietary format, it can optionally be compressed, support for reading and writing the container format is already widespread.

To give two examples of prior art, it worked for Quake 3 data files (.pk3) & geospatial data files (.kmz)

Maybe it's not the best choice but it doesn't seem like a bad one.

Re: Show HN: Carton – Run any ML model from any programming language

#10
post #6

> Carton wraps your model with some metadata and puts it in a zip file Why a zip file?

In addition to the benefits mentioned in the sibling comment, zip files let you seek to and access individual files in the archive without extracting all files (vs tar files for example).

This lets us do things like fetch model metadata [1] for a large remote model, by only fetching a few tiny byte ranges instead of the whole model archive.

It also means you can include sample data (images, etc) with your model and they're only fetched when necessary (for example with stable diffusion: https://carton.pub/stabilityai/sdxl)

[1] https://carton.run/docs/metadata

Post reply on HN