Skip to content

Refactor display device name / Fix tokenize_data from OpusMtEnESTransformer#353

Merged
cristian-tamblay merged 12 commits into
developfrom
refactor/device-name
Nov 7, 2025
Merged

Refactor display device name / Fix tokenize_data from OpusMtEnESTransformer#353
cristian-tamblay merged 12 commits into
developfrom
refactor/device-name

Conversation

@Irozuku
Copy link
Copy Markdown
Collaborator

@Irozuku Irozuku commented Oct 24, 2025

This pull request refactors how device selection (CPU/GPU) is handled across several Hugging Face model classes in the backend. The main improvement is centralizing device enumeration and mapping logic into a new utility module, which simplifies device handling and ensures consistency. Additionally, the device selection in model initialization is now more robust, and the translation model's data tokenization logic is improved for clarity and correctness.

Device handling refactor:

  • Introduced a new utility module utils.py that centralizes device enumeration, placeholder, and mapping logic (DEVICE_ENUM, DEVICE_PLACEHOLDER, NAME_TO_DEVICE) for CPU and available GPUs, using human-readable names for GPUs.
  • Updated stable_diffusion_v1_depth_controlnet.py, stable_diffusion_v2_model.py, and stable_diffusion_v3_model.py to import device constants and mappings from the new utility module, removing redundant device code from each file. [1] [2] [3] [4]

Model initialization improvements:

  • Modified model initializers to use the canonical device string from NAME_TO_DEVICE mapping, ensuring correct device assignment regardless of user input format. [1] [2] [3] [4]
  • Adjusted device serialization and deserialization in model loading to use human-readable device names and proper mapping back to device strings.
image

Translation model tokenization fix:

  • Refactored the tokenize_data method in OpusMtEnESTransformer to handle cases where target data (y) is missing more cleanly, and improved the logic for constructing tokenized samples.

Documentation update:

  • Updated the device selection field description in OpusMtEnESTransformerSchema to clarify that selecting GPU will use all available GPUs.
image

@Irozuku Irozuku marked this pull request as ready for review October 24, 2025 03:31
@Irozuku Irozuku marked this pull request as draft October 24, 2025 04:48
@Irozuku Irozuku marked this pull request as ready for review October 24, 2025 13:40
Comment thread DashAI/back/models/hugging_face/opus_mt_en_es_transformer.py Outdated
@Irozuku Irozuku marked this pull request as draft October 28, 2025 16:52
@Irozuku Irozuku marked this pull request as ready for review November 5, 2025 15:33
@Irozuku Irozuku force-pushed the refactor/device-name branch from dd9f46f to 804c2d6 Compare November 5, 2025 21:01
@cristian-tamblay cristian-tamblay merged commit 5b40996 into develop Nov 7, 2025
18 checks passed
@cristian-tamblay cristian-tamblay deleted the refactor/device-name branch November 7, 2025 15:41
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.

2 participants