Skip to main content

Model Import

Covers the end-to-end process of importing a LoRA model from Alibaba Cloud OSS into Alibaba Cloud Model Studio, including first-time OSS authorization, model file preparation, import form fields, imported model management, and troubleshooting.

Model import overview

This article describes the full process of importing a locally trained LoRA model from Alibaba Cloud Object Storage Service (OSS) to Bailian, covering the initial OSS authorization, model file preparation, import form filling, model viewing, management, and deletion, as well as troubleshooting common issues such as import failure and expired models. After a successful import, you can deploy services. For deployment, scaling, and decommissioning operations, see Deployment and O&M; for deployment and invocation through the API, see Deploy models by using the API; for deployment prerequisites and a comparison of billing plans, see Model deployment overview. Together with these three articles, this one forms the complete chain of concepts, import, deployment, and invocation. The base model field on the import page is dynamically populated by a Model Studio API that returns the list of currently importable base models, which may change with version updates. Refer to the options available in the console. The currently supported base models are listed below:
This list is dynamically returned by the backend API and may change with version updates. Refer to the actual options available in the console.

Model family

Model name

Qwen3

Qwen3-32B

Qwen3

Qwen3-14B

Qwen3

Qwen3-8B

Qwen3

Qwen3-4B-Instruct-2507

Qwen3-VL

Qwen3-VL-8B-Instruct

Qwen2.5

Qwen2.5-72B-Instruct

Qwen2.5

Qwen2.5-32B-Instruct

Qwen2.5

Qwen2.5-14B-Instruct

Qwen2.5

Qwen2.5-7B-Instruct

Qwen2.5-VL

Qwen2.5-VL-72B-Instruct

Qwen2.5-VL

Qwen2.5-VL-7B-Instruct

The available training method options depend on the selected base model; after choosing a base model, the training method field auto-renders its options and selects the first one by default. This version supports importing LoRA models; full-parameter fine-tuned models cannot be imported. The import source is "Import from OSS", selected by default; importing from other channels is not supported. After a successful import, the model enters the Created state and can be deployed from the My Models list. Models imported from OSS do not support incremental training; to iterate, retrain and import again. After import, the model record is stored using the free storage space provided by Model Studio.

Authorize OSS before first import

Before importing a model from OSS for the first time, you must complete the OSS service-linked role authorization and add an access tag to the target bucket. Authorization is done in one click from the import page. Once authorized, the system automatically creates the service-linked role AliyunServiceRoleForSFMDataHubOSSImport (service name datahub.sfm.aliyuncs.com, permission policy AliyunServiceRolePolicyForSFMDataHubOSSImport), which usually takes effect within seconds. For details on the service-linked role, see OSS service-linked role. For the concepts and differences between the Alibaba Cloud account and RAM users, see Alibaba Cloud account and RAM users. On the Import Model page, after selecting "Import from OSS" under Import source, if you have not authorized, the OSS field area shows "You have not authorized OSS" with a "Go to authorize" link, and the OK button is disabled until authorization is complete. The authorization path differs for Alibaba Cloud accounts and RAM users; choose by account type.
  • Using an Alibaba Cloud account
  • Use a sub-account
  1. On the Import Model page, after selecting "Import from OSS" as the Import Source, the page prompts "You have not authorized OSS yet". Click "Authorize Now" on the right side of the prompt bar.
  2. In the dialog box that appears, click "Authorize Now". The system automatically creates the service-linked role AliyunServiceRoleForSFMDataHubOSSImport, which usually takes effect within seconds; it may be slightly delayed during peak service hours.
  3. Add a tag to the target OSS Bucket: go to the Bucket list in the OSS management console, find the target Bucket, hover over the icon in the Tags column, and click "Go to Edit" → "Create Tag". Add the tag name bailian-datahub-access and the tag value read, then save.
  4. Return to the Import Model page, re-select the target Bucket, and try importing again. Bailian does not support accessing files in the Bucket root directory; you must select an existing subdirectory under the Bucket or create a new subdirectory.
After authorization, you must add a tag to the target OSS Bucket: the tag name is bailian-datahub-access and the tag value is read. This tag marks the Buckets that Bailian can access. Buckets without this tag are not selectable in the drop-down list; you must add the tag in the OSS management console and then select the Bucket again. The Bucket drop-down list is filtered by the current region: when the current region is China (Beijing), Buckets in all Chinese mainland regions are displayed; when the current region is Singapore, Buckets in all Chinese mainland regions and the Singapore region are displayed. The Archive, Cold Archive, and Deep Cold Archive OSS storage classes are not supported. For server-side encryption, OSS fully managed encryption is supported, while KMS-managed keys (SSE-KMS) and other server-side encryption methods are not supported. Private Buckets are supported. Bailian does not support accessing files in the Bucket root directory; you must select an existing subdirectory under the Bucket or create a new subdirectory.

Upgrade from the legacy authorization method

If you previously used the legacy authorization method, a message appears under the Bucket field on the import page: "We recommend switching to the new Bucket authorization method for better security", along with a "Switch Now" link. Click the link and confirm in the dialog box that appears. The authorization method is then upgraded to the service-linked role method, and the upgrade does not affect existing data.

OSS product not activated

If the primary account has not activated Object Storage Service (OSS), the import page displays "You have not activated OSS yet" together with a link to the purchase page. The primary account must first activate OSS in the OSS console, then return to the import page to authorize again.

Prepare LoRA model files

Before importing, you must place the LoRA model files in a subdirectory of an OSS Bucket according to the following requirements (the Bucket root directory is not supported) and pass the system's automatic validation before submitting. The model files must be placed directly in the selected subdirectory; the system identifies them automatically.
The current version supports importing LoRA models and does not support importing fully fine-tuned models.

Required files and directory structure

The subdirectory must contain the following files: adapter_model.safetensors (LoRA adapter weights in SafeTensors format), adapter_config.json (configuration file containing parameters such as rank and alpha), and config.json (foundation model configuration). After you select the directory, the system automatically validates the format and integrity of these files.

Training parameter constraints

  • rank value: rank must be one of 8, 16, 32, or 64, and all LoRA layers of the same model must use the same rank value; otherwise the model cannot be imported.
  • Vocabulary must not be modified: models that added new tokens or modified the original vocabulary during training cannot be imported; the vocabulary must be fully consistent with that of the foundation model.
  • Chat template must not be modified: models whose chat_template was modified during training cannot be imported; it must be consistent with the foundation model's default configuration. chat_template is located in the chat_template field of config.json or tokenizer_config.json.
  • Vision models must freeze the VIT: vision language models must freeze the Vision Transformer part. If the LoRA adapter contains visual-related weight parameters (that is, the VIT is not frozen), the model cannot be imported.
Before importing, you can run the following script to check whether adapter_model.safetensors contains parameter keys starting with visual, to determine whether the VIT is frozen.
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)
How to interpret the result: if the script output contains parameter keys starting with visual (such as visual.encoder.layer.0...), the VIT part is not frozen and the model cannot be imported; if it contains only LoRA-related parameter keys such as lora_A and lora_B, the VIT is frozen and the model can be imported normally.

Pre-submission automatic validation

After you select the model directory on the import page, the system automatically calls the file validation interface to check the format and integrity of the model files in the directory. If validation fails, a red prompt appears under the directory field and submission is blocked; you must fix the files as prompted before submitting. A common failure cause is missing required files, corresponding to the error code AvailableModelFileNotFound.

Import a LoRA model

After completing the OSS authorization and preparing the model files, go to the Bailian console · My Models page, click the "Import Model" button in the upper-right corner to enter the creation page, and complete the import following these steps.
  1. On the "My Models" page, click the "Import Model" button in the upper-right corner to enter the import model creation page.
  2. Fill in the model information according to the table below. The foundation model must be the same as the base model used for LoRA training, the Bucket must have the bailian-datahub-access=read tag, and after the model directory is selected the system validates the files automatically.
  3. After confirming that the information is correct, click OK to submit. The system automatically validates the file format and integrity, and the import starts once validation passes; to abandon the import, click Cancel to return to the list page. After the import, you can view the status in Manage imported models.
The fields of the import model form are described as follows:

Field

Description

Constraints

Model

Enter the display name of the model.

Required, up to 50 characters

Foundation model

Select the base model used for LoRA training; it must match the training base.

Required, dropdown selection

Training Method

The available options depend on the selected foundation model; after you select a foundation model, the options are automatically rendered with the first one selected by default.

Required, dropdown selection

Import Source

Set to "Import from OSS", with no other options.

Read-only, selected by default

Bucket

Select the OSS Bucket where the model files are stored. Only Buckets that have the bailian-datahub-access=read tag and are supported in the current region are listed (China (Beijing): all regions in the Chinese mainland; Singapore: all regions in the Chinese mainland and the Singapore region).

Required, dropdown selection

Model Directory

Browse the selected Bucket and choose the subdirectory that contains the model checkpoint; selecting the Bucket root directory is not supported.

Required, tree selection

Model Encryption

Bailian automatically enables OSS server-side encryption (SSE-OSS) for exported model files, using fully OSS-managed keys with AES256 as the encryption algorithm.

Read-only, enforced by Bailian

If OSS authorization has not been completed, the OK button is unavailable; you must first complete OSS authorization before the first import before submitting. Once the import succeeds, the model can be deployed; for deployment operations, see Deployment and O&M. After import, model statuses include Creating (import in progress), Created (deployable), Creation failed (import failed), and Expired (source files changed).

Manage imported models

After the import is submitted, you are returned to the My Models list page, where you can view and manage all imported models. The list displays model name, model ID (with a copy button), foundation model, source, supported deployment method, status, creation time, and the Actions column; the top-right corner provides an Import Model entry and a refresh button.

Status and transitions

Model statuses include Creating, Created, Creation failed, and Expired. Creating means the import is in progress; Created means the import is complete and the model is ready for deployment; Creation failed means the import did not succeed; Expired means the OSS source model files changed after the model was created. The list automatically and silently refreshes every 3 seconds for models in the Creating status; this is normal behavior, not an API error. Next to the Creation failed status is a "Details" link; hover over it to view the failure error code (such as AvailableModelFileNotFound) and the corresponding oss://bucket/path, which helps locate the failed file. Hover over the Expired status to view a popup showing "Updates detected for the following files" and the list of changed source file names, indicating that you must re-import the model.

Actions column availability

  • Deploy: Clickable only in the Created status; clicking it navigates to the deployment creation page. For deployment operations, see Deployment and O&M; in other statuses, or when no deployment method is available, the button is unavailable.
  • Incremental Training: Models imported from OSS do not support incremental training, and the button is unavailable.
  • Delete: Models in the Creating status cannot be deleted; quantized models must be deleted on the model compression page.
After you click Delete in the Actions column and confirm, only the model record on the Bailian side is deleted; OSS source files are not affected. When deleting in other statuses, the deletion API is called to clean up the record.
The delete operation is irreversible: it only removes the model record on the Bailian side, and you must re-import the model to restore it; it does not delete the source files in OSS.
The search box at the top of the list can filter models by model name and supports clearing to reset. The Source column is rendered based on the import source: OSS imports display oss://bucket/path, and training jobs display the source job ID (if the job has been deleted, "Training job deleted" is displayed), along with a full-parameter, LoRA, or quantization label. For calling a deployed model via API, see Deploy models with APIs. All operations are performed on a single model at a time; batch deletion and batch deployment are not supported.

FAQ

This section summarizes common issues and solutions during the import process.
This error indicates that the model directory files failed validation (due to format or integrity issues) and cannot be resolved by simply re-uploading the files. Check that the selected directory contains complete and compliant adapter_model.safetensors, adapter_config.json, and config.json files, and confirm that constraints such as rank, vocabulary, and chat_template are all satisfied. After making corrections, re-select the directory and submit.
Expired means that after the model was created successfully, the source model files in OSS changed. This is normal detection behavior, not a fault. Hover over the Expired status to view the list of changed file names. You must re-import the model to make it available again.
This usually occurs because the primary account has not activated Object Storage Service (OSS). The primary account must go to the OSS management console and activate OSS following the on-screen instructions, then return to the Model Studio model import page and retry the authorization.
RAM user authorization fails because the RAM user lacks the permission to create a service-linked role; this is not a true failure. The Alibaba Cloud account must first create a custom permission policy in the RAM console (action ram:CreateServiceLinkedRole, for service datahub.sfm.aliyuncs.com) and grant it to the RAM user, then the RAM user clicks authorize again. For details on the OSS service-linked role, see OSS service-linked role.
This is an authorization or region requirement, not a fault. Under the new authorization method, buckets without the bailian-datahub-access=read tag cannot be selected in the dropdown. You must go to the OSS management console, add this tag to the target bucket, and return to the import page to select it again. In addition, the dropdown list only shows buckets supported in the current region: China (Beijing) shows buckets from all regions in the Chinese mainland, while Singapore shows buckets from all regions in the Chinese mainland plus the Singapore region.
No. When the list detects models in the Creating state, it silently refreshes every 3 seconds to fetch the latest status, and stops automatically when no models are in the Creating state. This is normal behavior.
For inference parameter alignment, see API deployment guide.
No. Deletion only removes the model record on the Model Studio side; you must re-import the model to restore it. The source files in OSS belong to you, and Model Studio only reads them through the bailian-datahub-access=read tag. Deleting a model does not modify any files in OSS.