Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de08c72769 | ||
|
|
7f811c01a8 | ||
|
|
2d6dc64efd | ||
|
|
07ebe34570 | ||
|
|
c1ac451e39 | ||
|
|
d5ed9fb7e4 |
@@ -43,9 +43,9 @@ Namespaces are one honking great idea -- let's do more of those!
|
||||
|
||||
## Skills
|
||||
|
||||
Skills live in `skills/` and are symlinked to `.claude/skills/`. They teach agents how to handle specific workflows (e.g. starting the inference server, writing configs). When you make changes to the codebase, check if any skills need to be updated to stay accurate.
|
||||
Skills live in `skills/` and are symlinked to `.claude/skills/`. They teach agents how to handle specific workflows (e.g. starting the inference server, writing configs).
|
||||
|
||||
You are responsible for maintaining the skills folder. When a workflow fails and you fix it – whether with help from the user or through trial and error – you must update the skills to make implicit knowledge explicit. You are also responsible for keeping the skills up to date whenever you or anyone else modifies the code.
|
||||
If a repository skill could benefit from an update, suggest the specific change, explain why it would help, and ask the user for approval before making it. Wait for approval before creating, modifying, renaming, or deleting skills, including their supporting files and symlinks. If the user has already explicitly requested or approved the skill change, proceed without asking again. Requests to change code, fix workflows, update documentation, or open a PR do not implicitly authorize skill changes. You may read and follow skills without changing them.
|
||||
|
||||
## Testing
|
||||
|
||||
|
||||
Vendored
+1
-1
Submodule deps/verifiers updated: 5a69fb4d25...28f0893974
+4
-2
@@ -190,8 +190,10 @@ Both backends support the 2 most important things:
|
||||
- P/D disaggregation - handling the prefill and decode stages separately
|
||||
|
||||
### Routing policies
|
||||
The 2 policies you might want to configure are:
|
||||
- `consistent_hash` - this is the default policy that optimizes for KV cache re-use across turns - it hashes the `X-Session-ID` request header (sent per rollout by the verifiers clients) to pick a replica.
|
||||
The policies you might want to configure are:
|
||||
- `sticky_least_loaded` - the default policy. A new `X-Session-ID` is assigned to the least-loaded replica, then every later turn in that rollout remains on the same replica for KV cache reuse. The orchestrator releases sessions when rollouts complete, fail, or are cancelled, including traces discarded during retries. Failed release requests are logged without disabling future cleanup.
|
||||
|
||||
- `consistent_hash` - hashes the `X-Session-ID` request header (sent per rollout by the verifiers clients) to pick a replica, preserving KV cache reuse without considering current load.
|
||||
|
||||
- `round_robin` - this policy will round-robin the requests between the available replicas. This is useful if you want to balance the load between the replicas. This might give you better results if you don't have enough rollouts to make `consistent_hash` hashing saturated.
|
||||
|
||||
|
||||
@@ -303,8 +303,8 @@ class VllmRouterConfig(BaseConfig):
|
||||
|
||||
type: Literal["vllm-router"] = "vllm-router"
|
||||
|
||||
policy: str = "consistent_hash"
|
||||
"""Routing policy, e.g. ``consistent_hash`` or ``round_robin``."""
|
||||
policy: str = "sticky_least_loaded"
|
||||
"""Routing policy. Defaults to session-affine least-loaded routing; alternatives include ``consistent_hash`` and ``round_robin``."""
|
||||
|
||||
|
||||
class LlmdRouterConfig(BaseConfig):
|
||||
|
||||
+2
-2
@@ -269,8 +269,8 @@ torchao = [
|
||||
dion = { git = "https://github.com/samsja/dion.git", rev = "99e5f7e" }
|
||||
flash-attn-4 = { git = "https://github.com/Dao-AILab/flash-attention.git", subdirectory = "flash_attn/cute", rev = "0251105" }
|
||||
vllm-router = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_aarch64.whl", marker = "platform_machine == 'aarch64'" },
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_aarch64.whl", marker = "platform_machine == 'aarch64'" },
|
||||
]
|
||||
vllm = [
|
||||
{ url = "https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0-cp38-abi3-manylinux_2_28_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
|
||||
@@ -74,7 +74,9 @@ uv run sft @ examples/basic/reverse-text/sft.toml --dry-run
|
||||
|
||||
## `inference` — vLLM server
|
||||
|
||||
OpenAI-compatible API plus prime-rl custom endpoints (`/update_weights`, `/load_lora_adapter`, `/init_broadcaster`). Always use this entrypoint — never `vllm serve` directly. It starts a `vllm-router` on `server.port` (default 8000, the client-facing URL) fronting the engine on `backend_port` (default 8100); admin endpoints must target the engine port directly.
|
||||
Router session cleanup runs on successful, failed, and cancelled episodes, including discarded retry traces. Cleanup failures are logged per session and do not disable subsequent releases.
|
||||
|
||||
OpenAI-compatible API plus prime-rl custom endpoints (`/update_weights`, `/load_lora_adapter`, `/init_broadcaster`). Always use this entrypoint — never `vllm serve` directly. It starts a `vllm-router` on `server.port` (default 8000, the client-facing URL) fronting the engine on `backend_port` (default 8100); admin endpoints must target the engine port directly. The default `sticky_least_loaded` policy keeps each rollout on one replica while assigning new sessions to the least-loaded replica; RL and SFT online eval automatically release completed sessions.
|
||||
|
||||
```bash
|
||||
uv run inference --vllm.model Qwen/Qwen3-0.6B
|
||||
|
||||
@@ -406,8 +406,9 @@ const INFERENCE_PANELS = [
|
||||
["inference/agg/num_requests_running/mean", "inference/agg/num_requests_running/min", "inference/agg/num_requests_running/max"],
|
||||
["inference/agg/num_requests_waiting/mean", "inference/agg/num_requests_waiting/min", "inference/agg/num_requests_waiting/max"],
|
||||
["inference/agg/prefix_cache_hit_rate/pooled", "inference/agg/prefix_cache_hit_rate/min"],
|
||||
["inference/agg/generation_tokens_total:rate/sum", "inference/agg/generation_tokens_total:rate/min"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum", "inference/agg/prompt_tokens_total:rate/max"],
|
||||
["inference/agg/generation_tokens_total:rate/sum"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum"],
|
||||
["dispatcher/inflight/train", "dispatcher/inflight/eval", "concurrency/max_inflight"],
|
||||
];
|
||||
|
||||
const TRAINER_KEY_RE = /^(perf|optim|loss|entropy|system|mismatch_kl|kl_ent_ratio|is_masked|masked_|unmasked_|max_vio|routing_|ref_kl|val)[/_]?/;
|
||||
|
||||
@@ -531,7 +531,8 @@ def write_slurm_script(config: RLConfig, config_dir: Path, log_dir: Path, script
|
||||
use_zmq_transport=config.rollout_transport is not None and config.rollout_transport.type == "zmq",
|
||||
ranks_filter=",".join(map(str, config.trainer.log.ranks_filter)),
|
||||
orchestrator_on_inference=config.deployment.orchestrator_on_inference,
|
||||
env_names={"train": train_env_names, "eval": eval_env_names},
|
||||
train_env_names=train_env_names,
|
||||
eval_env_names=eval_env_names,
|
||||
**modelexpress_vars,
|
||||
)
|
||||
else:
|
||||
@@ -571,7 +572,8 @@ def write_slurm_script(config: RLConfig, config_dir: Path, log_dir: Path, script
|
||||
trainer_env_vars=trainer_env_vars,
|
||||
orchestrator_env_vars=orchestrator_env_vars,
|
||||
inference_env_vars=inference_env_vars,
|
||||
env_names={"train": train_env_names, "eval": eval_env_names},
|
||||
train_env_names=train_env_names,
|
||||
eval_env_names=eval_env_names,
|
||||
**modelexpress_vars,
|
||||
)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ from prime_rl.orchestrator import live
|
||||
from prime_rl.orchestrator.annotations import stamp_arrival, stamp_batch
|
||||
from prime_rl.orchestrator.clients import AdminPlane, InferenceClient
|
||||
from prime_rl.orchestrator.concurrency import ConcurrencyController
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMetrics, DispatcherMode
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMode
|
||||
from prime_rl.orchestrator.envs import EvalEnvs
|
||||
from prime_rl.orchestrator.eval_sink import EvalSink
|
||||
from prime_rl.orchestrator.eval_source import EvalSource
|
||||
@@ -79,7 +79,6 @@ class EvalRunner:
|
||||
# The launcher-set $PRL_RUN_ID is the run identity; standalone runs mint a local one.
|
||||
self.run_id = os.environ.get("PRL_RUN_ID") or uuid.uuid4().hex
|
||||
self.run_name = os.environ.get("PRL_RUN_NAME")
|
||||
wandb_enabled = monitors.get(monitors.WandbMonitor) is not None
|
||||
|
||||
get_logger().info(f"Initializing inference pool (base_url={config.client.base_url}, model={config.model})")
|
||||
self.clients = InferenceClient(config.client, model_name=config.model)
|
||||
@@ -153,13 +152,7 @@ class EvalRunner:
|
||||
self.periodic_logger = PeriodicLogger(
|
||||
name="Eval",
|
||||
collect=self.collect_pipeline_view,
|
||||
metric_keys=[
|
||||
*list(self.dispatcher.gauges().keys()),
|
||||
*list(self.concurrency.gauges().keys()),
|
||||
*DispatcherMetrics.drain_keys(train_envs=set(), eval_envs={env.name for env in self.eval_envs}),
|
||||
],
|
||||
interval=config.log.interval,
|
||||
wandb_enabled=wandb_enabled,
|
||||
)
|
||||
|
||||
async def start(self) -> None:
|
||||
|
||||
@@ -73,9 +73,9 @@ INFERENCE_PANELS = [
|
||||
"inference/agg/num_requests_waiting/max",
|
||||
],
|
||||
["inference/agg/prefix_cache_hit_rate/pooled", "inference/agg/prefix_cache_hit_rate/min"],
|
||||
["inference/agg/generation_tokens_total:rate/sum", "inference/agg/generation_tokens_total:rate/min"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum", "inference/agg/prompt_tokens_total:rate/max"],
|
||||
["dispatcher/inflight/train", "dispatcher/inflight/eval"],
|
||||
["inference/agg/generation_tokens_total:rate/sum"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum"],
|
||||
["dispatcher/inflight/train", "dispatcher/inflight/eval", "concurrency/max_inflight"],
|
||||
]
|
||||
|
||||
# SFT flavor: no rollout-based train sections — the training signal is the loss curve.
|
||||
|
||||
@@ -91,6 +91,13 @@ class InferenceClient:
|
||||
)
|
||||
self.eval_client = setup_client(client_config, client_type=eval_client_type)
|
||||
self._scorer = PrefillScorer()
|
||||
# Managed routed deployments set admin_base_url so engine admin traffic
|
||||
# bypasses the client-facing router. External and frozen clients do not.
|
||||
self._session_client = (
|
||||
setup_admin_clients(client_config.model_copy(update={"admin_base_url": None}))[0]
|
||||
if client_config.admin_base_url is not None
|
||||
else None
|
||||
)
|
||||
self.model_name = model_name
|
||||
|
||||
async def score(self, token_ids: list[int]) -> list[float]:
|
||||
@@ -100,6 +107,26 @@ class InferenceClient:
|
||||
|
||||
async def aclose(self) -> None:
|
||||
await self._scorer.aclose()
|
||||
if self._session_client is not None:
|
||||
await self._session_client.aclose()
|
||||
|
||||
async def finish_sessions(self, session_ids: list[str]) -> None:
|
||||
"""Release completed sessions when the client-facing router supports it."""
|
||||
if self._session_client is None or not session_ids:
|
||||
return
|
||||
|
||||
async def finish_session(session_id: str) -> None:
|
||||
try:
|
||||
await _admin_post(
|
||||
self._session_client,
|
||||
"/finish_session",
|
||||
timeout_s=5.0,
|
||||
params={"session_id": session_id},
|
||||
)
|
||||
except Exception as error:
|
||||
get_logger().debug(f"Failed to release inference session {session_id}: {error!r}")
|
||||
|
||||
await asyncio.gather(*(finish_session(session_id) for session_id in session_ids))
|
||||
|
||||
|
||||
class AdminPlane:
|
||||
|
||||
@@ -92,8 +92,8 @@ class DispatcherMetrics:
|
||||
|
||||
def drained(self, *, train_envs: set[str], eval_envs: set[str]) -> dict[str, float]:
|
||||
"""Return per-tick counters and clear them. Emits the full pre-
|
||||
registered key set every tick (zero when no activity) so the wandb
|
||||
time axis stays dense and ``define_metric`` lines up."""
|
||||
registered key set every tick (zero when no activity) so the
|
||||
time-keyed series stay dense on every monitor."""
|
||||
out: dict[str, float] = {}
|
||||
for kind in ("train", "eval"):
|
||||
envs = train_envs if kind == "train" else eval_envs
|
||||
@@ -112,21 +112,6 @@ class DispatcherMetrics:
|
||||
self.errored_by_kind_env.clear()
|
||||
return out
|
||||
|
||||
@staticmethod
|
||||
def drain_keys(*, train_envs: set[str], eval_envs: set[str]) -> list[str]:
|
||||
"""Full set of keys ``drained`` may emit; used by the periodic
|
||||
logger for ``wandb.define_metric``."""
|
||||
keys = [
|
||||
"dispatcher/cancelled/train",
|
||||
"dispatcher/cancelled/eval",
|
||||
"dispatcher/errored/train",
|
||||
"dispatcher/errored/eval",
|
||||
]
|
||||
for env in train_envs | eval_envs:
|
||||
keys.append(f"dispatcher/cancelled/{env}")
|
||||
keys.append(f"dispatcher/errored/{env}")
|
||||
return keys
|
||||
|
||||
|
||||
def _validate_episode_task(episode: vf.WireEpisode, task: vf.Task) -> None:
|
||||
expected = (task.key, task.hash)
|
||||
@@ -593,7 +578,10 @@ class Dispatcher:
|
||||
started_at=time.monotonic(),
|
||||
)
|
||||
|
||||
session_ids: set[str] = set()
|
||||
|
||||
def on_delta(delta: dict) -> None:
|
||||
session_ids.add(delta["trace"])
|
||||
first = not meta.live
|
||||
live.apply(meta, delta)
|
||||
self.queue_live({"delta": delta, "dispatch": live.dispatch_info(meta)})
|
||||
@@ -602,15 +590,26 @@ class Dispatcher:
|
||||
if first and meta.live:
|
||||
self.live_events.append(live.dispatched_event(meta))
|
||||
|
||||
task = asyncio.create_task(
|
||||
env.run(
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
cache_salt=cache_salt,
|
||||
task_data=group.task.data.model_dump(mode="json"),
|
||||
on_delta=on_delta,
|
||||
)
|
||||
)
|
||||
async def run_episode() -> vf.WireEpisode:
|
||||
try:
|
||||
episode = await env.run(
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
cache_salt=cache_salt,
|
||||
task_data=group.task.data.model_dump(mode="json"),
|
||||
on_delta=on_delta,
|
||||
)
|
||||
session_ids.update(trace.id for trace in episode.traces)
|
||||
return episode
|
||||
finally:
|
||||
cleanup = asyncio.create_task(clients.finish_sessions(sorted(session_ids)))
|
||||
try:
|
||||
await asyncio.shield(cleanup)
|
||||
except asyncio.CancelledError:
|
||||
await cleanup
|
||||
raise
|
||||
|
||||
task = asyncio.create_task(run_episode())
|
||||
self.inflight[task] = meta
|
||||
self.live_events.append(live.pending_event(meta))
|
||||
return True
|
||||
|
||||
@@ -11,7 +11,7 @@ and drives the pipeline. Components are single-purpose:
|
||||
- ``TrainEpisodes`` / ``EvalEpisodes`` preserve episode boundaries and build per-step metrics.
|
||||
- ``WeightWatcher`` advances ``Policy`` and notifies observers.
|
||||
- ``PeriodicLogger`` polls the components on a shared interval for the
|
||||
``_timestamp``-axis pipeline log.
|
||||
pipeline log, a time-keyed row through the monitors.
|
||||
|
||||
Components don't reference the orchestrator. The orchestrator wires them
|
||||
in ``setup()`` and drives them from ``main_loop()``.
|
||||
@@ -41,7 +41,7 @@ from prime_rl.orchestrator.annotations import stamp_arrival, stamp_batch
|
||||
from prime_rl.orchestrator.ckpt import setup_ckpt_manager
|
||||
from prime_rl.orchestrator.clients import AdminPlane, InferenceClient, setup_admin_plane
|
||||
from prime_rl.orchestrator.concurrency import ConcurrencyController
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMetrics, DispatcherMode
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMode
|
||||
from prime_rl.orchestrator.envs import EvalEnvs, TrainEnvs
|
||||
from prime_rl.orchestrator.eval_sink import EvalSink
|
||||
from prime_rl.orchestrator.eval_source import EvalSource
|
||||
@@ -336,7 +336,6 @@ class Orchestrator:
|
||||
)
|
||||
|
||||
log_interval = config.log.interval
|
||||
wandb_enabled = monitors.get(monitors.WandbMonitor) is not None
|
||||
|
||||
self.concurrency = ConcurrencyController(config.concurrency, fallback_cost=config.seq_len)
|
||||
self.dispatcher = Dispatcher(
|
||||
@@ -398,24 +397,7 @@ class Orchestrator:
|
||||
self.periodic_logger = PeriodicLogger(
|
||||
name="Pipeline",
|
||||
collect=self.collect_pipeline_view,
|
||||
metric_keys=[
|
||||
*list(self.dispatcher.gauges().keys()),
|
||||
*list(self.concurrency.gauges().keys()),
|
||||
*DispatcherMetrics.drain_keys(
|
||||
train_envs={e.name for e in self.train_envs},
|
||||
eval_envs={e.name for e in self.eval_envs} if self.eval_envs is not None else set(),
|
||||
),
|
||||
*list(self.watcher.gauges().keys()),
|
||||
"event_loop_lag/min",
|
||||
"event_loop_lag/mean",
|
||||
"event_loop_lag/median",
|
||||
"event_loop_lag/p90",
|
||||
"event_loop_lag/p99",
|
||||
"event_loop_lag/max",
|
||||
"event_loop_lag/n",
|
||||
],
|
||||
interval=log_interval,
|
||||
wandb_enabled=wandb_enabled,
|
||||
)
|
||||
|
||||
get_logger().info(f"Syncing inference to the trainer's startup broadcast (v{sync_version})")
|
||||
@@ -457,10 +439,12 @@ class Orchestrator:
|
||||
elapsed = format_time(time.perf_counter() - start_time)
|
||||
if clean_exit:
|
||||
get_logger().success(f"Orchestrator step loop done in {elapsed}")
|
||||
# The collector logs to the W&B run, so it must stop before
|
||||
# finalize marks the run finished
|
||||
# The background loggers write through the monitors, so they must
|
||||
# stop before finalize marks the run finished
|
||||
if self.inference_metrics is not None:
|
||||
await self.inference_metrics.stop()
|
||||
if self.periodic_logger is not None:
|
||||
await self.periodic_logger.stop()
|
||||
# Finalize only on a clean exit — a crashed run must not be marked
|
||||
# completed; the platform run's atexit hook marks it failed instead.
|
||||
await monitors.finalize()
|
||||
@@ -830,7 +814,7 @@ class Orchestrator:
|
||||
|
||||
def collect_pipeline_view(self) -> tuple[str, dict[str, float]]:
|
||||
"""Pipeline view for the orchestrator's ``PeriodicLogger``. Returns
|
||||
``(console_body, wandb_payload)``. Per-env ``(env=N, …)``
|
||||
``(console_body, payload)``. Per-env ``(env=N, …)``
|
||||
breakdowns inline only when there's more than one train / eval env;
|
||||
the eval halves drop entirely when nothing is accumulating."""
|
||||
disp_gauges = self.dispatcher.gauges()
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
"""PeriodicLogger: orchestrator's pipeline view, fires every ``interval``
|
||||
seconds. ``collect()`` returns ``(console_body, wandb_payload)`` in one
|
||||
call so drain-on-read counters fire exactly once per tick. Wandb writes
|
||||
land on the ``_timestamp`` axis."""
|
||||
seconds. ``collect()`` returns ``(console_body, payload)`` in one call so
|
||||
drain-on-read counters fire exactly once per tick. The payload goes to every
|
||||
registered monitor as a time-keyed row (``step=None``)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
import wandb
|
||||
|
||||
from prime_rl import monitors
|
||||
from prime_rl.utils.async_utils import safe_cancel
|
||||
from prime_rl.utils.logger import get_logger
|
||||
|
||||
@@ -21,21 +19,14 @@ class PeriodicLogger:
|
||||
*,
|
||||
name: str,
|
||||
collect: Callable[[], tuple[str, dict[str, float]]],
|
||||
metric_keys: list[str],
|
||||
interval: float,
|
||||
wandb_enabled: bool,
|
||||
) -> None:
|
||||
self.name = name
|
||||
self.collect = collect
|
||||
self.interval = interval
|
||||
self.wandb_enabled = wandb_enabled
|
||||
self.task: asyncio.Task | None = None
|
||||
self.stopped = asyncio.Event()
|
||||
|
||||
if self.wandb_enabled:
|
||||
for key in metric_keys:
|
||||
wandb.define_metric(key, step_metric="_timestamp")
|
||||
|
||||
async def start(self) -> None:
|
||||
self.task = asyncio.create_task(self.run(), name=f"{self.name}_periodic_logger")
|
||||
|
||||
@@ -46,16 +37,17 @@ class PeriodicLogger:
|
||||
await asyncio.wait_for(self.stopped.wait(), timeout=self.interval)
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
self.emit()
|
||||
await self.emit()
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
|
||||
def emit(self) -> None:
|
||||
async def emit(self) -> None:
|
||||
body, payload = self.collect()
|
||||
get_logger().info(body)
|
||||
if self.wandb_enabled and payload:
|
||||
payload["_timestamp"] = time.time()
|
||||
wandb.log(payload)
|
||||
if payload:
|
||||
# Time-keyed row: the pipeline view is sampled on wall time, not
|
||||
# the training step. Each monitor stamps its own time axis.
|
||||
await monitors.log(payload, step=None)
|
||||
|
||||
async def stop(self) -> None:
|
||||
self.stopped.set()
|
||||
|
||||
@@ -17,7 +17,7 @@ from prime_rl.trainer.models.kernels.fp8_utils import (
|
||||
def _compute_grad_weight(
|
||||
x: torch.Tensor,
|
||||
grad_output: torch.Tensor,
|
||||
weight_shape: torch.Size,
|
||||
weight: torch.Tensor,
|
||||
padded_total_m: int,
|
||||
block_to_group: torch.Tensor,
|
||||
ks_tensor: torch.Tensor,
|
||||
@@ -78,7 +78,7 @@ def _compute_grad_weight(
|
||||
)
|
||||
grouped_weight_grad = deep_gemm.k_grouped_fp8_gemm_nt_contiguous
|
||||
|
||||
grad_weight = torch.zeros(weight_shape, device=x.device, dtype=torch.float32)
|
||||
grad_weight = torch.zeros(weight.shape, device=x.device, dtype=torch.float32)
|
||||
grouped_weight_grad(
|
||||
x_fp8,
|
||||
dy_fp8,
|
||||
@@ -87,7 +87,7 @@ def _compute_grad_weight(
|
||||
ks_tensor,
|
||||
grad_weight,
|
||||
)
|
||||
return grad_weight.to(torch.bfloat16)
|
||||
return grad_weight.to(weight.dtype)
|
||||
|
||||
|
||||
@torch.library.custom_op("prime_rl::grouped_fp8_gemm", mutates_args=())
|
||||
@@ -165,14 +165,14 @@ def _grouped_fp8_gemm_backward(
|
||||
block_starts_tensor,
|
||||
) = build_grouped_layout(offs, total_m=x.size(0))
|
||||
grad_output = grad_output.contiguous()
|
||||
grad_x = torch.empty_like(x)
|
||||
grad_weight = torch.empty_like(weight)
|
||||
grad_x = x.new_empty(x.shape)
|
||||
grad_weight = weight.new_empty(weight.shape)
|
||||
|
||||
if needs_grad_weight:
|
||||
grad_weight = _compute_grad_weight(
|
||||
x,
|
||||
grad_output,
|
||||
weight.shape,
|
||||
weight,
|
||||
padded_total_m,
|
||||
block_to_group,
|
||||
ks_tensor,
|
||||
@@ -230,7 +230,7 @@ def _grouped_fp8_gemm_backward_fake(
|
||||
needs_grad_x: bool,
|
||||
needs_grad_weight: bool,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
return torch.empty_like(x), torch.empty_like(weight)
|
||||
return x.new_empty(x.shape), weight.new_empty(weight.shape)
|
||||
|
||||
|
||||
def _grouped_fp8_gemm_setup_context(ctx, inputs, output) -> None:
|
||||
|
||||
@@ -48,8 +48,8 @@ def _fp8_blockwise_mm_backward(
|
||||
x_2d = x.reshape(-1, x.shape[-1]).contiguous()
|
||||
grad_output_2d = grad_output.reshape(-1, grad_output.shape[-1]).contiguous()
|
||||
use_ue8m0 = ue8m0_for_device(grad_output.device)
|
||||
grad_x = torch.empty_like(x)
|
||||
grad_weight = torch.empty_like(weight)
|
||||
grad_x = x.new_empty(x.shape)
|
||||
grad_weight = weight.new_empty(weight.shape)
|
||||
|
||||
if needs_grad_x:
|
||||
grad_output_fp8 = per_token_cast_to_fp8_triton(grad_output_2d, use_ue8m0, block_size)
|
||||
@@ -68,7 +68,7 @@ def _fp8_blockwise_mm_backward(
|
||||
x_2d = torch.nn.functional.pad(x_2d, (0, 0, 0, pad_rows))
|
||||
grad_output_t_fp8 = per_token_cast_to_fp8_tp_triton(grad_output_2d, use_ue8m0, block_size)
|
||||
x_t_fp8 = per_token_cast_to_fp8_tp_triton(x_2d, use_ue8m0, block_size)
|
||||
grad_weight_fp32 = torch.zeros_like(weight, dtype=torch.float32)
|
||||
grad_weight_fp32 = torch.zeros(weight.shape, device=weight.device, dtype=torch.float32)
|
||||
deep_gemm.fp8_gemm_nt(
|
||||
grad_output_t_fp8,
|
||||
x_t_fp8,
|
||||
@@ -90,7 +90,7 @@ def _fp8_blockwise_mm_backward_fake(
|
||||
needs_grad_x: bool,
|
||||
needs_grad_weight: bool,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
return torch.empty_like(x), torch.empty_like(weight)
|
||||
return x.new_empty(x.shape), weight.new_empty(weight.shape)
|
||||
|
||||
|
||||
def _fp8_blockwise_mm_setup_context(ctx, inputs, output) -> None:
|
||||
|
||||
@@ -272,7 +272,7 @@ def _ring_attention_forward_fake(
|
||||
window_size_right: int,
|
||||
attention_backend: str,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
return torch.empty_like(q), q.new_empty((q.shape[1], q.shape[0]), dtype=torch.float32)
|
||||
return q.new_empty(q.shape), q.new_empty((q.shape[1], q.shape[0]), dtype=torch.float32)
|
||||
|
||||
|
||||
@torch.library.custom_op("prime_rl_ring::attention_backward", mutates_args=())
|
||||
|
||||
@@ -5058,8 +5058,8 @@ all = [
|
||||
{ name = "torchvision", marker = "sys_platform == 'linux'" },
|
||||
{ name = "vllm", version = "0.28.0", source = { url = "https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0-cp38-abi3-manylinux_2_28_aarch64.whl" }, marker = "platform_machine != 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm", version = "0.28.0", source = { url = "https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0-cp38-abi3-manylinux_2_28_x86_64.whl" }, marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.0", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_aarch64.whl" }, marker = "platform_machine != 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.0", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_x86_64.whl" }, marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.1", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_aarch64.whl" }, marker = "platform_machine != 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.1", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_x86_64.whl" }, marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
|
||||
]
|
||||
dashboard = [
|
||||
{ name = "fastapi" },
|
||||
@@ -5072,8 +5072,8 @@ disagg = [
|
||||
{ name = "deep-gemm", version = "2.5.0+891d57b", source = { url = "https://github.com/PrimeIntellect-ai/prime-kernels/releases/download/v0.1.1/deep_gemm-2.5.0+891d57b-cp312-cp312-linux_x86_64.whl" }, marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "nixl", marker = "sys_platform == 'linux'" },
|
||||
{ name = "nixl-cu13", marker = "sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.0", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_aarch64.whl" }, marker = "platform_machine != 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.0", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_x86_64.whl" }, marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.1", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_aarch64.whl" }, marker = "platform_machine != 'x86_64' and sys_platform == 'linux'" },
|
||||
{ name = "vllm-router", version = "0.2.1", source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_x86_64.whl" }, marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
|
||||
]
|
||||
dynamo = [
|
||||
{ name = "ai-dynamo", marker = "sys_platform == 'linux'" },
|
||||
@@ -5206,9 +5206,9 @@ requires-dist = [
|
||||
{ name = "vllm", marker = "platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'gpu'", url = "https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0-cp38-abi3-manylinux_2_28_aarch64.whl" },
|
||||
{ name = "vllm", marker = "platform_machine != 'aarch64' and platform_machine != 'x86_64' and sys_platform == 'linux' and extra == 'gpu'", specifier = ">=0.28.0" },
|
||||
{ name = "vllm", marker = "platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'gpu'", url = "https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0-cp38-abi3-manylinux_2_28_x86_64.whl" },
|
||||
{ name = "vllm-router", marker = "platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'disagg'", url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_aarch64.whl" },
|
||||
{ name = "vllm-router", marker = "platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'disagg'", url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_aarch64.whl" },
|
||||
{ name = "vllm-router", marker = "platform_machine != 'aarch64' and platform_machine != 'x86_64' and sys_platform == 'linux' and extra == 'disagg'" },
|
||||
{ name = "vllm-router", marker = "platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'disagg'", url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_x86_64.whl" },
|
||||
{ name = "vllm-router", marker = "platform_machine == 'x86_64' and sys_platform == 'linux' and extra == 'disagg'", url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_x86_64.whl" },
|
||||
{ name = "wandb", specifier = ">=0.26.1" },
|
||||
{ name = "wandb-workspaces", specifier = ">=0.4.3" },
|
||||
]
|
||||
@@ -8298,8 +8298,8 @@ provides-extras = ["zen", "bench", "tensorizer", "fastsafetensors", "instanttens
|
||||
|
||||
[[package]]
|
||||
name = "vllm-router"
|
||||
version = "0.2.0"
|
||||
source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_aarch64.whl" }
|
||||
version = "0.2.1"
|
||||
source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_aarch64.whl" }
|
||||
resolution-markers = [
|
||||
"platform_machine == 'aarch64' and sys_platform == 'linux'",
|
||||
]
|
||||
@@ -8312,7 +8312,7 @@ dependencies = [
|
||||
{ name = "uvicorn" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:07b4b18155231c926334a497db504767930fb81758049cbd9113c1e9f9c2ba69" },
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:0420aba42df1c970a78e1c4d4062eb00498e397f2dd506bade39eb915bf807b6" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
@@ -8331,8 +8331,8 @@ provides-extras = ["dev"]
|
||||
|
||||
[[package]]
|
||||
name = "vllm-router"
|
||||
version = "0.2.0"
|
||||
source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_x86_64.whl" }
|
||||
version = "0.2.1"
|
||||
source = { url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_x86_64.whl" }
|
||||
resolution-markers = [
|
||||
"platform_machine == 'x86_64' and sys_platform == 'linux'",
|
||||
]
|
||||
@@ -8345,7 +8345,7 @@ dependencies = [
|
||||
{ name = "uvicorn" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.0/vllm_router-0.2.0-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:bac193bedf10f9a0265fe4fdaae0f0418574cd1f15c45f27da1b4a2bae8c10b8" },
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.2.1/vllm_router-0.2.1-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:046591cac21424997600d30b500bbaa3c450601e8b2b4fad6db9d142d1c36a0e" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
|
||||
Reference in New Issue
Block a user