Skip to content

Conversation

mohamedzeidan2021
Copy link
Collaborator

These changes introduce a lazy loading system that improves the HPCLI startup performance. Dependencies are no longer loaded upfront (resulting in 2+ second startup time) and are now loaded only when needed, reducing the help command times by 50% while maintaining full functionality during execution.

Architecture

1. LazyImportManager

Replaces traditional imports with a config based system the defers heavy modules until they're accessed. Integrates with __getattr__ Python mechanism

2. LazyRegistry

Provides lightweight substitutes for heavy registries during CLI generation. The flow now stores basic metadata for immediate CLI option generation, and defers full schemas until commands are actually executed and need validation

3. LazyDecorator

Applies decorators based on current needs from the system. For example - immediately applies for CLI generation decorators (needed for help text), and deferred application for runtime decorators (telemetry, logging) that are ONLY needed during command execution

4. CommandRegistry

Removes the need for hardcoded command mappings by enabling commands to self-register with metadata during imports. This allows the CLI to discover available commands without loading heavy modules/deps; selects which modules to load based on which commands users actually run.

How they all work together

These components form the pipeline as such:

  • CommandRegistry discovers available commands from lightweight metadata
  • LazyImportManager provides module loading infra
  • LazyDecorator determines which decorators to apply immediately vs. at execution
  • LazyRegistry supplies minimal data for CLI generation and defers heavy registry loading

Example

hyp create hyp-pytorch-job --help

  1. CommandRegistry identifies that the command exists without loading the training module
  2. LazyDecorator applies CLI generation decorators immediately
  3. LazyRegistry provides version info for option generation
  4. Help displayed: no heavy modules loaded

!hyp create hyp-jumpstart-endpoint --model-id deepseek-llm-r1-distill-qwen-1-5b --instance-type ml.g5.8xlarge --endpoint-name new-endpoint

  1. CommandRegistry triggers inference module command (hyp-jumpstart-endpoint)
  2. LazyImportManager loads inference-specific deps
  • Jumpstart model hub libs, Sagemaker SDK for endpoint management, model validation and config systems
  1. LazyDecorator applies runtime decorators (telemetry, error handling, parameter validation)
  2. LazyRegistry loads JumpStart model registry and schemas

PR Approval Steps

For Requester

  1. Description
    • Check the PR title and description for clarity. It should describe the changes made and the reason behind them.
    • Ensure that the PR follows the contribution guidelines, if applicable.
  2. Security requirements
  3. Manual review
    1. Click on the Files changed tab to see the code changes. Review the changes thoroughly:
      • Code Quality: Check for coding standards, naming conventions, and readability.
      • Functionality: Ensure that the changes meet the requirements and that all necessary code paths are tested.
      • Security: Check for any security issues or vulnerabilities.
      • Documentation: Confirm that any necessary documentation (code comments, README updates, etc.) has been updated.
  4. Check for Merge Conflicts:
    • Verify if there are any merge conflicts with the base branch. GitHub will usually highlight this. If there are conflicts, you should resolve them.

For Reviewer

  1. Go through For Requester section to double check each item.
  2. Request Changes or Approve the PR:
    1. If the PR is ready to be merged, click Review changes and select Approve.
    2. If changes are required, select Request changes and provide feedback. Be constructive and clear in your feedback.
  3. Merging the PR
    1. Check the Merge Method:
      1. Decide on the appropriate merge method based on your repository's guidelines (e.g., Squash and merge, Rebase and merge, or Merge).
    2. Merge the PR:
      1. Click the Merge pull request button.
      2. Confirm the merge by clicking Confirm merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant