@aws/ml-container-creator 0.9.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/LICENSE-THIRD-PARTY +9304 -0
  2. package/bin/cli.js +2 -0
  3. package/config/bootstrap-e2e-stack.json +341 -0
  4. package/config/bootstrap-stack.json +40 -3
  5. package/config/parameter-schema-v2.json +2049 -0
  6. package/config/tune-catalog.json +1781 -0
  7. package/infra/ci-harness/buildspec.yml +1 -0
  8. package/infra/ci-harness/lambda/path-prover/brain.ts +306 -0
  9. package/infra/ci-harness/lambda/path-prover/write-results.ts +152 -0
  10. package/infra/ci-harness/lib/ci-harness-stack.ts +837 -7
  11. package/infra/ci-harness/state-machines/path-prover.asl.json +496 -0
  12. package/package.json +53 -68
  13. package/servers/base-image-picker/index.js +121 -121
  14. package/servers/e2e-status/index.js +297 -0
  15. package/servers/e2e-status/manifest.json +14 -0
  16. package/servers/e2e-status/package.json +15 -0
  17. package/servers/endpoint-picker/LICENSE +202 -0
  18. package/servers/endpoint-picker/index.js +536 -0
  19. package/servers/endpoint-picker/manifest.json +14 -0
  20. package/servers/endpoint-picker/package.json +18 -0
  21. package/servers/hyperpod-cluster-picker/index.js +125 -125
  22. package/servers/instance-sizer/index.js +138 -138
  23. package/servers/instance-sizer/lib/instance-ranker.js +76 -76
  24. package/servers/instance-sizer/lib/model-resolver.js +61 -61
  25. package/servers/instance-sizer/lib/quota-resolver.js +113 -113
  26. package/servers/instance-sizer/lib/vram-estimator.js +31 -31
  27. package/servers/lib/bedrock-client.js +38 -38
  28. package/servers/lib/catalogs/jumpstart-public.json +101 -16
  29. package/servers/lib/catalogs/model-servers.json +201 -3
  30. package/servers/lib/catalogs/models.json +182 -26
  31. package/servers/lib/custom-validators.js +13 -13
  32. package/servers/lib/dynamic-resolver.js +4 -4
  33. package/servers/marketplace-picker/index.js +342 -0
  34. package/servers/marketplace-picker/manifest.json +14 -0
  35. package/servers/marketplace-picker/package.json +18 -0
  36. package/servers/model-picker/index.js +382 -382
  37. package/servers/region-picker/index.js +56 -56
  38. package/servers/workload-picker/LICENSE +202 -0
  39. package/servers/workload-picker/catalogs/workload-profiles.json +67 -0
  40. package/servers/workload-picker/index.js +171 -0
  41. package/servers/workload-picker/manifest.json +16 -0
  42. package/servers/workload-picker/package.json +16 -0
  43. package/src/app.js +4 -390
  44. package/src/lib/bootstrap-command-handler.js +710 -1148
  45. package/src/lib/bootstrap-config.js +36 -0
  46. package/src/lib/bootstrap-profile-manager.js +641 -0
  47. package/src/lib/bootstrap-provisioners.js +421 -0
  48. package/src/lib/ci-register-helpers.js +74 -0
  49. package/src/lib/config-loader.js +408 -0
  50. package/src/lib/config-manager.js +66 -1685
  51. package/src/lib/config-mcp-client.js +118 -0
  52. package/src/lib/config-validator.js +634 -0
  53. package/src/lib/cuda-resolver.js +149 -0
  54. package/src/lib/e2e-catalog-validator.js +251 -3
  55. package/src/lib/e2e-ci-recorder.js +103 -0
  56. package/src/lib/generated/cli-options.js +315 -311
  57. package/src/lib/generated/parameter-matrix.js +671 -0
  58. package/src/lib/generated/validation-rules.js +71 -71
  59. package/src/lib/marketplace-flow.js +276 -0
  60. package/src/lib/mcp-query-runner.js +768 -0
  61. package/src/lib/parameter-schema-validator.js +62 -18
  62. package/src/lib/path-prover-brain.js +607 -0
  63. package/src/lib/prompt-runner.js +41 -1504
  64. package/src/lib/prompts/feature-prompts.js +172 -0
  65. package/src/lib/prompts/index.js +48 -0
  66. package/src/lib/prompts/infrastructure-prompts.js +690 -0
  67. package/src/lib/prompts/model-prompts.js +552 -0
  68. package/src/lib/prompts/project-prompts.js +82 -0
  69. package/src/lib/prompts.js +2 -1446
  70. package/src/lib/registry-command-handler.js +135 -3
  71. package/src/lib/secrets-prompt-runner.js +251 -0
  72. package/src/lib/template-variable-resolver.js +422 -0
  73. package/src/lib/tune-catalog-validator.js +37 -4
  74. package/templates/Dockerfile +9 -0
  75. package/templates/code/adapter_sidecar.py +444 -0
  76. package/templates/code/serve +6 -0
  77. package/templates/code/serve.d/vllm.ejs +1 -1
  78. package/templates/do/.benchmark_writer.py +1476 -0
  79. package/templates/do/.tune_helper.py +982 -57
  80. package/templates/do/__pycache__/.benchmark_writer.cpython-312.pyc +0 -0
  81. package/templates/do/adapter +149 -0
  82. package/templates/do/benchmark +639 -85
  83. package/templates/do/config +108 -5
  84. package/templates/do/deploy.d/managed-inference.ejs +192 -11
  85. package/templates/do/optimize +106 -37
  86. package/templates/do/register +89 -0
  87. package/templates/do/test +13 -0
  88. package/templates/do/tune +378 -59
  89. package/templates/do/validate +44 -4
  90. package/config/parameter-schema.json +0 -88
@@ -523,6 +523,155 @@ _adapter_add() {
523
523
  echo "📦 Using latest tune adapter output: ${weights_uri}"
524
524
  fi
525
525
  echo ""
526
+
527
+ # ── Package tune artifacts as tar.gz if needed ────────────────────
528
+ # Tune output is an S3 path that may be:
529
+ # 1. Already a tar.gz file (s3://...adapter.tar.gz) → use directly
530
+ # 2. An S3 directory prefix containing adapter files → download, validate, package, upload
531
+ if echo "${weights_uri}" | grep -qE '\.tar\.gz$'; then
532
+ echo "✅ Tune output is already a tar.gz archive."
533
+
534
+ # Validate adapter_config.json exists in the tar.gz
535
+ echo "🔍 Validating adapter_config.json in archive..."
536
+ local tar_validate_dir="/tmp/adapter_tar_validate_$$"
537
+ mkdir -p "${tar_validate_dir}"
538
+
539
+ if aws s3 cp "${weights_uri}" "${tar_validate_dir}/adapter.tar.gz" --region "${AWS_REGION}" --quiet 2>/dev/null; then
540
+ if ! tar -tzf "${tar_validate_dir}/adapter.tar.gz" 2>/dev/null | grep -q 'adapter_config\.json'; then
541
+ echo "❌ adapter_config.json not found in tar.gz archive."
542
+ echo ""
543
+ echo " Path: ${weights_uri}"
544
+ echo ""
545
+ echo " The archive does not appear to contain a valid"
546
+ echo " PEFT/LoRA adapter. A valid adapter must include:"
547
+ echo " • adapter_config.json"
548
+ echo " • adapter_model.safetensors (or adapter_model.bin)"
549
+ echo ""
550
+ echo " Check that the tune job completed successfully:"
551
+ echo " ./do/tune status"
552
+ rm -rf "${tar_validate_dir}"
553
+ exit 1
554
+ fi
555
+ echo " ✅ adapter_config.json found in archive"
556
+ else
557
+ echo " ⚠️ Could not download archive for validation. Proceeding anyway..."
558
+ fi
559
+
560
+ rm -rf "${tar_validate_dir}"
561
+ echo " Using directly without re-packaging."
562
+ else
563
+ echo "📦 Tune output is a directory — packaging as tar.gz..."
564
+ local tune_tmp_dir="/tmp/adapter_tune_package_$$"
565
+ mkdir -p "${tune_tmp_dir}/adapter_files"
566
+
567
+ # Normalize S3 prefix (ensure trailing slash for directory listing)
568
+ local s3_prefix="${weights_uri}"
569
+ if [[ "${s3_prefix}" != */ ]]; then
570
+ s3_prefix="${s3_prefix}/"
571
+ fi
572
+
573
+ # Download all adapter files from S3 directory
574
+ echo " Downloading adapter artifacts from: ${s3_prefix}"
575
+ if ! aws s3 cp "${s3_prefix}" "${tune_tmp_dir}/adapter_files/" --recursive --region "${AWS_REGION}" 2>/dev/null; then
576
+ echo "❌ Failed to download adapter artifacts from S3."
577
+ echo ""
578
+ echo " Path: ${s3_prefix}"
579
+ echo " Check that:"
580
+ echo " • The S3 path exists and contains adapter files"
581
+ echo " • Your IAM credentials have s3:GetObject and s3:ListBucket permission"
582
+ rm -rf "${tune_tmp_dir}"
583
+ exit 1
584
+ fi
585
+
586
+ # Validate adapter_config.json exists
587
+ if [ ! -f "${tune_tmp_dir}/adapter_files/adapter_config.json" ]; then
588
+ echo "❌ adapter_config.json not found in tune output."
589
+ echo ""
590
+ echo " Path: ${s3_prefix}"
591
+ echo ""
592
+ echo " The tune output does not appear to contain a valid"
593
+ echo " PEFT/LoRA adapter. A valid adapter must include:"
594
+ echo " • adapter_config.json"
595
+ echo " • adapter_model.safetensors (or adapter_model.bin)"
596
+ echo ""
597
+ echo " Check that the tune job completed successfully:"
598
+ echo " ./do/tune status"
599
+ rm -rf "${tune_tmp_dir}"
600
+ exit 1
601
+ fi
602
+
603
+ echo " ✅ adapter_config.json found"
604
+
605
+ # Optional: check base_model_name_or_path matches MODEL_NAME
606
+ if [ -n "${MODEL_NAME:-}" ]; then
607
+ local adapter_base_model=""
608
+ if command -v jq &>/dev/null; then
609
+ adapter_base_model=$(jq -r '.base_model_name_or_path // empty' "${tune_tmp_dir}/adapter_files/adapter_config.json" 2>/dev/null)
610
+ else
611
+ adapter_base_model=$(grep -o '"base_model_name_or_path"[[:space:]]*:[[:space:]]*"[^"]*"' "${tune_tmp_dir}/adapter_files/adapter_config.json" 2>/dev/null | sed 's/.*"base_model_name_or_path"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
612
+ fi
613
+
614
+ if [ -n "${adapter_base_model}" ] && [ "${adapter_base_model}" != "${MODEL_NAME}" ]; then
615
+ echo " ⚠️ Adapter was trained on '${adapter_base_model}' but base model is '${MODEL_NAME}'. Adapter may not work correctly."
616
+ fi
617
+ fi
618
+
619
+ # Flatten: move any nested files to root level and remove subdirectories
620
+ find "${tune_tmp_dir}/adapter_files" -mindepth 2 -type f -exec mv {} "${tune_tmp_dir}/adapter_files/" \; 2>/dev/null || true
621
+ find "${tune_tmp_dir}/adapter_files" -mindepth 1 -type d -exec rm -rf {} + 2>/dev/null || true
622
+
623
+ # Create flat tar.gz archive
624
+ echo " Creating adapter.tar.gz..."
625
+ if ! tar -czf "${tune_tmp_dir}/adapter.tar.gz" -C "${tune_tmp_dir}/adapter_files" . 2>/dev/null; then
626
+ echo "❌ Failed to create adapter.tar.gz from tune output."
627
+ rm -rf "${tune_tmp_dir}"
628
+ exit 1
629
+ fi
630
+
631
+ local tar_size
632
+ tar_size=$(du -h "${tune_tmp_dir}/adapter.tar.gz" | cut -f1)
633
+ echo " Archive size: ${tar_size}"
634
+
635
+ # Resolve S3 bucket for upload
636
+ local s3_bucket=""
637
+ if [ -n "${ADAPTER_S3_BUCKET:-}" ]; then
638
+ s3_bucket="${ADAPTER_S3_BUCKET}"
639
+ else
640
+ local account_id
641
+ account_id=$(aws sts get-caller-identity --query Account --output text 2>/dev/null || echo "")
642
+ if [ -z "${account_id}" ]; then
643
+ echo "❌ Could not determine AWS account ID."
644
+ echo " Ensure AWS credentials are configured."
645
+ rm -rf "${tune_tmp_dir}"
646
+ exit 1
647
+ fi
648
+ s3_bucket="mlcc-adapters-${account_id}-${AWS_REGION}"
649
+ fi
650
+
651
+ # Upload tar.gz to S3
652
+ local s3_tar_path="s3://${s3_bucket}/adapters/${PROJECT_NAME}/${adapter_name}/adapter.tar.gz"
653
+ echo " ☁️ Uploading to S3: ${s3_tar_path}"
654
+
655
+ if ! aws s3 cp "${tune_tmp_dir}/adapter.tar.gz" "${s3_tar_path}" --region "${AWS_REGION}"; then
656
+ echo "❌ Failed to upload adapter tar.gz to S3."
657
+ echo ""
658
+ echo " Check that:"
659
+ echo " • The S3 bucket '${s3_bucket}' exists"
660
+ echo " • Your IAM credentials have s3:PutObject permission"
661
+ echo " • Run bootstrap if the bucket doesn't exist: ./do/bootstrap"
662
+ rm -rf "${tune_tmp_dir}"
663
+ exit 1
664
+ fi
665
+
666
+ echo " ✅ Uploaded to S3: ${s3_tar_path}"
667
+
668
+ # Clean up temp directory
669
+ rm -rf "${tune_tmp_dir}"
670
+
671
+ # Update weights_uri to point to the uploaded tar.gz
672
+ weights_uri="${s3_tar_path}"
673
+ fi
674
+ echo ""
526
675
  fi
527
676
 
528
677
  # ── Validate HF repo ID format (if --from-hub) ───────────────────────