{"record":{"id":"adc34a3f67a0796a","repo":"vllm-project/vllm","slug":"source-code-has-changed-since-the-last-compilation","errorCode":null,"errorMessage":"Source code has changed since the last compilation. Recompiling the model.","messagePattern":"Source code has changed since the last compilation\\. Recompiling the model\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm/compilation/decorators.py","lineNumber":279,"sourceCode":"    sha256_hash.update(str(fn.__code__.co_firstlineno).encode())\n    return sha256_hash.hexdigest()\n\n\ndef _verify_source_unchanged(\n    source_info: \"SourceInfo\", vllm_config: VllmConfig\n) -> None:\n    from .caching import _compute_code_hash, _compute_code_hash_with_content\n\n    file_contents = {}\n    for source in source_info.inlined_sources:\n        module = sys.modules[source.module]\n        file = inspect.getfile(module)\n        vllm_config.compilation_config.traced_files.add(file)\n        file_contents[file] = source.content\n    expected_checksum = _compute_code_hash_with_content(file_contents)\n    actual_checksum = _compute_code_hash(set(file_contents.keys()))\n    if expected_checksum != actual_checksum:\n        raise RuntimeError(\n            \"Source code has changed since the last compilation. Recompiling the model.\"\n        )\n\n\ndef _try_load_aot_compiled_fn(\n    model: Any,\n    aot_compilation_path: str,\n) -> Any | None:\n    \"\"\"Try to load an AOT-compiled function from disk.\n\n    Returns the loaded callable on success, or None on failure.\n    Re-raises on failure when ``VLLM_FORCE_AOT_LOAD`` is set.\n    \"\"\"\n    try:\n        with monitor_torch_compile(model.vllm_config, is_encoder=model._is_encoder):\n            with (\n                set_current_vllm_config(model.vllm_config),\n                open(aot_compilation_path, \"rb\") as f,","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/compilation/decorators.py#L261-L297","documentation":"During cache verification, vLLM compares the checksum of the source code recorded at trace time (inlined_sources content embedded in the compilation artifact) against the checksum of the same files on disk. A mismatch means the .py files that produced the compiled artifact were edited afterwards, so the cached compiled graph no longer corresponds to the running code, and vLLM refuses to use it (RuntimeError telling you to recompile).","triggerScenarios":"Loading a cached/AOT compilation artifact (torch_compile_cache or AOT compilation path) after editing any traced source file — model implementation files registered in compilation_config.traced_files — between the compile run and the load run.","commonSituations":"Iterating on model code while reusing a persistent compilation cache; a git branch switch or pip reinstall changing file contents/mtimes between compile and serve; CI caching compiled artifacts across code changes.","solutions":["Clear the compilation cache so vLLM recompiles against current sources: rm -rf ~/.cache/vllm/torch_compile_cache.","Keep source files byte-identical between compile and load runs (don't edit model code, switch branches, or reinstall a different version in between).","In CI, key the compiled-artifact cache on the source checksum, not just the model name."],"exampleFix":"# before\ngit checkout my-model-experiment  # edit model source after compiling\npython run_vllm.py  # RuntimeError: Source code has changed since the last compilation\n# after\nrm -rf ~/.cache/vllm/torch_compile_cache\ngit checkout my-model-experiment\npython run_vllm.py","handlingStrategy":"validation","validationCode":"import hashlib, pathlib\n\ndef fingerprint(paths: list[str]) -> str:\n    h = hashlib.sha256()\n    for p in sorted(paths):\n        h.update(pathlib.Path(p).read_bytes())\n    return h.hexdigest()\n# record fingerprint(model_files) at compile time; compare before loading cache","typeGuard":null,"tryCatchPattern":"try:\n    run_with_compilation_cache()\nexcept RuntimeError as e:\n    if 'Source code has changed' in str(e):\n        clear_vllm_compile_cache(); run_with_compilation_cache()\n    else:\n        raise","preventionTips":["Never edit traced source files between compile and serve runs","Key CI caches on source checksums","Clear the cache after branch switches"],"tags":["compilation","cache-invalidation","source-tracking","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}