microsoft/qlib · error · SeedIteratorNotAvailable
Seed iterator for validation is not available.
Error message
Seed iterator for validation is not available.
What it means
SeedIteratorNotAvailable from the default `Vessel.val_seed_iterator` (qlib/rl/trainer/vessel.py:60). Same abstract-method contract as the training variant, but for the validation set: the trainer fetches validation initial states from this hook when running validation during/after training.
Source
Thrown at qlib/rl/trainer/vessel.py:60
simulator_fn: Callable[[InitialStateType], Simulator[InitialStateType, StateType, ActType]]
state_interpreter: StateInterpreter[StateType, ObsType]
action_interpreter: ActionInterpreter[StateType, PolicyActType, ActType]
policy: BasePolicy
reward: Reward
trainer: Trainer
def assign_trainer(self, trainer: Trainer) -> None:
self.trainer = weakref.proxy(trainer) # type: ignore
def train_seed_iterator(self) -> ContextManager[Iterable[InitialStateType]] | Iterable[InitialStateType]:
"""Override this to create a seed iterator for training.
If the iterable is a context manager, the whole training will be invoked in the with-block,
and the iterator will be automatically closed after the training is done."""
raise SeedIteratorNotAvailable("Seed iterator for training is not available.")
def val_seed_iterator(self) -> ContextManager[Iterable[InitialStateType]] | Iterable[InitialStateType]:
"""Override this to create a seed iterator for validation."""
raise SeedIteratorNotAvailable("Seed iterator for validation is not available.")
def test_seed_iterator(self) -> ContextManager[Iterable[InitialStateType]] | Iterable[InitialStateType]:
"""Override this to create a seed iterator for testing."""
raise SeedIteratorNotAvailable("Seed iterator for testing is not available.")
def train(self, vector_env: BaseVectorEnv) -> Dict[str, Any]:
"""Implement this to train one iteration. In RL, one iteration usually refers to one collect."""
raise NotImplementedError()
def validate(self, vector_env: FiniteVectorEnv) -> Dict[str, Any]:
"""Implement this to validate the policy once."""
raise NotImplementedError()
def test(self, vector_env: FiniteVectorEnv) -> Dict[str, Any]:
"""Implement this to evaluate the policy on test environment once."""
raise NotImplementedError()
def log(self, name: str, value: Any) -> None:View on GitHub (pinned to 79633dd950)
Solutions
- Override `val_seed_iterator` to return the iterable of validation initial states (typically a held-out date/order split).
- If you don't want validation, remove validation-triggering callbacks/arguments rather than letting the exception fire.
- To reuse training data for validation, return the same generator factory (fresh instance, not an exhausted iterator).
Example fix
// before
class MyVessel(Vessel):
def train_seed_iterator(self): return iter(train_orders)
# val_seed_iterator missing -> error when EarlyStopping validates
// after
class MyVessel(Vessel):
def train_seed_iterator(self): return iter(train_orders)
def val_seed_iterator(self): return iter(val_orders) Defensive patterns
Strategy: validation
Validate before calling
from qlib.rl.trainer.vessel import Vessel
def val_seeds_available(vessel: Vessel) -> bool:
return type(vessel).val_seed_iterator is not Vessel.val_seed_iterator Type guard
def vessel_supports_validation(v) -> bool:
from qlib.rl.trainer.vessel import Vessel
return type(v).val_seed_iterator is not Vessel.val_seed_iterator Try / catch
from qlib.rl.trainer.vessel import SeedIteratorNotAvailable
try:
trainer.validate(vessel)
except SeedIteratorNotAvailable:
log.warning("no validation seed iterator; skipping validation") Prevention
- If using EarlyStopping or any monitor callback, implement val_seed_iterator from day one.
- Split data into train/val/test seed sets up front and wire all three hooks.
- Return fresh generator factories, not shared exhausted iterators.
When it happens
Trigger: A vessel without a `val_seed_iterator` override used with `Trainer.fit(...)` while `num_episode`/callbacks request validation, or an explicit `trainer.validate(vessel)` call.
Common situations: Teams implement training seeds first and forget validation; validation intended to reuse the train iterator but the hook was never wired; EarlyStopping callback configured with a monitor, which forces validation and surfaces the missing override.
Related errors
- Seed iterator for training is not available.
- Seed iterator for testing is not available.
- Sample must be a dict with same length as space.
- Unexpected order direction: {direction}
- Unexpected order direction: {direction}
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/8ca5bbb740825961.
Report an issue: GitHub.