AIR Format

Architecture-Agnostic Intermediate Representation (AIR) Format

This module handles the conversion of model-specific LoRA weights to a portable format that can be transferred across different architectures.

class ual_adapter.core.air.AIRMetadata(version: str = '1.0.0', source_model: str = '', source_architecture: str = '', source_dimensions: Dict[str, int] = None, adapter_rank: int = 16, adapter_alpha: float = 16.0, training_config: Dict[str, Any] = None, domain: str = '', description: str = '', created_at: str = '')[source]

Bases: object

Metadata for AIR format adapters.

version: str = '1.0.0'
source_model: str = ''
source_architecture: str = ''
source_dimensions: Dict[str, int] = None
adapter_rank: int = 16
adapter_alpha: float = 16.0
training_config: Dict[str, Any] = None
domain: str = ''
description: str = ''
created_at: str = ''
__init__(version: str = '1.0.0', source_model: str = '', source_architecture: str = '', source_dimensions: Dict[str, int] = None, adapter_rank: int = 16, adapter_alpha: float = 16.0, training_config: Dict[str, Any] = None, domain: str = '', description: str = '', created_at: str = '') None
class ual_adapter.core.air.AIRFormat[source]

Bases: object

Handles conversion between model-specific LoRA weights and portable AIR format.

The AIR format uses semantic role-based naming instead of model-specific parameter names, enabling cross-architecture transfer.

ATTENTION_ROLES = {'attention_key': ['k_proj', 'key', 'k_lin', 'Wqkv.k'], 'attention_output': ['o_proj', 'out_proj', 'dense'], 'attention_query': ['q_proj', 'query', 'q_lin', 'Wqkv.q', 'c_attn'], 'attention_value': ['v_proj', 'value', 'v_lin', 'Wqkv.v']}
MLP_ROLES = {'mlp_down': ['down_proj', 'w2', 'c_proj', 'output.dense', 'mlp.fc2'], 'mlp_gate': ['gate_proj', 'w3', 'gate', 'mlp.gate'], 'mlp_up': ['up_proj', 'w1', 'c_fc', 'intermediate.dense', 'mlp.fc1']}
__init__()[source]

Initialize AIR format handler.

export_to_air(lora_weights: Dict[str, Tensor], metadata: AIRMetadata, output_path: str) None[source]

Export LoRA weights to AIR format.

Parameters:
  • lora_weights – Dictionary of LoRA weights with model-specific names

  • metadata – Metadata about the adapter

  • output_path – Path to save the AIR file

import_from_air(air_path: str, target_model_info: Dict[str, Any]) Tuple[Dict[str, Tensor], AIRMetadata][source]

Import AIR format adapter for a target model.

Parameters:
  • air_path – Path to the AIR format files

  • target_model_info – Information about the target model architecture

Returns:

Tuple of (converted weights dict, metadata)

The AIR (Architecture-Agnostic Intermediate Representation) format enables portable LoRA adapters.

AIRFormat Class

class ual_adapter.core.air.AIRFormat[source]

Handles conversion between model-specific LoRA weights and portable AIR format.

The AIR format uses semantic role-based naming instead of model-specific parameter names, enabling cross-architecture transfer.

ATTENTION_ROLES = {'attention_key': ['k_proj', 'key', 'k_lin', 'Wqkv.k'], 'attention_output': ['o_proj', 'out_proj', 'dense'], 'attention_query': ['q_proj', 'query', 'q_lin', 'Wqkv.q', 'c_attn'], 'attention_value': ['v_proj', 'value', 'v_lin', 'Wqkv.v']}
MLP_ROLES = {'mlp_down': ['down_proj', 'w2', 'c_proj', 'output.dense', 'mlp.fc2'], 'mlp_gate': ['gate_proj', 'w3', 'gate', 'mlp.gate'], 'mlp_up': ['up_proj', 'w1', 'c_fc', 'intermediate.dense', 'mlp.fc1']}
__init__()[source]

Initialize AIR format handler.

export_to_air(lora_weights: Dict[str, Tensor], metadata: AIRMetadata, output_path: str) None[source]

Export LoRA weights to AIR format.

Parameters:
  • lora_weights – Dictionary of LoRA weights with model-specific names

  • metadata – Metadata about the adapter

  • output_path – Path to save the AIR file

import_from_air(air_path: str, target_model_info: Dict[str, Any]) Tuple[Dict[str, Tensor], AIRMetadata][source]

Import AIR format adapter for a target model.

Parameters:
  • air_path – Path to the AIR format files

  • target_model_info – Information about the target model architecture

Returns:

Tuple of (converted weights dict, metadata)