Compare commits
9
Commits
v0.7.1.dev56
...
trinity
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6087c3addb | ||
|
|
99957ccd93 | ||
|
|
31ff561df6 | ||
|
|
dea7707526 | ||
|
|
fca9fb0975 | ||
|
|
1dcec737d9 | ||
|
|
43c2905243 | ||
|
|
54307fc301 | ||
|
|
069e580c78 |
@@ -1,8 +1,6 @@
|
||||
name: Build Image (ghcr)
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
@@ -27,12 +25,12 @@ on:
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: primeintellect-ai/prime-rl
|
||||
BUILD_REF: ${{ github.event.release.tag_name || inputs.ref || github.ref_name }}
|
||||
BUILD_TAG: ${{ github.event.release.tag_name || inputs.tag || '' }}
|
||||
BUILD_REF: ${{ inputs.ref || github.ref_name }}
|
||||
BUILD_TAG: ${{ inputs.tag || '' }}
|
||||
BUILD_PLATFORMS: ${{ inputs.platforms || 'both' }}
|
||||
|
||||
concurrency:
|
||||
group: build-image-${{ github.event.release.tag_name || inputs.tag || inputs.ref || github.ref_name }}
|
||||
group: build-image-${{ inputs.tag || inputs.ref || github.ref_name }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -8,6 +8,10 @@ on:
|
||||
description: "Full-FT config to dispatch (e.g. configs/ci/nightly-fft/wordle.toml). Leave empty to run all."
|
||||
required: false
|
||||
default: ""
|
||||
image_tag:
|
||||
description: "prime-rl image tag to pin (e.g. v0.7.1.dev58). Leave empty to auto-resolve the newest v*.dev* with a published manifest."
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
# Scheduled run at 3AM PST (11AM UTC) — disabled for now, enable once dry-run passes
|
||||
# schedule:
|
||||
@@ -70,26 +74,80 @@ jobs:
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Resolve latest prime-rl image tag
|
||||
- name: Resolve prime-rl image tag
|
||||
id: image
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Pass the dispatch input through env so a malicious value
|
||||
# cannot break out of shell context via $(...) or embedded
|
||||
# quotes — the GitHub expression is substituted before Bash
|
||||
# parses the script.
|
||||
REQUESTED_IMAGE_TAG: ${{ github.event.inputs.image_tag }}
|
||||
run: |
|
||||
# Query GHCR directly for tags whose manifests have actually
|
||||
# been pushed. devx_tag.yaml creates a `v*.dev*` git tag on
|
||||
# every main commit and dispatches build_image.yaml with that
|
||||
# tag, but the build takes time and can fail — the newest git
|
||||
# tag may not yet exist as an image. Ask GHCR, not git.
|
||||
tag=$(gh api --paginate \
|
||||
# If workflow_dispatch passed an explicit image_tag, validate
|
||||
# it as a Docker/OCI tag, verify its manifest is pullable,
|
||||
# and use it as-is (skip resolution).
|
||||
requested="$REQUESTED_IMAGE_TAG"
|
||||
if [ -n "$requested" ]; then
|
||||
# OCI/Docker tag charset: [A-Za-z0-9._-], max 128, no
|
||||
# leading '.' or '-'. Reject anything else before it
|
||||
# reaches curl or GITHUB_OUTPUT.
|
||||
if ! printf '%s' "$requested" | grep -Eq '^[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$'; then
|
||||
echo "Invalid image_tag: only [A-Za-z0-9._-] allowed, max 128 chars, no leading '.' or '-'." >&2
|
||||
exit 1
|
||||
fi
|
||||
registry_token=$(curl -fsSL \
|
||||
"https://ghcr.io/token?scope=repository:primeintellect-ai/prime-rl:pull" \
|
||||
| jq -r .token)
|
||||
code=$(curl -sS -o /dev/null -w '%{http_code}' \
|
||||
-H "Authorization: Bearer $registry_token" \
|
||||
-H 'Accept: application/vnd.oci.image.index.v1+json' \
|
||||
-H 'Accept: application/vnd.docker.distribution.manifest.list.v2+json' \
|
||||
"https://ghcr.io/v2/primeintellect-ai/prime-rl/manifests/$requested")
|
||||
if [ "$code" != "200" ]; then
|
||||
echo "Requested image_tag '$requested' has no published manifest (HTTP $code)." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Using pinned prime-rl image tag: $requested"
|
||||
echo "tag=$requested" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# The GHCR versions API can list a tag before its manifest is
|
||||
# actually pullable (build in-flight, or manifest step didn't
|
||||
# finish). So: pull the top N candidate tags, then verify each
|
||||
# with a manifest HEAD via the anonymous registry token flow;
|
||||
# take the newest one that resolves.
|
||||
candidates=$(gh api --paginate \
|
||||
"/orgs/primeintellect-ai/packages/container/prime-rl/versions" \
|
||||
--jq '.[].metadata.container.tags[]' \
|
||||
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+$' \
|
||||
| sort -Vr | head -n1)
|
||||
if [ -z "$tag" ]; then
|
||||
echo "No v*.dev* tag published on GHCR." >&2
|
||||
| sort -Vru | head -n 10)
|
||||
if [ -z "$candidates" ]; then
|
||||
echo "No v*.dev* tag listed on GHCR." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Latest prime-rl image tag on GHCR: $tag"
|
||||
registry_token=$(curl -fsSL \
|
||||
"https://ghcr.io/token?scope=repository:primeintellect-ai/prime-rl:pull" \
|
||||
| jq -r .token)
|
||||
tag=""
|
||||
for cand in $candidates; do
|
||||
code=$(curl -sS -o /dev/null -w '%{http_code}' \
|
||||
-H "Authorization: Bearer $registry_token" \
|
||||
-H 'Accept: application/vnd.oci.image.index.v1+json' \
|
||||
-H 'Accept: application/vnd.docker.distribution.manifest.list.v2+json' \
|
||||
"https://ghcr.io/v2/primeintellect-ai/prime-rl/manifests/$cand")
|
||||
if [ "$code" = "200" ]; then
|
||||
tag="$cand"
|
||||
break
|
||||
fi
|
||||
echo "Skip $cand — manifest HEAD returned $code"
|
||||
done
|
||||
if [ -z "$tag" ]; then
|
||||
echo "None of the top v*.dev* tags have a published manifest." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Latest published prime-rl image tag on GHCR: $tag"
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install uv
|
||||
@@ -108,12 +166,23 @@ jobs:
|
||||
run: |
|
||||
echo "Dispatching config: ${{ matrix.config_file }}"
|
||||
echo "Image tag: ${{ steps.image.outputs.tag }}"
|
||||
# Tag the RFTRun so it's identifiable on the platform as
|
||||
# coming from this workflow. Injected here rather than in
|
||||
# the checked-in toml because a top-level `name` field
|
||||
# breaks tests/unit/test_configs.py::test_load_configs
|
||||
# (RLConfig has no top-level name).
|
||||
config_base=$(basename "${{ matrix.config_file }}" .toml)
|
||||
run_name="nightly-${config_base}-$(date -u +%Y-%m-%d)-${{ github.run_id }}"
|
||||
dispatch_cfg=$(mktemp --suffix=.toml)
|
||||
printf 'name = "%s"\n\n' "$run_name" > "$dispatch_cfg"
|
||||
cat "${{ matrix.config_file }}" >> "$dispatch_cfg"
|
||||
echo "Dispatched run name: $run_name"
|
||||
# Forward WANDB_API_KEY / HF_TOKEN into the hosted payload:
|
||||
# the full-FT dispatch path (`prime train`) only picks up
|
||||
# secrets that were explicitly collected via `-e` / `--env-file`,
|
||||
# not ambient env, so the workflow env: block alone is not
|
||||
# enough to reach the hosted trainer/orchestrator pods.
|
||||
prime train "${{ matrix.config_file }}" \
|
||||
prime train "$dispatch_cfg" \
|
||||
--image-tag "${{ steps.image.outputs.tag }}" \
|
||||
-e WANDB_API_KEY \
|
||||
-e HF_TOKEN \
|
||||
|
||||
@@ -119,6 +119,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
# Needed to dispatch build_image.yaml below (POST .../dispatches).
|
||||
actions: write
|
||||
steps:
|
||||
- name: Publish draft release
|
||||
env:
|
||||
@@ -127,11 +129,22 @@ jobs:
|
||||
run: |
|
||||
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
|
||||
# Publishing runs as GITHUB_TOKEN, whose events don't retrigger
|
||||
# workflows, so dispatch the image build explicitly.
|
||||
- name: Trigger image build for the release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ needs.auto-tag-on-main.outputs.tag }}
|
||||
run: |
|
||||
gh workflow run build_image.yaml --repo "$GITHUB_REPOSITORY" -f ref="$TAG"
|
||||
|
||||
tag-and-release:
|
||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
# Needed to dispatch build_image.yaml below (POST .../dispatches).
|
||||
actions: write
|
||||
steps:
|
||||
- name: Checkout tagged release (dispatch)
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
@@ -195,6 +208,7 @@ jobs:
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Publish draft release
|
||||
id: publish
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
@@ -207,6 +221,17 @@ jobs:
|
||||
fi
|
||||
if [ "$STATE" = "false" ]; then
|
||||
echo "Release $TAG is already published; nothing to do."
|
||||
echo "published=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
echo "published=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Skipped when the release was already published (no rebuild needed).
|
||||
- name: Trigger image build for the release
|
||||
if: steps.publish.outputs.published == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
run: |
|
||||
gh workflow run build_image.yaml --repo "$GITHUB_REPOSITORY" -f ref="$TAG"
|
||||
|
||||
+2
-1
@@ -3,7 +3,8 @@
|
||||
url = git@github.com:PrimeIntellect-ai/verifiers.git
|
||||
[submodule "renderers"]
|
||||
path = deps/renderers
|
||||
url = git@github.com:PrimeIntellect-ai/renderers.git
|
||||
url = ../renderers.git
|
||||
branch = trinity
|
||||
[submodule "research-environments"]
|
||||
path = deps/research-environments
|
||||
url = git@github.com:PrimeIntellect-ai/research-environments.git
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
max_steps = 200
|
||||
seq_len = 2048
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 4
|
||||
num_infer_gpus = 4
|
||||
|
||||
[wandb]
|
||||
project = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
name = "alphabet-sort"
|
||||
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
|
||||
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 768
|
||||
|
||||
[trainer]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 4
|
||||
@@ -0,0 +1,49 @@
|
||||
max_steps = 5000
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 4
|
||||
num_infer_gpus = 4
|
||||
|
||||
[wandb]
|
||||
project = "hendrycks-sanity"
|
||||
name = "hendrycks-sanity"
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
group_size = 8
|
||||
seq_len = 8192
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
name = "hendrycks-math"
|
||||
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
|
||||
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 50
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
name = "aime2024"
|
||||
env.taskset = { id = "aime24-v1" }
|
||||
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
|
||||
group_size = 32
|
||||
|
||||
[trainer]
|
||||
|
||||
[trainer.model]
|
||||
seq_len = 16384
|
||||
attn = "flash_attention_2"
|
||||
|
||||
[inference.parallel]
|
||||
dp = 4
|
||||
|
||||
[inference.model]
|
||||
max_model_len = 8192
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
@@ -0,0 +1,34 @@
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 1
|
||||
num_infer_gpus = 1
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text"
|
||||
name = "reverse-text"
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[trainer]
|
||||
|
||||
[inference]
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "prime-qwen3"
|
||||
@@ -0,0 +1,40 @@
|
||||
max_steps = 200
|
||||
seq_len = 4096
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 4
|
||||
num_infer_gpus = 4
|
||||
|
||||
[wandb]
|
||||
project = "wiki-search"
|
||||
name = "wiki-search"
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
oversampling_factor = 2.0
|
||||
|
||||
[[orchestrator.pre_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
enforce = true
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
name = "wiki-search"
|
||||
env.taskset = { id = "wiki-search-v1" }
|
||||
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[trainer]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 4
|
||||
|
||||
[inference.model]
|
||||
tool_call_parser = "hermes"
|
||||
Vendored
+1
-1
Submodule deps/renderers updated: bdb96b0c84...e9619bf8f0
@@ -46,7 +46,7 @@ enable_router_replay = true
|
||||
[trainer.model]
|
||||
impl = "custom"
|
||||
attn = "flash_attention_3"
|
||||
cp = 8
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# term is pass_rate-scaled and normalized by the group's own max before the GRPO baseline
|
||||
# subtraction.
|
||||
#
|
||||
# 2 train + 4 infer nodes. Trainer uses cp=8 (ulysses) plus
|
||||
# 2 train + 4 infer nodes. Trainer uses cp=4 (ulysses) plus
|
||||
# the memory improvements from the GLM-5.1 prod run (research-prod rlm5/prod.toml): LM-head token
|
||||
# chunking, activation checkpointing (freq=1) + activation offloading (max_inflight=1), optimizer
|
||||
# CPU offload, and skip-gather / skip-optimizer checkpointing.
|
||||
@@ -57,7 +57,7 @@ enable_router_replay = true
|
||||
[trainer.model]
|
||||
impl = "custom"
|
||||
attn = "flash_attention_3"
|
||||
cp = 8
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
@@ -47,7 +47,7 @@ enable_router_replay = true
|
||||
[trainer.model]
|
||||
impl = "custom"
|
||||
attn = "flash_attention_3"
|
||||
cp = 8
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
@@ -32,6 +32,9 @@ class OptimizerConfig(BaseConfig):
|
||||
|
||||
|
||||
class LoRAConfig(BaseConfig):
|
||||
init_path: Path | None = None
|
||||
"""Initial adapter for a fresh optimizer run; full checkpoint resume takes precedence."""
|
||||
|
||||
name: str | None = None
|
||||
"""LoRA adapter name. If None, auto-generated from rank and alpha."""
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ class IndexCacheConfig(BaseConfig):
|
||||
|
||||
|
||||
class LoRAConfig(BaseConfig):
|
||||
init_path: Path | None = None
|
||||
"""Initialize adapter weights from a PEFT directory when not resuming a full checkpoint."""
|
||||
|
||||
rank: int = Field(16, ge=1)
|
||||
"""Rank of the low-rank decomposition matrices."""
|
||||
|
||||
|
||||
@@ -380,6 +380,15 @@ class Orchestrator:
|
||||
self.policy.model_name = self.lora_name
|
||||
self.policy.version = sync_version
|
||||
|
||||
elif config.model.lora is not None and config.model.lora.init_path is not None:
|
||||
await self.policy_inference.update_weights(
|
||||
config.model.lora.init_path, lora_name=self.lora_name, step=0
|
||||
)
|
||||
self.policy_inference.update_model_name(self.lora_name)
|
||||
self.policy.model_name = self.lora_name
|
||||
self.policy.version = 0
|
||||
get_logger().info(f"Initialized policy v0 from adapter {config.model.lora.init_path}")
|
||||
|
||||
self.train_source = TrainSource(self.train_envs, seed=42)
|
||||
self.eval_source: EvalSource | None = (
|
||||
EvalSource(
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Strict attention-only PEFT initialization without optimizer restoration."""
|
||||
|
||||
import json
|
||||
|
||||
import torch
|
||||
from safetensors.torch import load_file
|
||||
from torch.distributed.tensor import DTensor, distribute_tensor
|
||||
|
||||
from prime_rl.utils.logger import get_logger
|
||||
|
||||
|
||||
def load_attention_adapter(model, config):
|
||||
adapter = config.lora
|
||||
path = adapter.init_path
|
||||
metadata = json.loads((path / "adapter_config.json").read_text())
|
||||
allowed = {"q_proj", "k_proj", "v_proj", "o_proj"}
|
||||
if set(adapter.target_modules) != allowed or adapter.modules_to_save:
|
||||
raise ValueError("Adapter warm start supports only attention q/k/v/o with no modules_to_save")
|
||||
if (metadata.get("r") != adapter.rank or metadata.get("lora_alpha") != adapter.alpha
|
||||
or metadata.get("lora_dropout", 0.0) != adapter.dropout
|
||||
or set(metadata.get("target_modules", [])) != allowed
|
||||
or metadata.get("modules_to_save") or metadata.get("bias", "none") != "none"
|
||||
or metadata.get("base_model_name_or_path") != config.name):
|
||||
raise ValueError("Warm-start adapter metadata does not match trainer configuration")
|
||||
saved = {k.removeprefix("base_model.model."): v for k, v in
|
||||
load_file(str(path / "adapter_model.safetensors"), device="cpu").items()}
|
||||
targets = {}
|
||||
for name, param in model.named_parameters():
|
||||
if ".lora_A." not in name and ".lora_B." not in name:
|
||||
continue
|
||||
name = name.replace("._orig_mod", "")
|
||||
if not name.endswith(".0"):
|
||||
raise ValueError("Adapter warm start supports one adapter slot only")
|
||||
key = name[:-2] + ".weight"
|
||||
if key in targets:
|
||||
raise ValueError(f"Duplicate adapter destination: {key}")
|
||||
targets[key] = param
|
||||
if set(saved) != set(targets):
|
||||
raise ValueError(f"Adapter key mismatch: missing={set(targets)-set(saved)}, extra={set(saved)-set(targets)}")
|
||||
for key, param in targets.items():
|
||||
if saved[key].shape != param.shape or not torch.isfinite(saved[key]).all():
|
||||
raise ValueError(f"Invalid adapter tensor: {key}")
|
||||
with torch.no_grad():
|
||||
for key, param in targets.items():
|
||||
value = saved[key].to(device=param.device, dtype=param.dtype)
|
||||
if isinstance(param, DTensor):
|
||||
value = distribute_tensor(value, param.device_mesh, param.placements)
|
||||
param.copy_(value)
|
||||
actual = param.to_local() if isinstance(param, DTensor) else param
|
||||
expected = value.to_local() if isinstance(value, DTensor) else value
|
||||
if not torch.equal(actual, expected):
|
||||
raise ValueError(f"Adapter copy verification failed: {key}")
|
||||
get_logger().success(f"Warm-started {len(targets)} adapter tensors from {path}; optimizer state is fresh")
|
||||
@@ -937,7 +937,10 @@ def load_dcp_from_hf(model: nn.Module, config: ModelConfig, parallel_dims: Paral
|
||||
snapshot_keys = dict.fromkeys(load_state_dict_keys(source_path))
|
||||
model_keys = dict.fromkeys(model.state_dict().keys())
|
||||
|
||||
if model.is_hf_state_dict(snapshot_keys) and model.is_prime_state_dict(model_keys):
|
||||
snapshot_is_hf = model.is_hf_state_dict(snapshot_keys)
|
||||
snapshot_is_prime = model.is_prime_state_dict(snapshot_keys)
|
||||
|
||||
if snapshot_is_hf and not snapshot_is_prime and model.is_prime_state_dict(model_keys):
|
||||
logger.warning(
|
||||
"Found HF weight format in snapshot state dict and PrimeRL weight format in model state dict. Trying to auto-convert..."
|
||||
)
|
||||
@@ -951,7 +954,7 @@ def load_dcp_from_hf(model: nn.Module, config: ModelConfig, parallel_dims: Paral
|
||||
save_state_dict(snapshot_state_dict, snapshot_path)
|
||||
del snapshot_state_dict
|
||||
|
||||
elif model.is_prime_state_dict(snapshot_keys) and model.is_hf_state_dict(model_keys):
|
||||
elif snapshot_is_prime and not snapshot_is_hf and model.is_hf_state_dict(model_keys):
|
||||
logger.warning(
|
||||
"Found PrimeRL weight format in snapshot state dict and HF weight format in model state dict. Trying to auto-convert..."
|
||||
)
|
||||
|
||||
@@ -173,7 +173,14 @@ def train(config: TrainerConfig):
|
||||
cpu_offload=config.model.optim_cpu_offload,
|
||||
)
|
||||
scheduler = setup_scheduler(optimizer, config.scheduler, config.max_steps, config.optim.lr)
|
||||
# Run creation resets adapters; initialize only after that reset has finished.
|
||||
if checkpoint_step is None and config.model.lora is not None and config.model.lora.init_path is not None:
|
||||
from prime_rl.trainer.lora_init import load_attention_adapter
|
||||
|
||||
load_attention_adapter(model, config.model)
|
||||
else:
|
||||
if config.model.lora is not None and config.model.lora.init_path is not None:
|
||||
raise ValueError("Adapter warm start requires max_concurrent_runs=1")
|
||||
optimizer = setup_multi_optimizer(config.optim, parallel_dims)
|
||||
scheduler = setup_multi_scheduler(optimizer, config.scheduler, config.max_steps)
|
||||
|
||||
|
||||
@@ -457,15 +457,11 @@ def _is_retryable_lora_error(exception: BaseException) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
# Per-attempt and total bounds for `/load_lora_adapter`. A LoRA load is fast
|
||||
# (small adapter file + KV cache reset, single-digit seconds in practice) but
|
||||
# the global admin AsyncClient uses `timeout=None`, so a stuck server hangs
|
||||
# the orchestrator forever inside `ElasticInferencePool._sync_server_adapter`.
|
||||
# `_PER_ATTEMPT` converts a hang into a TimeoutException so tenacity retries;
|
||||
# `_TOTAL` is the wall-clock budget across all retries — pick whichever
|
||||
# stop condition fires first.
|
||||
LORA_LOAD_READ_TIMEOUT_S = 30.0
|
||||
LORA_LOAD_TOTAL_TIMEOUT_S = 120.0
|
||||
# Loaded multi-DP servers can take minutes to finish an adapter update. Keep
|
||||
# finite timeouts without retrying a healthy update after only a few seconds.
|
||||
# The retry budget is checked between attempts, not as a hard outer deadline.
|
||||
LORA_LOAD_READ_TIMEOUT_S = 300.0
|
||||
LORA_LOAD_TOTAL_TIMEOUT_S = 600.0
|
||||
|
||||
|
||||
async def load_lora_adapter(admin_clients: list[AsyncClient], lora_name: str, lora_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user