huggingface / huggingface/diffusers

Question about the `# Copied from` system

Aperta
#12,650 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stale
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

Hi team! 👋

While working on improving docstrings and type hints across scheduler files (issue #9567), I've noticed the # Copied from pattern used extensively throughout the codebase.

Examples:

  • Functions like betas_for_alpha_bar are duplicated across multiple schedulers
  • Output classes like DDPMSchedulerOutput are copied with name replacements (e.g., DDPM->EulerDiscrete)

My question: What's the rationale behind this duplication system instead of:

  1. Using a shared utils.py or common.py file for common functions
  2. Using class inheritance for similar Output classes

I understand there might be good architectural reasons (module independence, API stability, avoiding circular dependencies, etc.), but this isn't documented anywhere that I could find.

Suggested action: Regardless of the answer, I think we should either:

  • Option A: Refactor to use inheritance/shared utilities (if the current system is legacy)
  • Option B: Document this design decision in:
      - A CONTRIBUTING.md or architecture doc
      - Comments in the utils/check_copies.py script itself
      - Another README in the diffusers directory

This would help future contributors (like me! 😅) understand why this pattern exists and how to work with it properly when improving documentation. What do you think?

Thanks for maintaining such a great library! 🚀

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo gli esempi di scheduler menzionati nell’issue e utils/check_copies.py, quindi esamina la discussione per individuare eventuali decisioni su duplicazione, utilità condivise o ereditarietà. L’attività è completata quando la motivazione e il workflow per i contributori sono documentati in una posizione concordata, come CONTRIBUTING.md, un documento di architettura o commenti nello script di controllo delle copie.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
developer-experience, documentation
Tipo di issue
Documentazione
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.