初始化项目,由ModelHub XC社区提供模型

Model: ayh015/myLightningOPD
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-08-27 23:50:14 +08:00
commit d4e0a1af66
368 changed files with 559583 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

View File

@@ -0,0 +1,76 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import json
from pathlib import Path
from types import SimpleNamespace
from typing import Annotated
import torch
import typer
from slime.ray.rollout import compute_metrics_from_samples
from slime.utils.types import Sample
_WHITELIST_KEYS = [
"group_index",
"index",
"prompt",
"response",
"response_length",
"label",
"reward",
"status",
"metadata",
]
def main(
# Deliberately make this name consistent with main training arguments
load_debug_rollout_data: Annotated[str, typer.Option()],
show_metrics: bool = True,
show_samples: bool = True,
category: list[str] = None,
):
if category is None:
category = ["train", "eval"]
for rollout_id, path in _get_rollout_dump_paths(load_debug_rollout_data, category):
print("-" * 80)
print(f"{rollout_id=} {path=}")
print("-" * 80)
pack = torch.load(path)
sample_dicts = pack["samples"]
if show_metrics:
# TODO read these configs from dumps
args = SimpleNamespace(
advantage_estimator="grpo",
reward_key=None,
log_reward_category=None,
)
sample_objects = [Sample.from_dict(s) for s in sample_dicts]
metrics = compute_metrics_from_samples(args, sample_objects)
print("metrics", metrics)
if show_samples:
for sample in sample_dicts:
print(json.dumps({k: v for k, v in sample.items() if k in _WHITELIST_KEYS}))
def _get_rollout_dump_paths(load_debug_rollout_data: str, categories: list[str]):
# may improve later
for rollout_id in range(1000):
for category in categories:
prefix = {
"train": "",
"eval": "eval_",
}[category]
path = Path(load_debug_rollout_data.format(rollout_id=f"{prefix}{rollout_id}"))
if path.exists():
yield rollout_id, path
if __name__ == "__main__":
"""python -m slime.utils.debug_utils.display_debug_rollout_data --load-debug-rollout-data ..."""
typer.run(main)

View File

@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import asyncio
from typing import Annotated
import ray
import torch
import typer
from slime.utils.misc import load_function
from slime.utils.types import Sample
def _truncate(text, max_len=200):
"""Truncate text and add ellipsis if too long."""
if text is None:
return None
text = str(text).replace("\n", "\\n")
if len(text) > max_len:
return text[:max_len] + "..."
return text
def main(
rollout_data_path: Annotated[str, typer.Option()],
custom_rm_path: Annotated[str, typer.Option()],
):
if not ray.is_initialized():
ray.init()
pack = torch.load(rollout_data_path)
samples = [Sample.from_dict(s) for s in pack["samples"]]
asyncio.run(_main_async(samples=samples, custom_rm_path=custom_rm_path))
async def _main_async(samples, custom_rm_path):
rm_function = load_function(custom_rm_path)
rewards = await asyncio.gather(*[rm_function(None, sample) for sample in samples])
for i, (sample, reward) in enumerate(zip(samples, rewards, strict=True)):
print("-" * 60)
print(f"Sample {i + 1}/{len(samples)}")
print(f" Index: {sample.index}")
print(f" Status: {sample.status}")
print(f" Reward: {reward}")
print(f" Prompt: {_truncate(sample.prompt, 200)}")
print(f" Response: {_truncate(sample.response, 200)}")
print("-" * 60)
if __name__ == "__main__":
typer.run(main)

View File

@@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import asyncio
import json
from typing import Annotated
import typer
from openai import AsyncOpenAI
from slime.utils.data import read_file
# can unify w/ sglang_rollout.py later, e.g. add RM, if needed
def main(
prompt_data: Annotated[str, typer.Option()],
url: Annotated[str, typer.Option()] = "http://localhost:30000/v1",
input_key: Annotated[str, typer.Option()] = "input",
n_samples_per_prompt: Annotated[int, typer.Option()] = 1,
rollout_max_response_len: Annotated[int, typer.Option()] = 1024,
rollout_temperature: Annotated[float, typer.Option()] = 1.0,
rollout_top_p: Annotated[float, typer.Option()] = 1.0,
):
"""
Minimally send prompts to SGLang using OpenAI endpoints with arguments in the same format as main Slime.
Example usage:
python -m slime.utils.debug_utils.send_to_sglang --prompt-data /root/datasets/aime-2024/aime-2024.jsonl --input-key prompt --n-samples-per-prompt 16 --rollout-max-response-len 32768 --rollout-temperature 0.8 --rollout-top-p 0.7
"""
async def _main_async():
tasks = [
asyncio.create_task(_run_one(row, row_index=row_index, repeat_index=repeat_index))
for row_index, row in enumerate(read_file(prompt_data))
for repeat_index in range(n_samples_per_prompt)
]
outputs = await asyncio.gather(*tasks)
for output in outputs:
print(json.dumps(output))
async def _run_one(row, row_index: int, repeat_index: int):
resp = await client.chat.completions.create(
messages=row[input_key],
model="dummy_model",
max_tokens=rollout_max_response_len,
temperature=rollout_temperature,
top_p=rollout_top_p,
)
return dict(
row_index=row_index,
repeat_index=repeat_index,
**row,
response=resp.choices[0].message.content,
)
client = AsyncOpenAI(api_key="dummy_key", base_url=url)
asyncio.run(_main_async())
if __name__ == "__main__":
typer.run(main)