-
Notifications
You must be signed in to change notification settings - Fork 0
Workload Inference and Classification
Relevant source files
The following files were used as context for generating this wiki page:
- cmd/axis/llm.go
- cmd/axis/llm_test.go
- internal/llmrouter/adapter.go
- internal/llmrouter/adapter_test.go
- internal/llmrouter/cloud.go
- internal/llmrouter/cloud_test.go
- internal/llmrouter/engine.go
- internal/llmrouter/models.go
- internal/llmrouter/models_test.go
- internal/llmrouter/registry.go
- internal/mcp/testdata/placement_decision_corrupt_persistence.golden
- internal/workload/classifier.go
- internal/workload/match.go
- internal/workload/profiles.go
- internal/workload/requirements.go
- internal/workload/requirements_test.go
The Workload Inference and Classification system is responsible for transforming natural language task descriptions into structured TaskRequirements. This process bridges the gap between a user's intent (e.g., "run a 70b coding model") and the deterministic hardware constraints (RAM, tools, context window) required by the Placement Engine.
AXIS employs a hybrid approach to classification, combining a Semantic Path (LLM-based) with a Reflex Path (string-matching). The system prioritizes speed and reliability, ensuring that even if a local LLM is slow or unavailable, a deterministic fallback is provided within milliseconds.
The entry point for requirement derivation is workload.InferRequirements internal/workload/requirements.go:18-39.
graph TD
UserPrompt["User Prompt / Description"] --> InferReqs["workload.InferRequirements()"]
subgraph "Classification Layer"
InferReqs --> ResolveMatch["resolveWorkloadMatch()"]
ResolveMatch --> Semantic["llmrouter.Engine.Classify() (Semantic Path)"]
ResolveMatch --> Reflex["workload.Match() (Reflex Path)"]
Semantic -- "Timeout/Error" --> Reflex
end
subgraph "Requirement Derivation"
ResolveMatch --> ApplyProfile["Apply(match, reqs)"]
ApplyProfile --> Profiles["workload.profileForClass()"]
ApplyProfile --> Heuristics["Heuristic Refinement (RAM Floors, Tools)"]
end
subgraph "Additive Inference"
Heuristics --> ContextInference["InferContextWindowTokens()"]
ContextInference --> BackendInference["InferBackends()"]
end
BackendInference --> FinalReqs["models.TaskRequirements"]
Sources: internal/workload/requirements.go:10-39, internal/llmrouter/engine.go:137-150
The llmrouter.Engine acts as a "semantic reflex" classifier. It is designed to run locally with a strict latency budget to avoid delaying the placement pipeline internal/llmrouter/engine.go:5-11.
-
Default Model:
granite3.1-moe:1b(chosen for sub-1GB RAM footprint and high-speed CPU inference) internal/llmrouter/engine.go:117-127. -
Latency Budget: Defaults to 150ms. If the model does not respond within this window, the system triggers a
SourceReflexfallback internal/llmrouter/engine.go:117-127. -
Grammar Constraint: Uses Ollama's
format: "json"to force the model to emit a structuredclassifyResponseinternal/llmrouter/engine.go:179-184.
The IntentSignal captures the output of the semantic classification:
| Field | Type | Description |
|---|---|---|
Class |
models.WorkloadClass |
The identified category (e.g., go-build, local-llm-inference). |
Confidence |
float64 |
Model-reported confidence [0.0, 1.0]. |
Source |
ClassifySource |
Either semantic or reflex. |
Signals |
[]string |
Keywords or features that drove the decision. |
Sources: internal/llmrouter/engine.go:52-71, internal/llmrouter/engine.go:168-173
When the semantic engine fails or is disabled, AXIS uses workload.Match (Reflex Path). This is a deterministic keyword-based system that maps substrings to WorkloadClass internal/llmrouter/engine.go:40-48.
The reflex matcher handles "promotion" of specific classes to prevent ambiguous matches. For example, if a prompt contains both "ollama" and "128k context", it is promoted from ClassLocalLLMInference to ClassLongContextInference workload/match.go.
Common Mappings:
-
Go Build:
go test,go build,compileinternal/workload/requirements_test.go:151-152. -
Repo Analysis:
review codebase,analyze repo,commit historyinternal/workload/requirements_test.go:146-148. -
Local LLM:
ollama,llama3,inference,7b,70binternal/workload/requirements_test.go:175-180.
Sources: internal/workload/requirements.go:229-235, internal/workload/requirements_test.go:139-191
Once a WorkloadClass is identified, workload.Apply populates the TaskRequirements using a combination of static profiles and dynamic heuristics internal/workload/requirements.go:43-78.
The system applies "floors" based on model sizes mentioned in the prompt, which can override the base class requirements:
| Mentioned Size | RAM Floor (MB) |
|---|---|
70b |
12,288 MB |
13b / 32b
|
8,192 MB |
7b / 8b
|
4,096 MB |
Generic llm
|
6,144 MB |
Sources: internal/workload/requirements.go:169-182
The system scans for explicit backend preferences and required tools:
-
Tools: Detects
git,docker,go, andollamabased on the workload class or explicit keywords internal/workload/requirements.go:64-77. -
Backends:
InferBackendsidentifies preferences formlx,llama.cpp, orapple-foundation-modelsinternal/workload/requirements.go:90-107.
AXIS performs additive inference for long-context tasks. InferContextWindowTokens parses human-readable context sizes and adjusts RAM requirements accordingly internal/workload/requirements.go:110-124.
| Keyword | Tokens | RAM Adjustment |
|---|---|---|
1m tokens, million token
|
1,000,000 | Floor to 12,288 MB |
512k |
512,000 | Floor to 8,192 MB |
128k, long context
|
128,000 | Floor to 6,144 MB |
Sources: internal/workload/requirements.go:127-140
For the axis llm command surface, AXIS supports an interactive cloud fallback if the local classifier is unavailable cmd/axis/llm.go:185-200.
sequenceDiagram
participant CLI as "cmd/axis (llmCmd)"
participant Eng as "llmrouter.Engine"
participant Cloud as "llmrouter.SelectCloudFallback"
participant Prov as "Cloud Provider (Groq/Anthropic)"
CLI->>Eng: Classify(prompt)
Eng-->>CLI: SourceReflex (Local LLM Down)
CLI->>Cloud: Select best provider (cost/latency)
Cloud->>Prov: Health Check / Cost Estimate
Prov-->>Cloud: OK (Latency 40ms)
Cloud-->>CLI: Selected: Anthropic
CLI->>Prov: Send(Classification Prompt)
Prov-->>CLI: JSON {class: "go-build", ...}
Sources: cmd/axis/llm.go:116-141, internal/llmrouter/cloud.go:160-182, internal/llmrouter/cloud_test.go:162-197
The llmrouter.Registry manages multiple backends (OpenRouter, Groq, Anthropic). It selects the fallback based on the inference.prefer configuration (defaulting to latency) internal/llmrouter/registry.go:10-19, internal/llmrouter/cloud_test.go:162-184.
| Code Entity | File Path | Role |
|---|---|---|
TaskRequirements |
internal/models/tasks.go | Struct containing RAM, Tools, and Context Window. |
Engine |
internal/llmrouter/engine.go:74-79 | Orchestrates local LLM classification and reflex fallback. |
InferRequirements |
internal/workload/requirements.go:18 | Main logic for parsing strings into requirements. |
Apply |
internal/workload/requirements.go:43 | Maps WorkloadClass to hardware/tool profiles. |
CloudProvider |
internal/llmrouter/cloud.go:54-62 | Implementation for OpenAI-compatible and Anthropic APIs. |
Sources: internal/llmrouter/engine.go, internal/workload/requirements.go, internal/llmrouter/cloud.go