File size: 2,150 Bytes
532abe9
81f75fe
 
 
 
532abe9
 
81f75fe
 
 
 
 
 
 
532abe9
 
81f75fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
title: Compute Market Environment Server
emoji: 📊
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
app_port: 8000
base_path: /web
tags:
  - openenv
  - multi-agent
  - compute-allocation
  - market-simulation
---

# Compute Market Environment

An OpenEnv environment for training a single allocator/trader in a scarce-GPU market with scripted background actors, hidden incentives, delayed rewards, and partial observability.

## What v1 implements

- One trained agent: the allocator/trader
- Scripted counterparties: urgent tenant, cost-sensitive tenant, broker
- Jobs with deadlines, value, dependencies, and delayed payoff
- Actions: `bid_for_capacity`, `accept_offer`, `propose_swap`, `schedule_job`, `delay_job`, `inspect_market`, `noop`
- Reward = completed job value minus compute spend, missed-deadline penalties, and idle-hoarding penalties
- Separate training helper for TRL/Colab in `training/minimal_grpo_rollout.py`

## Quick Start

```python
from compute_market_env import ComputeMarketAction, ComputeMarketEnv

with ComputeMarketEnv(base_url="http://localhost:8000") as env:
    result = env.reset(seed=7)
    print(result.observation.market_price)
    print(result.observation.free_gpus)

    result = env.step(
        ComputeMarketAction(
            action_type="bid_for_capacity",
            gpu_count=4,
            price_per_gpu=6.5,
            duration=3,
        )
    )
    print(result.reward)
    print(result.observation.budget_remaining)
```

## Local Development

```bash
uv sync --extra dev
uv run pytest -q
uv run uvicorn server.app:app --host 0.0.0.0 --port 8000
openenv validate --verbose
```

## Docker

```bash
docker build -t compute-market-env:latest -f server/Dockerfile .
docker run -p 8000:8000 compute-market-env:latest
```

## Environment Loop

1. Agent observes market price, public free GPUs, visible offers, jobs, and public actor signals.
2. Agent takes one action.
3. The environment advances one tick.
4. Scripted actors update demand and offers.
5. Jobs progress, complete, pause, or miss deadlines.
6. The environment returns the next observation and realized reward for that tick.