easydel.infra.errors#
Custom exception classes for EasyDeL framework.
This module defines specialized exception classes used throughout EasyDeL to provide clear and specific error messages for different failure scenarios.
- Exception Hierarchy:
All exceptions inherit from Python’s base Exception class and are used to signal specific types of errors that can occur during model training, inference, or configuration.
Example
>>> try:
... # Some EasyDeL operation
... model.train()
... except EasyDeLRuntimeError as e:
... print(f"Runtime error occurred: {e}")
... except EasyDeLNotImplementedFeatureError as e:
... print(f"Feature not yet implemented: {e}")
- exception easydel.infra.errors.EasyDeLBlockWiseFFNError[source]#
Bases:
ExceptionError in block-wise feed-forward network operations.
Raised when block-wise FFN operations fail, typically due to incorrect input shapes, incompatible chunk sizes, or when the sequence length is not divisible by the specified chunk size.
This error is specific to the memory-efficient block-wise computation used in models with very long sequences.
Example
>>> if seq_len % chunk_size != 0: ... raise EasyDeLBlockWiseFFNError( ... f"Sequence length {seq_len} must be divisible by chunk size {chunk_size}" ... )
- exception easydel.infra.errors.EasyDeLBreakRequest[source]#
Bases:
ExceptionSignal to break out of a training or generation loop.
This exception is used as a control flow mechanism to cleanly exit from training loops, generation loops, or other iterative processes when certain conditions are met (e.g., NaN detected, user interrupt, convergence criteria).
Not typically an error condition, but rather a signal for controlled termination.
Example
>>> if jnp.isnan(loss): ... raise EasyDeLBreakRequest("NaN detected in loss, stopping training")
- exception easydel.infra.errors.EasyDeLComputeError[source]#
Bases:
ExceptionError during numerical computation or model forward pass.
Raised when mathematical operations fail, tensors have invalid values, or when the model’s forward pass encounters an error. This includes overflow, underflow, or dimension mismatches during computation.
Example
>>> if jnp.isinf(logits).any(): ... raise EasyDeLComputeError("Infinite values detected in model logits")
- exception easydel.infra.errors.EasyDeLNotImplementedFeatureError[source]#
Bases:
ExceptionRequested feature is not yet implemented.
Raised when attempting to use a feature that is planned but not yet implemented in the current version of EasyDeL. This helps distinguish between bugs and intentionally unimplemented features.
Example
>>> def new_attention_mechanism(): ... raise EasyDeLNotImplementedFeatureError( ... "Custom attention mechanism will be available in v2.1" ... )
- exception easydel.infra.errors.EasyDeLProcessError[source]#
Bases:
ExceptionError in multi-process or distributed operations.
Raised when errors occur in distributed training, multi-device operations, or inter-process communication. This includes failures in device mesh creation, collective operations, or process synchronization.
Example
>>> if jax.process_count() < required_processes: ... raise EasyDeLProcessError( ... f"Need at least {required_processes} processes, got {jax.process_count()}" ... )
- exception easydel.infra.errors.EasyDeLRuntimeError[source]#
Bases:
ExceptionGeneral runtime error in EasyDeL operations.
Raised when an unexpected runtime condition occurs during model execution, training, or inference that prevents normal operation.
This is the most general EasyDeL exception and should be used when a more specific exception type doesn’t apply.
Example
>>> if model_state is None: ... raise EasyDeLRuntimeError("Model state must be initialized before training")
- exception easydel.infra.errors.EasyDeLSyntaxRuntimeError[source]#
Bases:
ExceptionSyntax or configuration error in EasyDeL code.
Raised when there are syntax errors in configuration files, model definitions, or when invalid parameter combinations are detected at runtime.
This differs from Python’s SyntaxError as it relates to EasyDeL-specific syntax and configuration requirements.
Example
>>> if config.num_layers < 1: ... raise EasyDeLSyntaxRuntimeError("Number of layers must be at least 1")
- exception easydel.infra.errors.EasyDeLTimerError[source]#
Bases:
ExceptionError related to timing or profiling operations.
Raised when timer operations fail, such as when trying to stop a timer that was never started, or when timing measurements produce invalid results.
Used primarily by EasyDeL’s profiling and benchmarking utilities.
Example
>>> if timer_id not in active_timers: ... raise EasyDeLTimerError(f"Timer '{timer_id}' was not started")