mini-sglang icon indicating copy to clipboard operation
mini-sglang copied to clipboard

[Improvement] Enhance engine error handling and documentation add more logging and doc

Open louiswang524 opened this issue 1 week ago • 0 comments

Summary

  • Improve error handling in Engine initialization
  • Add better error messages for debugging
  • Fix page_size configuration usage
  • Add documentation for helper functions

Changes

  1. Error Handling Improvements:

    • Replace assert not torch.cuda.is_initialized() with proper RuntimeError exception
    • Replace assert for insufficient memory with detailed ValueError message including:
      • Available memory information
      • Memory per page calculation
      • Suggestions for configuration adjustments
  2. Configuration Fix:

    • Use config.page_size instead of hardcoded 1 in Context initialization (line 79)
    • Note: page_size=1 is still the only supported value (enforced in core.py), but this makes the code consistent
  3. Documentation:

    • Add docstring to _align_up_32() explaining 128-byte alignment purpose
    • Add return type hint to Engine.__init__()

Testing

  • Existing tests should pass
  • Better error messages will help users diagnose memory issues

louiswang524 avatar Dec 20 '25 21:12 louiswang524