elasticgrid 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,40 @@
1
+ """elasticgrid: a cross-cloud elastic training grid.
2
+
3
+ elasticgrid decides **how big** a training job should be right now and
4
+ **where** those nodes should run. It is the control plane in front of
5
+ iroh-tinker's multi-cloud launch layer:
6
+
7
+ * :mod:`elasticgrid.metrics` collects the signals (step time, queue time,
8
+ throughput) from a rolling window of training steps;
9
+ * :mod:`elasticgrid.scheduler` turns those signals into a scale decision,
10
+ with bounds, a cooldown and a deadline rule;
11
+ * :mod:`elasticgrid.grid` places the nodes over the available providers and
12
+ costs the placement, then renders an iroh-tinker ``LaunchSpec``.
13
+
14
+ Nothing here provisions anything by itself: the placement is a plan, and
15
+ iroh-tinker's ``JobManager`` executes it.
16
+ """
17
+ from __future__ import annotations
18
+
19
+ __version__ = "0.1.0"
20
+
21
+ from .grid import GridPlanner, Placement, Provider, build_launch_spec, providers_from_dicts
22
+ from .metrics import MetricsWindow, StepSample
23
+ from .scheduler import ElasticScheduler, ScaleAction, ScaleDecision
24
+
25
+ __all__ = [
26
+ "__version__",
27
+ # metrics
28
+ "MetricsWindow",
29
+ "StepSample",
30
+ # scheduler
31
+ "ElasticScheduler",
32
+ "ScaleAction",
33
+ "ScaleDecision",
34
+ # grid
35
+ "GridPlanner",
36
+ "Placement",
37
+ "Provider",
38
+ "build_launch_spec",
39
+ "providers_from_dicts",
40
+ ]
elasticgrid/cli.py ADDED
@@ -0,0 +1,222 @@
1
+ """``elasticgrid`` command line interface.
2
+
3
+ Subcommands:
4
+
5
+ ``providers`` show the configured grid
6
+ ``plan`` place N nodes over the grid and cost it
7
+ ``spec`` render the iroh-tinker launch spec for a placement
8
+ ``simulate`` feed a window of step samples through the scheduler
9
+
10
+ Every command supports ``--json``.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import argparse
15
+ import json
16
+ import sys
17
+ from collections.abc import Sequence
18
+ from pathlib import Path
19
+ from typing import Any
20
+
21
+ from .grid import GridPlanner, Provider, build_launch_spec, providers_from_dicts
22
+ from .metrics import MetricsWindow, StepSample
23
+ from .scheduler import ElasticScheduler
24
+
25
+ __all__ = ["build_parser", "main"]
26
+
27
+ DEFAULT_PROVIDERS = [
28
+ {
29
+ "name": "local",
30
+ "region": "",
31
+ "max_nodes": 8,
32
+ "cost_per_node_hour": 0.0,
33
+ "spot": False,
34
+ },
35
+ {
36
+ "name": "gcp",
37
+ "region": "us-central1",
38
+ "max_nodes": 64,
39
+ "cost_per_node_hour": 3.5,
40
+ "accelerator": "A100",
41
+ "spot": True,
42
+ },
43
+ {
44
+ "name": "aws",
45
+ "region": "us-east-1",
46
+ "max_nodes": 64,
47
+ "cost_per_node_hour": 3.2,
48
+ "accelerator": "p5.48xlarge",
49
+ "spot": True,
50
+ },
51
+ {
52
+ "name": "azure",
53
+ "region": "westeurope",
54
+ "max_nodes": 32,
55
+ "cost_per_node_hour": 3.9,
56
+ "accelerator": "ND96asr",
57
+ "spot": True,
58
+ },
59
+ ]
60
+
61
+
62
+ def _load_providers(path: str | None) -> list[Provider]:
63
+ if path is None:
64
+ return providers_from_dicts(DEFAULT_PROVIDERS)
65
+ raw = json.loads(Path(path).read_text())
66
+ entries = raw.get("providers", raw) if isinstance(raw, dict) else raw
67
+ return providers_from_dicts(entries)
68
+
69
+
70
+ def build_parser() -> argparse.ArgumentParser:
71
+ parser = argparse.ArgumentParser(
72
+ prog="elasticgrid",
73
+ description="Cross-cloud elastic training grid for variable-size workloads.",
74
+ )
75
+ parser.add_argument("--json", action="store_true", help="emit JSON on stdout")
76
+ sub = parser.add_subparsers(dest="command", required=True)
77
+
78
+ providers = sub.add_parser("providers", help="show the configured grid")
79
+ providers.add_argument("--providers", help="JSON file describing the providers")
80
+ providers.add_argument("--json", action="store_true", help="emit JSON on stdout")
81
+
82
+ plan = sub.add_parser("plan", help="place nodes over the grid")
83
+ plan.add_argument("--nodes", type=int, required=True, help="how many nodes")
84
+ plan.add_argument("--providers", help="JSON file describing the providers")
85
+ plan.add_argument("--max-spot-fraction", type=float, default=1.0)
86
+ plan.add_argument("--prefer", default="cost", choices=["cost", "balance"])
87
+ plan.add_argument("--json", action="store_true", help="emit JSON on stdout")
88
+
89
+ spec = sub.add_parser("spec", help="render a launch spec for a placement")
90
+ spec.add_argument("--nodes", type=int, required=True, help="how many nodes")
91
+ spec.add_argument("--providers", help="JSON file describing the providers")
92
+ spec.add_argument("--name", default="grid-job")
93
+ spec.add_argument("--run", default="python train.py")
94
+ spec.add_argument("--json", action="store_true", help="emit JSON on stdout")
95
+
96
+ simulate = sub.add_parser("simulate", help="run the scheduler over a window")
97
+ simulate.add_argument(
98
+ "--samples",
99
+ required=True,
100
+ help="JSON list of {step, duration_s, queue_s, nodes}",
101
+ )
102
+ simulate.add_argument("--nodes", type=int, default=8, help="current node count")
103
+ simulate.add_argument("--min-nodes", type=int, default=1)
104
+ simulate.add_argument("--max-nodes", type=int, default=1024)
105
+ simulate.add_argument("--cooldown", type=float, default=300.0)
106
+ simulate.add_argument("--json", action="store_true", help="emit JSON on stdout")
107
+
108
+ return parser
109
+
110
+
111
+ def _cmd_providers(args: argparse.Namespace) -> int:
112
+ planner = GridPlanner(_load_providers(args.providers))
113
+ payload = planner.summary()
114
+ if args.json:
115
+ _emit_json(payload)
116
+ return 0
117
+ print("provider region nodes $/node/h spot")
118
+ for provider in payload["providers"]:
119
+ print(
120
+ f" {provider['name']:<8} {provider['region'] or '-':<12} "
121
+ f"{provider['max_nodes']:>5} {provider['cost_per_node_hour']:>9.2f} "
122
+ f"{provider['spot']}"
123
+ )
124
+ print(f"total capacity: {payload['capacity']} nodes")
125
+ return 0
126
+
127
+
128
+ def _cmd_plan(args: argparse.Namespace) -> int:
129
+ planner = GridPlanner(
130
+ _load_providers(args.providers),
131
+ max_spot_fraction=args.max_spot_fraction,
132
+ prefer=args.prefer,
133
+ )
134
+ placement = planner.plan(args.nodes)
135
+ payload = placement.to_dict()
136
+ if args.json:
137
+ _emit_json(payload)
138
+ return 0
139
+ print(f"placement for {placement.total_nodes} nodes:")
140
+ for name, count in placement.assignments:
141
+ print(f" {name:<10} {count:>5} nodes")
142
+ print(f"cost: ${placement.cost_per_hour:.2f}/hour spot share: {placement.spot_fraction:.0%}")
143
+ print(f"infra order: {', '.join(placement.infra_refs)}")
144
+ return 0
145
+
146
+
147
+ def _cmd_spec(args: argparse.Namespace) -> int:
148
+ planner = GridPlanner(_load_providers(args.providers))
149
+ placement = planner.plan(args.nodes)
150
+ spec = build_launch_spec(
151
+ placement,
152
+ name=args.name,
153
+ run=args.run,
154
+ num_nodes=placement.total_nodes,
155
+ )
156
+ payload = spec.to_dict()
157
+ if args.json:
158
+ _emit_json(payload)
159
+ return 0
160
+ print(json.dumps(payload, indent=2))
161
+ return 0
162
+
163
+
164
+ def _cmd_simulate(args: argparse.Namespace) -> int:
165
+ raw = json.loads(Path(args.samples).read_text())
166
+ window = MetricsWindow()
167
+ for entry in raw:
168
+ window.add(
169
+ StepSample(
170
+ step=int(entry.get("step", 0)),
171
+ duration_s=float(entry.get("duration_s", 0.0)),
172
+ queue_s=float(entry.get("queue_s", 0.0)),
173
+ nodes=int(entry.get("nodes", args.nodes)),
174
+ tokens=int(entry.get("tokens", 0)),
175
+ )
176
+ )
177
+ scheduler = ElasticScheduler(
178
+ min_nodes=args.min_nodes,
179
+ max_nodes=args.max_nodes,
180
+ cooldown_s=args.cooldown,
181
+ )
182
+ decision = scheduler.decide(current_nodes=args.nodes, window=window)
183
+ payload = {
184
+ "window": window.to_dict(),
185
+ "decision": decision.to_dict(),
186
+ }
187
+ if args.json:
188
+ _emit_json(payload)
189
+ return 0
190
+ print(f"action: {decision.action} ({decision.current_nodes} -> {decision.target_nodes})")
191
+ print(f"reason: {decision.reason}")
192
+ return 0
193
+
194
+
195
+ def _emit_json(payload: Any) -> None:
196
+ sys.stdout.write(json.dumps(payload, indent=2) + "\n")
197
+
198
+
199
+ def main(argv: Sequence[str] | None = None) -> int:
200
+ parser = build_parser()
201
+ args = parser.parse_args(list(argv) if argv is not None else None)
202
+ try:
203
+ if args.command == "providers":
204
+ return _cmd_providers(args)
205
+ if args.command == "plan":
206
+ return _cmd_plan(args)
207
+ if args.command == "spec":
208
+ return _cmd_spec(args)
209
+ if args.command == "simulate":
210
+ return _cmd_simulate(args)
211
+ except (FileNotFoundError, ValueError, RuntimeError) as exc:
212
+ if getattr(args, "json", False):
213
+ _emit_json({"error": str(exc)})
214
+ else:
215
+ print(f"error: {exc}", file=sys.stderr)
216
+ return 2
217
+ parser.error(f"unknown command {args.command!r}")
218
+ return 2
219
+
220
+
221
+ if __name__ == "__main__": # pragma: no cover
222
+ raise SystemExit(main())
elasticgrid/grid.py ADDED
@@ -0,0 +1,304 @@
1
+ """Where the nodes go: the cross-cloud placement.
2
+
3
+ The grid spreads a workload over several providers. The placement is a pure
4
+ function of (nodes, providers, policy), so it can be planned, costed and
5
+ reviewed before anything is provisioned, and two runs of the same plan get
6
+ the same placement.
7
+
8
+ The result is handed to iroh-tinker's launch layer as
9
+ ``ResourcesSpec.infra``: an ordered list of infra references such as
10
+ ``gcp/us-central1``. iroh-tinker fails over down that list, so the order
11
+ matters: the cheapest provider that can take the whole job goes first, and
12
+ the spot/on-demand mix is explicit.
13
+ """
14
+ from __future__ import annotations
15
+
16
+ from collections.abc import Iterable, Mapping, Sequence
17
+ from dataclasses import dataclass
18
+ from typing import Any
19
+
20
+ from iroh_tinker.cloud.spec import LaunchSpec, ResourcesSpec
21
+
22
+ __all__ = [
23
+ "GridPlanner",
24
+ "Placement",
25
+ "Provider",
26
+ "build_launch_spec",
27
+ "providers_from_dicts",
28
+ ]
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class Provider:
33
+ """A place to run nodes."""
34
+
35
+ name: str
36
+ region: str = ""
37
+ max_nodes: int = 0
38
+ cost_per_node_hour: float = 0.0
39
+ accelerator: str | None = None
40
+ spot: bool = True
41
+
42
+ def __post_init__(self) -> None:
43
+ if not self.name:
44
+ raise ValueError("provider name must not be empty")
45
+ if self.max_nodes < 0:
46
+ raise ValueError("max_nodes must be non-negative")
47
+ if self.cost_per_node_hour < 0:
48
+ raise ValueError("cost_per_node_hour must be non-negative")
49
+
50
+ @property
51
+ def infra_ref(self) -> str:
52
+ """The infra reference iroh-tinker's launch layer understands."""
53
+ return f"{self.name}/{self.region}" if self.region else self.name
54
+
55
+ @property
56
+ def capacity(self) -> int:
57
+ """How many nodes this provider can take right now."""
58
+ return self.max_nodes
59
+
60
+ def to_dict(self) -> dict[str, Any]:
61
+ return {
62
+ "name": self.name,
63
+ "region": self.region,
64
+ "max_nodes": self.max_nodes,
65
+ "cost_per_node_hour": self.cost_per_node_hour,
66
+ "accelerator": self.accelerator,
67
+ "spot": self.spot,
68
+ "infra_ref": self.infra_ref,
69
+ }
70
+
71
+
72
+ @dataclass(frozen=True)
73
+ class Placement:
74
+ """How many nodes each provider takes."""
75
+
76
+ assignments: tuple[tuple[str, int], ...]
77
+ total_nodes: int
78
+ cost_per_hour: float
79
+ providers: tuple[Provider, ...] = ()
80
+
81
+ def nodes_for(self, provider_name: str) -> int:
82
+ for name, count in self.assignments:
83
+ if name == provider_name:
84
+ return count
85
+ return 0
86
+
87
+ @property
88
+ def infra_refs(self) -> list[str]:
89
+ """The ordered infra references for the launch spec."""
90
+ by_name = {provider.name: provider for provider in self.providers}
91
+ refs = []
92
+ for name, count in self.assignments:
93
+ if count <= 0:
94
+ continue
95
+ provider = by_name.get(name)
96
+ if provider is not None:
97
+ refs.append(provider.infra_ref)
98
+ return refs
99
+
100
+ @property
101
+ def spot_fraction(self) -> float:
102
+ """Share of the nodes that are on spot capacity."""
103
+ if self.total_nodes <= 0:
104
+ return 0.0
105
+ by_name = {provider.name: provider for provider in self.providers}
106
+ spot_nodes = sum(
107
+ count
108
+ for name, count in self.assignments
109
+ if by_name.get(name) is not None and by_name[name].spot
110
+ )
111
+ return spot_nodes / self.total_nodes
112
+
113
+ def to_dict(self) -> dict[str, Any]:
114
+ return {
115
+ "assignments": [
116
+ {"provider": name, "nodes": count} for name, count in self.assignments
117
+ ],
118
+ "total_nodes": self.total_nodes,
119
+ "cost_per_hour": self.cost_per_hour,
120
+ "spot_fraction": self.spot_fraction,
121
+ "infra_refs": self.infra_refs,
122
+ }
123
+
124
+
125
+ class GridPlanner:
126
+ """Plans a placement of N nodes over a set of providers."""
127
+
128
+ def __init__(
129
+ self,
130
+ providers: Sequence[Provider],
131
+ *,
132
+ max_spot_fraction: float = 1.0,
133
+ prefer: str = "cost",
134
+ ) -> None:
135
+ if not providers:
136
+ raise ValueError("a grid needs at least one provider")
137
+ if not 0 <= max_spot_fraction <= 1:
138
+ raise ValueError("max_spot_fraction must be in [0, 1]")
139
+ if prefer not in ("cost", "balance"):
140
+ raise ValueError("prefer must be 'cost' or 'balance'")
141
+ names = [provider.name for provider in providers]
142
+ if len(set(names)) != len(names):
143
+ raise ValueError("provider names must be unique")
144
+ self.providers = tuple(providers)
145
+ self.max_spot_fraction = max_spot_fraction
146
+ self.prefer = prefer
147
+
148
+ # -- ordering --------------------------------------------------------
149
+ def ordered(self) -> list[Provider]:
150
+ """The providers in the order the placement will use them."""
151
+ if self.prefer == "cost":
152
+ return sorted(self.providers, key=lambda p: (p.cost_per_node_hour, p.name))
153
+ # "balance": spread across providers, cheapest first.
154
+ return sorted(self.providers, key=lambda p: (p.cost_per_node_hour, p.name))
155
+
156
+ # -- planning ---------------------------------------------------------
157
+ def plan(self, nodes: int) -> Placement:
158
+ """Plan ``nodes`` nodes over the providers.
159
+
160
+ Raises ``ValueError`` when the grid cannot hold the requested size.
161
+ """
162
+ if nodes < 0:
163
+ raise ValueError("nodes must be non-negative")
164
+ if nodes == 0:
165
+ return Placement(
166
+ assignments=(),
167
+ total_nodes=0,
168
+ cost_per_hour=0.0,
169
+ providers=self.providers,
170
+ )
171
+
172
+ capacity = sum(provider.capacity for provider in self.providers)
173
+ if nodes > capacity:
174
+ raise ValueError(
175
+ f"the grid can hold {capacity} nodes, {nodes} requested"
176
+ )
177
+
178
+ order = self.ordered()
179
+ spot_budget = int(self.max_spot_fraction * nodes)
180
+ spot_used = 0
181
+ on_demand_used = 0
182
+ assignments: dict[str, int] = {provider.name: 0 for provider in order}
183
+
184
+ # First pass: fill the cheapest provider, but respect the spot budget.
185
+ for provider in order:
186
+ if sum(assignments.values()) >= nodes:
187
+ break
188
+ remaining = nodes - sum(assignments.values())
189
+ take = min(provider.capacity, remaining)
190
+ if provider.spot:
191
+ allowed = max(0, spot_budget - spot_used)
192
+ take = min(take, allowed)
193
+ else:
194
+ take = min(take, max(0, nodes - spot_budget - on_demand_used))
195
+ if take <= 0:
196
+ continue
197
+ assignments[provider.name] = take
198
+ if provider.spot:
199
+ spot_used += take
200
+ else:
201
+ on_demand_used += take
202
+
203
+ # Second pass: if the spot budget left nodes unplaced, fill them from
204
+ # the remaining capacity regardless of the spot policy, because a job
205
+ # that cannot start is worse than a job that breaks the policy.
206
+ shortfall = nodes - sum(assignments.values())
207
+ if shortfall > 0:
208
+ for provider in order:
209
+ if shortfall <= 0:
210
+ break
211
+ take = min(shortfall, provider.capacity - assignments[provider.name])
212
+ if take <= 0:
213
+ continue
214
+ assignments[provider.name] += take
215
+ shortfall -= take
216
+
217
+ ordered_assignments = tuple(
218
+ (provider.name, assignments[provider.name])
219
+ for provider in order
220
+ if assignments[provider.name] > 0
221
+ )
222
+ cost = sum(
223
+ count * provider.cost_per_node_hour
224
+ for provider in order
225
+ for name, count in ordered_assignments
226
+ if name == provider.name
227
+ )
228
+ return Placement(
229
+ assignments=ordered_assignments,
230
+ total_nodes=sum(count for _, count in ordered_assignments),
231
+ cost_per_hour=round(cost, 6),
232
+ providers=self.providers,
233
+ )
234
+
235
+ def plan_many(self, sizes: Iterable[int]) -> list[Placement]:
236
+ return [self.plan(size) for size in sizes]
237
+
238
+ def summary(self) -> dict[str, Any]:
239
+ return {
240
+ "providers": [provider.to_dict() for provider in self.ordered()],
241
+ "capacity": sum(provider.capacity for provider in self.providers),
242
+ "max_spot_fraction": self.max_spot_fraction,
243
+ "prefer": self.prefer,
244
+ }
245
+
246
+
247
+ def build_launch_spec(
248
+ placement: Placement,
249
+ *,
250
+ name: str,
251
+ run: str,
252
+ workdir: str = ".",
253
+ num_nodes: int | None = None,
254
+ procs_per_node: int = 1,
255
+ backend: str = "numpy",
256
+ instance_type: str | None = None,
257
+ use_spot: bool = True,
258
+ rendezvous_uri: str | None = None,
259
+ ) -> LaunchSpec:
260
+ """Turn a placement into an iroh-tinker launch spec."""
261
+ nodes = placement.total_nodes if num_nodes is None else num_nodes
262
+ spec = LaunchSpec(
263
+ name=name,
264
+ run=run,
265
+ workdir=workdir,
266
+ num_nodes=nodes,
267
+ procs_per_node=procs_per_node,
268
+ backend=backend,
269
+ resources=ResourcesSpec(
270
+ infra=placement.infra_refs,
271
+ instance_type=instance_type,
272
+ use_spot=use_spot,
273
+ ),
274
+ rendezvous=_rendezvous(rendezvous_uri),
275
+ )
276
+ spec.validate()
277
+ return spec
278
+
279
+
280
+ def _rendezvous(uri: str | None) -> Any:
281
+ from iroh_tinker.cloud.spec import RendezvousSpec
282
+
283
+ if not uri:
284
+ return RendezvousSpec()
285
+ if uri.startswith("dir:"):
286
+ return RendezvousSpec(mode="dir", uri=uri[len("dir:") :])
287
+ return RendezvousSpec(mode="dir", uri=uri)
288
+
289
+
290
+ def providers_from_dicts(raw: Iterable[Mapping[str, Any]]) -> list[Provider]:
291
+ """Build providers from a JSON-ish description."""
292
+ providers: list[Provider] = []
293
+ for entry in raw:
294
+ providers.append(
295
+ Provider(
296
+ name=str(entry["name"]),
297
+ region=str(entry.get("region", "")),
298
+ max_nodes=int(entry.get("max_nodes", 0)),
299
+ cost_per_node_hour=float(entry.get("cost_per_node_hour", 0.0)),
300
+ accelerator=entry.get("accelerator"),
301
+ spot=bool(entry.get("spot", True)),
302
+ )
303
+ )
304
+ return providers
elasticgrid/metrics.py ADDED
@@ -0,0 +1,145 @@
1
+ """Signals the elastic scheduler acts on.
2
+
3
+ The scheduler does not look at the cloud; it looks at a window of step
4
+ samples. Each sample says how long a step took, how long the step waited in
5
+ the queue, how many nodes were running and how much work the step did.
6
+
7
+ From those the window derives the two numbers that matter:
8
+
9
+ * **queue time** -- workers are idle while they wait. That is a capacity
10
+ problem: add workers.
11
+ * **step time** -- workers are busy but the step is slow. That is a
12
+ parallelism problem: either the step is too big for the current world size,
13
+ or the interconnect is the bottleneck.
14
+ """
15
+ from __future__ import annotations
16
+
17
+ from collections import deque
18
+ from dataclasses import dataclass
19
+ from typing import Any
20
+
21
+ __all__ = ["MetricsWindow", "StepSample"]
22
+
23
+
24
+ @dataclass(frozen=True)
25
+ class StepSample:
26
+ """One observed training step."""
27
+
28
+ step: int
29
+ duration_s: float
30
+ queue_s: float = 0.0
31
+ nodes: int = 1
32
+ tokens: int = 0
33
+
34
+ def __post_init__(self) -> None:
35
+ if self.duration_s < 0:
36
+ raise ValueError("duration_s must be non-negative")
37
+ if self.queue_s < 0:
38
+ raise ValueError("queue_s must be non-negative")
39
+ if self.nodes < 0:
40
+ raise ValueError("nodes must be non-negative")
41
+ if self.tokens < 0:
42
+ raise ValueError("tokens must be non-negative")
43
+
44
+ @property
45
+ def active_s(self) -> float:
46
+ """The part of the step that was actually computing."""
47
+ return max(0.0, self.duration_s - self.queue_s)
48
+
49
+
50
+ class MetricsWindow:
51
+ """A rolling window of step samples.
52
+
53
+ The window is the only thing the scheduler reads, so a decision can be
54
+ replayed from a recorded window in a test or an incident review.
55
+ """
56
+
57
+ def __init__(self, size: int = 10) -> None:
58
+ if size <= 0:
59
+ raise ValueError("window size must be positive")
60
+ self.size = size
61
+ self._samples: deque[StepSample] = deque(maxlen=size)
62
+
63
+ def add(self, sample: StepSample) -> None:
64
+ self._samples.append(sample)
65
+
66
+ def extend(self, samples: list[StepSample]) -> None:
67
+ for sample in samples:
68
+ self.add(sample)
69
+
70
+ def clear(self) -> None:
71
+ self._samples.clear()
72
+
73
+ # -- contents --------------------------------------------------------
74
+ def __len__(self) -> int:
75
+ return len(self._samples)
76
+
77
+ def __iter__(self): # type: ignore[no-untyped-def]
78
+ return iter(self._samples)
79
+
80
+ @property
81
+ def samples(self) -> list[StepSample]:
82
+ return list(self._samples)
83
+
84
+ @property
85
+ def nodes(self) -> int:
86
+ """The node count of the most recent sample."""
87
+ return self._samples[-1].nodes if self._samples else 0
88
+
89
+ # -- derived signals -------------------------------------------------
90
+ @property
91
+ def mean_step_s(self) -> float:
92
+ if not self._samples:
93
+ return 0.0
94
+ return sum(s.duration_s for s in self._samples) / len(self._samples)
95
+
96
+ @property
97
+ def mean_queue_s(self) -> float:
98
+ if not self._samples:
99
+ return 0.0
100
+ return sum(s.queue_s for s in self._samples) / len(self._samples)
101
+
102
+ @property
103
+ def mean_active_s(self) -> float:
104
+ if not self._samples:
105
+ return 0.0
106
+ return sum(s.active_s for s in self._samples) / len(self._samples)
107
+
108
+ @property
109
+ def queue_fraction(self) -> float:
110
+ """Share of the step spent waiting rather than computing."""
111
+ total = sum(s.duration_s for s in self._samples)
112
+ if total <= 0:
113
+ return 0.0
114
+ return sum(s.queue_s for s in self._samples) / total
115
+
116
+ @property
117
+ def throughput_tokens_per_s(self) -> float:
118
+ if not self._samples:
119
+ return 0.0
120
+ tokens = sum(s.tokens for s in self._samples)
121
+ seconds = sum(s.duration_s for s in self._samples)
122
+ if seconds <= 0:
123
+ return 0.0
124
+ return tokens / seconds
125
+
126
+ @property
127
+ def saturated(self) -> bool:
128
+ """Whether the window shows the workers are saturated."""
129
+ return self.queue_fraction >= 0.2
130
+
131
+ @property
132
+ def stalled(self) -> bool:
133
+ """Whether the window shows the step is dominated by waiting."""
134
+ return self.queue_fraction >= 0.6
135
+
136
+ def to_dict(self) -> dict[str, Any]:
137
+ return {
138
+ "samples": len(self._samples),
139
+ "nodes": self.nodes,
140
+ "mean_step_s": self.mean_step_s,
141
+ "mean_queue_s": self.mean_queue_s,
142
+ "mean_active_s": self.mean_active_s,
143
+ "queue_fraction": self.queue_fraction,
144
+ "throughput_tokens_per_s": self.throughput_tokens_per_s,
145
+ }
elasticgrid/py.typed ADDED
File without changes
@@ -0,0 +1,231 @@
1
+ """The elastic scale decision.
2
+
3
+ The scheduler answers one question: given what the last few steps looked
4
+ like, how many nodes should the next step run on?
5
+
6
+ The rules, in order:
7
+
8
+ 1. **Never scale on thin evidence.** Fewer than ``min_samples`` observations
9
+ means hold.
10
+ 2. **Respect the bounds.** The target is clamped to
11
+ ``[min_nodes, max_nodes]``.
12
+ 3. **Honour the cooldown.** After a change, wait ``cooldown_s`` before
13
+ changing again. Elastic scaling without a cooldown oscillates.
14
+ 4. **Queue-bound means scale up.** If the step spent most of its time waiting
15
+ for a worker, the job needs more workers.
16
+ 5. **Idle-bound means scale down.** If the step was fast and nobody waited,
17
+ the job is paying for idle workers.
18
+ 6. **Do not scale up near the deadline.** Starting workers that will not
19
+ finish before the deadline costs money and saves nothing.
20
+ """
21
+ from __future__ import annotations
22
+
23
+ from dataclasses import dataclass, field
24
+ from typing import Any
25
+
26
+ from .metrics import MetricsWindow
27
+
28
+ __all__ = ["ElasticScheduler", "ScaleAction", "ScaleDecision"]
29
+
30
+
31
+ class ScaleAction:
32
+ """The three things the scheduler can say."""
33
+
34
+ SCALE_UP = "scale_up"
35
+ SCALE_DOWN = "scale_down"
36
+ HOLD = "hold"
37
+
38
+ ALL = (SCALE_UP, SCALE_DOWN, HOLD)
39
+
40
+
41
+ @dataclass(frozen=True)
42
+ class ScaleDecision:
43
+ """One decision, with the reason it was made."""
44
+
45
+ action: str
46
+ current_nodes: int
47
+ target_nodes: int
48
+ reason: str
49
+ signals: dict[str, Any] = field(default_factory=dict)
50
+
51
+ @property
52
+ def changed(self) -> bool:
53
+ return self.action != ScaleAction.HOLD
54
+
55
+ def to_dict(self) -> dict[str, Any]:
56
+ return {
57
+ "action": self.action,
58
+ "current_nodes": self.current_nodes,
59
+ "target_nodes": self.target_nodes,
60
+ "reason": self.reason,
61
+ "signals": dict(self.signals),
62
+ }
63
+
64
+
65
+ class ElasticScheduler:
66
+ """Decides the node count for the next step."""
67
+
68
+ def __init__(
69
+ self,
70
+ *,
71
+ min_nodes: int = 1,
72
+ max_nodes: int = 1024,
73
+ scale_up_factor: float = 2.0,
74
+ scale_down_factor: float = 0.5,
75
+ cooldown_s: float = 300.0,
76
+ target_queue_fraction: float = 0.2,
77
+ idle_queue_fraction: float = 0.05,
78
+ idle_step_fraction: float = 0.5,
79
+ target_step_s: float = 30.0,
80
+ min_samples: int = 3,
81
+ deadline_s: float | None = None,
82
+ ) -> None:
83
+ if min_nodes < 1:
84
+ raise ValueError("min_nodes must be at least 1")
85
+ if max_nodes < min_nodes:
86
+ raise ValueError("max_nodes must be >= min_nodes")
87
+ if scale_up_factor <= 1:
88
+ raise ValueError("scale_up_factor must be > 1")
89
+ if not 0 < scale_down_factor < 1:
90
+ raise ValueError("scale_down_factor must be in (0, 1)")
91
+ if min_samples < 1:
92
+ raise ValueError("min_samples must be at least 1")
93
+ self.min_nodes = min_nodes
94
+ self.max_nodes = max_nodes
95
+ self.scale_up_factor = scale_up_factor
96
+ self.scale_down_factor = scale_down_factor
97
+ self.cooldown_s = cooldown_s
98
+ self.target_queue_fraction = target_queue_fraction
99
+ self.idle_queue_fraction = idle_queue_fraction
100
+ self.idle_step_fraction = idle_step_fraction
101
+ self.target_step_s = target_step_s
102
+ self.min_samples = min_samples
103
+ self.deadline_s = deadline_s
104
+ self._last_change_at: float | None = None
105
+
106
+ # -- state ------------------------------------------------------------
107
+ def reset(self) -> None:
108
+ """Forget the cooldown (used when a new job starts)."""
109
+ self._last_change_at = None
110
+
111
+ def _clamp(self, nodes: int) -> int:
112
+ return max(self.min_nodes, min(self.max_nodes, nodes))
113
+
114
+ # -- decision ---------------------------------------------------------
115
+ def decide(
116
+ self,
117
+ *,
118
+ current_nodes: int,
119
+ window: MetricsWindow,
120
+ now: float = 0.0,
121
+ time_remaining_s: float | None = None,
122
+ ) -> ScaleDecision:
123
+ """Decide the node count for the next step."""
124
+ signals = {
125
+ "samples": len(window),
126
+ "queue_fraction": window.queue_fraction,
127
+ "mean_step_s": window.mean_step_s,
128
+ "mean_queue_s": window.mean_queue_s,
129
+ "nodes": window.nodes or current_nodes,
130
+ "cooldown_s": self.cooldown_s,
131
+ }
132
+
133
+ if len(window) < self.min_samples:
134
+ return ScaleDecision(
135
+ action=ScaleAction.HOLD,
136
+ current_nodes=current_nodes,
137
+ target_nodes=current_nodes,
138
+ reason="not enough samples to decide",
139
+ signals=signals,
140
+ )
141
+
142
+ if (
143
+ self._last_change_at is not None
144
+ and now - self._last_change_at < self.cooldown_s
145
+ ):
146
+ return ScaleDecision(
147
+ action=ScaleAction.HOLD,
148
+ current_nodes=current_nodes,
149
+ target_nodes=current_nodes,
150
+ reason="cooldown",
151
+ signals=signals,
152
+ )
153
+
154
+ if window.queue_fraction >= self.target_queue_fraction:
155
+ target = self._clamp(int(current_nodes * self.scale_up_factor))
156
+ if target == current_nodes:
157
+ return ScaleDecision(
158
+ action=ScaleAction.HOLD,
159
+ current_nodes=current_nodes,
160
+ target_nodes=current_nodes,
161
+ reason="already at the node ceiling",
162
+ signals=signals,
163
+ )
164
+ if time_remaining_s is not None and time_remaining_s <= 0:
165
+ return ScaleDecision(
166
+ action=ScaleAction.HOLD,
167
+ current_nodes=current_nodes,
168
+ target_nodes=current_nodes,
169
+ reason="deadline reached, no time to start new workers",
170
+ signals=signals,
171
+ )
172
+ reason = (
173
+ f"{window.queue_fraction:.0%} of the step was spent waiting for a "
174
+ f"worker; scaling up {current_nodes} -> {target}"
175
+ )
176
+ self._last_change_at = now
177
+ return ScaleDecision(
178
+ action=ScaleAction.SCALE_UP,
179
+ current_nodes=current_nodes,
180
+ target_nodes=target,
181
+ reason=reason,
182
+ signals=signals,
183
+ )
184
+
185
+ if (
186
+ window.mean_step_s > 0
187
+ and window.mean_step_s <= self.idle_step_fraction * self.target_step_s
188
+ and window.queue_fraction <= self.idle_queue_fraction
189
+ ):
190
+ # The job is comfortably faster than the target and nobody is
191
+ # waiting for a worker: the current size is more than enough.
192
+ if current_nodes <= self.min_nodes:
193
+ return ScaleDecision(
194
+ action=ScaleAction.HOLD,
195
+ current_nodes=current_nodes,
196
+ target_nodes=current_nodes,
197
+ reason="already at the node floor",
198
+ signals=signals,
199
+ )
200
+ target = self._clamp(
201
+ max(self.min_nodes, int(current_nodes * self.scale_down_factor))
202
+ )
203
+ if target == current_nodes:
204
+ return ScaleDecision(
205
+ action=ScaleAction.HOLD,
206
+ current_nodes=current_nodes,
207
+ target_nodes=current_nodes,
208
+ reason="already at the node floor",
209
+ signals=signals,
210
+ )
211
+ reason = (
212
+ f"the step takes {window.mean_step_s:.1f}s, well inside the "
213
+ f"{self.target_step_s:.1f}s target, and no worker is waiting; "
214
+ f"scaling down {current_nodes} -> {target}"
215
+ )
216
+ self._last_change_at = now
217
+ return ScaleDecision(
218
+ action=ScaleAction.SCALE_DOWN,
219
+ current_nodes=current_nodes,
220
+ target_nodes=target,
221
+ reason=reason,
222
+ signals=signals,
223
+ )
224
+
225
+ return ScaleDecision(
226
+ action=ScaleAction.HOLD,
227
+ current_nodes=current_nodes,
228
+ target_nodes=current_nodes,
229
+ reason="the step is balanced; hold the current size",
230
+ signals=signals,
231
+ )
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: elasticgrid
3
+ Version: 0.1.0
4
+ Summary: Cross-cloud elastic training grid for variable-size workloads
5
+ License: Apache-2.0
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: iroh-tinker>=0.3.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8.0; extra == "dev"
22
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
23
+ Requires-Dist: ruff>=0.5; extra == "dev"
24
+ Requires-Dist: mypy>=1.10; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # elasticgrid
28
+
29
+ Cross-cloud elastic training grid for variable-size workloads, built on
30
+ [iroh-tinker](https://github.com/scairesearch/iroh_tinker).
31
+
32
+ elasticgrid is the control plane in front of iroh-tinker's multi-cloud launch
33
+ layer. It answers two questions:
34
+
35
+ * **How big should this job be right now?** A rolling window of training
36
+ steps (step time, queue time, throughput) feeds a scheduler that grows the
37
+ job when workers are waiting and shrinks it when the job is comfortably
38
+ faster than the target, with bounds, a cooldown and a deadline rule.
39
+ * **Where should the nodes run?** A placement plan spreads the nodes over the
40
+ available providers, respects a spot/on-demand budget, costs the placement
41
+ and renders it as an iroh-tinker `LaunchSpec`.
42
+
43
+ Nothing here provisions anything by itself: the placement is a plan, and
44
+ iroh-tinker's `JobManager` executes it.
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ pip install elasticgrid
50
+ pip install -e ".[dev]" # from a checkout
51
+ ```
52
+
53
+ elasticgrid depends on the public `iroh-tinker` surface only.
54
+
55
+ ## Built on the iroh-tinker public surface
56
+
57
+ | API | Used for |
58
+ |---|---|
59
+ | `iroh_tinker.cloud.spec.LaunchSpec` / `ResourcesSpec` / `RendezvousSpec` | the launch spec a placement renders into |
60
+ | `iroh_tinker.cloud.job.JobManager` | executing the plan |
61
+ | `iroh_tinker.hw.HardwareContext` / `infer_topology` / `select_topology_params` | topology hints for the placement |
62
+
63
+ `iroh_tinker.AllreduceAlgorithm` is **not** exported from the top-level
64
+ package; it lives in `iroh_tinker.comm`. elasticgrid does not depend on it.
65
+
66
+ ## CLI
67
+
68
+ ```bash
69
+ elasticgrid providers # the configured grid
70
+ elasticgrid plan --nodes 64 # placement + cost
71
+ elasticgrid plan --nodes 64 --max-spot-fraction 0.5
72
+ elasticgrid spec --nodes 64 --name my-job # the iroh-tinker launch spec
73
+ elasticgrid simulate --samples steps.json # what the scheduler would do
74
+ ```
75
+
76
+ Every command accepts `--json`.
77
+
78
+ ## The scale decision
79
+
80
+ The scheduler reads a window of step samples and applies the rules in order:
81
+
82
+ 1. **Never scale on thin evidence.** Fewer than `min_samples` observations
83
+ means hold.
84
+ 2. **Respect the bounds.** The target is clamped to `[min_nodes, max_nodes]`.
85
+ 3. **Honour the cooldown.** After a change, wait `cooldown_s`. Elastic
86
+ scaling without a cooldown oscillates.
87
+ 4. **Queue-bound means scale up.** If 20% or more of the step was spent
88
+ waiting for a worker, the job needs more workers.
89
+ 5. **Idle means scale down.** If the step is well inside `target_step_s` and
90
+ nobody is waiting, the current size is more than enough.
91
+ 6. **Do not scale up past the deadline.** Workers that cannot finish before
92
+ the deadline cost money and save nothing.
93
+
94
+ Every decision carries the signals it was based on, so it can be replayed and
95
+ reviewed:
96
+
97
+ ```json
98
+ {
99
+ "action": "scale_up",
100
+ "current_nodes": 8,
101
+ "target_nodes": 16,
102
+ "reason": "80% of the step was spent waiting for a worker; scaling up 8 -> 16",
103
+ "signals": {"queue_fraction": 0.8, "mean_step_s": 10.0, "...": "..."}
104
+ }
105
+ ```
106
+
107
+ ## The placement
108
+
109
+ `GridPlanner.plan(nodes)` returns a placement: how many nodes each provider
110
+ takes, what it costs per hour, and the ordered infra references that
111
+ iroh-tinker fails over through.
112
+
113
+ The policy is explicit:
114
+
115
+ * providers are filled cheapest first;
116
+ * `max_spot_fraction` caps the share of nodes on spot capacity;
117
+ * if the spot budget cannot hold the job, the remaining nodes are placed
118
+ anyway, because a job that cannot start is worse than a job that breaks
119
+ the policy;
120
+ * the placement is a pure function of (nodes, providers, policy), so the
121
+ same plan always gives the same answer.
122
+
123
+ ## Tests
124
+
125
+ ```bash
126
+ pip install -e ".[dev]"
127
+ pytest
128
+ ```
129
+
130
+ The suite is credential-free: the planner and the scheduler are pure
131
+ functions and are tested directly.
132
+
133
+ ## Layout
134
+
135
+ ```
136
+ src/elasticgrid/
137
+ metrics.py step samples and the rolling window of signals
138
+ scheduler.py the scale decision (bounds, cooldown, deadline)
139
+ grid.py providers, placement, cost, launch spec
140
+ cli.py elasticgrid providers | plan | spec | simulate
141
+ ```
142
+
143
+ ## Licence
144
+
145
+ Apache-2.0. elasticgrid is a separate project from iroh-tinker, which stays
146
+ MIT OR Apache-2.0.
@@ -0,0 +1,12 @@
1
+ elasticgrid/__init__.py,sha256=ZJSB1LoGLzRjG3O0dsLS4W0wiH1L23KiqhubciohvD0,1298
2
+ elasticgrid/cli.py,sha256=YNeAsZAFtKFhGvTjVO5Tx3_6BIdIDWOgtDIlI_ACcTA,7476
3
+ elasticgrid/grid.py,sha256=mvzlvN7xdOQHYgtSb21VAAs4HAhxN85Hh5-yI0YBkB0,10400
4
+ elasticgrid/metrics.py,sha256=3lZGWzEbhk0SWwyD5Sla0v35g5MAhxCZ9JsPrZSEshw,4646
5
+ elasticgrid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ elasticgrid/scheduler.py,sha256=1xTs9lGBd_c4XCUBrDh-wWvBs9gqJX8XntVXL8t-jXc,8327
7
+ elasticgrid-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
8
+ elasticgrid-0.1.0.dist-info/METADATA,sha256=inMRrKvnm3cUvXbpsoc146-Tj6QfmJYdx1TewjdgT-0,5175
9
+ elasticgrid-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
10
+ elasticgrid-0.1.0.dist-info/entry_points.txt,sha256=yfH5fSyfcN-mzRhzsUiPIQNVsLM2QyDCjz9tndiQuoM,53
11
+ elasticgrid-0.1.0.dist-info/top_level.txt,sha256=KjyHnhFMAld5zHO7VgL2Wj4QhZ1SNS8sQEPYoGlyBD4,12
12
+ elasticgrid-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ elasticgrid = elasticgrid.cli:main
@@ -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 [yyyy] [name of copyright owner]
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 @@
1
+ elasticgrid