mini-sglang
mini-sglang copied to clipboard
[Improvement] Enhance engine error handling and documentation add more logging and doc
Summary
- Improve error handling in Engine initialization
- Add better error messages for debugging
- Fix page_size configuration usage
- Add documentation for helper functions
Changes
-
Error Handling Improvements:
- Replace
assert not torch.cuda.is_initialized()with properRuntimeErrorexception - Replace assert for insufficient memory with detailed
ValueErrormessage including:- Available memory information
- Memory per page calculation
- Suggestions for configuration adjustments
- Replace
-
Configuration Fix:
- Use
config.page_sizeinstead of hardcoded1in Context initialization (line 79) - Note:
page_size=1is still the only supported value (enforced in core.py), but this makes the code consistent
- Use
-
Documentation:
- Add docstring to
_align_up_32()explaining 128-byte alignment purpose - Add return type hint to
Engine.__init__()
- Add docstring to
Testing
- Existing tests should pass
- Better error messages will help users diagnose memory issues