Skip to content

feat(translators): add M2M100 HuggingFace translator (Nvidia CUDA / AMD ROCm)#1157

Open
zachelnet wants to merge 1 commit into
zyddnys:mainfrom
zachelnet:pr/feat-m2m100-hf
Open

feat(translators): add M2M100 HuggingFace translator (Nvidia CUDA / AMD ROCm)#1157
zachelnet wants to merge 1 commit into
zyddnys:mainfrom
zachelnet:pr/feat-m2m100-hf

Conversation

@zachelnet

@zachelnet zachelnet commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Adds two new offline translator variants that use the HuggingFace transformers
library directly instead of ctranslate2.

Key Model Backend
m2m100_hf facebook/m2m100_418M HuggingFace / PyTorch
m2m100_hf_big facebook/m2m100_1.2B HuggingFace / PyTorch

Motivation

The existing m2m100 and m2m100_big translators depend on ctranslate2, which
only supports Nvidia CUDA. Users with AMD GPUs (ROCm) have no working M2M100
option. These new variants run on any PyTorch-supported device (Nvidia CUDA,
AMD ROCm, CPU).

Changes

  • manga_translator/translators/m2m100_hf.py — new translator using
    AutoModelForSeq2SeqLM + AutoTokenizer directly (no pipeline-per-sentence)
  • manga_translator/config.py — add m2m100_hf / m2m100_hf_big to Translator enum
  • manga_translator/translators/__init__.py — register m2m100_hf / m2m100_hf_big
    in OFFLINE_TRANSLATORS
  • README.md — add entries to translator reference table and JSON schema enum

Notes

  • Auto language detection via langdetect on the full batch
  • Falls back to '' on unrecoverable errors (no blocking input())
  • _check_downloaded checks both model.safetensors and pytorch_model.bin

Co-authored-by: GitHub Copilot <github-copilot[bot]@users.noreply.github.com>

@zachelnet zachelnet force-pushed the pr/feat-m2m100-hf branch from f6998d5 to c599b86 Compare July 3, 2026 20:30
@zachelnet zachelnet marked this pull request as draft July 3, 2026 20:31
@zachelnet zachelnet marked this pull request as ready for review July 3, 2026 20:35
@zachelnet zachelnet force-pushed the pr/feat-m2m100-hf branch 3 times, most recently from 6b9ecc9 to 7d79718 Compare July 3, 2026 20:53
Adds two new offline translator variants using HuggingFace transformers
directly instead of ctranslate2, enabling AMD ROCm support.

New translator keys:
  m2m100_hf     — facebook/m2m100_418M
  m2m100_hf_big — facebook/m2m100_1.2B

Changes:
- manga_translator/translators/m2m100_hf.py (new)
- manga_translator/config.py: add m2m100_hf / m2m100_hf_big to Translator enum
- manga_translator/translators/__init__.py: register in OFFLINE_TRANSLATORS
- README.md: add entries to translator reference table and JSON schema enum

Implementation details:
- Uses AutoModelForSeq2SeqLM + AutoTokenizer directly (no pipeline-per-sentence)
- Model moved to device via .to(device) — works on Nvidia CUDA, AMD ROCm, CPU
- Auto language detection via langdetect on the full batch
- Falls back to '' on unrecoverable errors
- _check_downloaded checks both model.safetensors and pytorch_model.bin

Co-authored-by: GitHub Copilot <github-copilot[bot]@users.noreply.github.com>
@zachelnet zachelnet force-pushed the pr/feat-m2m100-hf branch from 7d79718 to c289bf1 Compare July 3, 2026 20:55
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.

1 participant