yujiepan commited on
Commit
b240abb
·
verified ·
1 Parent(s): 80bfbe8

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +10 -143
  2. config.json +0 -16
  3. model.safetensors +2 -2
README.md CHANGED
@@ -13,7 +13,7 @@ Structural comparison with `mistralai/Timestral-209M`:
13
  | Forecasting interface | univariate, multivariate, past/known covariates | same |
14
  | Stored precision | F32 | F32 |
15
  | Patch size / block size | 32 / 32 | same |
16
- | Transformer layers | 24 | same; six 3-time + 1-time/variate cycles |
17
  | Width / attention heads / head dimension | 768 / 12 / 64 | 64 / 1 / 64 |
18
  | SwiGLU intermediate width | 2,048 | 128 |
19
  | Quantile knots | 21 | same |
@@ -27,7 +27,7 @@ serving model.
27
 
28
  | File path | Size |
29
  |------|------|
30
- | model.safetensors | 5.9MB |
31
 
32
 
33
  ### Example usage:
@@ -38,7 +38,7 @@ serving model.
38
  import torch
39
  from timestral import TimestralForecaster
40
 
41
- model_id = "tiny-random/timestral-209m"
42
  device = "cuda" if torch.cuda.is_available() else "cpu"
43
  forecaster = TimestralForecaster.from_pretrained(model_id, device=device, per_shot_horizon_patches=32)
44
  context = torch.sin(torch.arange(96, dtype=torch.float32) / 6).reshape(1, 1, -1)
@@ -63,15 +63,18 @@ from safetensors.torch import save_file
63
  from timestral import TimestralConfig, TimestralModel
64
 
65
  source_model_id = "mistralai/Timestral-209M"
66
- save_folder = "/tmp/tiny-random/timestral-209m"
67
  source_revision = "9874d252ab0aae16f7f7c999f98f98d6ad7d8365"
68
  torch.manual_seed(42)
69
  folder = Path(save_folder)
70
  folder.mkdir(parents=True, exist_ok=True)
71
  raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
72
- # Keep all 24 source layers and the 3-time + 1-time/variate cadence. A 64-wide
73
- # model with one head preserves Timestral's 64-wide attention head exactly.
74
- raw.update(d_model=64, num_heads=1, mlp_hidden_dim=128, context_length=1024)
 
 
 
75
  (folder / "config.json").write_text(json.dumps(raw, indent=2) + "\n", encoding="utf-8")
76
  config = TimestralConfig.load(folder / "config.json")
77
  model = TimestralModel(config).float()
@@ -177,142 +180,6 @@ TimestralModel(
177
  (w3): Linear(in_features=128, out_features=64, bias=False)
178
  )
179
  )
180
- (8-10): 3 x TransformerBlock(
181
- (attn_norms): ModuleList(
182
- (0): RMSNorm()
183
- )
184
- (attns): ModuleList(
185
- (0): Attention(
186
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
187
- (wO): Linear(in_features=64, out_features=64, bias=False)
188
- (_gate): Linear(in_features=64, out_features=64, bias=False)
189
- )
190
- )
191
- (mlp_norm): RMSNorm()
192
- (mlp): FusedSwiGLU(
193
- (w12): Linear(in_features=64, out_features=256, bias=False)
194
- (w3): Linear(in_features=128, out_features=64, bias=False)
195
- )
196
- )
197
- (11): TransformerBlock(
198
- (attn_norms): ModuleList(
199
- (0-1): 2 x RMSNorm()
200
- )
201
- (attns): ModuleList(
202
- (0-1): 2 x Attention(
203
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
204
- (wO): Linear(in_features=64, out_features=64, bias=False)
205
- (_gate): Linear(in_features=64, out_features=64, bias=False)
206
- )
207
- )
208
- (mlp_norm): RMSNorm()
209
- (mlp): FusedSwiGLU(
210
- (w12): Linear(in_features=64, out_features=256, bias=False)
211
- (w3): Linear(in_features=128, out_features=64, bias=False)
212
- )
213
- )
214
- (12-14): 3 x TransformerBlock(
215
- (attn_norms): ModuleList(
216
- (0): RMSNorm()
217
- )
218
- (attns): ModuleList(
219
- (0): Attention(
220
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
221
- (wO): Linear(in_features=64, out_features=64, bias=False)
222
- (_gate): Linear(in_features=64, out_features=64, bias=False)
223
- )
224
- )
225
- (mlp_norm): RMSNorm()
226
- (mlp): FusedSwiGLU(
227
- (w12): Linear(in_features=64, out_features=256, bias=False)
228
- (w3): Linear(in_features=128, out_features=64, bias=False)
229
- )
230
- )
231
- (15): TransformerBlock(
232
- (attn_norms): ModuleList(
233
- (0-1): 2 x RMSNorm()
234
- )
235
- (attns): ModuleList(
236
- (0-1): 2 x Attention(
237
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
238
- (wO): Linear(in_features=64, out_features=64, bias=False)
239
- (_gate): Linear(in_features=64, out_features=64, bias=False)
240
- )
241
- )
242
- (mlp_norm): RMSNorm()
243
- (mlp): FusedSwiGLU(
244
- (w12): Linear(in_features=64, out_features=256, bias=False)
245
- (w3): Linear(in_features=128, out_features=64, bias=False)
246
- )
247
- )
248
- (16-18): 3 x TransformerBlock(
249
- (attn_norms): ModuleList(
250
- (0): RMSNorm()
251
- )
252
- (attns): ModuleList(
253
- (0): Attention(
254
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
255
- (wO): Linear(in_features=64, out_features=64, bias=False)
256
- (_gate): Linear(in_features=64, out_features=64, bias=False)
257
- )
258
- )
259
- (mlp_norm): RMSNorm()
260
- (mlp): FusedSwiGLU(
261
- (w12): Linear(in_features=64, out_features=256, bias=False)
262
- (w3): Linear(in_features=128, out_features=64, bias=False)
263
- )
264
- )
265
- (19): TransformerBlock(
266
- (attn_norms): ModuleList(
267
- (0-1): 2 x RMSNorm()
268
- )
269
- (attns): ModuleList(
270
- (0-1): 2 x Attention(
271
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
272
- (wO): Linear(in_features=64, out_features=64, bias=False)
273
- (_gate): Linear(in_features=64, out_features=64, bias=False)
274
- )
275
- )
276
- (mlp_norm): RMSNorm()
277
- (mlp): FusedSwiGLU(
278
- (w12): Linear(in_features=64, out_features=256, bias=False)
279
- (w3): Linear(in_features=128, out_features=64, bias=False)
280
- )
281
- )
282
- (20-22): 3 x TransformerBlock(
283
- (attn_norms): ModuleList(
284
- (0): RMSNorm()
285
- )
286
- (attns): ModuleList(
287
- (0): Attention(
288
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
289
- (wO): Linear(in_features=64, out_features=64, bias=False)
290
- (_gate): Linear(in_features=64, out_features=64, bias=False)
291
- )
292
- )
293
- (mlp_norm): RMSNorm()
294
- (mlp): FusedSwiGLU(
295
- (w12): Linear(in_features=64, out_features=256, bias=False)
296
- (w3): Linear(in_features=128, out_features=64, bias=False)
297
- )
298
- )
299
- (23): TransformerBlock(
300
- (attn_norms): ModuleList(
301
- (0-1): 2 x RMSNorm()
302
- )
303
- (attns): ModuleList(
304
- (0-1): 2 x Attention(
305
- (wQKV): Linear(in_features=64, out_features=192, bias=False)
306
- (wO): Linear(in_features=64, out_features=64, bias=False)
307
- (_gate): Linear(in_features=64, out_features=64, bias=False)
308
- )
309
- )
310
- (mlp_norm): RMSNorm()
311
- (mlp): FusedSwiGLU(
312
- (w12): Linear(in_features=64, out_features=256, bias=False)
313
- (w3): Linear(in_features=128, out_features=64, bias=False)
314
- )
315
- )
316
  )
317
  (rope): SinCosRoPE()
318
  (out_norm): RMSNorm()
 
13
  | Forecasting interface | univariate, multivariate, past/known covariates | same |
14
  | Stored precision | F32 | F32 |
15
  | Patch size / block size | 32 / 32 | same |
16
+ | Transformer layers | 24 | 8; two 3-time + 1-time/variate cycles |
17
  | Width / attention heads / head dimension | 768 / 12 / 64 | 64 / 1 / 64 |
18
  | SwiGLU intermediate width | 2,048 | 128 |
19
  | Quantile knots | 21 | same |
 
27
 
28
  | File path | Size |
29
  |------|------|
30
+ | model.safetensors | 2.7MB |
31
 
32
 
33
  ### Example usage:
 
38
  import torch
39
  from timestral import TimestralForecaster
40
 
41
+ model_id = "tiny-random/timestral"
42
  device = "cuda" if torch.cuda.is_available() else "cpu"
43
  forecaster = TimestralForecaster.from_pretrained(model_id, device=device, per_shot_horizon_patches=32)
44
  context = torch.sin(torch.arange(96, dtype=torch.float32) / 6).reshape(1, 1, -1)
 
63
  from timestral import TimestralConfig, TimestralModel
64
 
65
  source_model_id = "mistralai/Timestral-209M"
66
+ save_folder = "/tmp/tiny-random/timestral"
67
  source_revision = "9874d252ab0aae16f7f7c999f98f98d6ad7d8365"
68
  torch.manual_seed(42)
69
  folder = Path(save_folder)
70
  folder.mkdir(parents=True, exist_ok=True)
71
  raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
72
+ # Keep two source 3-time + 1-time/variate cycles. A 64-wide model with one
73
+ # head preserves Timestral's 64-wide attention head exactly.
74
+ raw.update(
75
+ d_model=64, num_heads=1, mlp_hidden_dim=128, context_length=1024,
76
+ block_schedule=["time", "time", "time", "time_variate"] * 2,
77
+ )
78
  (folder / "config.json").write_text(json.dumps(raw, indent=2) + "\n", encoding="utf-8")
79
  config = TimestralConfig.load(folder / "config.json")
80
  model = TimestralModel(config).float()
 
180
  (w3): Linear(in_features=128, out_features=64, bias=False)
181
  )
182
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  )
184
  (rope): SinCosRoPE()
185
  (out_norm): RMSNorm()
config.json CHANGED
@@ -4,22 +4,6 @@
4
  "num_heads": 1,
5
  "mlp_hidden_dim": 128,
6
  "block_schedule": [
7
- "time",
8
- "time",
9
- "time",
10
- "time_variate",
11
- "time",
12
- "time",
13
- "time",
14
- "time_variate",
15
- "time",
16
- "time",
17
- "time",
18
- "time_variate",
19
- "time",
20
- "time",
21
- "time",
22
- "time_variate",
23
  "time",
24
  "time",
25
  "time",
 
4
  "num_heads": 1,
5
  "mlp_hidden_dim": 128,
6
  "block_schedule": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  "time",
8
  "time",
9
  "time",
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8d18e064286ac9af4eef447fa806eb4ac8267132c5b604ad2e540fef910a269a
3
- size 5927432
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:564921d8f9e096df7bfecce109f6bc2ae52b93ca55b4c67d344fde3d587db1fb
3
+ size 2693368