Model Import

更新时间:
复制 MD 格式

My Models lets you manage models you created or imported. Use this page to import a locally trained LoRA model from Alibaba Cloud Object Storage Service (OSS) into Alibaba Cloud Model Studio.

Prerequisites

Before importing, ensure the following conditions are met:

  • OSS Bucket preparation: Create an OSS bucket and add a tag to it.

    Note
    • The supported OSS bucket storage classes exclude Archive, Cold Archive, and Deep Cold Archive. Buckets with server-side encryption enabled are supported. Private buckets are also supported.

    • Do not store model files in the root directory of the OSS bucket. Select an existing subdirectory or create a new one for Alibaba Cloud Model Studio to access.

    • You can import model files of any size. After import, they use the free storage space provided by Alibaba Cloud Model Studio.

  • Model file preparation: Your model files must meet the import requirements and limitations. Place the model folder directly in the OSS bucket. The system detects it automatically.

Supported Base Models

You can currently import LoRA fine-tuned versions of the following base models:

Model family

Model name

Qwen3

Qwen3-32B

Qwen3-14B

Qwen3-8B

Qwen3-4B-Instruct-2507

Qwen3-VL

Qwen3-VL-8B-Instruct

Qwen2.5

Qwen2.5-72B-Instruct

Qwen2.5-32B-Instruct

Qwen2.5-14B-Instruct

Qwen2.5-7B-Instruct

Qwen2.5-VL

Qwen2.5-VL-72B-Instruct

Qwen2.5-VL-7B-Instruct

Procedure

Follow these steps to import a LoRA model from OSS into Model Studio:

  1. On the My Models page, click the Import Model button.

  2. On the Import Model page, enter the following information:

    • Model name: Enter a display name for the model (up to 50 characters).

    • Base model: Select the base model corresponding to your LoRA model.

    • Training method: Select the training method used for the model. Options depend on the selected base model and appear automatically after selection.

    • Import source: Only "Import from OSS" is supported. This option is selected by default.

    • Bucket: Select the OSS bucket that stores your model files.

    • Model directory: Browse and select the directory in the chosen bucket that contains your model checkpoint.

    • Model encryption: To protect your data, the platform enables OSS server-side encryption (SSE-OSS) using fully managed keys. The encryption algorithm is AES256.

  3. After verifying the information, click OK to submit the import request. To cancel, click Cancel to return to the list page. The system validates the model file format and integrity. If validation passes, the import starts. After completion, view the imported model on the My Models page and deploy, fine-tune incrementally, or delete it.

    Imported model states include the following: Creating (importing), Created (import succeeded, ready to deploy), Creation Failed (import failed), and Expired (model file changed). The list page also shows model name/ID, base model, source, supported deployment methods, and creation time. Use the search box at the top to filter models by name.

Import Requirements and Limitations

Important

Important: This version supports only LoRA (Low-Rank Adaptation) models. Full-parameter fine-tuned models are not supported.

Before importing a LoRA model, ensure the following requirements are met:

  • Required files: The OSS bucket must contain the following files:

    • adapter_model.safetensors: The LoRA adapter weight file stored in SafeTensors format.

    • adapter_config.json: The LoRA adapter configuration file containing key parameters such as rank and alpha.

  • Rank parameter restriction: The rank value must be 8, 16, 32, or 64. All LoRA layers in the same model must use the same rank value.

  • Models with modified vocabulary: Models that added new tokens or modified the original vocabulary during training cannot be imported. The system requires the vocabulary to exactly match that of the base model.

  • Models with modified chat templates: Models that modified the chat_template during training cannot be imported. The system supports only the default chat_template of the corresponding open-source base model.

    The chat_template configuration is usually located in one of the following places:

    • The chat_template field in the model’s config.json file.

      image

    • The chat_template field in the tokenizer_config.json file.

      image

  • Vision-language models with unfrozen VIT: For VL (Vision-Language) models, the Vision Transformer (VIT) part must be frozen. Models whose LoRA adapters include visual-related weights (indicating unfrozen VIT) cannot be imported.

    Run the following code to check:

    from safetensors import safe_open
    import argparse
    
    def print_safetensor_structure(file_path):
        print(f"Loading safetensor file: {file_path}")
        print("="*80)
        
        with safe_open(file_path, framework="pt") as f:
            keys = f.keys()
            print(f"Found {len(keys)} tensors in the file:\n")
            
            for key in sorted(keys):
                tensor = f.get_tensor(key)
                shape = tuple(tensor.shape)
                dtype = str(tensor.dtype)
                device = tensor.device if hasattr(tensor, 'device') else 'cpu'
                
                lora_tag = " [LoRA]" if "lora_A" in key or "lora_B" in key else ""
                
                print(f"[{dtype:>14}] {shape} | {key} {lora_tag}")
    
    if __name__ == "__main__":
        parser = argparse.ArgumentParser(description="Print structure of a .safetensors LoRA adapter.")
        parser.add_argument("filepath", type=str, help="Path to the .safetensors file")
        args = parser.parse_args()
    
        print_safetensor_structure(args.filepath)

    Method: Check whether the adapter_model.safetensors file contains visual-related weight parameters. If the file contains parameter keys that start with visual (for example, visual.encoder.layer.0...), the ViT component is not frozen, and the model cannot be imported.

    冻结VIT的adapter文件示例

    未冻结VIT的adapter文件示例(包含visual参数)

FAQ

Why does the imported model produce different inference results compared to local vLLM or SGLang?

Model Studio’s inference engine may use different default parameter values than your local framework. To ensure consistent results, adjust the following parameters when calling the API:

Parameter name

Recommended value (matches vLLM defaults)

temperature

Range: [0, 2). Set to 1.0 to match vLLM’s default.

top_p

Range: (0, 1.0]. Set to 1.0 to match vLLM’s default.

top_k

Set to None or a value greater than 100 to disable top_k sampling (only top_p applies). Setting to 99 approximates vLLM’s default value of 0 (full sampling).

presence_penalty

Range: [-2.0, 2.0]. Set to 0 to match vLLM’s default.

repetition_penalty (DashScope protocol)

Increasing repetition_penalty reduces repetition in generated text. A value of 1.0 means no penalty. Range: greater than 0. Set to 1.0 to match vLLM’s default.

Note: These parameter values are based on vLLM’s defaults. If you use SGLang or another inference framework locally, refer to its documentation to adjust parameters accordingly.

How do I import files from OSS to Alibaba Cloud Model Studio for the first time?

If this is your first time importing files from OSS to Alibaba Cloud Model Studio, complete authorization as prompted and add the bailian-datahub-access tag to your target OSS bucket before importing.

If you are unfamiliar with Alibaba Cloud accounts and RAM users, read Permission Management first.

Using an Alibaba Cloud account

  1. Click Go to authorize.

    After selecting Import from OSS under Import source, the page displays “You have not authorized OSS.” Find the Go to authorize link on the right side of this message.

  2. In the dialog box that appears, click Confirm Authorization. The system automatically creates the OSS service-linked role (required).

    This typically takes effect within seconds but may be delayed during peak hours.
  3. Add the bailian-datahub-access tag to your target OSS bucket.

    This tag marks buckets accessible by Alibaba Cloud Model Studio. Model Studio cannot access untagged buckets.
    1. Go to the OSS console. In the navigation pane on the left, click Bucket List to view your buckets.

    2. In the Tag column for the target bucket, hover over the image icon and click Go to edit.

    3. Click Create Tag.

    4. Click Tag, add a tag with name bailian-datahub-access and value read, then click Save.

  4. Return to the Import Model page, reselect the target bucket, and try importing again.

    Note: Alibaba Cloud Model Studio does not support accessing files stored in the bucket root directory. Select an existing folder in the bucket or create a new one for Model Studio to access.

Using a RAM user

  1. Click Go to authorize.

  2. In the dialog box that appears, click Confirm Authorization. The interface shows Authorization failed and The current user lacks permission to create a service-linked role (because the RAM user lacks this permission). You must first grant the RAM user permission to create a service-linked role, then grant permission to access OSS through Model Studio.

    The dialog shows Service Name as datahub.sfm.aliyuncs.com, service-linked role name as AliyunServiceRoleForSFMDataHubOSSImport, and required user permission as ram:CreateServiceLinkedRole.

  3. Grant the RAM user permission to create a service-linked role.

    1. The Alibaba Cloud account must log on to the RAM console. In the navigation pane on the left, choose Permission Management > Policies, then click Create Policy.

    2. In the Script Editor, enter the following content in the Effect, Action, Resource, and Condition fields, then click OK.

      {
          "Action": [
              "ram:CreateServiceLinkedRole"
          ],
          "Resource": "*",
          "Effect": "Allow",
          "Condition": {
              "StringEquals": {
                  "ram:ServiceName": "datahub.sfm.aliyuncs.com"
              }
          }
      }
    3. Enter a policy name and click OK.

      In this example, the policy name is Service-Linked Role.

    4. In the navigation pane on the left, choose Identity Management > Users. Find the target RAM user in the list and click Add Permissions in the Actions column.

    5. Select the custom policy you just created and click Confirm New Authorization. The RAM user now has permission to create a service-linked role.

  4. Authorize the RAM user to access OSS through Alibaba Cloud Model Studio.

    1. Return to the Import Model page and click Go to authorize.

      After selecting Import from OSS under Import source, the page displays “You have not authorized OSS.”

    2. In the dialog box that appears, click Confirm Authorization. The system automatically creates the OSS service-linked role (required).

      This typically takes effect within seconds but may be delayed during peak hours.
  5. Add the bailian-datahub-access tag to your target OSS bucket.

    This tag marks buckets accessible by Alibaba Cloud Model Studio. Model Studio cannot access untagged buckets.
    1. Go to the OSS console. In the navigation pane on the left, click Bucket List to view your buckets.

    2. In the Tag column for the target bucket, hover over the image icon and click Go to edit.

    3. Click Create Tag.

    4. Click Tag, add a tag with name bailian-datahub-access and value read, then click Save.

  6. Return to the Import Model page, reselect the target bucket, and try importing again.

    Note: Alibaba Cloud Model Studio does not support accessing files stored in the bucket root directory. Select an existing folder in the bucket or create a new one for Model Studio to access.

What should I do if I encounter error “10041495”?

This usually occurs because the Alibaba Cloud account has not activated OSS. Follow these steps:

  1. The Alibaba Cloud account must go to the OSS console and activate OSS as instructed.

  2. Return to the Alibaba Cloud Model Studio Import Model page and try authorizing again.