Skip to content

Commit effbaa3

Browse files
committed
review feedback
Signed-off-by: Huamin Chen <[email protected]>
1 parent 500e541 commit effbaa3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/training/training_lora/classifier_model_fine_tuning_lora/ft_qwen3_generative_lora.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@
7171
)
7272

7373
# Import common LoRA utilities
74-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
74+
# Note: Using sys.path for standalone script compatibility.
75+
# For package installations, use: from semantic_router.training.common_lora_utils import ...
76+
_parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
77+
if _parent_dir not in sys.path:
78+
sys.path.insert(0, _parent_dir)
79+
7580
from common_lora_utils import (
7681
clear_gpu_memory,
7782
get_device_info,
@@ -435,8 +440,9 @@ def main(
435440
num_train_epochs=num_epochs,
436441
per_device_train_batch_size=batch_size, # Configurable via parameter
437442
per_device_eval_batch_size=batch_size,
438-
gradient_accumulation_steps=16
439-
// batch_size, # Maintain effective batch size of 16
443+
gradient_accumulation_steps=max(
444+
1, 16 // batch_size
445+
), # Maintain effective batch size of 16, minimum 1
440446
learning_rate=learning_rate,
441447
weight_decay=0.01,
442448
logging_dir=f"{output_dir}/logs",
@@ -589,7 +595,7 @@ def demo_inference(model_path: str, model_name: str = "Qwen/Qwen3-0.6B"):
589595
use_fp16 = (
590596
compute_capability[0] >= 7
591597
) # Volta and newer support efficient FP16
592-
except:
598+
except Exception:
593599
use_fp16 = False
594600

595601
base_model = AutoModelForCausalLM.from_pretrained(

0 commit comments

Comments
 (0)