Repository navigation
Description
Describe the bug
When a ProcessingStep is built from a FrameworkProcessor using source_dir=/dependencies=, CacheConfig never produces a cache hit, even with byte-identical code and inputs.
The SDK computes the correct content hash for this case and plumbs it into the step-compilation context, but the multi-file upload path never reads it:
get_processing_code_hash()(sagemaker-core/src/sagemaker/core/workflow/utilities.py) has an explicit# FrameworkProcessorbranch returninghash_files_or_dirs([code, source_dir] + dependencies)._steps_compiler.pysets it ascode_hashon_pipeline_configbefore replaying the step's deferredprocessor.run().ScriptProcessor._upload_code()consults it and builds a content-addressed key:if _pipeline_config and _pipeline_config.code_hash: desired_s3_uri = s3.s3_path_join(..., _pipeline_config.pipeline_name, self._CODE_CONTAINER_INPUT_NAME, _pipeline_config.code_hash)
FrameworkProcessor._package_code()never references_pipeline_config. It builds the path from the job name instead:ands3_uri = s3.s3_path_join(self._s3_code_prefix(), job_name, "source", "sourcedir.tar.gz")
job_namecomes from_generate_current_job_name()→name_from_base(...), i.e. timestamped on every compile.
Since ProcessingInputs is a documented cache-key attribute, the differing sourcedir.tar.gz URI changes the step signature on every upsert()/definition() call, so no step can ever match a previous run.
This looks like the ScriptProcessor half of #2736's fix never being carried over to the FrameworkProcessor path.
To reproduce
proc = FrameworkProcessor(image_uri=IMAGE, role=ROLE, instance_count=1,
instance_type="ml.m5.large", base_job_name="probe",
sagemaker_session=PipelineSession())
step = ProcessingStep(name="Probe",
cache_config=CacheConfig(enable_caching=True, expire_after="30d"),
step_args=proc.run(code="entry.py", source_dir="steps/probe"))
pipeline = Pipeline(name="probe", steps=[step], sagemaker_session=session)
# compile twice, with no code changes in between
for _ in range(2):
d = json.loads(pipeline.definition())
print([i["S3Input"]["S3Uri"] for i in d["Steps"][0]["Arguments"]["ProcessingInputs"]
if i["InputName"] == "code"])Output (SDK 3.24.0):
['s3://.../probe-2026-10-16-11-12-35-333/source/']
['s3://.../probe-2026-10-16-11-12-37-141/source/']
The entrypoint input (runproc.sh) is content-addressed correctly in the same definition, which makes the asymmetry easy to see.
Expected behaviour
The sourcedir.tar.gz key should be content-addressed from _pipeline_config.code_hash when compiling inside a pipeline, the way ScriptProcessor._upload_code already does — so that an unchanged source_dir yields an unchanged ProcessingInputs and caching can match.
Notes
PipelineDefinitionConfig(use_custom_job_prefix=True)does not work around this. It trims the timestamp fromProcessingJobNamein the compiled definition, but the S3 upload path is built duringrun(), beforetrim_request_dictrewrites the definition, so the path keeps its timestamp. Verified by compiling twice under both settings.- A working workaround is to pass an explicit, content-derived
job_nametoprocessor.run(), which makes the upload path deterministic.ProcessingJobNameis popped from the definition by default, so this does not affect job naming at execution time:code_hash = get_processing_code_hash(entry_abs_path, source_dir, dependencies) processor.run(..., job_name=f"{step}-{code_hash[:12]}")
- This is easy to miss because it fails open: the step simply always reruns, which is hard to distinguish from "the inputs genuinely changed". Nothing errors or warns. It only bites when
source_diris used (needed to share Python modules across steps) and caching is enabled and someone verifies hits actually occur. - Related: upserting a pipeline kills caching #2736 (the partial fix), Use of
source_dirargument forFrameworkProcessordisables step caching functionality #4246 (source_dircontents being hashed), TuningStep changing sagemaker_job_name in StaticHyperParameters when run get pipeline definition and pipeline upsert and kill cache #3651 (the same class of problem forTuningStep, closed without a fix).
System information
- SDK version:
sagemaker==3.24.0(sagemaker-core2.25.0,sagemaker-mlops1.25.0); code paths above also verified present onmaster@ce3ac25 - Framework:
FrameworkProcessoragainst an AWS PyTorch DLC - Python: 3.12 (container), 3.14 (client)
- Region: eu-north-1
Activity
Nimisha987 commentedon Oct 16, 2026
Hi! I'd love to contribute to this issue.
I've been exploring the reported caching issue and would like to investigate why
FrameworkProcessor._package_code()does not use_pipeline_config.code_hash, unlikeScriptProcessor._upload_code(). As described, this can cause the generated S3 URI to change across repeated pipeline compilations even when the source code and dependencies remain unchanged, preventing the expected pipeline cache hits.I'd like to work on reproducing this behavior, adding a regression test to cover repeated compilations with unchanged source code, and implementing a minimal fix that keeps the generated S3 URI deterministic when a pipeline code hash is available, while preserving the existing behavior outside pipeline compilation.
Before proceeding with the implementation, could a maintainer please confirm whether this issue is available to work on and whether I could be assigned to it?
Thank you for the detailed bug report!
Nimisha987 commentedon Oct 16, 2026
Hi! I noticed that you've opened a PR for this issue. I'm also interested in contributing and have started investigating the reported caching behavior.
I'd love to help strengthen the fix, particularly by reviewing the regression tests and checking edge cases such as unchanged source files, modified dependencies, and behavior outside pipeline compilation.
Would you be open to additional testing or review contributions on this PR? I'd be happy to help where needed.
fix: use pipeline code_hash for FrameworkProcessor sourcedir upload (a…