Independent work / Distributed systems
Distributed AI inference
Matching computational workloads to available resources
An independently operated AI infrastructure spanning Linux and macOS, combining distributed inference endpoints, heterogeneous Apple silicon hardware, workload benchmarking and a separate resource-aware scheduling prototype.
- ApplicationSubwave and other inference clients
- HAProxyShared inference endpoint and backend routing
- OllamaIndependent model-serving instances
- Apple siliconHardware-accelerated local computation
01 / Engineering objective
The objective was to distribute local AI workloads across existing hardware without requiring application clients to manage individual inference hosts.
The environment contains machines with different processor capabilities, memory capacities and operational responsibilities. This creates a practical resource allocation problem: a reachable backend is not necessarily the best destination for every workload.
My work explores this problem through two distinct implementations: an operational HAProxy and Ollama deployment, and a separate Python-based ComfyUI scheduling prototype.
02 / Distributed inference architecture
| Host | Configured responsibilities |
|---|---|
| M1 Mac mini 16 GB / Asahi Fedora |
Containerized applications, orchestration and HAProxy routing. |
| M4 Mac mini 16 GB / macOS |
Ollama inference backend, acoustic analysis and speech synthesis workloads. |
| M1 Max MacBook Pro 32 GB / macOS |
Higher-memory Ollama inference backend. |
HAProxy exposes a shared API entry point for the configured Ollama instances. Applications can submit requests without embedding individual backend addresses into their configuration.
Each backend executes its own inference workload. This is request-level distribution, not a distributed model execution system that combines the memory or compute resources of multiple machines into a single inference operation.
Backend availability varies with host availability and workload allocation. The portable inference host is not assumed to be continuously available.
03 / Inference throughput benchmarking
To establish a comparative performance baseline, I benchmarked the same Qwen3.5:9b model through Ollama on both inference hosts in November 2026.
Benchmark configuration
Model: qwen3.5:9b
API: /api/generate
Temperature: 0
Thinking: disabled
Maximum generated tokens: 512
Execution: 3 sequential runs per host
Prompt: identical across hosts
| Hardware | Run 1 | Run 2 | Run 3 | Median |
|---|---|---|---|---|
| M1 Max / 32 GB | 48.9 | 49.1 | 50.4 | 49.1 |
| M4 / 16 GB | 26.8 | 27.0 | 27.4 | 27.0 |
All measurements are expressed in generated tokens per second. Under these test conditions, the M1 Max achieved higher generation throughput despite belonging to an older processor generation.
The results illustrate why hardware selection should be based on workload-specific measurements rather than processor generation alone.
04 / Request distribution verification
I verified the initial HAProxy routing configuration by issuing six sequential API requests and observing which backend processed each request.
| Request | Selected backend |
|---|---|
| 1 | M4 |
| 2 | M1 Max |
| 3 | M4 |
| 4 | M1 Max |
| 5 | M4 |
| 6 | M1 Max |
The initial test established successful request distribution across both configured inference endpoints. Subsequent configuration experiments included unequal backend weights to reflect differing compute capabilities.
These routing tests verify observed backend selection. They do not independently establish seamless failover, optimal workload placement or production-scale load balancing performance.
05 / Resource contention and service lifecycle
The M4 host also runs audio analysis and speech synthesis services supporting the Subwave radio platform. These workloads compete with language-model inference for unified memory and computational resources.
My investigations examined model residency, concurrency, memory pressure and the effects of running multiple Python-based services on the same machine.
During audio workload experiments, I temporarily removed the M4 inference workload to isolate competing resource demands. This allowed individual service behavior to be investigated without treating all observed latency as a language-model performance problem.
I also configured macOS launchd services for Ollama, acoustic analysis and speech synthesis, including persistent local service logs and service status checks.
Resource-aware automatic backend selection remains a potential extension of the deployed inference architecture rather than an implemented capability.
06 / Resource-aware ComfyUI scheduling prototype
A separate Python router prototype addresses workflow scheduling across heterogeneous ComfyUI workers. Unlike request-level inference balancing, this prototype considers whether a worker satisfies the requirements of a specific job before selecting it.
| Scheduling consideration | Prototype behavior |
|---|---|
| Worker availability | Evaluate whether a worker is reachable. |
| Workflow compatibility | Check advertised node classes and required model availability. |
| Memory requirements | Compare configured job requirements with worker eligibility. |
| Worker preference | Prefer the smallest eligible worker to preserve larger-worker capacity. |
| Blocked workloads | Allow later eligible jobs to proceed while incompatible jobs wait. |
| Persistent job state | Record queue and submission state in SQLite. |
The scheduling policy is intended to avoid assigning lightweight workflows to scarce higher-capacity resources when another eligible worker is available.
Memory eligibility is based on configured requirements. It is not a guarantee of sufficient instantaneous memory under arbitrary concurrent workloads.
07 / Handling ambiguous submission outcomes
Distributed job submission introduces a failure mode that ordinary connectivity checks cannot resolve. A worker may accept a workflow while the response is lost before the router can confirm acceptance.
Automatically retrying such a submission could execute the same workflow twice. The prototype instead records the uncertain submission outcome in persistent job state.
Conceptual submission decision
Submit workflow to eligible worker
|
+-- Acceptance confirmed
| Record accepted submission
|
+-- Outcome uncertain
Preserve uncertain job state
Avoid automatic duplicate submission
This approach prioritizes explicit uncertainty over assuming that a failed response necessarily means a failed operation. It does not establish exactly-once execution guarantees.
Local tests with simulated workers exercise eligibility, worker preference, missing dependencies, worker outages, queue changes and ambiguous submission outcomes.
08 / Engineering contributions
- Multi-host AI inference integration across Linux and macOS.
- Shared API routing and backend distribution using HAProxy.
- Controlled inference throughput benchmarking.
- Hardware capacity and workload contention investigation.
- macOS service lifecycle management using launchd.
- Resource-aware workflow scheduling with Python.
- Persistent job state management using SQLite.
- Explicit handling of ambiguous distributed submission outcomes.
The central engineering lesson is that distributing requests and scheduling workloads are related but distinct problems. Effective resource allocation requires evidence about hardware capabilities, workload requirements and the behavior of systems when dependencies fail.
This work was performed within my independently operated environment, integrating existing open-source inference and workflow execution systems.
Independent work / Plain English
Distributed AI inference
Giving the right job to the right computer.
What did I do?
Imagine two kitchens. One has a small countertop and the other has a huge one. Both can make a sandwich, but only the bigger kitchen has enough space to prepare a feast.
How does that apply to computers?
I connected computers with different capabilities so applications could send AI requests through a shared entry point. I measured how quickly each computer could work.
What else did I experiment with?
I worked on a separate scheduling prototype that checks what a job needs before choosing a computer. It tries to save larger computers for jobs that actually need them.
Why does it matter?
Computers have limited resources. Giving them the right jobs can reduce waste and help keep work moving. The scheduling prototype was tested with simulated workers.
Independent work / Stone Age
Big rock. Small rock.
Technology. But rock.
Big rock think fast.
Small rock think slower.
Me test how fast rock think.
Give small problem to small rock.
Save big rock for big problem.
Many rock. Less wait. Tribe happy.