Skip to content

Commit

Permalink
fix no cache dir case
Browse files Browse the repository at this point in the history
Signed-off-by: youkaichao <[email protected]>
  • Loading branch information
youkaichao committed Jan 21, 2025
1 parent c25cd1d commit ed404d9
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions vllm/compilation/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,24 @@ def bytecode_hook(self, old_code: CodeType, new_code: CodeType):

self.compiled_codes.append(new_code)
local_cache_dir = self.vllm_config.compilation_config.local_cache_dir
decompiled_file = os.path.join(local_cache_dir, "transformed_code.py")
if not os.path.exists(decompiled_file):
try:
# usually the decompilation will succeed for most models, as
# we guarantee a full-graph compilation in Dynamo.
# but there's no 100% guarantee, since decompliation is not a
# reversible process.
import depyf
src = depyf.decompile(new_code)
with open(decompiled_file, "w") as f:
f.write(src)

logger.info("Dynamo transformed code saved to %s",
decompiled_file)
except Exception:
pass
if isinstance(local_cache_dir, str):
decompiled_file = os.path.join(local_cache_dir,
"transformed_code.py")
if not os.path.exists(decompiled_file):
try:
# usually the decompilation will succeed for most models,
# as we guarantee a full-graph compilation in Dynamo.
# but there's no 100% guarantee, since decompliation is
# not a reversible process.
import depyf
src = depyf.decompile(new_code)
with open(decompiled_file, "w") as f:
f.write(src)

logger.info("Dynamo transformed code saved to %s",
decompiled_file)
except Exception:
pass

if self.vllm_config.compilation_config.use_cudagraph and \
"update" in new_code.co_names:
Expand Down

0 comments on commit ed404d9

Please sign in to comment.