Run this model with HF Jobs
Run Codeseys/composer-replication-framework on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Codeseys/composer-replication-framework. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Codeseys/composer-replication-framework on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Codeseys/composer-replication-framework with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Codeseys/composer-replication-framework with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Codeseys/composer-replication-framework", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Wave 3 cleanup: close deferred-LOW review items R5/R6/R11
Browse files- R5: EKSExecutor.cancel + SageMakerExecutor.cancel now re-raise genuinely
unexpected errors instead of swallowing ALL exceptions; only already-terminated
signals are idempotent no-ops (EKS: 404/409; SM: ResourceNotFound +
already-terminal ValidationException via new _is_already_terminal). + a test
that an AccessDenied-class error propagates.
- R6: EKSExecutor.collect() result dicts include a 'result' key (the S3
rendezvous URI, or None) for cross-backend shape uniformity with
Local/Modal/SageMaker.
- R11: seed torch.manual_seed(0) in spike-006 test_alternating_batches_loss_
decreases so the loss-trend assertion is reproducible and no longer flaky
under CPU contention (it failed only in the contended full suite, passed in
isolation). Root cause was unseeded nondeterminism, not a real regression.
All Wave-3 review findings (R1-R11) now closed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files changed (5)
591 unmodified lines59259359459559659759859960060160260364 unmodified lines668669670671672673591 unmodified lines),)except ApiException as e:if getattr(e, "status", None) == 404:return # already deleted# Best-effort: swallow other API errors (network blip, etc.).returnexcept Exception:returndef collect(self,64 unmodified lines"exit_code": exit_code,"error": error,"job_name": handle.metadata.get("job_name"),}591 unmodified lines59259359459559659759859960060160260360460564 unmodified lines670671672673674675676677678679680681591 unmodified lines),)except ApiException as e:# R5: swallow ONLY already-terminated signals (404 Not Found, 409# Conflict on a job mid-deletion). A genuinely unexpected API error# (403 forbidden, 500, malformed request) must NOT be reported as a# successful cancel — re-raise so a real teardown failure (leaking# GPU-burning pods) is visible rather than silently swallowed.if getattr(e, "status", None) in (404, 409):return # already deleted / mid-deletion — idempotent no-opraisedef collect(self,64 unmodified lines"exit_code": exit_code,"error": error,"job_name": handle.metadata.get("job_name"),# R6: cross-backend uniformity with Local/Modal/SageMaker collect()# shapes. EKS replicas write their real output to the S3 rendezvous# (ObjectStoreAllReduce), not back through the k8s API, so the Job# status carries no in-band payload — the value is the rendezvous# URI when known (callers read the artifact from S3), else None."result": handle.metadata.get("rendezvous_uri"),}
468 unmodified lines469470471472473474475476477478136 unmodified lines615616617618619468 unmodified linesreturntry:self._client.stop_training_job(TrainingJobName=meta["job_name"])except Exception:# ResourceNotFound, already-Completed/Stopped ValidationException,# transient network blip — all best-effort no-ops.passdef collect(self,136 unmodified linesreturn Truereturn False__all__ = ["SageMakerExecutor"]468 unmodified lines469470471472473474475476477478479480481482483484136 unmodified lines621622623624625626627628629630631632633634635636637638639640641642643644645468 unmodified linesreturntry:self._client.stop_training_job(TrainingJobName=meta["job_name"])except Exception as e:# R5: swallow ONLY already-terminated signals — a vanished job# (ResourceNotFound) or an already-Completed/Stopped job (boto3# raises ValidationException for "cannot stop a job in status X").# A genuinely unexpected error (AccessDenied, throttling that# outlived retries, malformed request) must propagate rather than# masquerade as a successful cancel.if self._is_resource_not_found(e) or self._is_already_terminal(e):returnraisedef collect(self,136 unmodified linesreturn Truereturn Falsedef _is_already_terminal(self, exc: Exception) -> bool:"""True if ``exc`` is the boto3 "cannot stop a job in status X" error.``stop_training_job`` raises a ``ValidationException`` when the job isalready Completed/Failed/Stopped — that is an idempotent no-op forcancel(), distinct from a genuinely unexpected error. Matched on theClientError code + message text (robust to a mock raising a plainException whose message carries the phrase)."""resp = getattr(exc, "response", None)if isinstance(resp, Mapping):err = resp.get("Error", {})if err.get("Code") == "ValidationException":return Truemsg = str(exc).lower()return ("cannot be stopped" in msgor "already" in msg and ("stopped" in msg or "complete" in msg or "terminal" in msg))__all__ = ["SageMakerExecutor"]
241 unmodified lines242243244241 unmodified linesex.cancel(h) # must not raise# unknown handle must also be a no-opex.cancel(ReplicaHandle(rank=42, backend_name="sagemaker", metadata={}))241 unmodified lines242243244245246247248249250251252253254255256257241 unmodified linesex.cancel(h) # must not raise# unknown handle must also be a no-opex.cancel(ReplicaHandle(rank=42, backend_name="sagemaker", metadata={}))def test_cancel_reraises_unexpected_error():"""R5: a genuinely unexpected error (not already-terminated) must propagate,not be silently swallowed as a successful cancel."""class _BoomClient(_MockSMClient):def stop_training_job(self, TrainingJobName): # noqa: N803raise RuntimeError("AccessDeniedException: not authorized")client = _BoomClient()ex = _make_executor(client)h = ex.launch_replicas(1, entrypoint="x", entrypoint_args=_VALID_ARGS)[0]with pytest.raises(RuntimeError, match="AccessDenied"):ex.cancel(h)
74 unmodified lines7576777879808174 unmodified lines| R11 | Flaky test `spikes/006-real-hf-model-smoke/tests/test_strict.py::test_alternating_batches_loss_decreases` — fails under CPU contention (full suite w/ concurrent pytest + Docker), PASSES in isolation (verified 3x). Loss-trend assertion is timing/noise-sensitive. Pin seed / widen tolerance / mark flaky. Pre-existing, not a Wave-2 regression. | LOW | OPEN || R12 | B7-complete ✅ (top-level `__all__` now includes the 3 factories) + B4-complete ✅ (the 4 surviving "115" claims → 266/62). | — | DONE |**Wave 3 — DONE (Phase-7 reconciliation):** R1 ✅ (HeldOutGuard wired into ComposerReplicationTrainer — optional, OFF by default, soft/hard stop; + integration test), R2 ✅ (HeldoutSplit disjointness enforcer `safety/holdout.py` + 10 tests), R3 ✅ (EKS entrypoint contract bug fixed — `replica_entrypoint.__main__` now resolves from env OR argv; proven end-to-end with a pure-env invocation), R4 ✅ (calibrate_kl_threshold rejects factor<=0/negative-baseline + positive floor), R7 ✅ (API_REFERENCE §15-17: EKS/SageMaker/DockerSandbox/safety), R8 ✅ (ADR-015 authored + indexed), R10 ✅ (path-(c) divergence-rate test). R12 ✅ (B4/B7 complete). DEFERRED-LOW: R5 (cancel exception-narrowing) + R6 (EKS collect result-key) — stale-base worktree casualties, tracked, LOW severity. R11 (spike-006 flaky-under-contention) — pre-existing, tracked.Sandbox refactor verdict: **clean** (no regression to LocalSubprocessSandbox/FeatureDeletionEnv).74 unmodified lines7576777879808174 unmodified lines| R11 | Flaky test `spikes/006-real-hf-model-smoke/tests/test_strict.py::test_alternating_batches_loss_decreases` — fails under CPU contention (full suite w/ concurrent pytest + Docker), PASSES in isolation (verified 3x). Loss-trend assertion is timing/noise-sensitive. Pin seed / widen tolerance / mark flaky. Pre-existing, not a Wave-2 regression. | LOW | OPEN || R12 | B7-complete ✅ (top-level `__all__` now includes the 3 factories) + B4-complete ✅ (the 4 surviving "115" claims → 266/62). | — | DONE |**Wave 3 — DONE (Phase-7 reconciliation):** R1 ✅ (HeldOutGuard wired into ComposerReplicationTrainer — optional, OFF by default, soft/hard stop; + integration test), R2 ✅ (HeldoutSplit disjointness enforcer `safety/holdout.py` + 10 tests), R3 ✅ (EKS entrypoint contract bug fixed — `replica_entrypoint.__main__` now resolves from env OR argv; proven end-to-end with a pure-env invocation), R4 ✅ (calibrate_kl_threshold rejects factor<=0/negative-baseline + positive floor), R7 ✅ (API_REFERENCE §15-17: EKS/SageMaker/DockerSandbox/safety), R8 ✅ (ADR-015 authored + indexed), R10 ✅ (path-(c) divergence-rate test). R12 ✅ (B4/B7 complete). R5 ✅ (EKS+SageMaker cancel now re-raise unexpected errors, swallow only 404/409/already-terminal + propagation test), R6 ✅ (EKS collect() result dicts include `result`=rendezvous URI), R11 ✅ (spike-006 test seeded torch.manual_seed(0) → no longer contention-flaky). ALL Wave-3 items (R1-R11) CLOSED.Sandbox refactor verdict: **clean** (no regression to LocalSubprocessSandbox/FeatureDeletionEnv).
58 unmodified lines59606162636458 unmodified linesaveraged loss over the first 2 steps. (Looser than the strict-monotonicsingle-batch test, because alternation makes per-step noise larger.)"""batch_factorial = build_batch(tokenizer, device="cpu", variant="factorial")batch_bsearch = build_batch(tokenizer, device="cpu", variant="binary_search")optimizer = torch.optim.AdamW(model.parameters(), lr=1e-5)58 unmodified lines59606162636465666768697058 unmodified linesaveraged loss over the first 2 steps. (Looser than the strict-monotonicsingle-batch test, because alternation makes per-step noise larger.)"""# Determinism (R11): pin the seed so the loss trajectory is reproducible# regardless of host CPU contention. Without this the test was flaky under# the full suite (competing pytest workers + Docker containers perturbed# torch op scheduling enough to occasionally miss the <50% threshold),# while passing in isolation. The seed makes the trend assertion stable.torch.manual_seed(0)batch_factorial = build_batch(tokenizer, device="cpu", variant="factorial")batch_bsearch = build_batch(tokenizer, device="cpu", variant="binary_search")optimizer = torch.optim.AdamW(model.parameters(), lr=1e-5)