# GPU jobs

URL: https://docs.hanzo.ai/docs/science/gpu-jobs

> Submit GPU workloads to the fleet queue (/v1/compute/fleet/jobs), poll status, fetch results. Target specific linked nodes or broadcast on the shared gpu-jobs lane.

**GPU workloads run through the fleet queue.** Submit a job targeting a specific linked node (e.g., `gpu: "dgx"` → queue `gpu:dgx`) or broadcast on the shared `gpu-jobs` lane by omitting `gpu`. The default `type` is `research.bench`.

## Submit → Status → Result

```mermaid
flowchart LR
    S["POST /v1/compute/fleet/jobs<br/>(submit: gpu?, input, type)"] --> P["GET /v1/compute/fleet/jobs/{id}<br/>(poll: status, worker, result)"]
    P --> C{"status == completed?"}
    C -->|No| P
    C -->|Yes| R["result.exitCode, result.stdout, result.stderr"]
    P -.-> X["POST /v1/compute/fleet/jobs/{id}/cancel<br/>(reason)"]
```

## Submit a job (POST /v1/compute/fleet/jobs)

```bash
curl -s -X POST https://api.hanzo.ai/v1/compute/fleet/jobs \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "gpu": "dgx",
    "type": "research.bench",
    "input": {
      "name": "gb10-probe",
      "command": ["nvidia-smi"]
    }
  }' | jq '.'
```

Response:

```json
{
  "id": "job-1",
  "runId": "job-1",
  "gpu": "dgx",
  "status": "queued",
  "type": "research.bench"
}
```

- `gpu` (optional): Target a specific linked node by its name (e.g., `"dgx"`). Omit to broadcast on the shared `gpu-jobs` lane.
- `type` (optional, default `research.bench`): Job type identifier.
- `input.command`: Array of command + args to execute on the worker.
- `input.name`: Human-readable job name.
- **Idempotent on `id`**: Re-submitting an existing job id returns that job without duplicating or resetting an active claim.

## Poll status & fetch result (`GET /v1/compute/fleet/jobs/{id}`)

```bash
curl -s "https://api.hanzo.ai/v1/compute/fleet/jobs/job-1" \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'
```

Response (while queued/running):

```json
{
  "id": "job-1",
  "runId": "job-1",
  "gpu": "dgx",
  "status": "running",
  "type": "research.bench",
  "attempt": 1,
  "worker": "dgx"
}
```

Response (completed):

```json
{
  "id": "job-1",
  "runId": "job-1",
  "gpu": "dgx",
  "status": "completed",
  "type": "research.bench",
  "attempt": 1,
  "worker": "dgx",
  "result": {
    "exitCode": 0,
    "stdout": "Mon Nov 30 12:00:00 2026\n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 550.90.07    Driver Version: 550.90.07    CUDA Version: 12.4     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|                               |                      |               MIG M. |\n|===============================+======================+======================|\n|   0  GB10            On   | 00000000:00:00.0 Off |                    0 |\n| N/A   32C    P8     9W /  40W |      4MiB /  24576MiB |      0%      Default |\n|                               |                      |             N/A      |\n+-------------------------------+----------------------+----------------------+\n",
    "stderr": ""
  }
}
```

Response (failed):

```json
{
  "id": "job-1",
  "runId": "job-1",
  "gpu": "dgx",
  "status": "failed",
  "type": "research.bench",
  "attempt": 1,
  "worker": "dgx",
  "failureCause": "container_start_failed",
  "result": {
    "exitCode": 1,
    "stdout": "",
    "stderr": "Error: GPU dgx not available"
  }
}
```

Fields:

- `status`: `queued` | `running` | `completed` | `failed` | `canceled`
- `worker`: The node that claimed the job
- `attempt`: Retry attempt number
- `result.exitCode`: Process exit code (0 = success)
- `result.stdout` / `result.stderr`: Captured output
- `failureCause`: Normalized failure reason when `status == "failed"`

## Cancel a job (`POST /v1/compute/fleet/jobs/{id}/cancel`)

```bash
curl -s -X POST "https://api.hanzo.ai/v1/compute/fleet/jobs/job-1/cancel" \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason": "superseded"}' | jq '.'
```

Response:

```json
{
  "canceled": "job-1",
  "run": "job-1"
}
```

- Only queued or running jobs can be canceled (finished → 409).
- Org-scoped: a tenant can only cancel its own jobs.

## List queue (GET /v1/compute/fleet/jobs)

```bash
curl -s "https://api.hanzo.ai/v1/compute/fleet/jobs?gpu=dgx&status=queued" \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'
```

Query parameters:

- `gpu` (optional): Narrow to one GPU's queue
- `status` (optional): Filter by status

Response:

```json
{
  "jobs": [
    {"id": "job-1", "gpu": "dgx", "status": "queued", "type": "research.bench", "runId": "job-1"},
    {"id": "job-2", "gpu": "dgx", "status": "running", "type": "research.bench", "runId": "job-2", "worker": "dgx"}
  ]
}
```

## Run on all four surfaces

**CLI**

```bash
# Submit
hanzo compute fleet jobs submit --gpu dgx --type research.bench --input '{"name":"gb10-probe","command":["nvidia-smi"]}'

# Poll status
hanzo compute fleet jobs get job-1

# Cancel
hanzo compute fleet jobs cancel job-1 --reason superseded

# List queue
hanzo compute fleet jobs list --gpu dgx --status queued
```

**SDK**

**Python**

```python
import os
from hanzo_research import HanzoResearch  # or appropriate compute client

client = HanzoResearch(api_key=os.environ["HANZO_API_KEY"])

# Submit
job = client.compute.fleet.jobs.submit(
    gpu="dgx",
    type="research.bench",
    input={"name": "gb10-probe", "command": ["nvidia-smi"]}
)

# Poll status
job = client.compute.fleet.jobs.get(job["id"])

# Cancel
client.compute.fleet.jobs.cancel(job["id"], reason="superseded")

# List queue
jobs = client.compute.fleet.jobs.list(gpu="dgx", status="queued")
```

**Rust**

```rust
use hanzo_research::{HanzoResearch, ComputeJobSubmit};

let client = HanzoResearch::new(std::env::var("HANZO_API_KEY")?);

// Submit
let job = client.compute().fleet().jobs().submit(ComputeJobSubmit {
    gpu: Some("dgx".into()),
    type: Some("research.bench".into()),
    input: serde_json::json!({"name": "gb10-probe", "command": ["nvidia-smi"]}),
}).await?;

// Poll status
let job = client.compute().fleet().jobs().get(&job.id).await?;

// Cancel
client.compute().fleet().jobs().cancel(&job.id, "superseded").await?;

// List queue
let jobs = client.compute().fleet().jobs().list(Some("dgx"), Some("queued")).await?;
```

**HTTP**

```bash
# All examples above use HTTP directly with curl
# See each section above for exact curl commands
```

**MCP**

```bash
# Submit
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "compute",
      "arguments": {"op": "submit_fleet_job", "input": {"gpu": "dgx", "type": "research.bench", "input": {"name": "gb10-probe", "command": ["nvidia-smi"]}}}
    }
  }'

# Get status
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "compute",
      "arguments": {"op": "get_fleet_job", "input": {"id": "job-1"}}
    }
  }'

# Cancel
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "compute",
      "arguments": {"op": "cancel_fleet_job", "input": {"id": "job-1", "reason": "superseded"}}
    }
  }'
```

## GPU job types

| Type             | Description                    |
| ---------------- | ------------------------------ |
| `research.bench` | Benchmark run (default)        |
| `research.train` | Training job                   |
| `research.eval`  | Evaluation job                 |
| `custom.*`       | Custom types for BYO workloads |

## Notes

- The `gpu-jobs` namespace is the queue name. `hanzo link` binds a node to this namespace.
- BYO (Bring Your Own) GPU units also carry their `gpu-jobs` queue depth.
- Shared lane: omit `gpu` to broadcast on the shared any-GPU queue.
- Job `id` is idempotent — use a deterministic ID to avoid duplicate submissions.

## Related

- [Experiments & Evidence](https://docs.hanzo.ai/docs/science/experiments-evidence) — pre-register, run, claim, study
- [Research Autopilot](https://docs.hanzo.ai/docs/science/research-autopilot) — event-triggered automations that can submit GPU jobs
- [Scientific Method](https://docs.hanzo.ai/docs/science/scientific-method) — hypothesis, baselines, paired observations
