Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed syntax warnings #1522

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

KareemMusleh
Copy link
Contributor

@KareemMusleh KareemMusleh commented Jan 8, 2025

I kept getting SyntaxWarnings when importing unsloth from the terminal.

flake8 | grep escape

@KareemMusleh KareemMusleh changed the title fixed most of syntax warnings fixed most syntax warnings Jan 8, 2025
@KareemMusleh KareemMusleh changed the title fixed most syntax warnings fixed syntax warnings Jan 9, 2025
@danielhanchen
Copy link
Contributor

Oh thanks for this - let me confirm all issues in a new runtime!

@steve2972
Copy link

I also keep getting SyntaxWarnings. Hope this PR fixes this!
Weird thing is, I only get these syntax warnings when using cold builds. Every subsequent run doesn't seem to have this problem.

Unsloth: Patching Xformers to fix some performance issues.
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/llama.py:1599: SyntaxWarning: invalid escape sequence '\ '
  f"   \\\   /|    GPU: {gpu_stats.name}. Max memory: {max_memory} GB. Platform: {platform_system}.\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/llama.py:1600: SyntaxWarning: invalid escape sequence '\_'
  f"O^O/ \_/ \\    Torch: {torch.__version__}. CUDA: {gpu_stats.major}.{gpu_stats.minor}. CUDA Toolkit: {torch.version.cuda}. Triton: {triton_version}\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/llama.py:1601: SyntaxWarning: invalid escape sequence '\ '
  f"\        /    Bfloat16 = {str(SUPPORTS_BFLOAT16).upper()}. FA [Xformers = {xformers_version}. FA2 = {HAS_FLASH_ATTENTION}]\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/llama.py:1752: SyntaxWarning: invalid escape sequence '\.'
  start = re.search('logger\.info\([\"\'].+?Running training', inner_training_loop).span(0)[0]
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/llama.py:1755: SyntaxWarning: invalid escape sequence '\s'
  spaces = re.search('\n([\s\t]{1,})', original_debug).group(0)[1:]
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/llama.py:1756: SyntaxWarning: invalid escape sequence '\s'
  front_spaces = re.match('([\s\t]{1,})', inner_training_loop).group(0)
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/_utils.py:584: SyntaxWarning: invalid escape sequence '\.'
  source = re.sub("([^\.])nn\.", r"\1torch.nn.", source)
... {Multiple other SyntaxWarnings}
🦥 Unsloth Zoo will now patch everything to make training faster!
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/save.py:481: SyntaxWarning: invalid escape sequence '\s'
  gb_found = re.match("([0-9]{1,})[\s]{0,}GB", max_shard_size, flags = re.IGNORECASE)
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/save.py:482: SyntaxWarning: invalid escape sequence '\s'
  mb_found = re.match("([0-9]{1,})[\s]{0,}MB", max_shard_size, flags = re.IGNORECASE)
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/save.py:1011: SyntaxWarning: invalid escape sequence '\ '
  f"   \\\   /|    [0] Installing llama.cpp might take 3 minutes.\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/save.py:1012: SyntaxWarning: invalid escape sequence '\_'
  f"O^O/ \_/ \\    [1] Converting HF to GGUF 16bits might take 3 minutes.\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/save.py:1013: SyntaxWarning: invalid escape sequence '\ '
  f"\        /    [2] Converting GGUF 16bits to {quantization_method} might take 10 minutes each.\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/vision.py:101: SyntaxWarning: invalid escape sequence '\ '
  f"   \\\   /|    GPU: {gpu_stats.name}. Max memory: {max_memory} GB. Platform: {platform_system}.\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/vision.py:102: SyntaxWarning: invalid escape sequence '\_'
  f"O^O/ \_/ \\    Torch: {torch.__version__}. CUDA: {gpu_stats.major}.{gpu_stats.minor}. CUDA Toolkit: {torch.version.cuda}. Triton: {triton_version}\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/models/vision.py:103: SyntaxWarning: invalid escape sequence '\ '
  f"\        /    Bfloat16 = {str(SUPPORTS_BFLOAT16).upper()}. FA [Xformers = {xformers_version}. FA2 = {HAS_FLASH_ATTENTION}]\n"\
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/chat_templates.py:1683: SyntaxWarning: invalid escape sequence '\{'
  try: found = next(re.finditer("(" + try_find + ").+?\{INPUT\}", chat_template, flags = re.DOTALL | re.MULTILINE))
/home/user/.../.venv/lib/python3.12/site-packages/unsloth/chat_templates.py:2124: SyntaxWarning: invalid escape sequence '\d'
  gguf_tokenized = re.findall("([\d]{1,}) \-\> \'([^\']{1,})\'", gguf_tokens, flags = re.MULTILINE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants