Git Product home page Git Product logo

Comments (10)

stellaraccident avatar stellaraccident commented on September 24, 2024 1

FYI - in the above linked issues, the transformers devs fixed their bug where they unconditionally import jax. While this fixes the worst of it, I still think that under the principle of paying for what you use, the onnx exporter should definitely not be importing transformers as part of the main import of torch dynamo. It would be best to have no cross dependencies like that unless if the things in question are actually used (and only then if absolutely required).

from pytorch.

stellaraccident avatar stellaraccident commented on September 24, 2024

Related: google/jax#18989 (comment)

from pytorch.

stellaraccident avatar stellaraccident commented on September 24, 2024

If we really need to do package installed probing, we should be using find_spec. Some notes here: https://stackoverflow.com/questions/1051254/check-if-python-package-is-installed

Then for something like the onnx patcher, if that really needs to happen, I think it needs to be done only when using the onnx exporter and can probably just check sys.modules at that point to see if transformers has been loaded at runtime.

from pytorch.

stellaraccident avatar stellaraccident commented on September 24, 2024

Some commentary at the point that is doing the fork: https://github.com/pytorch/pytorch/blob/main/torch/_inductor/codecache.py#L2780

I think this might be good to revisit how this is done (I would have expected that such backend compiler workers could be spawned and should have been very light-weight things that did not themselves pull in the world). However, the expectation set on what the state of the world is on doing this fork isn't quite right: the intention is that this get done very early in the process lifetime, but the sequencing is such that it is happening quite late (in this case, even after we've probed external deps, causing third party backends to start a bunch of threads, etc). I expect this mechanism needs a rethink.

from pytorch.

ezyang avatar ezyang commented on September 24, 2024

see also #121197 for more discussion on why the fork subprocess thing is terrible, and also why it is not so easy to get rid of

from pytorch.

stellaraccident avatar stellaraccident commented on September 24, 2024

see also #121197 for more discussion on why the fork subprocess thing is terrible, and also why it is not so easy to get rid of

I believe it. Been stung by this basic issue many times. It's super easy to start using multiprocessing like that and it tends to often end badly and then is hard to back out without triggering other fallout.

from pytorch.

atalman avatar atalman commented on September 24, 2024

as per conversation with @jansel adding it to 2.3.1 milestone

from pytorch.

ezyang avatar ezyang commented on September 24, 2024

Follow up: when you call onnx exporter, it still imports. Is this desirable?

from pytorch.

huydhn avatar huydhn commented on September 24, 2024

This is to confirm that transformers hasn't been loaded in 2.3.1. The list of loaded module includes:

abc
argparse
array
ast
asyncio
asyncio.base_events
asyncio.base_futures
asyncio.base_subprocess
asyncio.base_tasks
asyncio.constants
asyncio.coroutines
asyncio.events
asyncio.exceptions
asyncio.format_helpers
asyncio.futures
asyncio.locks
asyncio.log
asyncio.mixins
asyncio.protocols
asyncio.queues
asyncio.runners
asyncio.selector_events
asyncio.sslproto
asyncio.staggered
asyncio.streams
asyncio.subprocess
asyncio.taskgroups
asyncio.tasks
asyncio.threads
asyncio.timeouts
asyncio.transports
asyncio.trsock
asyncio.unix_events
atexit
base64
bdb
binascii
bisect
builtins
bz2
cProfile
calendar
cmath
cmd
code
codecs
codeop
collections
collections.abc
collections.abc
colorsys
concurrent
concurrent.futures
concurrent.futures._base
contextlib
contextvars
copy
copyreg
ctypes
ctypes._endian
cython_runtime
dataclasses
datetime
decimal
decimal
difflib
dill
dill.__info__
dill._dill
dill._shims
dill.detect
dill.logger
dill.objtypes
dill.pointers
dill.session
dill.settings
dill.source
dill.temp
dis
doctest
email
email._encoded_words
email._parseaddr
email._policybase
email.base64mime
email.charset
email.encoders
email.errors
email.feedparser
email.header
email.iterators
email.message
email.parser
email.quoprimime
email.utils
encodings
encodings.aliases
encodings.utf_8
enum
errno
fcntl
fnmatch
fractions
functools
gc
genericpath
getpass
gettext
glob
google
grp
gzip
hashlib
heapq
hmac
http
http.client
importlib
importlib._abc
importlib._bootstrap
importlib._bootstrap
importlib._bootstrap_external
importlib._bootstrap_external
importlib.machinery
importlib.util
inspect
io
io
ipaddress
itertools
json
json.decoder
json.encoder
json.scanner
keyword
linecache
locale
logging
lzma
marshal
math
mpmath
mpmath.calculus
mpmath.calculus.approximation
mpmath.calculus.calculus
mpmath.calculus.differentiation
mpmath.calculus.extrapolation
mpmath.calculus.inverselaplace
mpmath.calculus.odes
mpmath.calculus.optimization
mpmath.calculus.polynomials
mpmath.calculus.quadrature
mpmath.ctx_base
mpmath.ctx_fp
mpmath.ctx_iv
mpmath.ctx_mp
mpmath.ctx_mp_python
mpmath.function_docs
mpmath.functions
mpmath.functions.bessel
mpmath.functions.elliptic
mpmath.functions.expintegrals
mpmath.functions.factorials
mpmath.functions.functions
mpmath.functions.hypergeometric
mpmath.functions.orthogonal
mpmath.functions.qfunctions
mpmath.functions.rszeta
mpmath.functions.signals
mpmath.functions.theta
mpmath.functions.zeta
mpmath.functions.zetazeros
mpmath.identification
mpmath.libmp
mpmath.libmp.backend
mpmath.libmp.gammazeta
mpmath.libmp.libelefun
mpmath.libmp.libhyper
mpmath.libmp.libintmath
mpmath.libmp.libmpc
mpmath.libmp.libmpf
mpmath.libmp.libmpi
mpmath.math2
mpmath.matrices
mpmath.matrices.calculus
mpmath.matrices.eigen
mpmath.matrices.eigen_symmetric
mpmath.matrices.linalg
mpmath.matrices.matrices
mpmath.rational
mpmath.usertools
mpmath.visualization
multiprocessing
multiprocessing.connection
multiprocessing.context
multiprocessing.process
multiprocessing.reduction
multiprocessing.resource_sharer
multiprocessing.util
ntpath
numbers
numpy
numpy.__config__
numpy._distributor_init
numpy._globals
numpy._pytesttester
numpy._typing
numpy._typing._array_like
numpy._typing._char_codes
numpy._typing._dtype_like
numpy._typing._nbit
numpy._typing._nested_sequence
numpy._typing._scalars
numpy._typing._shape
numpy._utils
numpy._utils._convertions
numpy._utils._inspect
numpy.compat
numpy.compat.py3k
numpy.core
numpy.core._add_newdocs
numpy.core._add_newdocs_scalars
numpy.core._asarray
numpy.core._dtype
numpy.core._dtype_ctypes
numpy.core._exceptions
numpy.core._internal
numpy.core._machar
numpy.core._methods
numpy.core._multiarray_tests
numpy.core._multiarray_umath
numpy.core._string_helpers
numpy.core._type_aliases
numpy.core._ufunc_config
numpy.core.arrayprint
numpy.core.defchararray
numpy.core.einsumfunc
numpy.core.fromnumeric
numpy.core.function_base
numpy.core.getlimits
numpy.core.memmap
numpy.core.multiarray
numpy.core.numeric
numpy.core.numerictypes
numpy.core.overrides
numpy.core.records
numpy.core.shape_base
numpy.core.umath
numpy.ctypeslib
numpy.dtypes
numpy.exceptions
numpy.fft
numpy.fft._pocketfft
numpy.fft._pocketfft_internal
numpy.fft.helper
numpy.lib
numpy.lib._datasource
numpy.lib._iotools
numpy.lib._version
numpy.lib.arraypad
numpy.lib.arraysetops
numpy.lib.arrayterator
numpy.lib.format
numpy.lib.function_base
numpy.lib.histograms
numpy.lib.index_tricks
numpy.lib.mixins
numpy.lib.nanfunctions
numpy.lib.npyio
numpy.lib.polynomial
numpy.lib.scimath
numpy.lib.shape_base
numpy.lib.stride_tricks
numpy.lib.twodim_base
numpy.lib.type_check
numpy.lib.ufunclike
numpy.lib.utils
numpy.linalg
numpy.linalg._umath_linalg
numpy.linalg.linalg
numpy.ma
numpy.ma.core
numpy.ma.extras
numpy.matrixlib
numpy.matrixlib.defmatrix
numpy.polynomial
numpy.polynomial._polybase
numpy.polynomial.chebyshev
numpy.polynomial.hermite
numpy.polynomial.hermite_e
numpy.polynomial.laguerre
numpy.polynomial.legendre
numpy.polynomial.polynomial
numpy.polynomial.polyutils
numpy.random
numpy.random._bounded_integers
numpy.random._common
numpy.random._generator
numpy.random._mt19937
numpy.random._pcg64
numpy.random._philox
numpy.random._pickle
numpy.random._sfc64
numpy.random.bit_generator
numpy.random.mtrand
numpy.version
opcode
operator
optree
optree._C
optree.integration
optree.ops
optree.registry
optree.typing
optree.utils
optree.version
os
pathlib
pdb
pickle
pickletools
pkgutil
platform
posix
posixpath
posixpath
pprint
profile
pstats
pwd
queue
quopri
random
re
re._casefix
re._compiler
re._constants
re._parser
reprlib
ruamel
secrets
select
selectors
shutil
signal
site
socket
ssl
stat
string
struct
subprocess
sympy
sympy.algebras
sympy.algebras.quaternion
sympy.assumptions
sympy.assumptions.ask
sympy.assumptions.ask_generated
sympy.assumptions.assume
sympy.assumptions.cnf
sympy.assumptions.refine
sympy.assumptions.relation
sympy.assumptions.relation.binrel
sympy.calculus
sympy.calculus.accumulationbounds
sympy.calculus.euler
sympy.calculus.finite_diff
sympy.calculus.singularities
sympy.calculus.util
sympy.concrete
sympy.concrete.expr_with_intlimits
sympy.concrete.expr_with_limits
sympy.concrete.gosper
sympy.concrete.products
sympy.concrete.summations
sympy.core
sympy.core._print_helpers
sympy.core.add
sympy.core.alphabets
sympy.core.assumptions
sympy.core.basic
sympy.core.cache
sympy.core.containers
sympy.core.core
sympy.core.coreerrors
sympy.core.decorators
sympy.core.evalf
sympy.core.expr
sympy.core.exprtools
sympy.core.facts
sympy.core.function
sympy.core.kind
sympy.core.logic
sympy.core.mod
sympy.core.mul
sympy.core.multidimensional
sympy.core.numbers
sympy.core.operations
sympy.core.parameters
sympy.core.power
sympy.core.random
sympy.core.relational
sympy.core.rules
sympy.core.singleton
sympy.core.sorting
sympy.core.symbol
sympy.core.sympify
sympy.core.traversal
sympy.discrete
sympy.discrete.convolutions
sympy.discrete.transforms
sympy.external
sympy.external.gmpy
sympy.external.importtools
sympy.external.pythonmpq
sympy.functions
sympy.functions.combinatorial
sympy.functions.combinatorial.factorials
sympy.functions.combinatorial.numbers
sympy.functions.elementary
sympy.functions.elementary.complexes
sympy.functions.elementary.exponential
sympy.functions.elementary.hyperbolic
sympy.functions.elementary.integers
sympy.functions.elementary.miscellaneous
sympy.functions.elementary.piecewise
sympy.functions.elementary.trigonometric
sympy.functions.special
sympy.functions.special.bessel
sympy.functions.special.beta_functions
sympy.functions.special.bsplines
sympy.functions.special.delta_functions
sympy.functions.special.elliptic_integrals
sympy.functions.special.error_functions
sympy.functions.special.gamma_functions
sympy.functions.special.hyper
sympy.functions.special.mathieu_functions
sympy.functions.special.polynomials
sympy.functions.special.singularity_functions
sympy.functions.special.spherical_harmonics
sympy.functions.special.tensor_functions
sympy.functions.special.zeta_functions
sympy.geometry
sympy.geometry.curve
sympy.geometry.ellipse
sympy.geometry.entity
sympy.geometry.exceptions
sympy.geometry.line
sympy.geometry.parabola
sympy.geometry.plane
sympy.geometry.point
sympy.geometry.polygon
sympy.geometry.util
sympy.integrals
sympy.integrals.deltafunctions
sympy.integrals.integrals
sympy.integrals.meijerint
sympy.integrals.rationaltools
sympy.integrals.singularityfunctions
sympy.integrals.transforms
sympy.integrals.trigonometry
sympy.interactive
sympy.interactive.printing
sympy.interactive.session
sympy.interactive.traversal
sympy.logic
sympy.logic.boolalg
sympy.logic.inference
sympy.matrices
sympy.matrices.common
sympy.matrices.decompositions
sympy.matrices.dense
sympy.matrices.determinant
sympy.matrices.eigen
sympy.matrices.expressions
sympy.matrices.expressions.adjoint
sympy.matrices.expressions.blockmatrix
sympy.matrices.expressions.companion
sympy.matrices.expressions.determinant
sympy.matrices.expressions.diagonal
sympy.matrices.expressions.dotproduct
sympy.matrices.expressions.funcmatrix
sympy.matrices.expressions.hadamard
sympy.matrices.expressions.inverse
sympy.matrices.expressions.kronecker
sympy.matrices.expressions.matadd
sympy.matrices.expressions.matexpr
sympy.matrices.expressions.matmul
sympy.matrices.expressions.matpow
sympy.matrices.expressions.permutation
sympy.matrices.expressions.sets
sympy.matrices.expressions.slice
sympy.matrices.expressions.special
sympy.matrices.expressions.trace
sympy.matrices.expressions.transpose
sympy.matrices.graph
sympy.matrices.immutable
sympy.matrices.inverse
sympy.matrices.matrices
sympy.matrices.reductions
sympy.matrices.repmatrix
sympy.matrices.solvers
sympy.matrices.sparse
sympy.matrices.sparsetools
sympy.matrices.subspaces
sympy.matrices.utilities
sympy.multipledispatch
sympy.multipledispatch.conflict
sympy.multipledispatch.core
sympy.multipledispatch.dispatcher
sympy.multipledispatch.utils
sympy.ntheory
sympy.ntheory.continued_fraction
sympy.ntheory.digits
sympy.ntheory.ecm
sympy.ntheory.egyptian_fraction
sympy.ntheory.factor_
sympy.ntheory.generate
sympy.ntheory.modular
sympy.ntheory.multinomial
sympy.ntheory.partitions_
sympy.ntheory.primetest
sympy.ntheory.qs
sympy.ntheory.residue_ntheory
sympy.parsing
sympy.parsing.sympy_parser
sympy.plotting
sympy.plotting.experimental_lambdify
sympy.plotting.intervalmath
sympy.plotting.intervalmath.interval_arithmetic
sympy.plotting.intervalmath.interval_membership
sympy.plotting.intervalmath.lib_interval
sympy.plotting.plot
sympy.plotting.plot_implicit
sympy.plotting.pygletplot
sympy.plotting.textplot
sympy.polys
sympy.polys.agca
sympy.polys.agca.extensions
sympy.polys.agca.homomorphisms
sympy.polys.agca.ideals
sympy.polys.agca.modules
sympy.polys.compatibility
sympy.polys.constructor
sympy.polys.densearith
sympy.polys.densebasic
sympy.polys.densetools
sympy.polys.domainmatrix
sympy.polys.domains
sympy.polys.domains.algebraicfield
sympy.polys.domains.characteristiczero
sympy.polys.domains.complexfield
sympy.polys.domains.compositedomain
sympy.polys.domains.domain
sympy.polys.domains.domainelement
sympy.polys.domains.expressiondomain
sympy.polys.domains.expressionrawdomain
sympy.polys.domains.field
sympy.polys.domains.finitefield
sympy.polys.domains.fractionfield
sympy.polys.domains.gaussiandomains
sympy.polys.domains.gmpyfinitefield
sympy.polys.domains.gmpyintegerring
sympy.polys.domains.gmpyrationalfield
sympy.polys.domains.groundtypes
sympy.polys.domains.integerring
sympy.polys.domains.modularinteger
sympy.polys.domains.mpelements
sympy.polys.domains.polynomialring
sympy.polys.domains.pythonfinitefield
sympy.polys.domains.pythonintegerring
sympy.polys.domains.pythonrational
sympy.polys.domains.pythonrationalfield
sympy.polys.domains.rationalfield
sympy.polys.domains.realfield
sympy.polys.domains.ring
sympy.polys.domains.simpledomain
sympy.polys.euclidtools
sympy.polys.factortools
sympy.polys.fglmtools
sympy.polys.fields
sympy.polys.galoistools
sympy.polys.groebnertools
sympy.polys.heuristicgcd
sympy.polys.matrices
sympy.polys.matrices.ddm
sympy.polys.matrices.dense
sympy.polys.matrices.domainmatrix
sympy.polys.matrices.domainscalar
sympy.polys.matrices.eigen
sympy.polys.matrices.exceptions
sympy.polys.matrices.linsolve
sympy.polys.matrices.normalforms
sympy.polys.matrices.sdm
sympy.polys.monomials
sympy.polys.numberfields
sympy.polys.numberfields.basis
sympy.polys.numberfields.exceptions
sympy.polys.numberfields.minpoly
sympy.polys.numberfields.modules
sympy.polys.numberfields.primes
sympy.polys.numberfields.subfield
sympy.polys.numberfields.utilities
sympy.polys.orderings
sympy.polys.orthopolys
sympy.polys.partfrac
sympy.polys.polyclasses
sympy.polys.polyconfig
sympy.polys.polyerrors
sympy.polys.polyfuncs
sympy.polys.polyoptions
sympy.polys.polyquinticconst
sympy.polys.polyroots
sympy.polys.polytools
sympy.polys.polyutils
sympy.polys.rationaltools
sympy.polys.ring_series
sympy.polys.rings
sympy.polys.rootisolation
sympy.polys.rootoftools
sympy.polys.solvers
sympy.polys.specialpolys
sympy.polys.sqfreetools
sympy.printing
sympy.printing.codeprinter
sympy.printing.conventions
sympy.printing.defaults
sympy.printing.dot
sympy.printing.glsl
sympy.printing.gtk
sympy.printing.jscode
sympy.printing.julia
sympy.printing.lambdarepr
sympy.printing.latex
sympy.printing.maple
sympy.printing.mathematica
sympy.printing.mathml
sympy.printing.numpy
sympy.printing.octave
sympy.printing.precedence
sympy.printing.pretty
sympy.printing.pretty.pretty
sympy.printing.pretty.pretty_symbology
sympy.printing.pretty.stringpict
sympy.printing.preview
sympy.printing.printer
sympy.printing.pycode
sympy.printing.python
sympy.printing.rcode
sympy.printing.repr
sympy.printing.rust
sympy.printing.str
sympy.printing.tableform
sympy.printing.tree
sympy.release
sympy.series
sympy.series.approximants
sympy.series.formal
sympy.series.fourier
sympy.series.gruntz
sympy.series.limits
sympy.series.limitseq
sympy.series.order
sympy.series.residues
sympy.series.sequences
sympy.series.series
sympy.series.series_class
sympy.sets
sympy.sets.conditionset
sympy.sets.contains
sympy.sets.fancysets
sympy.sets.handlers
sympy.sets.handlers.comparison
sympy.sets.handlers.intersection
sympy.sets.handlers.union
sympy.sets.ordinals
sympy.sets.powerset
sympy.sets.sets
sympy.simplify
sympy.simplify.combsimp
sympy.simplify.cse_main
sympy.simplify.cse_opts
sympy.simplify.epathtools
sympy.simplify.fu
sympy.simplify.gammasimp
sympy.simplify.hyperexpand
sympy.simplify.powsimp
sympy.simplify.radsimp
sympy.simplify.ratsimp
sympy.simplify.simplify
sympy.simplify.sqrtdenest
sympy.simplify.trigsimp
sympy.solvers
sympy.solvers.bivariate
sympy.solvers.decompogen
sympy.solvers.deutils
sympy.solvers.diophantine
sympy.solvers.diophantine.diophantine
sympy.solvers.inequalities
sympy.solvers.ode
sympy.solvers.ode.hypergeometric
sympy.solvers.ode.lie_group
sympy.solvers.ode.nonhomogeneous
sympy.solvers.ode.ode
sympy.solvers.ode.riccati
sympy.solvers.ode.single
sympy.solvers.ode.subscheck
sympy.solvers.ode.systems
sympy.solvers.pde
sympy.solvers.polysys
sympy.solvers.recurr
sympy.solvers.solvers
sympy.solvers.solveset
sympy.strategies
sympy.strategies.branch
sympy.strategies.branch.core
sympy.strategies.branch.tools
sympy.strategies.branch.traverse
sympy.strategies.core
sympy.strategies.rl
sympy.strategies.tools
sympy.strategies.traverse
sympy.strategies.tree
sympy.strategies.util
sympy.tensor
sympy.tensor.array
sympy.tensor.array.array_comprehension
sympy.tensor.array.arrayop
sympy.tensor.array.dense_ndim_array
sympy.tensor.array.mutable_ndim_array
sympy.tensor.array.ndim_array
sympy.tensor.array.sparse_ndim_array
sympy.tensor.functions
sympy.tensor.index_methods
sympy.tensor.indexed
sympy.testing
sympy.testing.runtests
sympy.utilities
sympy.utilities.decorator
sympy.utilities.enumerative
sympy.utilities.exceptions
sympy.utilities.iterables
sympy.utilities.lambdify
sympy.utilities.magic
sympy.utilities.mathml
sympy.utilities.memoization
sympy.utilities.misc
sympy.utilities.pkgdata
sympy.utilities.source
sympy.utilities.timeutils
sys
tarfile
tempfile
termios
textwrap
threading
time
timeit
token
tokenize
tqdm
tqdm._dist_ver
tqdm._monitor
tqdm._tqdm_pandas
tqdm.cli
tqdm.gui
tqdm.std
tqdm.utils
tqdm.version
traceback
types
typing
typing.io
typing.re
typing_extensions
unicodedata
unittest
unittest.case
unittest.loader
unittest.main
unittest.mock
unittest.result
unittest.runner
unittest.signals
unittest.suite
unittest.util
urllib
urllib.error
urllib.parse
urllib.request
urllib.response
uuid
warnings
weakref
zipfile
zipimport
zlib

from pytorch.

stellaraccident avatar stellaraccident commented on September 24, 2024

Follow up: when you call onnx exporter, it still imports. Is this desirable?

Not sure who you were talking to. I don't regularly invoke the onnx exporter and don't have an opinion. Kind of seems broken to have the dependencies run this way, though.

from pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.