forked from DaoyuanLi2816/mini-verl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
138 lines (88 loc) · 3.83 KB
/
Copy patherrors.py
File metadata and controls
138 lines (88 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
"""Domain-specific exceptions.
Every miniVERL error carries a human-readable ``message`` and an optional
``hint`` describing the concrete next action. The CLI renders ``hint`` on a
separate line, so hints should be imperative and copy-pasteable.
"""
from __future__ import annotations
__all__ = [
"MiniVerlError",
"ConfigError",
"SchemaValidationError",
"TrajectoryError",
"AlignmentError",
"TokenizerMismatchError",
"ToolCallParseError",
"ToolEnvironmentError",
"CacheError",
"StaleCacheError",
"CacheCorruptionError",
"MissingDependencyError",
"BackendError",
"MemoryStrategyError",
"GpuMemoryError",
"LifecycleError",
"RunLockedError",
"SerializationError",
"CheckpointError",
"ReportError",
"RunNotFoundError",
"RunDirectoryError",
]
class MiniVerlError(Exception):
"""Base class for every error raised on purpose by miniVERL."""
def __init__(self, message: str, hint: str | None = None) -> None:
super().__init__(message)
self.message = message
self.hint = hint
def __str__(self) -> str:
if self.hint:
return f"{self.message}\n hint: {self.hint}"
return self.message
class ConfigError(MiniVerlError):
"""A run configuration is malformed, contradictory or unsupported."""
class SchemaValidationError(MiniVerlError):
"""A serialized artifact does not match its declared schema."""
class TrajectoryError(MiniVerlError):
"""A trajectory violates the span/mask/token invariants."""
class AlignmentError(MiniVerlError):
"""Student and teacher prediction positions could not be aligned."""
class TokenizerMismatchError(AlignmentError):
"""Student and teacher tokenizers differ; miniVERL requires an identical one."""
class ToolCallParseError(MiniVerlError):
"""The model emitted text that is not a valid tool call or final answer."""
class ToolEnvironmentError(MiniVerlError):
"""A tool environment rejected an operation or failed to execute one."""
class CacheError(MiniVerlError):
"""Generic teacher-target cache failure."""
class StaleCacheError(CacheError):
"""A cache entry was produced by an incompatible policy/model/config."""
class CacheCorruptionError(CacheError):
"""A cache shard failed its checksum or structural validation."""
class MissingDependencyError(MiniVerlError):
"""An optional dependency is required for the requested operation."""
def __init__(self, package: str, extra: str, purpose: str) -> None:
message = f"{purpose} requires the optional dependency '{package}', which is not installed."
hint = f'pip install "miniverl[{extra}]"'
super().__init__(message, hint)
self.package = package
self.extra = extra
class BackendError(MiniVerlError):
"""A model backend could not be constructed or used as configured."""
class MemoryStrategyError(MiniVerlError):
"""A memory strategy could not honour its contract."""
class GpuMemoryError(MiniVerlError):
"""CUDA ran out of memory and the bounded, equivalence-preserving retries failed."""
class LifecycleError(MiniVerlError):
"""An operation used a closed object or resource teardown failed."""
class RunLockedError(LifecycleError):
"""Another process owns the exclusive mutation lock for a run."""
class SerializationError(MiniVerlError):
"""A value cannot be represented as standards-compliant machine JSON."""
class CheckpointError(MiniVerlError):
"""A checkpoint could not be written, read or resumed."""
class ReportError(MiniVerlError):
"""A report could not be produced from the run artifacts."""
class RunNotFoundError(MiniVerlError):
"""A run directory does not exist or is missing required artifacts."""
class RunDirectoryError(MiniVerlError):
"""A run directory could not be created, resumed or safely replaced."""