Keep deep sharing generation within host memory guards
This commit is contained in:
@@ -23,7 +23,6 @@ SCHEDULES = {'native': (), 'direct_3': (15, 19, 23),
|
||||
'direct_4': (11, 15, 19, 23), 'direct_5': (7, 11, 15, 19, 23)}
|
||||
STOP_TEXT = ('<|im_end|>', '<|endoftext|>')
|
||||
MAX_NEW_TOKENS = 24
|
||||
PROCESS_SWAP_LIMIT_KIB = 384 * 1024
|
||||
|
||||
|
||||
def fixed_problems():
|
||||
@@ -172,7 +171,7 @@ def main():
|
||||
raise ValueError('Frozen protocol or prompts changed')
|
||||
write_json(manifest, frozen)
|
||||
model = StreamingLM(args.source/'weights', json.loads((args.source/'model_config.json').read_text()),
|
||||
seconds=args.seconds, process_swap_limit_kib=PROCESS_SWAP_LIMIT_KIB)
|
||||
seconds=args.seconds, process_swap_limit_kib=None)
|
||||
tokenizer = Tokenizer.from_file(str(args.source/'tokenizer.json'))
|
||||
examples = frozen['problems']['screen']
|
||||
if args.preflight:
|
||||
|
||||
@@ -8,7 +8,7 @@ import torch
|
||||
from tokenizers import Tokenizer
|
||||
|
||||
from crossqkv.lisa_effect_audit import paired
|
||||
from crossqkv.lisa_full_answer import (PROCESS_SWAP_LIMIT_KIB, SCHEDULES, STOP_TEXT, choose, evaluate, fingerprint,
|
||||
from crossqkv.lisa_full_answer import (SCHEDULES, STOP_TEXT, choose, evaluate, fingerprint,
|
||||
prompt, summarize)
|
||||
from crossqkv.lisa_tail import TorchTail, weight_chunks
|
||||
from crossqkv.lisa_train import LearnableSharingAttention, huber_distillation, language_model_loss
|
||||
@@ -181,7 +181,7 @@ def main():
|
||||
tasks = {name: [r for r in rows if r['task'] == selection['task']]
|
||||
for name, rows in manifest['problems'].items()}
|
||||
model = StreamingLM(args.source/'weights', json.loads((args.source/'model_config.json').read_text()),
|
||||
seconds=86400, process_swap_limit_kib=PROCESS_SWAP_LIMIT_KIB)
|
||||
seconds=86400, process_swap_limit_kib=None)
|
||||
model.sites = sites
|
||||
tokenizer = Tokenizer.from_file(str(args.source/'tokenizer.json'))
|
||||
capture(model, tokenizer, tasks['fit'], args.out/'fit-capture')
|
||||
|
||||
@@ -73,6 +73,7 @@ class GenerationDecoder(TorchTail):
|
||||
k_valid[:, None, None, :] | ~q_valid[:, None, :, None])
|
||||
h = torch.from_numpy(self.source.embedding(ids.numpy())) * q_valid[..., None]
|
||||
donor = None
|
||||
trim = getattr(self.source, 'malloc_trim', None)
|
||||
for layer, kind in enumerate(self.c['layer_types']):
|
||||
if hasattr(self.source, 'guard'):
|
||||
self.source.guard()
|
||||
@@ -86,6 +87,9 @@ class GenerationDecoder(TorchTail):
|
||||
n = self.norm(h, p+'post_attention_layernorm')
|
||||
activation = F.silu(self.linear(n, p+'mlp.gate_proj')) * self.linear(n, p+'mlp.up_proj')
|
||||
h = h + self.linear(activation, p+'mlp.down_proj')
|
||||
del n, out, activation
|
||||
if trim is not None:
|
||||
trim(0)
|
||||
self.position = stop
|
||||
return self.norm(h, 'norm')
|
||||
|
||||
|
||||
@@ -34,4 +34,4 @@ RESULT=runs/NEW_FULL_ANSWER_RESULT
|
||||
|
||||
使用原目录运行相同命令即可续跑。筛选和测试将按已保存的题号继续。训练使用已保存的优化器和训练步。
|
||||
|
||||
服务器约有 1.7 GiB 内存。本轮每次筛选只输入一道题,四个配置共享一次权重读取。PyTorch 进程在前两次预检中累计换页约 230 MiB,在服务器仍有约 1 GiB 可用内存时被退出。第三次预检沿用同一批冻结题,换页上限设为 384 MiB,保留服务器可用内存、进程 RSS 及运行时间检查。
|
||||
服务器约有 1.7 GiB 内存。本轮每次筛选输入一道题,四个配置共享权重读取。前两次预检和一次生成在服务器仍有约 1 GiB 可用内存时触发进程独立换页上限。当前作业沿用原冻结题集,并在每层结束时释放空闲内存。可用内存、进程 RSS、低可用内存下的持续换页压力和运行时间均由原检查器监控。
|
||||
|
||||
+3
-2
@@ -109,8 +109,9 @@ class StreamingLM:
|
||||
rate = (count-self.swap_observation[1])*4096/elapsed
|
||||
self.swap_pressure_windows = self.swap_pressure_windows+1 if rate > 4*1024**2 else 0
|
||||
own_swap_kib = int(status.get('VmSwap', '0 kB').split()[0])
|
||||
if self.swap_pressure_windows >= 3 and (
|
||||
available < 384*1024 or own_swap_kib > self.process_swap_limit_kib):
|
||||
over_process_limit = (self.process_swap_limit_kib is not None
|
||||
and own_swap_kib > self.process_swap_limit_kib)
|
||||
if self.swap_pressure_windows >= 3 and (available < 384*1024 or over_process_limit):
|
||||
raise MemoryError(f'Sustained host swap pressure plus constrained memory: available={available} KiB, process_swap={own_swap_kib} KiB')
|
||||
self.swap_observation = (now,count)
|
||||
if rss_kib > 512*1024 or available < 256*1024:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
a8ad25f70b2ccabfb92b82f7288e02738361d31c010e0fc83a02b5f5ecaff76b functional/model.py
|
||||
987420dbdd8b885821e7e7c09c38f0b34bf3651160857941554433adec645cc0 crossqkv/lisa_generate.py
|
||||
890654f75ea0ccf3cb83e221d2cc99f4873dd8a6fc016ed43fde490c9f2621ba crossqkv/lisa_full_answer.py
|
||||
97bb4882ec6949c2cf2528b97f2a6f00bc0c24194f72ebdc57bc1d3c810cd185 crossqkv/lisa_full_answer_train.py
|
||||
94437e0138c54ec34b1beaaa0e08a334ce0822f60af598a5a896459b778a3a1c functional/model.py
|
||||
98927a1ccd935b2f7a438bad31bbd973e210a54deceac911c61551092e52c96c crossqkv/lisa_generate.py
|
||||
519e0a031efcfb69c9b86fca1cb649fe8bb93d799401c8023ff7b6549cded448 crossqkv/lisa_full_answer.py
|
||||
74d6cbe3be94a8118f670c8810037b6d8abe085bd42b638a58af856eb45a17f3 crossqkv/lisa_full_answer_train.py
|
||||
d47b4c9cc34082e9b356e745821298a43981e4cd18ed55a3f59b4b6fe7cc46e3 crossqkv/lisa_tail.py
|
||||
9f0b6a53f107950661e91c16f03b49440708b3936120e2f84ef1d66f185257b6 crossqkv/lisa_train.py
|
||||
96d12fdfa266ca02ac50330971ff403e04b977358f479d63c8d6276a514fe025 tests/test_lisa_full_answer.py
|
||||
|
||||
Reference in New Issue
Block a user