Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c335f6e
train with only layer distillation losses
oleksost Dec 16, 2025
e06a4b2
unscaled loss llogging + training with distillation loss factor = 0
oleksost Dec 16, 2025
179ae25
make logging more explicit
oleksost Dec 17, 2025
af456f0
Merge remote-tracking branch 'origin/main' into train_only_layer_losses
oleksost Dec 17, 2025
9968aac
clean + tests
oleksost Dec 17, 2025
945c5a7
nvm
oleksost Dec 17, 2025
4b6e3d7
forward KL
oleksost Dec 19, 2025
c5fefa0
test forward kl
oleksost Dec 19, 2025
4119596
wip: report unscaled + kl loss
oleksost Dec 19, 2025
b55a0a4
loss config
oleksost Dec 22, 2025
097baeb
wip
oleksost Dec 22, 2025
d773d98
tests
oleksost Dec 22, 2025
35400c1
Merge remote-tracking branch 'origin/main' into train_only_layer_losses
oleksost Dec 22, 2025
282925c
test
oleksost Dec 22, 2025
0f73ea2
tests
oleksost Dec 22, 2025
04a0193
Merge branch 'main' into train_only_layer_losses
oleksost Dec 22, 2025
fa85c41
wip
oleksost Dec 22, 2025
feb416e
Merge branch 'train_only_layer_losses' of https://github.com/ServiceN…
oleksost Dec 22, 2025
31cfb84
wip
oleksost Dec 23, 2025
24fe67b
no grad if factor 0
oleksost Dec 23, 2025
00f6118
Merge remote-tracking branch 'origin/main' into train_only_layer_losses
oleksost Dec 23, 2025
0cadf98
Merge branch 'main' into train_only_layer_losses
oleksost Dec 23, 2025
0e562e9
addressed comments
oleksost Dec 23, 2025
2a474e2
Merge branch 'train_only_layer_losses' of https://github.com/ServiceN…
oleksost Dec 23, 2025
52c1c11
addressed comments
oleksost Dec 23, 2025
406d0a2
Removed Targets class
oleksost Dec 30, 2025
f25380a
fixes
oleksost Dec 30, 2025
8adb7dd
imports
oleksost Dec 30, 2025
1ce641d
polish naming
oleksost Jan 6, 2026
95f14af
addresseing comments
oleksost Jan 8, 2026
5ad4c0c
explicit z_loss grads
oleksost Jan 8, 2026
0a66e14
removed z_loss as aux loss
oleksost Jan 8, 2026
f8f7041
move loss configs to the lm config
oleksost Jan 8, 2026
ab9c917
tests
oleksost Jan 8, 2026
89470dc
Merge branch 'main' into train_only_layer_losses
oleksost Jan 9, 2026
6e54c93
comments
oleksost Jan 12, 2026
8137b8c
Merge remote-tracking branch 'origin/main' into train_only_layer_losses
jlamypoirier Jan 13, 2026
3c8f3c2
misc
jlamypoirier Jan 13, 2026
705c482
fix
jlamypoirier Jan 13, 2026
4fbc7a8
stuff
jlamypoirier Jan 13, 2026
99a73b5
fixes
jlamypoirier Jan 13, 2026
fb679d1
stuff
jlamypoirier Jan 16, 2026
982f945
Merge remote-tracking branch 'origin/main' into jlp_entropy_loss
jlamypoirier Jan 16, 2026
3c8ce50
Merge branch 'main' into train_only_layer_losses
jlamypoirier Jan 16, 2026
63ac004
Merge remote-tracking branch 'origin/train_only_layer_losses' into jl…
jlamypoirier Jan 16, 2026
afc33f3
stuff
jlamypoirier Jan 16, 2026
f8dcce6
stuff
jlamypoirier Jan 16, 2026
98ee4fb
Merge branch 'jlp_cpu' into jlp_entropy_loss
jlamypoirier Jan 16, 2026
2a4362f
fixes
jlamypoirier Jan 16, 2026
b464e4e
fixes
jlamypoirier Jan 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions fast_llm/core/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ def check_parallel_match(tensor: torch.Tensor, group: ProcessGroup | None, name:
)


def safe_barrier(group: ProcessGroup | None, value: int | str = 1, timeout: float | None = None) -> None:
def safe_barrier(
group: ProcessGroup | None, value: int | str = 1, timeout: float | None = None, device: torch.device | None = None
) -> None:
if group:
hashed = hash(value) % 2**32
out = allreduce_scalar(hashed, dtype=torch.int64, group=group, timeout=timeout)
out = allreduce_scalar(hashed, dtype=torch.int64, group=group, timeout=timeout, device=device)
if out != hashed * group.size():
raise RuntimeError(f"Desync detected for barrier {value} ({out}!={hashed*group.size()})")

Expand All @@ -86,9 +88,10 @@ def allreduce_scalar(
group: torch.distributed.ProcessGroup | None = None,
op=ReduceOp.SUM,
timeout: float | None = None,
device: torch.device | None = None,
) -> float | int:
if group:
value = torch.full([1], value, dtype=dtype, device=torch.cuda.current_device())
value = torch.full([1], value, dtype=dtype, device=torch.cuda.current_device() if device is None else device)
with set_timeout(group, timeout):
torch.distributed.all_reduce(value, op=op, group=group)
return value.item()
Expand Down
4 changes: 3 additions & 1 deletion fast_llm/engine/schedule/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ def _preprocess_data(
self, context: BatchContext, data_iterator: typing.Iterator, preprocessed: bool
) -> typing.Generator[None, None, None]:
batch_config = context.schedule.batch_config
grad_output = (1 if self._optimizer is None else self._optimizer.grad_scale) / batch_config.num_inputs
grad_output = (
self._optimizer.grad_scale / batch_config.num_inputs if context.schedule.phase.is_training else None
)
for micro_batch in range(batch_config.sequential_micro_batches):
micro_batch_data = next(data_iterator)
if not preprocessed:
Expand Down
7 changes: 4 additions & 3 deletions fast_llm/functional/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@ def _set_activation_fn_map() -> None:
MAX_DROPLESS_BLOCK_SIZE_ROW = 128


class CrossEntropyImpl(str, enum.Enum):
class EntropyLossImplementation(enum.StrEnum):
auto = "auto"
torch = "torch"
fused = "fused"
triton = "triton"


class DistillationLossImpl(str, enum.Enum):
reverse_kl = "reverse_kl"
class EntropyLossType(enum.StrEnum):
cross_entropy = "cross_entropy"
forward_kl = "forward_kl"
reverse_kl = "reverse_kl"


class TargetFormat(enum.StrEnum):
Expand Down
Loading
Loading