← ClaudeAtlas

pytriolisted

Guide for using the PyTRIO SDK — remote LLM training and inference. Trigger when code imports pytrio, or user mentions PyTRIO / TRIO training / TRIO SDK / remote LLM training.
SwanHubX/pytrio-skill · ★ 26 · AI & Automation · score 80
Install: claude install-skill SwanHubX/pytrio-skill
# PyTRIO SDK Skill ## PyTRIO 是什么 PyTRIO 是远程 LLM 训练与推理 SDK。本地代码只做数据准备和调度,实际的前向传播、反向传播、优化器步骤和推理采样都在远端 GPU 集群上执行。不需要本地 GPU。 - 安装: `pip install pytrio transformers torch`(或 `uv add pytrio transformers torch`) - 导入约定: `import pytrio as trio`,所有 API 通过 `trio.xxx` 访问 - Tokenizer: 使用 `train.get_tokenizer()` 或 `sampler.get_tokenizer()`(需安装 modelscope) - 环境搭建详见 `references/00-overview.md` ## 认证(重要) 使用 PyTRIO 前必须先完成认证,否则所有 API 调用都会失败。 **检查是否已登录:** 查看 `~/.pytrio/config.toml` 是否存在且包含 `api_key` 字段。 **如果未登录,按以下流程操作:** 1. 提示用户提供 API Key(可从 https://pytrio.cn/dashboard 获取) 2. 用户提供 key 后,执行非交互式登录命令: ```bash trio login -k <用户提供的API_KEY> ``` 3. 登录成功后凭证保存在 `~/.pytrio/config.toml`,后续 `ServiceClient()` 无需传 api_key **在代码中也可以直接传入(适合临时使用):** ```python client = ServiceClient(api_key="YOUR_API_KEY") ``` 注意:CLI 命令是 `trio login`,不是 `pytrio login`。 ## PyTRIO ↔ PyTorch 概念速查 | PyTorch | PyTRIO | 说明 | |---|---|---| | `model = AutoModel(...)` | `client = ServiceClient(api_key=...)` | 无本地模型对象 | | `model(input_ids)` | `train.forward(data)` | 远端前向 | | `loss.backward()` | `train.forward_backward(data)` | 前向+反向合一 | | `optimizer.step()` | `train.optim_step(AdamParams(...))` | 远端 Adam | | `optimizer.zero_grad()` | 不需要 | 远端自动管理 | | `torch.save(...)` | `train.save_state(name)` | 保存到云端 | | `model.generate(...)` | `sampler.sample(prompt, ...)` | 远端推理 | | `torch.Tensor` | `TensorData` / plain `list` | 自动互转 | ## 核心 API 速查 ### 入口 ```python import pytrio as trio client = trio.ServiceClient(api_key="..