Q-TensorFormer / reports /CONFIG_PROVENANCE.md
Premchandyadav369
Complete 16-phase scientific hardening, strict checkpoint audit, empirical benchmarks, and documentation
7aefd9e
|
Raw History Blame Contribute Delete
3.51 kB

Phase Two — Configuration Provenance Report

1. Configuration File & Class Inventory

Config Source Class / Schema Intended Model Family Key Hyperparameters
src/config.py src.config.ModelConfig Family 3 (src.models.QTensorFormer, src.models.DenseBaseline) d_model=128, n_heads=4, n_layers=2, ff_multiplier=4, max_seq_len=128, vocab_size=10000, tt_rank=8, tt_min_rank=2, n_qubits=4, use_quantum=True
configuration_qtensorformer.py QTensorFormerConfig(PretrainedConfig) Family 4 (modeling_qtensorformer.QTensorFormerForCausalLM) vocab_size=32000, hidden_size=2048, num_hidden_layers=16, num_attention_heads=16, num_key_value_heads=4, intermediate_size=5632, tt_ranks=[1, 16, 16, 1], hysteresis_threshold=0.15
config.json JSON serialized QTensorFormerConfig Family 4 (AutoConfig / AutoModelForCausalLM) model_type="qtensorformer", vocab_size=32000, hidden_size=2048, num_hidden_layers=16, num_attention_heads=16, num_key_value_heads=4, tt_ranks=[1, 16, 16, 1]
qtensorformer_small.pt["config"] Embedded Python dict Legacy external TensorLy container (/app/qtensorformer) vocab_size=10000, hidden_dim=128, intermediate_size=256, n_heads=4, n_layers=3, seq_len=64, tt_rank=4, n_qubits=4
q_tensor_former.py q_tensor_former.CFG Family 1 (v1 prototype) d_model=64, n_heads=4, n_layers=2, vocab_size=1000, tt_rank=8
q_tensor_former_v2.py q_tensor_former_v2.Config Family 2 (v2 prototype) d_model=128, n_heads=4, n_layers=2, vocab_size=10000, tt_rank=8

2. Root Cause of Historical Config Construction Failures

Earlier external benchmark notebooks encountered errors involving backend_type and unresolved attributes (d_model, dropout, n_heads, n_layers) due to two distinct issues:

  1. Passing the embedded dictionary inside qtensorformer_small.pt["config"] directly into src.config.ModelConfig(**ckpt["config"]):
    • qtensorformer_small.pt["config"] uses keys hidden_dim, intermediate_size, seq_len, quantum_layers, quantum_ratio, use_quantum_attention, use_adaptive_rank, use_selective_routing, r_min, r_max, alpha, which do not match src.config.ModelConfig (d_model, ff_multiplier, max_seq_len, n_quantum_layers, quantum_sparsity, tt_min_rank).
  2. Mixing Hugging Face QTensorFormerConfig (hidden_size, num_hidden_layers, num_attention_heads) with src.models.QTensorFormer (d_model, n_layers, n_heads):
    • src.models.QTensorFormer expects src.config.ModelConfig, whereas modeling_qtensorformer.QTensorFormerForCausalLM expects QTensorFormerConfig.

3. Source-Level Resolution & Guardrails

  1. src.config.validate_model_config(config, model_class) explicitly checks that d_model, n_heads, n_layers, ff_multiplier, max_seq_len, and vocab_size exist on the supplied config object and raises ValueError("ConfigurationValidationError: ...") rather than guessing defaults.
  2. src.models.QTensorFormer safely resolves optional backend_type = getattr(config, "backend_type", "classical_surrogate") while requiring core architectural dimensions to be explicitly defined.
  3. QTensorFormerConfig in configuration_qtensorformer.py exposes read-only property bridges (.d_model, .n_layers, .n_heads, .n_kv_heads, .max_seq_len) and sets keys_to_ignore_at_loading = [].