Skip to content

fix(trainer): drain single-teacher RTensor input caches - #1800

Merged
sitabulaixizawaluduo merged 1 commit into
areal-project:mainfrom
zhuqiweigit:bugfix/teacher-rtensor-cache-cleanup
Oct 19, 2026
Merged

sitabulaixizawaluduo merged 1 commit into
areal-project:mainfrom
zhuqiweigit:bugfix/teacher-rtensor-cache-cleanup

Conversation

@zhuqiweigit

Copy link
Copy Markdown
Contributor

Description

In single-controller distillation, teacher scoring localizes rollout RTensors into each teacher worker's _fetch_buffer, but step cleanup omits the teacher. Actor cleanup deletes the source shards without releasing these process-local copies, so teacher memory grows across training steps.

Include the single teacher in step cleanup for both training and rollout teachers. Add RolloutController.clear_batches() to send deduplicated shard IDs to every worker without refetching inputs or deleting source storage. Wait for all worker drains before propagating a failure. CPU regressions exercise repeated training steps with real RTensor serialization, storage, and worker cache eviction.

Related Issue

Follow-up to #1209, covering the single-teacher consumer cache.

Type of Change

  • 🐛 Bug fix

Checklist

  • I have read the Contributing Guide
  • Pre-commit hooks pass (pre-commit run --all-files)
  • Relevant tests pass; new regression tests added
  • Documentation updated (not applicable: internal cache lifecycle fix)
  • Branch is up to date with main
  • Self-reviewed, including an infrastructure expert review
  • This PR was created by a coding agent using the create-pr skill
  • This PR is a breaking change

Additional Context

Validation: 163 passed, 1 deselected (the slow model-serving integration test); all pre-commit checks passed.

pre-commit run --all-files
HF_HUB_OFFLINE=1 NO_PROXY='*' no_proxy='*' PYTHONPATH="$PWD" pytest -q \
  tests/test_teacher_rtensor_cleanup.py \
  tests/test_eval_rtensor_cleanup.py \
  tests/test_trainer_utils.py \
  tests/test_train_controller.py \
  tests/test_trainer_eval_before_train.py \
  tests/test_rollout_controller.py \
  -m 'not slow'

The new repeated-training regression fails on the unmodified base because teacher input caches survive the first step. Test environment flags use the cached model files and keep local callback requests out of the HTTP proxy.

Full model-serving, GPU training, and multi-node integration suites were not run; validation targets the CPU-side RTensor lifecycle and controller cleanup paths without launching a training deployment.

Teacher scoring caches rollout inputs in each worker process. Deleting
source shards through the actor does not release those consumer caches,
so repeated distillation steps retain tensors indefinitely.

Include the single teacher in step cleanup and send shard IDs to every
rollout teacher worker without refetching inputs. Wait for all workers
before surfacing failures and preserve unrelated caches.

Add CPU regressions for repeated training steps, both teacher types,
nested inputs, cleanup failures, and SPMD behavior.

Refs: areal-project#1209
Signed-off-by: qw <zhuqiweiyx@qq.com>
@sitabulaixizawaluduo
sitabulaixizawaluduo merged commit 25c1dd1 into areal-project:main Oct 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants