flowmesh 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flowmesh-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 The FlowMesh Authors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowmesh
3
+ Version: 0.1.0
4
+ Summary: FlowMesh: A Multi-tenant Service Fabric for LLM Agentic Workflows
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Provides-Extra: sdk
10
+ Requires-Dist: flowmesh-sdk==0.1.0; extra == "sdk"
11
+ Provides-Extra: cli
12
+ Requires-Dist: flowmesh-cli[stack]==0.1.0; extra == "cli"
13
+ Provides-Extra: hook
14
+ Requires-Dist: flowmesh-hook==0.1.0; extra == "hook"
15
+ Provides-Extra: all
16
+ Requires-Dist: flowmesh-cli[stack]==0.1.0; extra == "all"
17
+ Requires-Dist: flowmesh-hook==0.1.0; extra == "all"
18
+ Requires-Dist: flowmesh-sdk==0.1.0; extra == "all"
19
+ Dynamic: license-file
20
+
21
+ # FlowMesh
22
+
23
+ [![arXiv](https://img.shields.io/badge/arXiv-2510.26913-b31b1b.svg)](https://arxiv.org/abs/2510.26913)
24
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
25
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
26
+ [![Lint](https://github.com/mlsys-io/FlowMesh/actions/workflows/lint-typecheck.yml/badge.svg)](https://github.com/mlsys-io/FlowMesh/actions/workflows/lint-typecheck.yml)
27
+ [![Tests](https://github.com/mlsys-io/FlowMesh/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/mlsys-io/FlowMesh/actions/workflows/unit-tests.yml)
28
+
29
+ A service fabric for running LLM agentic workflows on distributed GPU workers.
30
+
31
+ FlowMesh accepts workflow definitions (YAML, JSON, or n8n graph format), parses
32
+ them into a DAG of tasks, schedules and dispatches each task to a suitable
33
+ worker, and collects results and artifacts. It supports inference (vLLM, HF
34
+ transformers, diffusers), training (SFT, LoRA, DPO, PPO), retrieval-augmented
35
+ generation, agent execution, SSH-style interactive sessions, and arbitrary
36
+ container jobs.
37
+
38
+ ## Architecture
39
+
40
+ ```
41
+ Client (CLI / SDK / HTTP)
42
+
43
+ ▼ HTTP (default 8000)
44
+ ┌─────────────────────────────────────────────────┐
45
+ │ Server (FastAPI orchestrator) │
46
+ │ • workflow parsing, DAG resolution │
47
+ │ • task scheduling and dispatch │
48
+ │ • result and artifact collection │
49
+ │ • REST API + SSE log streaming │
50
+ └──────────────┬──────────────────────────────────┘
51
+ │ Redis pub/sub (control + telemetry)
52
+
53
+ ┌─────────────────────────────────────────────────┐
54
+ │ Supervisor (per-node agent) │
55
+ │ • registers node, manages worker containers │
56
+ │ • relays tasks/events via gRPC streams │
57
+ └──────────────┬──────────────────────────────────┘
58
+ │ gRPC (default 50051)
59
+
60
+ ┌─────────────────────────────────────────────────┐
61
+ │ Worker (executor process) │
62
+ │ • vllm, transformers, diffusers, training, │
63
+ │ RAG, agent, SSH, echo, data profiling │
64
+ │ • streams logs and events back via gRPC │
65
+ └─────────────────────────────────────────────────┘
66
+ ```
67
+
68
+ Server and Worker are the two top-level processes. The **Supervisor** is a
69
+ subsystem that lives under `src/server/` and runs as a child process spawned
70
+ from the server (`multiprocessing.Process`); single-node deployments spawn
71
+ one supervisor child alongside the server, multi-node deployments run a root
72
+ server plus one supervisor-only server process per worker node.
73
+
74
+ ## Quick start
75
+
76
+ Requires Docker, Docker Compose, and Python 3.12+. If you want to use GPU
77
+ workers, ensure the NVIDIA Container Toolkit is also installed.
78
+
79
+ ```bash
80
+ # 1. Install
81
+ git clone https://github.com/mlsys-io/FlowMesh.git
82
+ cd FlowMesh
83
+ pip install uv
84
+ uv sync --all-packages --group ci
85
+
86
+ # 2. Bring up the local stack (Server + Redis + Supervisor)
87
+ uv run flowmesh stack up
88
+
89
+ # 3. Start one CPU worker
90
+ uv run flowmesh stack worker up cpu 1
91
+
92
+ # 4. Submit a workflow
93
+ uv run flowmesh workflow submit examples/templates/echo_local.yaml
94
+
95
+ # 5. Watch it run
96
+ uv run flowmesh workflow list
97
+ uv run flowmesh workflow watch <workflow_id>
98
+ ```
99
+
100
+ For a GPU worker:
101
+
102
+ ```bash
103
+ # Pin to specific GPUs (or 'all')
104
+ uv run flowmesh stack worker up gpu --targets 0
105
+ ```
106
+
107
+ For inference templates:
108
+
109
+ ```bash
110
+ uv run flowmesh workflow submit examples/templates/inference_vllm_chat.yaml
111
+ uv run flowmesh workflow submit examples/templates/inference_hf_chat.yaml
112
+ ```
113
+
114
+ Tear down:
115
+
116
+ ```bash
117
+ uv run flowmesh stack worker down all
118
+ uv run flowmesh stack down
119
+ ```
120
+
121
+ ## Workflow format
122
+
123
+ A minimal single-task workflow:
124
+
125
+ ```yaml
126
+ apiVersion: flowmesh/v1
127
+ kind: InferenceTask
128
+ metadata:
129
+ name: hello-inference
130
+ spec:
131
+ taskType: inference
132
+ resources:
133
+ hardware: { gpu: { type: any, count: 1 } }
134
+ model:
135
+ source: { type: huggingface, identifier: TinyLlama/TinyLlama-1.1B-Chat-v1.0 }
136
+ vllm: { gpu_memory_utilization: 0.5 }
137
+ data:
138
+ type: list
139
+ items:
140
+ - - role: user
141
+ content: What is the capital of France?
142
+ inference: { max_tokens: 64, temperature: 0.0 }
143
+ output:
144
+ destination: { type: http }
145
+ ```
146
+
147
+ Multi-stage DAGs, conditional execution, graph-template prompts, task merging,
148
+ and SSH sessions are all supported. See `examples/templates/` for end-to-end examples
149
+ and `AGENTS.md` for the full schema reference.
150
+
151
+ ## Extending FlowMesh
152
+
153
+ FlowMesh exposes plugin hooks for organisations that want to layer additional
154
+ auth, submission policy, usage tracking, authorisation, supplier attribution,
155
+ or resource lifecycle behaviour on top of the core server. Install the
156
+ standalone hook contract with:
157
+
158
+ ```bash
159
+ pip install "flowmesh[hook]"
160
+ ```
161
+
162
+ A plugin is any Python module that exposes `install()` returning
163
+ `flowmesh_hook.HookBindings`. Plugins are loaded by setting
164
+ `FLOWMESH_PLUGINS` to a comma-separated list of importable module names.
165
+ Plugins can ship as in-tree modules, sibling-mounted packages, or
166
+ pip-installable wheels — the core never references plugin names.
167
+
168
+ See [`docs/PLUGINS.md`](docs/PLUGINS.md) for the full plugin contract.
169
+
170
+ ## Development
171
+
172
+ ```bash
173
+ # Install dev tooling
174
+ uv sync --all-packages --group ci
175
+
176
+ # Format / lint / type-check
177
+ uv run pre-commit run --all-files
178
+
179
+ # Tests — skip the multiprocessing GPU-cleanup test because it requires a
180
+ # real CUDA device and isolated processes; CI also skips it.
181
+ uv run pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py
182
+ ```
183
+
184
+ Detailed contributor docs (project layout, env vars, dispatch internals,
185
+ executor registry, commit-message conventions) live in `AGENTS.md`.
186
+
187
+ ## Contributing
188
+
189
+ We welcome bug fixes, new features, documentation improvements, and feedback.
190
+ Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) for the contributor setup,
191
+ code style, testing, dependency-pin, and DCO sign-off conventions, and
192
+ [`AGENTS.md`](AGENTS.md) for a deeper architecture and source-layout tour.
193
+
194
+ ## Citation
195
+
196
+ If you use FlowMesh in your research, please cite:
197
+
198
+ ```bibtex
199
+ @misc{shen2025flowmesh,
200
+ title={FlowMesh: A Service Fabric for Composable LLM Workflows},
201
+ author={Junyi Shen and Noppanat Wadlom and Lingfeng Zhou and Dequan Wang and Xu Miao and Lei Fang and Yao Lu},
202
+ year={2025},
203
+ eprint={2510.26913},
204
+ archivePrefix={arXiv},
205
+ primaryClass={cs.DC},
206
+ url={https://arxiv.org/abs/2510.26913},
207
+ }
208
+ ```
209
+
210
+ ## License
211
+
212
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,192 @@
1
+ # FlowMesh
2
+
3
+ [![arXiv](https://img.shields.io/badge/arXiv-2510.26913-b31b1b.svg)](https://arxiv.org/abs/2510.26913)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
5
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
6
+ [![Lint](https://github.com/mlsys-io/FlowMesh/actions/workflows/lint-typecheck.yml/badge.svg)](https://github.com/mlsys-io/FlowMesh/actions/workflows/lint-typecheck.yml)
7
+ [![Tests](https://github.com/mlsys-io/FlowMesh/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/mlsys-io/FlowMesh/actions/workflows/unit-tests.yml)
8
+
9
+ A service fabric for running LLM agentic workflows on distributed GPU workers.
10
+
11
+ FlowMesh accepts workflow definitions (YAML, JSON, or n8n graph format), parses
12
+ them into a DAG of tasks, schedules and dispatches each task to a suitable
13
+ worker, and collects results and artifacts. It supports inference (vLLM, HF
14
+ transformers, diffusers), training (SFT, LoRA, DPO, PPO), retrieval-augmented
15
+ generation, agent execution, SSH-style interactive sessions, and arbitrary
16
+ container jobs.
17
+
18
+ ## Architecture
19
+
20
+ ```
21
+ Client (CLI / SDK / HTTP)
22
+
23
+ ▼ HTTP (default 8000)
24
+ ┌─────────────────────────────────────────────────┐
25
+ │ Server (FastAPI orchestrator) │
26
+ │ • workflow parsing, DAG resolution │
27
+ │ • task scheduling and dispatch │
28
+ │ • result and artifact collection │
29
+ │ • REST API + SSE log streaming │
30
+ └──────────────┬──────────────────────────────────┘
31
+ │ Redis pub/sub (control + telemetry)
32
+
33
+ ┌─────────────────────────────────────────────────┐
34
+ │ Supervisor (per-node agent) │
35
+ │ • registers node, manages worker containers │
36
+ │ • relays tasks/events via gRPC streams │
37
+ └──────────────┬──────────────────────────────────┘
38
+ │ gRPC (default 50051)
39
+
40
+ ┌─────────────────────────────────────────────────┐
41
+ │ Worker (executor process) │
42
+ │ • vllm, transformers, diffusers, training, │
43
+ │ RAG, agent, SSH, echo, data profiling │
44
+ │ • streams logs and events back via gRPC │
45
+ └─────────────────────────────────────────────────┘
46
+ ```
47
+
48
+ Server and Worker are the two top-level processes. The **Supervisor** is a
49
+ subsystem that lives under `src/server/` and runs as a child process spawned
50
+ from the server (`multiprocessing.Process`); single-node deployments spawn
51
+ one supervisor child alongside the server, multi-node deployments run a root
52
+ server plus one supervisor-only server process per worker node.
53
+
54
+ ## Quick start
55
+
56
+ Requires Docker, Docker Compose, and Python 3.12+. If you want to use GPU
57
+ workers, ensure the NVIDIA Container Toolkit is also installed.
58
+
59
+ ```bash
60
+ # 1. Install
61
+ git clone https://github.com/mlsys-io/FlowMesh.git
62
+ cd FlowMesh
63
+ pip install uv
64
+ uv sync --all-packages --group ci
65
+
66
+ # 2. Bring up the local stack (Server + Redis + Supervisor)
67
+ uv run flowmesh stack up
68
+
69
+ # 3. Start one CPU worker
70
+ uv run flowmesh stack worker up cpu 1
71
+
72
+ # 4. Submit a workflow
73
+ uv run flowmesh workflow submit examples/templates/echo_local.yaml
74
+
75
+ # 5. Watch it run
76
+ uv run flowmesh workflow list
77
+ uv run flowmesh workflow watch <workflow_id>
78
+ ```
79
+
80
+ For a GPU worker:
81
+
82
+ ```bash
83
+ # Pin to specific GPUs (or 'all')
84
+ uv run flowmesh stack worker up gpu --targets 0
85
+ ```
86
+
87
+ For inference templates:
88
+
89
+ ```bash
90
+ uv run flowmesh workflow submit examples/templates/inference_vllm_chat.yaml
91
+ uv run flowmesh workflow submit examples/templates/inference_hf_chat.yaml
92
+ ```
93
+
94
+ Tear down:
95
+
96
+ ```bash
97
+ uv run flowmesh stack worker down all
98
+ uv run flowmesh stack down
99
+ ```
100
+
101
+ ## Workflow format
102
+
103
+ A minimal single-task workflow:
104
+
105
+ ```yaml
106
+ apiVersion: flowmesh/v1
107
+ kind: InferenceTask
108
+ metadata:
109
+ name: hello-inference
110
+ spec:
111
+ taskType: inference
112
+ resources:
113
+ hardware: { gpu: { type: any, count: 1 } }
114
+ model:
115
+ source: { type: huggingface, identifier: TinyLlama/TinyLlama-1.1B-Chat-v1.0 }
116
+ vllm: { gpu_memory_utilization: 0.5 }
117
+ data:
118
+ type: list
119
+ items:
120
+ - - role: user
121
+ content: What is the capital of France?
122
+ inference: { max_tokens: 64, temperature: 0.0 }
123
+ output:
124
+ destination: { type: http }
125
+ ```
126
+
127
+ Multi-stage DAGs, conditional execution, graph-template prompts, task merging,
128
+ and SSH sessions are all supported. See `examples/templates/` for end-to-end examples
129
+ and `AGENTS.md` for the full schema reference.
130
+
131
+ ## Extending FlowMesh
132
+
133
+ FlowMesh exposes plugin hooks for organisations that want to layer additional
134
+ auth, submission policy, usage tracking, authorisation, supplier attribution,
135
+ or resource lifecycle behaviour on top of the core server. Install the
136
+ standalone hook contract with:
137
+
138
+ ```bash
139
+ pip install "flowmesh[hook]"
140
+ ```
141
+
142
+ A plugin is any Python module that exposes `install()` returning
143
+ `flowmesh_hook.HookBindings`. Plugins are loaded by setting
144
+ `FLOWMESH_PLUGINS` to a comma-separated list of importable module names.
145
+ Plugins can ship as in-tree modules, sibling-mounted packages, or
146
+ pip-installable wheels — the core never references plugin names.
147
+
148
+ See [`docs/PLUGINS.md`](docs/PLUGINS.md) for the full plugin contract.
149
+
150
+ ## Development
151
+
152
+ ```bash
153
+ # Install dev tooling
154
+ uv sync --all-packages --group ci
155
+
156
+ # Format / lint / type-check
157
+ uv run pre-commit run --all-files
158
+
159
+ # Tests — skip the multiprocessing GPU-cleanup test because it requires a
160
+ # real CUDA device and isolated processes; CI also skips it.
161
+ uv run pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py
162
+ ```
163
+
164
+ Detailed contributor docs (project layout, env vars, dispatch internals,
165
+ executor registry, commit-message conventions) live in `AGENTS.md`.
166
+
167
+ ## Contributing
168
+
169
+ We welcome bug fixes, new features, documentation improvements, and feedback.
170
+ Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) for the contributor setup,
171
+ code style, testing, dependency-pin, and DCO sign-off conventions, and
172
+ [`AGENTS.md`](AGENTS.md) for a deeper architecture and source-layout tour.
173
+
174
+ ## Citation
175
+
176
+ If you use FlowMesh in your research, please cite:
177
+
178
+ ```bibtex
179
+ @misc{shen2025flowmesh,
180
+ title={FlowMesh: A Service Fabric for Composable LLM Workflows},
181
+ author={Junyi Shen and Noppanat Wadlom and Lingfeng Zhou and Dequan Wang and Xu Miao and Lei Fang and Yao Lu},
182
+ year={2025},
183
+ eprint={2510.26913},
184
+ archivePrefix={arXiv},
185
+ primaryClass={cs.DC},
186
+ url={https://arxiv.org/abs/2510.26913},
187
+ }
188
+ ```
189
+
190
+ ## License
191
+
192
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowmesh
3
+ Version: 0.1.0
4
+ Summary: FlowMesh: A Multi-tenant Service Fabric for LLM Agentic Workflows
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Provides-Extra: sdk
10
+ Requires-Dist: flowmesh-sdk==0.1.0; extra == "sdk"
11
+ Provides-Extra: cli
12
+ Requires-Dist: flowmesh-cli[stack]==0.1.0; extra == "cli"
13
+ Provides-Extra: hook
14
+ Requires-Dist: flowmesh-hook==0.1.0; extra == "hook"
15
+ Provides-Extra: all
16
+ Requires-Dist: flowmesh-cli[stack]==0.1.0; extra == "all"
17
+ Requires-Dist: flowmesh-hook==0.1.0; extra == "all"
18
+ Requires-Dist: flowmesh-sdk==0.1.0; extra == "all"
19
+ Dynamic: license-file
20
+
21
+ # FlowMesh
22
+
23
+ [![arXiv](https://img.shields.io/badge/arXiv-2510.26913-b31b1b.svg)](https://arxiv.org/abs/2510.26913)
24
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
25
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
26
+ [![Lint](https://github.com/mlsys-io/FlowMesh/actions/workflows/lint-typecheck.yml/badge.svg)](https://github.com/mlsys-io/FlowMesh/actions/workflows/lint-typecheck.yml)
27
+ [![Tests](https://github.com/mlsys-io/FlowMesh/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/mlsys-io/FlowMesh/actions/workflows/unit-tests.yml)
28
+
29
+ A service fabric for running LLM agentic workflows on distributed GPU workers.
30
+
31
+ FlowMesh accepts workflow definitions (YAML, JSON, or n8n graph format), parses
32
+ them into a DAG of tasks, schedules and dispatches each task to a suitable
33
+ worker, and collects results and artifacts. It supports inference (vLLM, HF
34
+ transformers, diffusers), training (SFT, LoRA, DPO, PPO), retrieval-augmented
35
+ generation, agent execution, SSH-style interactive sessions, and arbitrary
36
+ container jobs.
37
+
38
+ ## Architecture
39
+
40
+ ```
41
+ Client (CLI / SDK / HTTP)
42
+
43
+ ▼ HTTP (default 8000)
44
+ ┌─────────────────────────────────────────────────┐
45
+ │ Server (FastAPI orchestrator) │
46
+ │ • workflow parsing, DAG resolution │
47
+ │ • task scheduling and dispatch │
48
+ │ • result and artifact collection │
49
+ │ • REST API + SSE log streaming │
50
+ └──────────────┬──────────────────────────────────┘
51
+ │ Redis pub/sub (control + telemetry)
52
+
53
+ ┌─────────────────────────────────────────────────┐
54
+ │ Supervisor (per-node agent) │
55
+ │ • registers node, manages worker containers │
56
+ │ • relays tasks/events via gRPC streams │
57
+ └──────────────┬──────────────────────────────────┘
58
+ │ gRPC (default 50051)
59
+
60
+ ┌─────────────────────────────────────────────────┐
61
+ │ Worker (executor process) │
62
+ │ • vllm, transformers, diffusers, training, │
63
+ │ RAG, agent, SSH, echo, data profiling │
64
+ │ • streams logs and events back via gRPC │
65
+ └─────────────────────────────────────────────────┘
66
+ ```
67
+
68
+ Server and Worker are the two top-level processes. The **Supervisor** is a
69
+ subsystem that lives under `src/server/` and runs as a child process spawned
70
+ from the server (`multiprocessing.Process`); single-node deployments spawn
71
+ one supervisor child alongside the server, multi-node deployments run a root
72
+ server plus one supervisor-only server process per worker node.
73
+
74
+ ## Quick start
75
+
76
+ Requires Docker, Docker Compose, and Python 3.12+. If you want to use GPU
77
+ workers, ensure the NVIDIA Container Toolkit is also installed.
78
+
79
+ ```bash
80
+ # 1. Install
81
+ git clone https://github.com/mlsys-io/FlowMesh.git
82
+ cd FlowMesh
83
+ pip install uv
84
+ uv sync --all-packages --group ci
85
+
86
+ # 2. Bring up the local stack (Server + Redis + Supervisor)
87
+ uv run flowmesh stack up
88
+
89
+ # 3. Start one CPU worker
90
+ uv run flowmesh stack worker up cpu 1
91
+
92
+ # 4. Submit a workflow
93
+ uv run flowmesh workflow submit examples/templates/echo_local.yaml
94
+
95
+ # 5. Watch it run
96
+ uv run flowmesh workflow list
97
+ uv run flowmesh workflow watch <workflow_id>
98
+ ```
99
+
100
+ For a GPU worker:
101
+
102
+ ```bash
103
+ # Pin to specific GPUs (or 'all')
104
+ uv run flowmesh stack worker up gpu --targets 0
105
+ ```
106
+
107
+ For inference templates:
108
+
109
+ ```bash
110
+ uv run flowmesh workflow submit examples/templates/inference_vllm_chat.yaml
111
+ uv run flowmesh workflow submit examples/templates/inference_hf_chat.yaml
112
+ ```
113
+
114
+ Tear down:
115
+
116
+ ```bash
117
+ uv run flowmesh stack worker down all
118
+ uv run flowmesh stack down
119
+ ```
120
+
121
+ ## Workflow format
122
+
123
+ A minimal single-task workflow:
124
+
125
+ ```yaml
126
+ apiVersion: flowmesh/v1
127
+ kind: InferenceTask
128
+ metadata:
129
+ name: hello-inference
130
+ spec:
131
+ taskType: inference
132
+ resources:
133
+ hardware: { gpu: { type: any, count: 1 } }
134
+ model:
135
+ source: { type: huggingface, identifier: TinyLlama/TinyLlama-1.1B-Chat-v1.0 }
136
+ vllm: { gpu_memory_utilization: 0.5 }
137
+ data:
138
+ type: list
139
+ items:
140
+ - - role: user
141
+ content: What is the capital of France?
142
+ inference: { max_tokens: 64, temperature: 0.0 }
143
+ output:
144
+ destination: { type: http }
145
+ ```
146
+
147
+ Multi-stage DAGs, conditional execution, graph-template prompts, task merging,
148
+ and SSH sessions are all supported. See `examples/templates/` for end-to-end examples
149
+ and `AGENTS.md` for the full schema reference.
150
+
151
+ ## Extending FlowMesh
152
+
153
+ FlowMesh exposes plugin hooks for organisations that want to layer additional
154
+ auth, submission policy, usage tracking, authorisation, supplier attribution,
155
+ or resource lifecycle behaviour on top of the core server. Install the
156
+ standalone hook contract with:
157
+
158
+ ```bash
159
+ pip install "flowmesh[hook]"
160
+ ```
161
+
162
+ A plugin is any Python module that exposes `install()` returning
163
+ `flowmesh_hook.HookBindings`. Plugins are loaded by setting
164
+ `FLOWMESH_PLUGINS` to a comma-separated list of importable module names.
165
+ Plugins can ship as in-tree modules, sibling-mounted packages, or
166
+ pip-installable wheels — the core never references plugin names.
167
+
168
+ See [`docs/PLUGINS.md`](docs/PLUGINS.md) for the full plugin contract.
169
+
170
+ ## Development
171
+
172
+ ```bash
173
+ # Install dev tooling
174
+ uv sync --all-packages --group ci
175
+
176
+ # Format / lint / type-check
177
+ uv run pre-commit run --all-files
178
+
179
+ # Tests — skip the multiprocessing GPU-cleanup test because it requires a
180
+ # real CUDA device and isolated processes; CI also skips it.
181
+ uv run pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py
182
+ ```
183
+
184
+ Detailed contributor docs (project layout, env vars, dispatch internals,
185
+ executor registry, commit-message conventions) live in `AGENTS.md`.
186
+
187
+ ## Contributing
188
+
189
+ We welcome bug fixes, new features, documentation improvements, and feedback.
190
+ Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) for the contributor setup,
191
+ code style, testing, dependency-pin, and DCO sign-off conventions, and
192
+ [`AGENTS.md`](AGENTS.md) for a deeper architecture and source-layout tour.
193
+
194
+ ## Citation
195
+
196
+ If you use FlowMesh in your research, please cite:
197
+
198
+ ```bibtex
199
+ @misc{shen2025flowmesh,
200
+ title={FlowMesh: A Service Fabric for Composable LLM Workflows},
201
+ author={Junyi Shen and Noppanat Wadlom and Lingfeng Zhou and Dequan Wang and Xu Miao and Lei Fang and Yao Lu},
202
+ year={2025},
203
+ eprint={2510.26913},
204
+ archivePrefix={arXiv},
205
+ primaryClass={cs.DC},
206
+ url={https://arxiv.org/abs/2510.26913},
207
+ }
208
+ ```
209
+
210
+ ## License
211
+
212
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ flowmesh.egg-info/PKG-INFO
5
+ flowmesh.egg-info/SOURCES.txt
6
+ flowmesh.egg-info/dependency_links.txt
7
+ flowmesh.egg-info/requires.txt
8
+ flowmesh.egg-info/top_level.txt
@@ -0,0 +1,14 @@
1
+
2
+ [all]
3
+ flowmesh-cli[stack]==0.1.0
4
+ flowmesh-hook==0.1.0
5
+ flowmesh-sdk==0.1.0
6
+
7
+ [cli]
8
+ flowmesh-cli[stack]==0.1.0
9
+
10
+ [hook]
11
+ flowmesh-hook==0.1.0
12
+
13
+ [sdk]
14
+ flowmesh-sdk==0.1.0
@@ -0,0 +1,246 @@
1
+ [project]
2
+ name = "flowmesh"
3
+ version = "0.1.0"
4
+ description = "FlowMesh: A Multi-tenant Service Fabric for LLM Agentic Workflows"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ dependencies = []
10
+
11
+ [project.optional-dependencies]
12
+ # Public PyPI install surface.
13
+ sdk = ["flowmesh-sdk==0.1.0"]
14
+ cli = ["flowmesh-cli[stack]==0.1.0"]
15
+ hook = ["flowmesh-hook==0.1.0"]
16
+ all = [
17
+ "flowmesh-cli[stack]==0.1.0",
18
+ "flowmesh-hook==0.1.0",
19
+ "flowmesh-sdk==0.1.0",
20
+ ]
21
+
22
+ [dependency-groups]
23
+ # Runtime/container dependencies.
24
+ runtime-server = [
25
+ "aiohttp>=3.13.4",
26
+ "cryptography>=46.0.7",
27
+ "docker>=7.1.0",
28
+ "fastapi>=0.120.3",
29
+ "flowmesh-hook",
30
+ "grpcio>=1.76.0",
31
+ "httpx>=0.28.1",
32
+ "lumid-hooks>=0.1.0",
33
+ "protobuf>=5.29.6",
34
+ "pydantic>=2.12.3",
35
+ "python-multipart>=0.0.26",
36
+ "pyyaml>=6.0.2",
37
+ "redis>=7.0.1",
38
+ "requests>=2.33.0",
39
+ "uvicorn[standard]>=0.32.1",
40
+ "vastai-sdk>=0.2.5",
41
+ "websockets>=15.0.1",
42
+ ]
43
+ runtime-worker-core = [
44
+ "colorama>=0.4.6",
45
+ "colorlog>=6.9.0",
46
+ "docker>=7.1.0",
47
+ "grpcio>=1.76.0",
48
+ "httpx>=0.28.1",
49
+ "nvidia-ml-py>=13.580.82",
50
+ "protobuf>=5.29.6",
51
+ "python-dotenv>=1.2.2",
52
+ "websocket-client>=1.9.0",
53
+ ]
54
+ runtime-inference = [
55
+ "accelerate>=1.12.0",
56
+ "datasets>=4.3.0",
57
+ "diffusers>=0.36.0",
58
+ "pillow>=11.3.0", # held <12 by gradio 5.50 (transitive via vllm-omni)
59
+ "torch>=2.10.0",
60
+ "transformers>=4.57.6", # held at 4.57 by vllm/vllm-omni 0.18 compatibility
61
+ ]
62
+ runtime-training = [
63
+ "peft>=0.17.1",
64
+ "trl>=0.23.0",
65
+ ]
66
+ runtime-rag = [
67
+ "fastembed>=0.7.3,<0.8",
68
+ "qdrant-client>=1.15.1",
69
+ ]
70
+ runtime-inference-gpu = [
71
+ "bitsandbytes>=0.49.2",
72
+ "flashinfer-python>=0.6.6",
73
+ "vllm==0.18.0", # pinned with transformers 4.57; 0.19+ needs transformers 5.x
74
+ "vllm-omni==0.18.0", # follows vllm pin
75
+ ]
76
+ runtime-training-gpu = [
77
+ "deepspeed>=0.18.1",
78
+ ]
79
+ runtime-agent = [
80
+ "aiofiles>=24.1.0",
81
+ "aiohttp>=3.13.4",
82
+ "art>=6.5",
83
+ "arxiv>=2.2.0",
84
+ "beautifulsoup4>=4.14.3",
85
+ "chunkr-ai>=0.3.7",
86
+ "crawl4ai>=0.8.0",
87
+ "ddgs>=9.10.0",
88
+ "google-genai>=1.47.0",
89
+ "hydra-core>=1.3.2",
90
+ "ipython>=9.5.0",
91
+ "jinja2>=3.1.6",
92
+ "matplotlib>=3.10.6",
93
+ "mcp>=1.23.0",
94
+ "openai>=2.9.0",
95
+ "openai-agents>=0.7.0",
96
+ "opencv-python-headless>=4.13.0.92",
97
+ "openpyxl>=3.1.5",
98
+ "pexpect>=4.9.0",
99
+ "prompt-toolkit>=3.0.52",
100
+ "pymupdf>=1.26.7",
101
+ "rich>=14.2.0",
102
+ "sqlmodel>=0.0.27",
103
+ "tiktoken>=0.12.0",
104
+ "toml>=0.10.2",
105
+ "wikipedia-api>=0.8.1",
106
+ ]
107
+ runtime-observability = [
108
+ "arize-phoenix-client>=1.21.0",
109
+ "arize-phoenix-otel>=0.13.1",
110
+ "openinference-instrumentation-openai>=0.1.39",
111
+ "openinference-instrumentation-openai-agents>=1.3.0",
112
+ "opentelemetry-api>=1.38.0",
113
+ "opentelemetry-instrumentation>=0.59b0",
114
+ "opentelemetry-sdk>=1.38.0",
115
+ "opentelemetry-semantic-conventions>=0.59b0",
116
+ ]
117
+ runtime-analytics = [
118
+ "boto3>=1.41.5",
119
+ "pandas>=2.3.3",
120
+ "psycopg[binary]>=3.2.12",
121
+ "sqlalchemy>=2.0.44",
122
+ "lumid-data-sdk>=0.1.0",
123
+ ]
124
+ runtime-worker-cpu = [
125
+ { include-group = "runtime-worker-core" },
126
+ { include-group = "runtime-inference" },
127
+ { include-group = "runtime-training" },
128
+ { include-group = "runtime-rag" },
129
+ { include-group = "runtime-agent" },
130
+ { include-group = "runtime-observability" },
131
+ { include-group = "runtime-analytics" },
132
+ ]
133
+ runtime-worker-gpu = [
134
+ { include-group = "runtime-inference-gpu" },
135
+ { include-group = "runtime-training-gpu" },
136
+ ]
137
+ dev = [
138
+ "black>=25.12.0",
139
+ "boto3-stubs>=1.42.14",
140
+ "codespell>=2.4.1",
141
+ "grpcio-tools>=1.71.2",
142
+ "isort>=7.0.0",
143
+ "mypy>=1.19.1",
144
+ "nvidia-ml-py>=13.580.82",
145
+ "pandas-stubs>=2.3.3.251219",
146
+ "pip>=25.3",
147
+ "pre-commit>=4.5.1",
148
+ "protoletariat>=3.3.10",
149
+ "psutil>=7.1.2",
150
+ "pyarrow-stubs>=20.0.0.20251215",
151
+ "pytest>=8.4.2",
152
+ "pytest-asyncio>=1.3.0",
153
+ "respx>=0.22.0",
154
+ "ruff>=0.14.10",
155
+ "types-colorama>=0.4.15.20250801",
156
+ "types-docker>=7.1.0.20251202",
157
+ "types-grpcio>=1.0.0.20251009",
158
+ "types-pexpect>=4.9.0.20250916",
159
+ "types-protobuf>=6.32.1.20251210",
160
+ "types-psutil>=7.1.3.20251211",
161
+ "types-pyyaml>=6.0.12.20250915",
162
+ "types-requests>=2.32.4.20250913",
163
+ ]
164
+ ci = [
165
+ { include-group = "dev" },
166
+ { include-group = "runtime-server" },
167
+ { include-group = "runtime-worker-cpu" },
168
+ { include-group = "runtime-worker-gpu" },
169
+ ]
170
+
171
+ [build-system]
172
+ requires = ["setuptools>=77", "wheel"]
173
+ build-backend = "setuptools.build_meta"
174
+
175
+ [tool.setuptools]
176
+ packages = []
177
+ py-modules = []
178
+
179
+ [tool.isort]
180
+ profile = "black"
181
+
182
+ [tool.black]
183
+ target-version = ["py312"]
184
+
185
+ [tool.ruff]
186
+ target-version = "py312"
187
+ lint.select = ["E", "F", "UP", "I"]
188
+ lint.ignore = ["I001"]
189
+ extend-exclude = ["__init__.pyi", "*_pb2*"]
190
+
191
+ [tool.pytest.ini_options]
192
+ pythonpath = ["src"]
193
+
194
+ [tool.mypy]
195
+ python_version = "3.12"
196
+ files = [
197
+ "src",
198
+ "cli/src",
199
+ "cli/stack/src",
200
+ "hook/src",
201
+ "sdk/src",
202
+ "sdk/stack/src",
203
+ "tests",
204
+ ]
205
+ ignore_missing_imports = false
206
+ warn_unused_configs = true
207
+
208
+ [[tool.mypy.overrides]]
209
+ module = [
210
+ "datasets",
211
+ "worker.executors.*",
212
+ "worker.runner",
213
+ ]
214
+ ignore_missing_imports = true
215
+
216
+ [[tool.mypy.overrides]]
217
+ module = ["pynvml", "vllm_omni.*", "deepspeed.*", "lumid_data.sdk"]
218
+ follow_untyped_imports = true
219
+
220
+ [tool.codespell]
221
+ skip = "*.lock,*.csv,*.tsv,*.jsonl"
222
+ ignore-words-list = "pre-select"
223
+
224
+ [tool.bandit]
225
+ skips = [
226
+ "B101", # assert: internal invariants, not shipped with -O
227
+ "B102", # exec: agent Python executor sandbox feature
228
+ "B104", # 0.0.0.0 bind: containerized; exposure controlled at orchestration
229
+ "B107", # password default: placeholder, not a real credential
230
+ "B110", # try/except/pass: best-effort cleanup paths
231
+ "B112", # try/except/continue: iteration over partially-bad inputs
232
+ "B307", # eval: agent Python executor sandbox feature
233
+ "B311", # random: non-cryptographic sampling / jitter / tie-breaking
234
+ "B404", # subprocess module import: actual unsafe patterns caught by B602/B603/B607
235
+ "B615", # unpinned hf_hub downloads: user-supplied workflow inputs
236
+ ]
237
+
238
+ [tool.uv.sources]
239
+ flowmesh-cli = { workspace = true }
240
+ flowmesh-cli-stack = { workspace = true }
241
+ flowmesh-hook = { workspace = true }
242
+ flowmesh-sdk = { workspace = true }
243
+ flowmesh-sdk-stack = { workspace = true }
244
+
245
+ [tool.uv.workspace]
246
+ members = ["cli", "cli/stack", "hook", "sdk", "sdk/stack"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+